From patchwork Sat Nov 13 01:22:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raghavendra Rao Ananta X-Patchwork-Id: 12692468 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A716EC433F5 for ; Sat, 13 Nov 2021 01:24:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 72CC860F55 for ; Sat, 13 Nov 2021 01:24:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 72CC860F55 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=aHDAPqTaDdEkyU67BWqT6tVtKLVCC7VTDcKW45RKo+c=; b=PrNdBKMilz95NJvYd8iMBiqg9w /Ul7ibrfO0jcOBLT74/vvLz4J+3Sd3/P1vSZtnXh1A2TcuXdZiawx1ilb8wgi1AfVXP74cvrlF58O 9A0Ki0V+d86GPDQGx1kzK0/AB/3dSG4+pAlSeVoEalFrack+4SCckQeNnZr+1HZtP3Rzv5jAoFoY4 xTHs7+YlQU4Z75BW/Q86GSOJkvzVt+1eZzBC3Op4ajOJI8AfjXO9b2Ad9xY2z35QgdRN8SCo8wtYc fLrnpmV9T3qswbzQMy6ffZ/ufm8fc+VrmZ7BNZy7KBlkXoRUr4ZXb+WTB+iX2Vnwo/HLSuxes4jgI 4O890NSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mlhlJ-00Bxti-Br; Sat, 13 Nov 2021 01:23:21 +0000 Received: from mail-pj1-x104a.google.com ([2607:f8b0:4864:20::104a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mlhkr-00BxkP-Il for linux-arm-kernel@lists.infradead.org; Sat, 13 Nov 2021 01:22:54 +0000 Received: by mail-pj1-x104a.google.com with SMTP id y18-20020a17090abd1200b001a4dcd1501cso5273871pjr.4 for ; Fri, 12 Nov 2021 17:22:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Ba+wxobSaiFgmTcgNPo/VsfplrPQ2ANaflUkZ8U4a0Y=; b=B2RXTSE+PsDQxq7oyt7onb151ClNd8WGtfxbuo8u0TZgh9aOnDTWAnvdB/5/Dy0rzQ W0SVhNnv9T96lHG4/HucXMgaCt2V6L/wjk9GMjXIyF1SLKA3QiUJ1+NyrPEjPNeQCF8L L7kGJS/2VpOghFFwbmHpzBKTMy1rH586KW5wzi0d6hgzl5ZT2hHP62qfgOs/PBN1QLR3 I283eK87ObcpukWe/Tw04Po+bpk1cxT80eJ/Vb3iF3jFtt6VLa1UmfuvwFNryAuWFGf+ NbsBedNB+i2THjX+c+6HFo+oIyw/Fidj1xiS3ksdMJJhZhV4oinNo3UnIYCJtHJGTh+W j+qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Ba+wxobSaiFgmTcgNPo/VsfplrPQ2ANaflUkZ8U4a0Y=; b=vjffBvwhMDefl57jSle8HrVM3pV157cfdm1EKtiZpFVLUaEMOZK1+PkySOOU+9aGA2 O3m6p0WIVvJl8PWu5oPBrrmkTbexjRyvzxTGBq0hldcXnOZw11z0HkFrbylQ9QCyOVG6 7g7W2z6+1f/OmD1Bew5miwV5Oa+464nI7xKO7+y9s4mCwk7lLj9SB6/RvrqPMlijP9tE rJ87GWJZZPVa8anUIaqB6IDmm4UGrVwZUtGsggdZ+OGulY/5JijGbt+vugRwWWJZl9Wc NA8HmRP33AkV3M5H5+5nv3zG1LVKU0Xx4bpL8UukvPJzbjTEKXB36KeDVYPf+IKDKbGC 8HPQ== X-Gm-Message-State: AOAM533159mYOgYDE0G4kn2XK+0p+h0owxJBIKlhFg90ZmpdX1WWY4TU pL0bcU+yqq9earWNgpxMzpjA1iHxDcqc X-Google-Smtp-Source: ABdhPJxd9EBwwuIBPspUU4u87Oi0TkCWLlVKjb1nJ8VxwRhr5W5IAS2T2mLzZod60TuVuSRdfolwZ6rvNCJY X-Received: from rananta-virt.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1bcc]) (user=rananta job=sendgmr) by 2002:a17:90a:3905:: with SMTP id y5mr141689pjb.0.1636766571415; Fri, 12 Nov 2021 17:22:51 -0800 (PST) Date: Sat, 13 Nov 2021 01:22:26 +0000 In-Reply-To: <20211113012234.1443009-1-rananta@google.com> Message-Id: <20211113012234.1443009-4-rananta@google.com> Mime-Version: 1.0 References: <20211113012234.1443009-1-rananta@google.com> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog Subject: [RFC PATCH v2 03/11] KVM: Introduce kvm_vm_has_run_once From: Raghavendra Rao Ananta To: Marc Zyngier , Andrew Jones , James Morse , Alexandru Elisei , Suzuki K Poulose Cc: Paolo Bonzini , Catalin Marinas , Will Deacon , Peter Shier , Ricardo Koller , Oliver Upton , Reiji Watanabe , Jing Zhang , Raghavendra Rao Anata , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211112_172253_649350_5A3EB9B6 X-CRM114-Status: GOOD ( 10.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The upcoming patches need a way to detect if the VM, as a whole, has started. Hence, unionize kvm_vcpu_has_run_once() of all the vcpus of the VM and build kvm_vm_has_run_once() to achieve the functionality. No functional change intended. Signed-off-by: Raghavendra Rao Ananta --- include/linux/kvm_host.h | 2 ++ virt/kvm/kvm_main.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index b373929c71eb..102e00c0e21c 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1854,4 +1854,6 @@ static inline bool kvm_vcpu_has_run_once(struct kvm_vcpu *vcpu) return vcpu->has_run_once; } +bool kvm_vm_has_run_once(struct kvm *kvm); + #endif diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 1ec8a8e959b2..3d8d96e8f61d 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -4339,6 +4339,23 @@ static int kvm_vm_ioctl_get_stats_fd(struct kvm *kvm) return fd; } +bool kvm_vm_has_run_once(struct kvm *kvm) +{ + int i, ret = false; + struct kvm_vcpu *vcpu; + + mutex_lock(&kvm->lock); + + kvm_for_each_vcpu(i, vcpu, kvm) { + ret = kvm_vcpu_has_run_once(vcpu); + if (ret) + break; + } + + mutex_unlock(&kvm->lock); + return ret; +} + static long kvm_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) {