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 v2 11/13] KVM: arm64: Let errors from SMCCC emulation to reach userspace
Date: Thu, 30 Mar 2023 15:49:16 +0000 [thread overview]
Message-ID: <20230330154918.4014761-12-oliver.upton@linux.dev> (raw)
In-Reply-To: <20230330154918.4014761-1-oliver.upton@linux.dev>
Typically a negative return from an exit handler is used to request a
return to userspace with the specified error. KVM's handling of SMCCC
emulation (i.e. both HVCs and SMCs) deviates from the trend and resumes
the guest instead.
Stop handling negative returns this way and instead let the error
percolate to userspace.
Suggested-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
---
arch/arm64/kvm/handle_exit.c | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
index 3f43e20c48b6..6dcd6604b6bc 100644
--- a/arch/arm64/kvm/handle_exit.c
+++ b/arch/arm64/kvm/handle_exit.c
@@ -36,8 +36,6 @@ static void kvm_handle_guest_serror(struct kvm_vcpu *vcpu, u64 esr)
static int handle_hvc(struct kvm_vcpu *vcpu)
{
- int ret;
-
trace_kvm_hvc_arm64(*vcpu_pc(vcpu), vcpu_get_reg(vcpu, 0),
kvm_vcpu_hvc_get_imm(vcpu));
vcpu->stat.hvc_exit_stat++;
@@ -52,19 +50,11 @@ static int handle_hvc(struct kvm_vcpu *vcpu)
return 1;
}
- ret = kvm_smccc_call_handler(vcpu);
- if (ret < 0) {
- vcpu_set_reg(vcpu, 0, ~0UL);
- return 1;
- }
-
- return ret;
+ return kvm_smccc_call_handler(vcpu);
}
static int handle_smc(struct kvm_vcpu *vcpu)
{
- int ret;
-
/*
* "If an SMC instruction executed at Non-secure EL1 is
* trapped to EL2 because HCR_EL2.TSC is 1, the exception is a
@@ -93,11 +83,7 @@ static int handle_smc(struct kvm_vcpu *vcpu)
* at Non-secure EL1 is trapped to EL2 if HCR_EL2.TSC==1, rather than
* being treated as UNDEFINED.
*/
- ret = kvm_smccc_call_handler(vcpu);
- if (ret < 0)
- vcpu_set_reg(vcpu, 0, ~0UL);
-
- return ret;
+ return kvm_smccc_call_handler(vcpu);
}
/*
--
2.40.0.348.gf938b09366-goog
next prev parent reply other threads:[~2023-03-30 15:50 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 15:49 [PATCH v2 00/13] KVM: arm64: Userspace SMCCC call filtering Oliver Upton
2023-03-30 15:49 ` [PATCH v2 01/13] KVM: x86: Redefine 'longmode' as a flag for KVM_EXIT_HYPERCALL Oliver Upton
2023-03-30 17:32 ` Sean Christopherson
2023-03-30 15:49 ` [PATCH v2 02/13] KVM: arm64: Add a helper to check if a VM has ran once Oliver Upton
2023-03-30 15:49 ` [PATCH v2 03/13] KVM: arm64: Add vm fd device attribute accessors Oliver Upton
2023-03-30 15:49 ` [PATCH v2 04/13] KVM: arm64: Rename SMC/HVC call handler to reflect reality Oliver Upton
2023-03-30 15:49 ` [PATCH v2 05/13] KVM: arm64: Start handling SMCs from EL1 Oliver Upton
2023-03-30 15:49 ` [PATCH v2 06/13] KVM: arm64: Refactor hvc filtering to support different actions Oliver Upton
2023-03-31 17:03 ` Marc Zyngier
2023-03-31 17:58 ` Oliver Upton
2023-03-30 15:49 ` [PATCH v2 07/13] KVM: arm64: Use a maple tree to represent the SMCCC filter Oliver Upton
2023-03-30 15:49 ` [PATCH v2 08/13] KVM: arm64: Add support for KVM_EXIT_HYPERCALL Oliver Upton
2023-03-31 17:10 ` Marc Zyngier
2023-03-31 18:00 ` Oliver Upton
2023-03-30 15:49 ` [PATCH v2 09/13] KVM: arm64: Indroduce support for userspace SMCCC filtering Oliver Upton
2023-03-31 19:13 ` Marc Zyngier
2023-04-03 16:28 ` Oliver Upton
2023-03-30 15:49 ` [PATCH v2 10/13] KVM: arm64: Return NOT_SUPPORTED to guest for unknown PSCI version Oliver Upton
2023-03-30 15:49 ` Oliver Upton [this message]
2023-03-30 15:49 ` [PATCH v2 12/13] KVM: selftests: Add a helper for SMCCC calls with SMC instruction Oliver Upton
2023-03-30 15:49 ` [PATCH v2 13/13] KVM: selftests: Add test for SMCCC filter 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=20230330154918.4014761-12-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox