From: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org
Cc: maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com,
suzuki.poulose@arm.com, yuzenghui@huawei.com,
darren@os.amperecomputing.com,
gankulkarni@os.amperecomputing.com
Subject: [PATCH] KVM: arm64: nv: Forward hvc traps if originated from nested VM
Date: Thu, 10 Apr 2025 00:07:43 -0700 [thread overview]
Message-ID: <20250410070743.1072583-1-gankulkarni@os.amperecomputing.com> (raw)
It was discovered while trying selftest(smccc_filter) that the
hvc trap is getting forwarded to guest hypervisor even if it is
originated from itself.
HVC traps from guest hypervisor should be handled by the host
hypervisor and traps originating from nested VM should be
forwarded. Adding check to forward only if the hvc is trapped
from the nested VM.
Signed-off-by: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
---
arch/arm64/kvm/handle_exit.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
index 80218f62773b..894f92693ed9 100644
--- a/arch/arm64/kvm/handle_exit.c
+++ b/arch/arm64/kvm/handle_exit.c
@@ -40,8 +40,8 @@ static int handle_hvc(struct kvm_vcpu *vcpu)
kvm_vcpu_hvc_get_imm(vcpu));
vcpu->stat.hvc_exit_stat++;
- /* Forward hvc instructions to the virtual EL2 if the guest has EL2. */
- if (vcpu_has_nv(vcpu)) {
+ /* Forward hvc instructions to the virtual EL2, if it is from nested VM. */
+ if (vcpu_has_nv(vcpu) && !is_hyp_ctxt(vcpu)) {
if (vcpu_read_sys_reg(vcpu, HCR_EL2) & HCR_HCD)
kvm_inject_undefined(vcpu);
else
--
2.48.1
next reply other threads:[~2025-04-10 7:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 7:07 Ganapatrao Kulkarni [this message]
2025-04-10 7:19 ` Marc Zyngier
2025-04-10 10:20 ` Ganapatrao Kulkarni
2025-04-10 10:52 ` Marc Zyngier
2025-04-10 13:22 ` Ganapatrao Kulkarni
2025-04-10 17:31 ` 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=20250410070743.1072583-1-gankulkarni@os.amperecomputing.com \
--to=gankulkarni@os.amperecomputing.com \
--cc=darren@os.amperecomputing.com \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--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
all inboxes | Powered by JetHome®