From: Fuad Tabba <fuad.tabba@linux.dev>
To: Marc Zyngier <maz@kernel.org>, Oliver Upton <oupton@kernel.org>,
kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org
Cc: Joey Gouly <joey.gouly@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Steffen Eiden <seiden@linux.ibm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Vincent Donnefort <vdonnefort@google.com>,
Fuad Tabba <tabba@google.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 12/20] KVM: arm64: Advertise TCR2, SCTLR2, S1PIE and S1POE to protected VMs
Date: Wed, 25 Nov 2026 15:39:03 +0000 [thread overview]
Message-ID: <20261125153911.106793-13-fuad.tabba@linux.dev> (raw)
In-Reply-To: <20261125153911.106793-1-fuad.tabba@linux.dev>
Advertise FEAT_TCR2, FEAT_SCTLR2, FEAT_S1PIE and FEAT_S1POE to
protected VMs, with S1POE only when the kernel supports POE, as EL2
doesn't switch the POE registers otherwise. With the fields set,
vcpu_set_hcrx() sets HCRX_EL2.{TCR2En,SCTLR2En} for them, and since
the previous patch their PIE and POE registers don't trap.
Reset the new registers as KVM does for a non-protected vCPU.
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
arch/arm64/include/asm/kvm_hyp.h | 1 +
arch/arm64/kvm/arm.c | 1 +
arch/arm64/kvm/hyp/nvhe/sys_regs.c | 24 +++++++++++++++++++++++-
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/kvm_hyp.h b/arch/arm64/include/asm/kvm_hyp.h
index 920c1d8d45b1a..ab22b395d0908 100644
--- a/arch/arm64/include/asm/kvm_hyp.h
+++ b/arch/arm64/include/asm/kvm_hyp.h
@@ -151,6 +151,7 @@ extern u64 kvm_nvhe_sym(id_aa64isar2_el1_sys_val);
extern u64 kvm_nvhe_sym(id_aa64mmfr0_el1_sys_val);
extern u64 kvm_nvhe_sym(id_aa64mmfr1_el1_sys_val);
extern u64 kvm_nvhe_sym(id_aa64mmfr2_el1_sys_val);
+extern u64 kvm_nvhe_sym(id_aa64mmfr3_el1_sys_val);
extern u64 kvm_nvhe_sym(id_aa64smfr0_el1_sys_val);
extern u64 kvm_nvhe_sym(id_aa64dfr0_el1_sys_val);
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 3b4bc646d894a..71afc5a5c9346 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -2840,6 +2840,7 @@ static void kvm_hyp_init_symbols(void)
kvm_nvhe_sym(id_aa64mmfr0_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1);
kvm_nvhe_sym(id_aa64mmfr1_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64MMFR1_EL1);
kvm_nvhe_sym(id_aa64mmfr2_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64MMFR2_EL1);
+ kvm_nvhe_sym(id_aa64mmfr3_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64MMFR3_EL1);
kvm_nvhe_sym(id_aa64smfr0_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64SMFR0_EL1);
kvm_nvhe_sym(id_aa64dfr0_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64DFR0_EL1);
kvm_nvhe_sym(__icache_flags) = __icache_flags;
diff --git a/arch/arm64/kvm/hyp/nvhe/sys_regs.c b/arch/arm64/kvm/hyp/nvhe/sys_regs.c
index 0a536b237a7c9..4f13b100007fa 100644
--- a/arch/arm64/kvm/hyp/nvhe/sys_regs.c
+++ b/arch/arm64/kvm/hyp/nvhe/sys_regs.c
@@ -30,6 +30,7 @@ u64 id_aa64isar2_el1_sys_val;
u64 id_aa64mmfr0_el1_sys_val;
u64 id_aa64mmfr1_el1_sys_val;
u64 id_aa64mmfr2_el1_sys_val;
+u64 id_aa64mmfr3_el1_sys_val;
u64 id_aa64smfr0_el1_sys_val;
u64 id_aa64dfr0_el1_sys_val;
@@ -83,6 +84,11 @@ static bool vm_has_sve(const struct kvm *kvm)
return system_supports_sve() && kvm_vcpu_has_feature(kvm, KVM_ARM_VCPU_SVE);
}
+static bool vm_has_s1poe(const struct kvm *kvm)
+{
+ return system_supports_poe();
+}
+
/*
* Definitions for features to be allowed or restricted for protected guests.
*
@@ -176,6 +182,14 @@ static const struct pvm_ftr_bits pvmid_aa64mmfr2[] = {
FEAT_END
};
+static const struct pvm_ftr_bits pvmid_aa64mmfr3[] = {
+ MAX_FEAT(ID_AA64MMFR3_EL1, TCRX, IMP),
+ MAX_FEAT(ID_AA64MMFR3_EL1, SCTLRX, IMP),
+ MAX_FEAT(ID_AA64MMFR3_EL1, S1PIE, IMP),
+ MAX_FEAT_FUNC(ID_AA64MMFR3_EL1, S1POE, IMP, vm_has_s1poe),
+ FEAT_END
+};
+
static const struct pvm_ftr_bits pvmid_aa64isar1[] = {
MAX_FEAT(ID_AA64ISAR1_EL1, DPB, DPB2),
MAX_FEAT_FUNC(ID_AA64ISAR1_EL1, APA, PAuth, vm_has_ptrauth),
@@ -273,6 +287,8 @@ static u64 pvm_calc_id_reg(const struct kvm_vcpu *vcpu, u32 id)
return get_restricted_features(vcpu, id_aa64mmfr1_el1_sys_val, pvmid_aa64mmfr1);
case SYS_ID_AA64MMFR2_EL1:
return get_restricted_features(vcpu, id_aa64mmfr2_el1_sys_val, pvmid_aa64mmfr2);
+ case SYS_ID_AA64MMFR3_EL1:
+ return get_restricted_features(vcpu, id_aa64mmfr3_el1_sys_val, pvmid_aa64mmfr3);
case SYS_ID_AA64DFR0_EL1:
return get_restricted_features(vcpu, id_aa64dfr0_el1_sys_val, pvmid_aa64dfr0);
case SYS_ID_AA64MMFR4_EL1:
@@ -706,7 +722,7 @@ static const struct sys_reg_desc pvm_sys_reg_descs[] = {
AARCH64(SYS_ID_AA64MMFR0_EL1),
AARCH64(SYS_ID_AA64MMFR1_EL1),
AARCH64(SYS_ID_AA64MMFR2_EL1),
- ID_UNALLOCATED(7,3),
+ AARCH64(SYS_ID_AA64MMFR3_EL1),
ID_UNALLOCATED(7,4),
ID_UNALLOCATED(7,5),
ID_UNALLOCATED(7,6),
@@ -792,7 +808,13 @@ static const struct sys_reg_desc_reset pvm_sys_reg_reset_vals[] = {
RESET_ZERO(CPACR_EL1),
RESET_VAL(CONTEXTIDR_EL1, 0x00000000dbadc0deULL),
RESET_VAL(SCTLR_EL1, 0x00C50078ULL),
+ RESET_ZERO(SCTLR2_EL1),
RESET_ZERO(TCR_EL1),
+ RESET_ZERO(TCR2_EL1),
+ RESET_UNKNOWN(PIR_EL1),
+ RESET_UNKNOWN(PIRE0_EL1),
+ RESET_UNKNOWN(POR_EL1),
+ RESET_UNKNOWN(POR_EL0),
RESET_UNKNOWN(AFSR0_EL1),
RESET_UNKNOWN(AFSR1_EL1),
RESET_UNKNOWN(ESR_EL1),
--
2.47.3
next prev parent reply other threads:[~2026-11-25 15:40 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 15:38 [PATCH v2 00/20] KVM: arm64: Support debug, SVE, MOPS, PIE/POE, FPMR and more in protected VMs Fuad Tabba
2026-11-25 15:38 ` [PATCH v2 01/20] KVM: arm64: Only allow ptrauth for a pVM on a system with full ptrauth Fuad Tabba
2026-11-25 15:38 ` [PATCH v2 02/20] KVM: arm64: Don't advertise the host's MTE_frac to protected VMs Fuad Tabba
2026-11-25 15:49 ` sashiko-bot
2026-11-25 15:52 ` Fuad Tabba
2026-11-25 15:38 ` [PATCH v2 03/20] KVM: arm64: Add support for self-hosted debug in protected guests Fuad Tabba
2026-11-25 15:38 ` [PATCH v2 04/20] KVM: arm64: Remove redundant kern_hyp_va() calls from the pKVM FP sync Fuad Tabba
2026-11-25 15:38 ` [PATCH v2 05/20] KVM: arm64: Allocate a protected vCPU's SVE state at EL2 Fuad Tabba
2026-11-25 15:38 ` [PATCH v2 06/20] KVM: arm64: Advertise ID_AA64ZFR0_EL1 to protected VMs Fuad Tabba
2026-11-25 15:38 ` [PATCH v2 07/20] KVM: arm64: Allow protected VMs to use SVE Fuad Tabba
2026-11-25 15:38 ` [PATCH v2 08/20] KVM: arm64: Move the VM's FGU initialisation into config.c Fuad Tabba
2026-11-25 15:39 ` [PATCH v2 09/20] KVM: arm64: Report an incomplete feature map with WARN_ON() Fuad Tabba
2026-11-25 15:55 ` sashiko-bot
2026-11-25 15:58 ` Fuad Tabba
2026-11-25 15:39 ` [PATCH v2 10/20] KVM: arm64: Advertise the GICv3 CPU interface to protected VMs on GICv5 Fuad Tabba
2026-11-25 15:39 ` [PATCH v2 11/20] KVM: arm64: Compute a protected vCPU's fine-grained traps at EL2 Fuad Tabba
2026-11-25 15:39 ` Fuad Tabba [this message]
2026-11-25 15:39 ` [PATCH v2 13/20] KVM: arm64: Advertise MOPS to protected VMs Fuad Tabba
2026-11-25 15:39 ` [PATCH v2 14/20] KVM: arm64: Advertise FPMR " Fuad Tabba
2026-11-25 15:39 ` [PATCH v2 15/20] KVM: arm64: Advertise HBC, CLRBHB, RPRFM, CSSC and LUT " Fuad Tabba
2026-11-25 15:39 ` [PATCH v2 16/20] KVM: arm64: Advertise FAMINMAX, LSFE, LSUI and FPRCVT " Fuad Tabba
2026-11-25 15:39 ` [PATCH v2 17/20] KVM: arm64: Advertise AFP and RPRES " Fuad Tabba
2026-11-25 15:39 ` [PATCH v2 18/20] KVM: arm64: Advertise ECBHB, TIDCP1, TTST and LVA " Fuad Tabba
2026-11-25 15:39 ` [PATCH v2 19/20] KVM: arm64: Advertise FP8 and F16MM " Fuad Tabba
2026-11-25 15:39 ` [PATCH v2 20/20] KVM: arm64: Advertise ECV, HAFT and ETS3 " Fuad Tabba
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=20261125153911.106793-13-fuad.tabba@linux.dev \
--to=fuad.tabba@linux.dev \
--cc=catalin.marinas@arm.com \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=seiden@linux.ibm.com \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.com \
--cc=vdonnefort@google.com \
--cc=will@kernel.org \
--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.