All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Upton <oliver.upton@linux.dev>
To: kvmarm@lists.linux.dev
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
	Marc Zyngier <maz@kernel.org>, James Morse <james.morse@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Sean Christopherson <seanjc@google.com>,
	Salil Mehta <salil.mehta@huawei.com>,
	Oliver Upton <oliver.upton@linux.dev>
Subject: [PATCH v3 05/13] KVM: arm64: Start handling SMCs from EL1
Date: Tue,  4 Apr 2023 15:40:42 +0000	[thread overview]
Message-ID: <20230404154050.2270077-6-oliver.upton@linux.dev> (raw)
In-Reply-To: <20230404154050.2270077-1-oliver.upton@linux.dev>

Whelp, the architecture gods have spoken and confirmed that the function
ID space is common between SMCs and HVCs. Not only that, the expectation
is that hypervisors handle calls to both SMC and HVC conduits. KVM
recently picked up support for SMCCCs in commit bd36b1a9eb5a ("KVM:
arm64: nv: Handle SMCs taken from virtual EL2") but scoped it only to a
nested hypervisor.

Let's just open the floodgates and let EL1 access our SMCCC
implementation with the SMC instruction as well.

Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
---
 arch/arm64/kvm/handle_exit.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
index 5e4f9737cbd5..68f95dcd41a1 100644
--- a/arch/arm64/kvm/handle_exit.c
+++ b/arch/arm64/kvm/handle_exit.c
@@ -72,13 +72,15 @@ static int handle_smc(struct kvm_vcpu *vcpu)
 	 *
 	 * We need to advance the PC after the trap, as it would
 	 * otherwise return to the same address...
-	 *
-	 * Only handle SMCs from the virtual EL2 with an immediate of zero and
-	 * skip it otherwise.
 	 */
-	if (!vcpu_is_el2(vcpu) || kvm_vcpu_hvc_get_imm(vcpu)) {
+	kvm_incr_pc(vcpu);
+
+	/*
+	 * SMCs with a nonzero immediate are reserved according to DEN0028E 2.9
+	 * "SMC and HVC immediate value".
+	 */
+	if (kvm_vcpu_hvc_get_imm(vcpu)) {
 		vcpu_set_reg(vcpu, 0, ~0UL);
-		kvm_incr_pc(vcpu);
 		return 1;
 	}
 
@@ -93,8 +95,6 @@ static int handle_smc(struct kvm_vcpu *vcpu)
 	if (ret < 0)
 		vcpu_set_reg(vcpu, 0, ~0UL);
 
-	kvm_incr_pc(vcpu);
-
 	return ret;
 }
 
-- 
2.40.0.348.gf938b09366-goog


  parent reply	other threads:[~2023-04-04 15:41 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-04 15:40 [PATCH v3 00/13] KVM: arm64: Userspace SMCCC call filtering Oliver Upton
2023-04-04 15:40 ` [PATCH v3 01/13] KVM: x86: Redefine 'longmode' as a flag for KVM_EXIT_HYPERCALL Oliver Upton
2023-04-04 15:40 ` [PATCH v3 02/13] KVM: arm64: Add a helper to check if a VM has ran once Oliver Upton
2023-04-04 15:40 ` [PATCH v3 03/13] KVM: arm64: Add vm fd device attribute accessors Oliver Upton
2023-04-04 15:40 ` [PATCH v3 04/13] KVM: arm64: Rename SMC/HVC call handler to reflect reality Oliver Upton
2023-04-04 15:40 ` Oliver Upton [this message]
2023-04-04 15:40 ` [PATCH v3 06/13] KVM: arm64: Refactor hvc filtering to support different actions Oliver Upton
2023-04-04 15:40 ` [PATCH v3 07/13] KVM: arm64: Use a maple tree to represent the SMCCC filter Oliver Upton
2023-04-04 15:40 ` [PATCH v3 08/13] KVM: arm64: Add support for KVM_EXIT_HYPERCALL Oliver Upton
2023-04-05  7:35   ` Marc Zyngier
2023-04-05 11:59     ` Marc Zyngier
2023-04-05 15:30       ` Oliver Upton
2023-05-17 18:00       ` Salil Mehta
2023-05-17 18:38         ` Oliver Upton
2023-05-18  8:06           ` Marc Zyngier
2023-05-18  9:08             ` Salil Mehta
2023-05-18  9:42               ` Marc Zyngier
2023-05-18 12:16                 ` Salil Mehta
2023-05-18  8:54           ` Salil Mehta
2023-04-04 15:40 ` [PATCH v3 09/13] KVM: arm64: Introduce support for userspace SMCCC filtering Oliver Upton
2023-04-04 15:40 ` [PATCH v3 10/13] KVM: arm64: Return NOT_SUPPORTED to guest for unknown PSCI version Oliver Upton
2023-04-04 15:40 ` [PATCH v3 11/13] KVM: arm64: Let errors from SMCCC emulation to reach userspace Oliver Upton
2023-04-04 15:40 ` [PATCH v3 12/13] KVM: selftests: Add a helper for SMCCC calls with SMC instruction Oliver Upton
2023-04-04 15:40 ` [PATCH v3 13/13] KVM: selftests: Add test for SMCCC filter Oliver Upton
2023-04-05 18:45 ` [PATCH v3 00/13] KVM: arm64: Userspace SMCCC call filtering Marc Zyngier

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=20230404154050.2270077-6-oliver.upton@linux.dev \
    --to=oliver.upton@linux.dev \
    --cc=james.morse@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=salil.mehta@huawei.com \
    --cc=seanjc@google.com \
    --cc=suzuki.poulose@arm.com \
    --cc=yuzenghui@huawei.com \
    /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.