public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: Joey Gouly <joey.gouly@arm•com>
To: kvmarm@lists•linux.dev
Cc: joey.gouly@arm•com, Marc Zyngier <maz@kernel•org>,
	Oliver Upton <oliver.upton@linux•dev>,
	Suzuki K Poulose <suzuki.poulose@arm•com>,
	Zenghui Yu <yuzenghui@huawei•com>,
	Steffen Eiden <seiden@linux•ibm.com>,
	linux-arm-kernel@lists•infradead.org
Subject: [PATCH v1] KVM: arm64: Restore POR_EL0 access to host EL0
Date: Thu,  4 Jun 2026 11:54:34 +0100	[thread overview]
Message-ID: <20260604105434.2297268-1-joey.gouly@arm.com> (raw)

CPTR_EL2.E0POE was being cleared in __deactivate_cptr_traps_vhe(), which meant
that any accesses to POR_EL0 from host EL0 would trap and be reported to
userspace as an Illegal instruction. This would happen after running any VM,
regardless if it used POE or not.

Signed-off-by: Joey Gouly <joey.gouly@arm•com>
Link: https://sashiko.dev/#/patchset/20260602155430.2088142-1-maz@kernel.org?part=1
---

Tested by (paraphrased):

	$ ./read_por_el0
	$ ./lkvm run -f kvm-unit-tests/timer.flat
	$ ./read_por_el0 # This gets "Illegal instruction"

Also ran the above flow in a nested VM.

 arch/arm64/kvm/hyp/include/hyp/switch.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h
index 320cd45d49c5..e9b36a3b27bb 100644
--- a/arch/arm64/kvm/hyp/include/hyp/switch.h
+++ b/arch/arm64/kvm/hyp/include/hyp/switch.h
@@ -181,6 +181,8 @@ static inline void __deactivate_cptr_traps_vhe(struct kvm_vcpu *vcpu)
 		val |= CPACR_EL1_ZEN;
 	if (cpus_have_final_cap(ARM64_SME))
 		val |= CPACR_EL1_SMEN;
+	if (cpus_have_final_cap(ARM64_HAS_S1POE))
+		val |= CPACR_EL1_E0POE;
 
 	write_sysreg(val, cpacr_el1);
 }
-- 
2.25.1



                 reply	other threads:[~2026-06-04 10:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260604105434.2297268-1-joey.gouly@arm.com \
    --to=joey.gouly@arm$(echo .)com \
    --cc=kvmarm@lists$(echo .)linux.dev \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    --cc=maz@kernel$(echo .)org \
    --cc=oliver.upton@linux$(echo .)dev \
    --cc=seiden@linux$(echo .)ibm.com \
    --cc=suzuki.poulose@arm$(echo .)com \
    --cc=yuzenghui@huawei$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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