All of lore.kernel.org
 help / color / mirror / Atom feed
From: Raghavendra Rao Ananta <rananta@google.com>
To: Marc Zyngier <maz@kernel.org>, Andrew Jones <drjones@redhat.com>,
	James Morse <james.morse@arm.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>, Peter Shier <pshier@google.com>,
	Ricardo Koller <ricarkol@google.com>,
	Oliver Upton <oupton@google.com>,
	Reiji Watanabe <reijiw@google.com>,
	Jing Zhang <jingzhangos@google.com>,
	Raghavendra Rao Anata <rananta@google.com>,
	linux-arm-kernel@lists.infradead.org,
	kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org
Subject: [PATCH v4 04/13] KVM: arm64: Capture VM's first run
Date: Thu, 24 Feb 2022 17:25:50 +0000	[thread overview]
Message-ID: <20220224172559.4170192-5-rananta@google.com> (raw)
In-Reply-To: <20220224172559.4170192-1-rananta@google.com>

Capture the first run of the KVM VM, which is basically the
first KVM_RUN issued for any vCPU. This state of the VM is
helpful in the upcoming patches to prevent user-space from
configuring certain VM features, such as the feature bitmap
exposed by the psuedo-firmware registers, after the VM has
started running.

Signed-off-by: Raghavendra Rao Ananta <rananta@google.com>
---
 arch/arm64/include/asm/kvm_host.h | 9 +++++++++
 arch/arm64/kvm/arm.c              | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 657733554d98..e823571e50cc 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -139,6 +139,9 @@ struct kvm_arch {
 
 	/* Register scoping enabled for KVM registers */
 	bool reg_scope_enabled;
+
+	/* Capture first run of the VM */
+	bool has_run_once;
 };
 
 struct kvm_vcpu_fault_info {
@@ -796,6 +799,12 @@ bool kvm_arm_vcpu_is_finalized(struct kvm_vcpu *vcpu);
 int kvm_trng_call(struct kvm_vcpu *vcpu);
 int kvm_arm_reg_id_encode_scope(struct kvm_vcpu *vcpu, u64 *reg_id);
 void kvm_arm_reg_id_clear_scope(struct kvm_vcpu *vcpu, u64 *reg_id);
+
+static inline bool kvm_arm_vm_has_run_once(struct kvm_arch *kvm_arch)
+{
+	return kvm_arch->has_run_once;
+}
+
 #ifdef CONFIG_KVM
 extern phys_addr_t hyp_mem_base;
 extern phys_addr_t hyp_mem_size;
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 107977c82c6c..f61cd8d57eae 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -635,6 +635,8 @@ int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu)
 	if (kvm_vm_is_protected(kvm))
 		kvm_call_hyp_nvhe(__pkvm_vcpu_init_traps, vcpu);
 
+	kvm->arch.has_run_once = true;
+
 	return ret;
 }
 
-- 
2.35.1.473.g83b2b277ed-goog


WARNING: multiple messages have this Message-ID (diff)
From: Raghavendra Rao Ananta <rananta@google.com>
To: Marc Zyngier <maz@kernel.org>, Andrew Jones <drjones@redhat.com>,
	 James Morse <james.morse@arm.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: kvm@vger.kernel.org, Catalin Marinas <catalin.marinas@arm.com>,
	Peter Shier <pshier@google.com>,
	linux-kernel@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
	Will Deacon <will@kernel.org>,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 04/13] KVM: arm64: Capture VM's first run
Date: Thu, 24 Feb 2022 17:25:50 +0000	[thread overview]
Message-ID: <20220224172559.4170192-5-rananta@google.com> (raw)
In-Reply-To: <20220224172559.4170192-1-rananta@google.com>

Capture the first run of the KVM VM, which is basically the
first KVM_RUN issued for any vCPU. This state of the VM is
helpful in the upcoming patches to prevent user-space from
configuring certain VM features, such as the feature bitmap
exposed by the psuedo-firmware registers, after the VM has
started running.

Signed-off-by: Raghavendra Rao Ananta <rananta@google.com>
---
 arch/arm64/include/asm/kvm_host.h | 9 +++++++++
 arch/arm64/kvm/arm.c              | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 657733554d98..e823571e50cc 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -139,6 +139,9 @@ struct kvm_arch {
 
 	/* Register scoping enabled for KVM registers */
 	bool reg_scope_enabled;
+
+	/* Capture first run of the VM */
+	bool has_run_once;
 };
 
 struct kvm_vcpu_fault_info {
@@ -796,6 +799,12 @@ bool kvm_arm_vcpu_is_finalized(struct kvm_vcpu *vcpu);
 int kvm_trng_call(struct kvm_vcpu *vcpu);
 int kvm_arm_reg_id_encode_scope(struct kvm_vcpu *vcpu, u64 *reg_id);
 void kvm_arm_reg_id_clear_scope(struct kvm_vcpu *vcpu, u64 *reg_id);
+
+static inline bool kvm_arm_vm_has_run_once(struct kvm_arch *kvm_arch)
+{
+	return kvm_arch->has_run_once;
+}
+
 #ifdef CONFIG_KVM
 extern phys_addr_t hyp_mem_base;
 extern phys_addr_t hyp_mem_size;
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 107977c82c6c..f61cd8d57eae 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -635,6 +635,8 @@ int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu)
 	if (kvm_vm_is_protected(kvm))
 		kvm_call_hyp_nvhe(__pkvm_vcpu_init_traps, vcpu);
 
+	kvm->arch.has_run_once = true;
+
 	return ret;
 }
 
-- 
2.35.1.473.g83b2b277ed-goog

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

WARNING: multiple messages have this Message-ID (diff)
From: Raghavendra Rao Ananta <rananta@google.com>
To: Marc Zyngier <maz@kernel.org>, Andrew Jones <drjones@redhat.com>,
	 James Morse <james.morse@arm.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	 Will Deacon <will@kernel.org>, Peter Shier <pshier@google.com>,
	 Ricardo Koller <ricarkol@google.com>,
	Oliver Upton <oupton@google.com>,
	 Reiji Watanabe <reijiw@google.com>,
	Jing Zhang <jingzhangos@google.com>,
	 Raghavendra Rao Anata <rananta@google.com>,
	linux-arm-kernel@lists.infradead.org,
	 kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org,
	 kvm@vger.kernel.org
Subject: [PATCH v4 04/13] KVM: arm64: Capture VM's first run
Date: Thu, 24 Feb 2022 17:25:50 +0000	[thread overview]
Message-ID: <20220224172559.4170192-5-rananta@google.com> (raw)
In-Reply-To: <20220224172559.4170192-1-rananta@google.com>

Capture the first run of the KVM VM, which is basically the
first KVM_RUN issued for any vCPU. This state of the VM is
helpful in the upcoming patches to prevent user-space from
configuring certain VM features, such as the feature bitmap
exposed by the psuedo-firmware registers, after the VM has
started running.

Signed-off-by: Raghavendra Rao Ananta <rananta@google.com>
---
 arch/arm64/include/asm/kvm_host.h | 9 +++++++++
 arch/arm64/kvm/arm.c              | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 657733554d98..e823571e50cc 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -139,6 +139,9 @@ struct kvm_arch {
 
 	/* Register scoping enabled for KVM registers */
 	bool reg_scope_enabled;
+
+	/* Capture first run of the VM */
+	bool has_run_once;
 };
 
 struct kvm_vcpu_fault_info {
@@ -796,6 +799,12 @@ bool kvm_arm_vcpu_is_finalized(struct kvm_vcpu *vcpu);
 int kvm_trng_call(struct kvm_vcpu *vcpu);
 int kvm_arm_reg_id_encode_scope(struct kvm_vcpu *vcpu, u64 *reg_id);
 void kvm_arm_reg_id_clear_scope(struct kvm_vcpu *vcpu, u64 *reg_id);
+
+static inline bool kvm_arm_vm_has_run_once(struct kvm_arch *kvm_arch)
+{
+	return kvm_arch->has_run_once;
+}
+
 #ifdef CONFIG_KVM
 extern phys_addr_t hyp_mem_base;
 extern phys_addr_t hyp_mem_size;
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 107977c82c6c..f61cd8d57eae 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -635,6 +635,8 @@ int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu)
 	if (kvm_vm_is_protected(kvm))
 		kvm_call_hyp_nvhe(__pkvm_vcpu_init_traps, vcpu);
 
+	kvm->arch.has_run_once = true;
+
 	return ret;
 }
 
-- 
2.35.1.473.g83b2b277ed-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2022-02-24 17:26 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-24 17:25 [PATCH v4 00/13] KVM: arm64: Add support for hypercall services selection Raghavendra Rao Ananta
2022-02-24 17:25 ` Raghavendra Rao Ananta
2022-02-24 17:25 ` Raghavendra Rao Ananta
2022-02-24 17:25 ` [PATCH v4 01/13] KVM: arm64: Factor out firmware register handling from psci.c Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-03-14 18:15   ` Oliver Upton
2022-03-14 18:15     ` Oliver Upton
2022-03-14 18:15     ` Oliver Upton
2022-03-14 23:15     ` Raghavendra Rao Ananta
2022-03-14 23:15       ` Raghavendra Rao Ananta
2022-03-14 23:15       ` Raghavendra Rao Ananta
2022-02-24 17:25 ` [PATCH v4 02/13] KVM: arm64: Introduce KVM_CAP_ARM_REG_SCOPE Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-25  6:42   ` Oliver Upton
2022-02-25  6:42     ` Oliver Upton
2022-02-25  6:42     ` Oliver Upton
2022-02-25 17:34     ` Raghavendra Rao Ananta
2022-02-25 17:34       ` Raghavendra Rao Ananta
2022-02-25 17:34       ` Raghavendra Rao Ananta
2022-02-25 18:26       ` Oliver Upton
2022-02-25 18:26         ` Oliver Upton
2022-02-25 18:26         ` Oliver Upton
2022-02-28 19:46         ` Raghavendra Rao Ananta
2022-02-28 19:46           ` Raghavendra Rao Ananta
2022-02-28 19:46           ` Raghavendra Rao Ananta
2022-02-28 19:46           ` Raghavendra Rao Ananta
2022-02-28 19:46           ` Raghavendra Rao Ananta
2022-02-24 17:25 ` [PATCH v4 03/13] KVM: arm64: Encode the scope for firmware registers Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-03-14 19:16   ` Oliver Upton
2022-03-14 19:16     ` Oliver Upton
2022-03-14 19:16     ` Oliver Upton
2022-02-24 17:25 ` Raghavendra Rao Ananta [this message]
2022-02-24 17:25   ` [PATCH v4 04/13] KVM: arm64: Capture VM's first run Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-03-14 18:02   ` Oliver Upton
2022-03-14 18:02     ` Oliver Upton
2022-03-14 18:02     ` Oliver Upton
2022-03-14 23:12     ` Raghavendra Rao Ananta
2022-03-14 23:12       ` Raghavendra Rao Ananta
2022-03-14 23:12       ` Raghavendra Rao Ananta
2022-02-24 17:25 ` [PATCH v4 05/13] KVM: arm64: Setup a framework for hypercall bitmap firmware registers Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-03-14 19:41   ` Oliver Upton
2022-03-14 19:41     ` Oliver Upton
2022-03-14 19:41     ` Oliver Upton
2022-03-14 20:25     ` Oliver Upton
2022-03-14 20:25       ` Oliver Upton
2022-03-14 20:25       ` Oliver Upton
2022-03-15  0:22     ` Raghavendra Rao Ananta
2022-03-15  0:22       ` Raghavendra Rao Ananta
2022-03-15  0:22       ` Raghavendra Rao Ananta
2022-03-15  7:25       ` Oliver Upton
2022-03-15  7:25         ` Oliver Upton
2022-03-15  7:25         ` Oliver Upton
2022-03-15 16:59         ` Raghavendra Rao Ananta
2022-03-15 16:59           ` Raghavendra Rao Ananta
2022-03-15 16:59           ` Raghavendra Rao Ananta
2022-03-15 17:35           ` Oliver Upton
2022-03-15 17:35             ` Oliver Upton
2022-03-15 17:35             ` Oliver Upton
2022-02-24 17:25 ` [PATCH v4 06/13] KVM: arm64: Add standard hypervisor firmware register Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-03-14 19:45   ` Oliver Upton
2022-03-14 19:45     ` Oliver Upton
2022-03-14 19:45     ` Oliver Upton
2022-03-15  0:23     ` Raghavendra Rao Ananta
2022-03-15  0:23       ` Raghavendra Rao Ananta
2022-03-15  0:23       ` Raghavendra Rao Ananta
2022-02-24 17:25 ` [PATCH v4 07/13] KVM: arm64: Add vendor " Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-03-14 19:59   ` Oliver Upton
2022-03-14 19:59     ` Oliver Upton
2022-03-14 19:59     ` Oliver Upton
2022-03-15  0:30     ` Raghavendra Rao Ananta
2022-03-15  0:30       ` Raghavendra Rao Ananta
2022-03-15  0:30       ` Raghavendra Rao Ananta
2022-03-15  6:41       ` Oliver Upton
2022-03-15  6:41         ` Oliver Upton
2022-03-15  6:41         ` Oliver Upton
2022-03-15 17:53         ` Raghavendra Rao Ananta
2022-03-15 17:53           ` Raghavendra Rao Ananta
2022-03-15 17:53           ` Raghavendra Rao Ananta
2022-02-24 17:25 ` [PATCH v4 08/13] Docs: KVM: Add doc for the bitmap firmware registers Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-24 17:25 ` [PATCH v4 09/13] Docs: KVM: Rename psci.rst to hypercalls.rst Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-03-14 20:01   ` Oliver Upton
2022-03-14 20:01     ` Oliver Upton
2022-03-14 20:01     ` Oliver Upton
2022-03-15  0:31     ` Raghavendra Rao Ananta
2022-03-15  0:31       ` Raghavendra Rao Ananta
2022-03-15  0:31       ` Raghavendra Rao Ananta
2022-02-24 17:25 ` [PATCH v4 10/13] tools: Import ARM SMCCC definitions Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-24 17:25 ` [PATCH v4 11/13] selftests: KVM: aarch64: Introduce hypercall ABI test Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-24 17:25 ` [PATCH v4 12/13] selftests: KVM: aarch64: hypercalls: Test with KVM_CAP_ARM_REG_SCOPE Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-24 17:25 ` [PATCH v4 13/13] selftests: KVM: aarch64: Add the bitmap firmware registers to get-reg-list Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-02-24 17:25   ` Raghavendra Rao Ananta
2022-03-14 20:02   ` Oliver Upton
2022-03-14 20:02     ` Oliver Upton
2022-03-14 20:02     ` Oliver Upton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220224172559.4170192-5-rananta@google.com \
    --to=rananta@google.com \
    --cc=alexandru.elisei@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=drjones@redhat.com \
    --cc=james.morse@arm.com \
    --cc=jingzhangos@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=oupton@google.com \
    --cc=pbonzini@redhat.com \
    --cc=pshier@google.com \
    --cc=reijiw@google.com \
    --cc=ricarkol@google.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.