KVM: arm64: Support debug, SVE, MOPS, PIE/POE, FPMR and more in protected VMs
Subsystems (4)
Fuad Tabba
reviewercover KVM: arm64: Support debug, SVE, MOPS, PIE/POE, FPMR and more in protected VMs
Hi folks,
With most of the groundwork now merged, bringing protected VMs up to the features we support for them in Android turns out not to be a big series. So this folds self-hosted debug [1] and SVE [2], which I posted separately last week, into one series with the rest. Both are small, and keeping them apart would only leave a few conflicts where they add neighbouring lines to the pVM ID-register code. The debug and SVE patches are unchanged from those postings.
01: Self-hosted debug. 02-05: SVE, with EL2 owning a protected vCPU's SVE state. 06-07: Compute a protected vCPU's fine-grained traps at EL2. 08-16: Advertise TCR2, SCTLR2, S1PIE, S1POE, MOPS, FPMR and the
features EL2 already handles for non-protected guests.
Tested on QEMU, in hVHE and nVHE, and on FVP for S1POE and the fields QEMU doesn't model (CLRBHB, RPRFM, ECBHB, LSFE, LSUI, HAFT, ETS3 and F16MM). v2 of the pKVM selftests series [3] will cover debug, SVE, MOPS, PIE, POE and FPMR.
Based on Linux 7.4-rc1 (6628e7d4c6b25); it also applies to 7.4-rc2 (7475ea8b58616).
Cheers,
/fuad
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
Fuad Tabba (16):
KVM: arm64: Add support for self-hosted debug in protected guests
KVM: arm64: Remove redundant kern_hyp_va() calls from the pKVM FP sync
KVM: arm64: Allocate a protected vCPU's SVE state at EL2
KVM: arm64: Advertise ID_AA64ZFR0_EL1 to protected VMs
KVM: arm64: Allow protected VMs to use SVE
KVM: arm64: Move the VM's FGU initialisation into config.c
KVM: arm64: Compute a protected vCPU's fine-grained traps at EL2
KVM: arm64: Advertise TCR2, SCTLR2, S1PIE and S1POE to protected VMs
KVM: arm64: Advertise MOPS to protected VMs
KVM: arm64: Advertise FPMR to protected VMs
KVM: arm64: Advertise HBC, CLRBHB, RPRFM, CSSC and LUT to protected
VMs
KVM: arm64: Advertise FAMINMAX, LSFE, LSUI and FPRCVT to protected VMs
KVM: arm64: Advertise AFP and RPRES to protected VMs
KVM: arm64: Advertise ECBHB, TIDCP1, TTST and LVA to protected VMs
KVM: arm64: Advertise FP8 and F16MM to protected VMs
KVM: arm64: Advertise ECV, HAFT and ETS3 to protected VMs
Documentation/virt/kvm/arm/pkvm.rst | 13 +- arch/arm64/include/asm/kvm_host.h | 2 +- arch/arm64/include/asm/kvm_hyp.h | 6 + arch/arm64/include/asm/kvm_pkvm.h | 1 + arch/arm64/kvm/arm.c | 5 + arch/arm64/kvm/config.c | 32 ++- arch/arm64/kvm/hyp/include/nvhe/pkvm.h | 1 + arch/arm64/kvm/hyp/nvhe/Makefile | 1 + arch/arm64/kvm/hyp/nvhe/hyp-main.c | 6 +- arch/arm64/kvm/hyp/nvhe/pkvm.c | 51 ++-- arch/arm64/kvm/hyp/nvhe/switch.c | 1 + arch/arm64/kvm/hyp/nvhe/sys_regs.c | 349 +++++++++++++++++++++++-- arch/arm64/kvm/reset.c | 2 + arch/arm64/kvm/sys_regs.c | 17 +- 14 files changed, 413 insertions(+), 74 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.47.3
Fuad Tabba
reviewerPATCH 1/16 KVM: arm64: Add support for self-hosted debug in protected guests
pKVM hides DebugVer from protected guests and makes their debug registers RAZ/WI or UNDEFINED, so they don't have breakpoints, watchpoints or single-step. For a non-protected guest, the host sets the owner of the debug registers at vcpu load, from the guest's MDSCR_EL1 and OS Lock, and EL2 copies the owner and the registers in at each entry. However, the host can't see a protected guest's registers.
Set the owner at EL2 for a protected vCPU instead, by the rules the host uses for a non-protected guest, but keep MDCR_EL2.TDA set when the guest is the owner. A trap handler returns to the guest without going back through the world switch, so a handler that changes the owner switches the debug registers itself. The PSCI CPU_ON reset runs after the vcpu load, so it sets the owner again.
Advertise DebugVer, capped at V8P8 as for a non-protected guest, and the breakpoint, watchpoint and context-aware breakpoint counts. The other debug registers that took an UNDEF behave as they do for a non-protected guest that doesn't own its debug registers.
--- Documentation/virt/kvm/arm/pkvm.rst | 7 +- arch/arm64/include/asm/kvm_hyp.h | 1 + arch/arm64/kvm/arm.c | 1 + arch/arm64/kvm/hyp/include/nvhe/pkvm.h | 1 + arch/arm64/kvm/hyp/nvhe/hyp-main.c | 2 + arch/arm64/kvm/hyp/nvhe/pkvm.c | 8 +- arch/arm64/kvm/hyp/nvhe/sys_regs.c | 253 +++++++++++++++++++++++-- 7 files changed, 248 insertions(+), 25 deletions(-)
Documentation/virt/kvm/arm/pkvm.rst +3 -4
@@ -241,10 +241,9 @@ Other interface differences Debug ----- -Hardware-assisted debugging is not available to protected guests. -``MDSCR_EL1``, ``OSLAR_EL1``, ``OSLSR_EL1``, ``OSDLR_EL1``, and breakpoint -and watchpoint 0 are RAZ/WI; any other debug register access takes an -undefined instruction exception. +A protected guest can use self-hosted debug (breakpoints, watchpoints and +single-step) as a non-protected guest can. ``KVM_SET_GUEST_DEBUG`` returns +``-EPERM`` for a protected VM. Resources =========
arch/arm64/include/asm/kvm_hyp.h +1 -0
@@ -151,6 +151,7 @@ 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_aa64smfr0_el1_sys_val ); +extern u64 kvm_nvhe_sym (id_aa64dfr0_el1_sys_val );extern unsigned long kvm_nvhe_sym (__icache_flags );extern unsigned int kvm_nvhe_sym (kvm_arm_vmid_bits );
arch/arm64/kvm/arm.c +1 -0
@@ -2834,6 +2834,7 @@ static void kvm_hyp_init_symbols(void)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_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;kvm_nvhe_sym (kvm_arm_vmid_bits) = kvm_arm_vmid_bits;
arch/arm64/kvm/hyp/include/nvhe/pkvm.h +1 -0
@@ -130,6 +130,7 @@ void put_pkvm_hyp_vm(struct pkvm_hyp_vm *hyp_vm);bool kvm_handle_pvm_hvc64 (struct kvm_vcpu *vcpu,u64 *exit_code);bool kvm_handle_pvm_sysreg (struct kvm_vcpu *vcpu,u64 *exit_code);bool kvm_handle_pvm_restricted (struct kvm_vcpu *vcpu,u64 *exit_code); +void kvm_load_pvm_debug (struct kvm_vcpu *vcpu);void kvm_init_pvm_id_regs (struct kvm_vcpu *vcpu);void kvm_reset_pvm_sys_regs (struct kvm_vcpu *vcpu);int kvm_check_pvm_sysreg_table (void );
arch/arm64/kvm/hyp/nvhe/hyp-main.c +2 -0
@@ -837,6 +837,8 @@ DEFINE_KVM_HOST_HCALL(void, __pkvm_vcpu_load, hyp_vcpu->vcpu.arch.hcr_el2 &= ~(HCR_EL2_TWE |HCR_EL2_TWI ); hyp_vcpu->vcpu.arch.hcr_el2 |= hcr_el2 & (HCR_EL2_TWE |HCR_EL2_TWI ); +kvm_load_pvm_debug (&hyp_vcpu->vcpu); +/* HPMN == 0 is reserved without FEAT_HPMN0. */ if (pmuv3_implemented (SYS_FIELD_GET (ID_AA64DFR0_EL1 , PMUVer, dfr0))) u64p_replace_bits(&hyp_vcpu->vcpu.arch.mdcr_el2,
arch/arm64/kvm/hyp/nvhe/pkvm.c +6 -2
@@ -123,8 +123,11 @@ static void pvm_init_traps_mdcr(struct kvm_vcpu *vcpu) val &= ~(MDCR_EL2_HPME |MDCR_EL2_MTPME ); } -if (!kvm_has_feat (kvm,ID_AA64DFR0_EL1 , DebugVer,IMP )) - val |=MDCR_EL2_TDRA |MDCR_EL2_TDA ; +/* +* Keep TDA set even when the guest owns debug: it also traps the DCC +* and the claim tags, which the world switch doesn't switch. +*/ + val |=MDCR_EL2_TDRA |MDCR_EL2_TDA ;if (!kvm_has_feat (kvm,ID_AA64DFR0_EL1 , DoubleLock,IMP )) val |=MDCR_EL2_TDOSA ;
@@ -1245,6 +1248,7 @@ int pkvm_reset_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu)kvm_reset_vcpu_core (&hyp_vcpu->vcpu);kvm_reset_pvm_sys_regs (&hyp_vcpu->vcpu); +kvm_load_pvm_debug (&hyp_vcpu->vcpu);/* Must be done after resetting sys registers. */ kvm_reset_vcpu_psci (&hyp_vcpu->vcpu, reset_state);
arch/arm64/kvm/hyp/nvhe/sys_regs.c +234 -19
315 lines not on this page · raw message
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.47.3
Fuad Tabba
reviewerPATCH 2/16 KVM: arm64: Remove redundant kern_hyp_va() calls from the pKVM FP sync
In reply to Fuad TabbaWith pKVM, EL2 saves a guest's FP and SVE state on exit into the hyp vCPU, whose kvm is the hyp VM's and whose sve_state is already a hyp address. kern_hyp_va() returns both unchanged.
Remove the two calls, in fpsimd_sve_sync() and __hyp_sve_save_guest(). The one in __hyp_sve_restore_guest() stays, as nVHE without pKVM reaches it with the host's pointer.
No functional change intended.
--- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/hyp/nvhe/hyp-main.c +2 -2
@@ -482,7 +482,7 @@ static void __hyp_sve_save_guest(struct kvm_vcpu *vcpu)* on the VL, so use a consistent (i.e., the maximum) guest VL. */ sve_cond_update_zcr_vq (vcpu_sve_max_vq (vcpu) -1 ,SYS_ZCR_EL2 ); -sve_save_state (kern_hyp_va (vcpu->arch.sve_state), true); +sve_save_state (vcpu->arch.sve_state, true);fpsimd_save_common (&vcpu->arch.ctxt.fp_regs);write_sysreg_s (sve_vq_from_vl (kvm_host_sve_max_vl) -1 ,SYS_ZCR_EL2 ); }
@@ -531,7 +531,7 @@ static void fpsimd_sve_sync(struct kvm_vcpu *vcpu)else fpsimd_save_state (&vcpu->arch.ctxt.fp_regs); - has_fpmr =kvm_has_fpmr (kern_hyp_va (vcpu->kvm)); + has_fpmr =kvm_has_fpmr (vcpu->kvm);if (has_fpmr)__vcpu_assign_sys_reg (vcpu,FPMR ,read_sysreg_s (SYS_FPMR ));
Signature · 1 line
2.47.3
Fuad Tabba
reviewerPATCH 3/16 KVM: arm64: Allocate a protected vCPU's SVE state at EL2
In reply to Fuad TabbaFor a vCPU with SVE, EL2 pins the buffer the host allocated at KVM_ARM_VCPU_FINALIZE and saves the guest's SVE registers there. The host can still read and write that buffer, so it can't hold a protected vCPU's state.
Allocate a protected vCPU's SVE state from the hyp heap instead, and free it with the vCPU. When EL2 resets a protected vCPU, zero its SVE state and ZCR_EL1, as KVM does for a non-protected one. The host still allocates its own buffer, which KVM_{GET,SET}_ONE_REG access before the first run, but EL2 doesn't use it.
For a protected vCPU, the host's sve_max_vl now sizes an EL2 allocation and is the guest's maximum vector length on every CPU. Give EL2 a copy of kvm_sve_max_vl, the largest length all CPUs can give a guest, and check every vCPU's sve_max_vl against it rather than clamping it to the host's own maximum. set_sve_vls() already keeps the host's value within that bound.
--- arch/arm64/include/asm/kvm_hyp.h | 1 + arch/arm64/kvm/hyp/nvhe/pkvm.c | 41 ++++++++++++++++++++---------- arch/arm64/kvm/hyp/nvhe/sys_regs.c | 1 + arch/arm64/kvm/reset.c | 2 ++ 4 files changed, 31 insertions(+), 14 deletions(-)
arch/arm64/include/asm/kvm_hyp.h +1 -0
@@ -158,6 +158,7 @@ extern unsigned int kvm_nvhe_sym(kvm_arm_vmid_bits);extern enum mitigation_state kvm_nvhe_sym (spectre_v2_state );extern enum mitigation_state kvm_nvhe_sym (spectre_v4_state );extern enum mitigation_state kvm_nvhe_sym (spectre_bhb_state ); +extern unsigned int kvm_nvhe_sym (kvm_sve_max_vl );extern unsigned int kvm_nvhe_sym (kvm_host_sve_max_vl );extern unsigned long kvm_nvhe_sym (hyp_nr_cpus );extern unsigned int kvm_nvhe_sym (hyp_gicv3_nr_lr );
arch/arm64/kvm/hyp/nvhe/pkvm.c +27 -14
93 lines not on this page · raw message
arch/arm64/kvm/hyp/nvhe/sys_regs.c +1 -0
@@ -783,6 +783,7 @@ static const struct sys_reg_desc_reset pvm_sys_reg_reset_vals[] = {RESET_UNKNOWN (MAIR_EL1 ),RESET_ZERO (AMAIR_EL1 ),RESET_ZERO (MDSCR_EL1 ), +RESET_ZERO (ZCR_EL1 ),RESET_ZERO (CNTV_CTL_EL0 ),RESET_UNKNOWN (TTBR0_EL1 ), RESET_UNKNOWN(TTBR1_EL1),
arch/arm64/kvm/reset.c +2 -0
@@ -52,6 +52,8 @@ int __init kvm_arm_init_sve(void)if (WARN_ON (kvm_sve_max_vl >VL_ARCH_MAX )) kvm_sve_max_vl =VL_ARCH_MAX ; +kvm_nvhe_sym (kvm_sve_max_vl) = kvm_sve_max_vl; +/* * Don't even try to make use of vector lengths that * aren't available on all CPUs, for now:
Signature · 1 line
2.47.3
Fuad Tabba
reviewerPATCH 4/16 KVM: arm64: Advertise ID_AA64ZFR0_EL1 to protected VMs
In reply to Fuad TabbaEL2 builds a protected guest's ID registers from the host's sanitised values, most of them capped per field. It has no case for ID_AA64ZFR0_EL1, so the register reads as 0, and a protected guest with SVE wouldn't see any of the SVE extensions the CPUs implement.
Keep a copy of the host's sanitised ID_AA64ZFR0_EL1 at EL2, and advertise it when the guest has SVE, as KVM does for a non-protected guest. Cap each field at the highest value the sysreg file defines.
--- arch/arm64/include/asm/kvm_hyp.h | 1 + arch/arm64/kvm/arm.c | 1 + arch/arm64/kvm/hyp/nvhe/sys_regs.c | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+)
arch/arm64/include/asm/kvm_hyp.h +1 -0
@@ -144,6 +144,7 @@ void __noreturn __host_enter(struct kvm_cpu_context *host_ctxt);extern u64 kvm_nvhe_sym (id_aa64pfr0_el1_sys_val );extern u64 kvm_nvhe_sym (id_aa64pfr1_el1_sys_val );extern u64 kvm_nvhe_sym (id_aa64pfr2_el1_sys_val ); +extern u64 kvm_nvhe_sym (id_aa64zfr0_el1_sys_val );extern u64 kvm_nvhe_sym (id_aa64isar0_el1_sys_val );extern u64 kvm_nvhe_sym (id_aa64isar1_el1_sys_val );extern u64 kvm_nvhe_sym (id_aa64isar2_el1_sys_val );
arch/arm64/kvm/arm.c +1 -0
@@ -2827,6 +2827,7 @@ static void kvm_hyp_init_symbols(void)kvm_nvhe_sym (id_aa64pfr0_el1_sys_val) =get_hyp_id_aa64pfr0_el1 ();kvm_nvhe_sym (id_aa64pfr1_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64PFR1_EL1 );kvm_nvhe_sym (id_aa64pfr2_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64PFR2_EL1 ); +kvm_nvhe_sym (id_aa64zfr0_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64ZFR0_EL1 );kvm_nvhe_sym (id_aa64isar0_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64ISAR0_EL1 );kvm_nvhe_sym (id_aa64isar1_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64ISAR1_EL1 );kvm_nvhe_sym (id_aa64isar2_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64ISAR2_EL1 );
arch/arm64/kvm/hyp/nvhe/sys_regs.c +19 -0
@@ -23,6 +23,7 @@u64 id_aa64pfr0_el1_sys_val;u64 id_aa64pfr1_el1_sys_val;u64 id_aa64pfr2_el1_sys_val; +u64 id_aa64zfr0_el1_sys_val;u64 id_aa64isar0_el1_sys_val;u64 id_aa64isar1_el1_sys_val;u64 id_aa64isar2_el1_sys_val;
@@ -124,6 +125,22 @@ static const struct pvm_ftr_bits pvmid_aa64pfr2[] = {FEAT_END }; +static const struct pvm_ftr_bits pvmid_aa64zfr0[] = { +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 , SVEver, SVE2p3, vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,AES ,AES2 , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 , EltPerm,IMP , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 , BitPerm,IMP , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,BF16 ,EBF16 , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,B16B16 ,B16MM , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,SHA3 ,IMP , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,SM4 ,IMP , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,I8MM ,IMP , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,F16MM ,IMP , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,F32MM ,IMP , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,F64MM ,IMP , vm_has_sve), +FEAT_END +}; +static const struct pvm_ftr_bits pvmid_aa64mmfr0[] = {MAX_FEAT_ENUM (ID_AA64MMFR0_EL1 ,PARANGE ,40 ),MAX_FEAT_ENUM (ID_AA64MMFR0_EL1 ,ASIDBITS ,16 ),
@@ -243,6 +260,8 @@ static u64 pvm_calc_id_reg(const struct kvm_vcpu *vcpu, u32 id)return get_restricted_features (vcpu, id_aa64pfr1_el1_sys_val, pvmid_aa64pfr1);case SYS_ID_AA64PFR2_EL1 :return get_restricted_features (vcpu, id_aa64pfr2_el1_sys_val, pvmid_aa64pfr2); +case SYS_ID_AA64ZFR0_EL1 : +return get_restricted_features (vcpu, id_aa64zfr0_el1_sys_val, pvmid_aa64zfr0);case SYS_ID_AA64ISAR0_EL1 :return id_aa64isar0_el1_sys_val;case SYS_ID_AA64ISAR1_EL1 :
Signature · 1 line
2.47.3
Fuad Tabba
reviewerPATCH 5/16 KVM: arm64: Allow protected VMs to use SVE
In reply to Fuad TabbaNow that EL2 owns a protected vCPU's SVE state and advertises ID_AA64ZFR0_EL1, allow KVM_CAP_ARM_SVE for a protected VM, which lets KVM_ARM_VCPU_INIT take KVM_ARM_VCPU_SVE.
A protected guest's SVE access trap injects an UNDEF. An SVE instruction takes the SVE trap rather than the FP one, so a guest whose first vector instruction is an SVE one would get an UNDEF instead of the lazy FP switch. Handle the SVE trap as the FP trap is:kvm_handle_pvm_fpsimd() switches the state for a vCPU with SVE and still injects the UNDEF for one without.
Update the documentation to match.
--- Documentation/virt/kvm/arm/pkvm.rst | 6 +++--- arch/arm64/include/asm/kvm_pkvm.h | 1 + arch/arm64/kvm/hyp/nvhe/switch.c | 1 + arch/arm64/kvm/hyp/nvhe/sys_regs.c | 2 -- 4 files changed, 5 insertions(+), 5 deletions(-)
Documentation/virt/kvm/arm/pkvm.rst +3 -3
@@ -134,9 +134,9 @@ A protected VM boots from a single primary vCPU. Before the first * Set the primary vCPU's boot state with ``KVM_SET_ONE_REG``: the kernel entry address in ``PC`` and the DTB pointer in ``x0``. -``PC`` and ``x0`` are the only registers EL2 takes from the host. Other -pre-run writes are accepted, but the guest starts from the state the -hypervisor resets it to. +``PC``, ``x0`` and the SVE vector lengths (``KVM_REG_ARM64_SVE_VLS``) are +the only registers EL2 takes from the host. Other pre-run writes are +accepted, but the guest starts from the state the hypervisor resets it to. Secondary vCPUs are started by the guest itself through PSCI ``CPU_ON`` (see `Power state`_), which supplies their entry point and context ID.
arch/arm64/include/asm/kvm_pkvm.h +1 -0
@@ -40,6 +40,7 @@ static inline bool kvm_pkvm_ext_allowed(struct kvm *kvm, long ext)case KVM_CAP_MAX_VCPU_ID :case KVM_CAP_MSI_DEVID :case KVM_CAP_ARM_VM_IPA_SIZE : +case KVM_CAP_ARM_SVE :case KVM_CAP_ARM_PTRAUTH_ADDRESS :case KVM_CAP_ARM_PTRAUTH_GENERIC :case KVM_CAP_ONE_REG :
arch/arm64/kvm/hyp/nvhe/switch.c +1 -0
@@ -230,6 +230,7 @@ static const exit_handler_fn pvm_exit_handlers[] = { [ESR_ELx_EC_WFx] = kvm_handle_pvm_wfx, [ESR_ELx_EC_HVC64] = kvm_handle_pvm_hvc64, [ESR_ELx_EC_SYS64] = kvm_handle_pvm_sys64, + [ESR_ELx_EC_SVE] = kvm_handle_pvm_fpsimd, [ESR_ELx_EC_FP_ASIMD] = kvm_handle_pvm_fpsimd, [ESR_ELx_EC_IABT_LOW] = kvm_hyp_handle_iabt_low, [ESR_ELx_EC_DABT_LOW] = kvm_hyp_handle_dabt_low,
arch/arm64/kvm/hyp/nvhe/sys_regs.c +0 -2
@@ -713,8 +713,6 @@ static const struct sys_reg_desc pvm_sys_reg_descs[] = {ID_UNALLOCATED (7 ,6 ),ID_UNALLOCATED (7 ,7 ), -/* Scalable Vector Registers are restricted. */ -HOST_HANDLED (SYS_ICC_PMR_EL1 ), RAZ_WI(SYS_ERRIDR_EL1),
Signature · 1 line
2.47.3
Fuad Tabba
reviewerPATCH 6/16 KVM: arm64: Move the VM's FGU initialisation into config.c
In reply to Fuad TabbaThe first time one of a VM's vCPUs runs, kvm_calculate_traps() computes the VM's fine-grained UNDEF masks from its ID registers, one compute_fgu() call per FGT group, and sets KVM_ARCH_FLAG_FGU_INITIALIZED so that it computes them once. The next patch computes the same masks for protected VMs at EL2.
Move the calls and the flag into kvm_init_fgu() in config.c, so that a group added later is computed at EL2 too. compute_fgu() then has no caller outside config.c, so make it static.
No functional change intended.
--- arch/arm64/include/asm/kvm_host.h | 2 +- arch/arm64/kvm/config.c | 20 +++++++++++++++++++- arch/arm64/kvm/sys_regs.c | 17 +---------------- 3 files changed, 21 insertions(+), 18 deletions(-)
arch/arm64/include/asm/kvm_host.h +1 -1
@@ -1748,7 +1748,7 @@ static inline bool kvm_arch_has_irq_bypass(void) }void kvm_idregs_enforce_dependencies (struct kvm *kvm); -void compute_fgu (struct kvm *kvm,enum fgt_group_id fgt); +void kvm_init_fgu (struct kvm *kvm);struct resx get_reg_fixed_bits (struct kvm *kvm,enum vcpu_sysreg reg);void check_feature_map (void );void kvm_vcpu_load_fgt (struct kvm_vcpu *vcpu);
arch/arm64/kvm/config.c +19 -1
@@ -1586,7 +1586,7 @@ static u64 compute_fgu_bits(struct kvm *kvm, const struct reg_feat_map_desc *r)return resx.res0 | resx.res1; } -void compute_fgu (struct kvm *kvm,enum fgt_group_id fgt) +static void compute_fgu (struct kvm *kvm,enum fgt_group_id fgt) {u64 val =0 ;
@@ -1630,6 +1630,24 @@ void compute_fgu(struct kvm *kvm, enum fgt_group_id fgt) kvm->arch.fgu[fgt] = val; } +void kvm_init_fgu (struct kvm *kvm) +{ +if (test_bit (KVM_ARCH_FLAG_FGU_INITIALIZED , &kvm->arch.flags)) +return ; + +compute_fgu (kvm,HFGRTR_GROUP ); +compute_fgu (kvm,HFGITR_GROUP ); +compute_fgu (kvm,HDFGRTR_GROUP ); +compute_fgu (kvm,HAFGRTR_GROUP ); +compute_fgu (kvm,HFGRTR2_GROUP ); +compute_fgu (kvm,HFGITR2_GROUP ); +compute_fgu (kvm,HDFGRTR2_GROUP ); +compute_fgu (kvm,ICH_HFGRTR_GROUP ); +compute_fgu (kvm,ICH_HFGITR_GROUP ); + +set_bit (KVM_ARCH_FLAG_FGU_INITIALIZED , &kvm->arch.flags); +} +struct resx get_reg_fixed_bits (struct kvm *kvm,enum vcpu_sysreg reg) {struct resx resx;
arch/arm64/kvm/sys_regs.c +1 -16
@@ -5841,22 +5841,7 @@ void kvm_calculate_traps(struct kvm_vcpu *vcpu)vcpu_set_hcr (vcpu);vcpu_set_ich_hcr (vcpu);vcpu_set_hcrx (vcpu); - -if (test_bit (KVM_ARCH_FLAG_FGU_INITIALIZED , &kvm->arch.flags)) - goto out; - -compute_fgu (kvm,HFGRTR_GROUP ); -compute_fgu (kvm,HFGITR_GROUP ); -compute_fgu (kvm,HDFGRTR_GROUP ); -compute_fgu (kvm,HAFGRTR_GROUP ); -compute_fgu (kvm,HFGRTR2_GROUP ); -compute_fgu (kvm,HFGITR2_GROUP ); -compute_fgu (kvm,HDFGRTR2_GROUP ); -compute_fgu (kvm,ICH_HFGRTR_GROUP ); -compute_fgu (kvm,ICH_HFGITR_GROUP ); - -set_bit (KVM_ARCH_FLAG_FGU_INITIALIZED , &kvm->arch.flags); -out: +kvm_init_fgu (kvm);mutex_unlock (&kvm->arch.config_lock); }
Signature · 1 line
2.47.3
Fuad Tabba
reviewerPATCH 7/16 KVM: arm64: Compute a protected vCPU's fine-grained traps at EL2
In reply to Fuad TabbapKVM sets a protected vCPU's HCR_EL2, MDCR_EL2 and HCRX_EL2 at EL2 from the VM's ID registers, but never computes its fine-grained traps, which stay 0. That traps every register with a negative-polarity trap bit, so a feature such as S1PIE can't be advertised to a protected VM: EL2 would inject an UNDEF for the guest's accesses to PIR_EL1.
Link config.c into the nVHE hyp and compute the VM's FGU masks and the vCPU's fine-grained traps there, under vm_table_lock, once the ID registers are set. The init-time check of the feature maps stays out of the hyp, since it prints and the host runs it anyway.
A protected vCPU then traps the registers of the features it doesn't support, as a non-protected vCPU does. Its TCR_EL1 writes also get the AmpereOne AC03_CPU_38 masking again, which protected vCPUs lost when the erratum's trap moved into the per-vCPU fine-grained traps.
--- arch/arm64/kvm/config.c | 12 +++++++----- arch/arm64/kvm/hyp/nvhe/Makefile | 1 + arch/arm64/kvm/hyp/nvhe/pkvm.c | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-)
arch/arm64/kvm/config.c +7 -5
@@ -1395,6 +1395,12 @@ static const struct reg_bits_to_feat_map ich_hfgitr_feat_map[] = { static const DECLARE_FEAT_MAP_FGT(ich_hfgitr_desc, ich_hfgitr_masks, ich_hfgitr_feat_map, FEAT_GCIE); +static u64 reg_feat_map_bits (const struct reg_bits_to_feat_map *map) +{ +return map->flags &MASKS_POINTER ? (map->masks->mask | map->masks->nmask) : map->bits; +} + +#ifndef __KVM_NVHE_HYPERVISOR__static void __init check_feat_map (const struct reg_bits_to_feat_map *map,int map_size,u64 resx,const char *str) {
@@ -1414,11 +1420,6 @@ static void __init check_feat_map(const struct reg_bits_to_feat_map *map, str, mask ^ ~resx); } -static u64 reg_feat_map_bits (const struct reg_bits_to_feat_map *map) -{ -return map->flags &MASKS_POINTER ? (map->masks->mask | map->masks->nmask) : map->bits; -} -static void __init check_reg_desc (const struct reg_feat_map_desc *r) { check_feat_map(r->bit_feat_map, r->bit_feat_map_sz,
@@ -1451,6 +1452,7 @@ void __init check_feature_map(void)check_reg_desc (&ich_hfgwtr_desc);check_reg_desc (&ich_hfgitr_desc); } +#endif static const struct reg_feat_map_desc *idreg_feat_maps[] = { &id_aa64mmfr3_el1_desc,
arch/arm64/kvm/hyp/nvhe/Makefile +1 -0
@@ -27,6 +27,7 @@ hyp-obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o hyp-init.o host.o cache.o setup.o mm.o mem_protect.o sys_regs.o pkvm.o stacktrace.o ffa.o hyp-obj-y += ../vgic-v3-sr.o ../aarch32.o ../vgic-v2-cpuif-proxy.o ../entry.o \ ../hyp-entry.o ../exception.o ../pgtable.o ../vgic-v5-sr.o +hyp-obj-y += ../../config.o hyp-obj-y += ../../../kernel/smccc-call.o hyp-obj-$(CONFIG_LIST_HARDENED) += list_debug.o hyp-obj-$(CONFIG_NVHE_EL2_TRACING) += clock.o trace.o events.o
arch/arm64/kvm/hyp/nvhe/pkvm.c +2 -0
@@ -206,6 +206,8 @@ static int pkvm_vcpu_init_traps(struct pkvm_hyp_vcpu *hyp_vcpu)pvm_init_traps_hcr (vcpu);pvm_init_traps_mdcr (vcpu);vcpu_set_hcrx (vcpu); +kvm_init_fgu (vcpu->kvm); +kvm_vcpu_load_fgt (vcpu);return 0 ; }
Signature · 1 line
2.47.3
Fuad Tabba
reviewerPATCH 8/16 KVM: arm64: Advertise TCR2, SCTLR2, S1PIE and S1POE to protected VMs
In reply to Fuad TabbaAdvertise 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.
--- 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(-)
arch/arm64/include/asm/kvm_hyp.h +1 -0
@@ -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 );
arch/arm64/kvm/arm.c +1 -0
@@ -2834,6 +2834,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;
arch/arm64/kvm/hyp/nvhe/sys_regs.c +23 -1
@@ -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. *
@@ -177,6 +183,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),
@@ -274,6 +288,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 :
@@ -707,7 +723,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),
@@ -793,7 +809,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),
Signature · 1 line
2.47.3
Fuad Tabba
reviewerPATCH 9/16 KVM: arm64: Advertise MOPS to protected VMs
In reply to Fuad TabbaAdvertise FEAT_MOPS to protected VMs. With the field set, vcpu_set_hcrx() sets HCRX_EL2.{MSCEn,MCE2} for them, and kvm_hyp_handle_mops() already handles their MOPS exceptions.
--- arch/arm64/kvm/hyp/nvhe/sys_regs.c | 1 + 1 file changed, 1 insertion(+)
arch/arm64/kvm/hyp/nvhe/sys_regs.c +1 -0
@@ -212,6 +212,7 @@ static const struct pvm_ftr_bits pvmid_aa64isar1[] = {static const struct pvm_ftr_bits pvmid_aa64isar2[] = {MAX_FEAT_FUNC (ID_AA64ISAR2_EL1 ,GPA3 ,IMP , vm_has_ptrauth),MAX_FEAT_FUNC (ID_AA64ISAR2_EL1 ,APA3 , PAuth, vm_has_ptrauth), +MAX_FEAT (ID_AA64ISAR2_EL1 ,MOPS ,IMP ),MAX_FEAT (ID_AA64ISAR2_EL1 ,ATS1A ,IMP ),FEAT_END };
Signature · 1 line
2.47.3
Fuad Tabba
reviewerPATCH 10/16 KVM: arm64: Advertise FPMR to protected VMs
In reply to Fuad TabbaAdvertise FEAT_FPMR to protected VMs, and reset FPMR to 0 as KVM does for a non-protected vCPU. With the field set, vcpu_set_hcrx() sets HCRX_EL2.EnFPM for them, and FPMR is switched with the rest of the FP state.
--- arch/arm64/kvm/hyp/nvhe/sys_regs.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/kvm/hyp/nvhe/sys_regs.c +2 -0
@@ -128,6 +128,7 @@ static const struct pvm_ftr_bits pvmid_aa64pfr1[] = {static const struct pvm_ftr_bits pvmid_aa64pfr2[] = {MAX_FEAT (ID_AA64PFR2_EL1 ,GCIE ,NI ), +MAX_FEAT (ID_AA64PFR2_EL1 ,FPMR ,IMP ),FEAT_END };
@@ -829,6 +830,7 @@ static const struct sys_reg_desc_reset pvm_sys_reg_reset_vals[] = {RESET_UNKNOWN (TTBR1_EL1 ),RESET_UNKNOWN (FAR_EL1 ),RESET_VAL (VBAR_EL1 ,0x1de7ec7edbadc000ULL ), + RESET_ZERO(FPMR), };void kvm_reset_pvm_sys_regs (struct kvm_vcpu *vcpu)
Signature · 1 line
2.47.3
Fuad Tabba
reviewerPATCH 11/16 KVM: arm64: Advertise HBC, CLRBHB, RPRFM, CSSC and LUT to protected VMs
In reply to Fuad TabbaAdvertise FEAT_HBC, FEAT_CLRBHB, FEAT_RPRFM, FEAT_CSSC and FEAT_LUT to protected VMs, with CSSC up to CMPBR and LUT up to LUT6, as for a non-protected VM.
--- arch/arm64/kvm/hyp/nvhe/sys_regs.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/kvm/hyp/nvhe/sys_regs.c +5 -0
@@ -214,6 +214,11 @@ static const struct pvm_ftr_bits pvmid_aa64isar2[] = {MAX_FEAT_FUNC (ID_AA64ISAR2_EL1 ,GPA3 ,IMP , vm_has_ptrauth),MAX_FEAT_FUNC (ID_AA64ISAR2_EL1 ,APA3 , PAuth, vm_has_ptrauth),MAX_FEAT (ID_AA64ISAR2_EL1 ,MOPS ,IMP ), +MAX_FEAT (ID_AA64ISAR2_EL1 ,BC ,IMP ), +MAX_FEAT (ID_AA64ISAR2_EL1 ,CLRBHB ,IMP ), +MAX_FEAT (ID_AA64ISAR2_EL1 ,RPRFM ,IMP ), +MAX_FEAT (ID_AA64ISAR2_EL1 ,CSSC ,CMPBR ), +MAX_FEAT (ID_AA64ISAR2_EL1 ,LUT ,LUT6 ),MAX_FEAT (ID_AA64ISAR2_EL1 ,ATS1A ,IMP ),FEAT_END };
Signature · 1 line
2.47.3
Fuad Tabba
reviewerPATCH 12/16 KVM: arm64: Advertise FAMINMAX, LSFE, LSUI and FPRCVT to protected VMs
In reply to Fuad TabbaAdvertise FEAT_FAMINMAX, FEAT_LSFE, FEAT_LSUI and FEAT_FPRCVT to protected VMs, the ID_AA64ISAR3_EL1 fields a non-protected VM sees.
--- arch/arm64/include/asm/kvm_hyp.h | 1 + arch/arm64/kvm/arm.c | 1 + arch/arm64/kvm/hyp/nvhe/sys_regs.c | 13 ++++++++++++- 3 files changed, 14 insertions(+), 1 deletion(-)
arch/arm64/include/asm/kvm_hyp.h +1 -0
@@ -148,6 +148,7 @@ extern u64 kvm_nvhe_sym(id_aa64zfr0_el1_sys_val);extern u64 kvm_nvhe_sym (id_aa64isar0_el1_sys_val );extern u64 kvm_nvhe_sym (id_aa64isar1_el1_sys_val );extern u64 kvm_nvhe_sym (id_aa64isar2_el1_sys_val ); +extern u64 kvm_nvhe_sym (id_aa64isar3_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 );
arch/arm64/kvm/arm.c +1 -0
@@ -2831,6 +2831,7 @@ static void kvm_hyp_init_symbols(void)kvm_nvhe_sym (id_aa64isar0_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64ISAR0_EL1 );kvm_nvhe_sym (id_aa64isar1_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64ISAR1_EL1 );kvm_nvhe_sym (id_aa64isar2_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64ISAR2_EL1 ); +kvm_nvhe_sym (id_aa64isar3_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64ISAR3_EL1 );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 );
arch/arm64/kvm/hyp/nvhe/sys_regs.c +12 -1
@@ -27,6 +27,7 @@ u64 id_aa64zfr0_el1_sys_val;u64 id_aa64isar0_el1_sys_val;u64 id_aa64isar1_el1_sys_val;u64 id_aa64isar2_el1_sys_val; +u64 id_aa64isar3_el1_sys_val;u64 id_aa64mmfr0_el1_sys_val;u64 id_aa64mmfr1_el1_sys_val;u64 id_aa64mmfr2_el1_sys_val;
@@ -223,6 +224,14 @@ static const struct pvm_ftr_bits pvmid_aa64isar2[] = {FEAT_END }; +static const struct pvm_ftr_bits pvmid_aa64isar3[] = { +MAX_FEAT (ID_AA64ISAR3_EL1 ,FAMINMAX ,IMP ), +MAX_FEAT (ID_AA64ISAR3_EL1 ,LSFE ,IMP ), +MAX_FEAT (ID_AA64ISAR3_EL1 ,LSUI ,IMP ), +MAX_FEAT (ID_AA64ISAR3_EL1 ,FPRCVT ,IMP ), +FEAT_END +}; +/* DoubleLock and MTPMU are hidden, but their Not-Implemented values are non-zero. */ static const struct pvm_ftr_bits pvmid_aa64dfr0[] = {MAX_FEAT (ID_AA64DFR0_EL1 , DebugVer,V8P8 ),
@@ -289,6 +298,8 @@ static u64 pvm_calc_id_reg(const struct kvm_vcpu *vcpu, u32 id)return get_restricted_features (vcpu, id_aa64isar1_el1_sys_val, pvmid_aa64isar1);case SYS_ID_AA64ISAR2_EL1 :return get_restricted_features (vcpu, id_aa64isar2_el1_sys_val, pvmid_aa64isar2); +case SYS_ID_AA64ISAR3_EL1 : +return get_restricted_features (vcpu, id_aa64isar3_el1_sys_val, pvmid_aa64isar3);case SYS_ID_AA64MMFR0_EL1 :return get_restricted_features (vcpu, id_aa64mmfr0_el1_sys_val, pvmid_aa64mmfr0);case SYS_ID_AA64MMFR1_EL1 :
@@ -722,7 +733,7 @@ static const struct sys_reg_desc pvm_sys_reg_descs[] = {AARCH64 (SYS_ID_AA64ISAR0_EL1 ),AARCH64 (SYS_ID_AA64ISAR1_EL1 ),AARCH64 (SYS_ID_AA64ISAR2_EL1 ), -ID_UNALLOCATED (6 ,3 ), +AARCH64 (SYS_ID_AA64ISAR3_EL1 ),ID_UNALLOCATED (6 ,4 ),ID_UNALLOCATED (6 ,5 ), ID_UNALLOCATED(6,6),
Signature · 1 line
2.47.3
Fuad Tabba
reviewerPATCH 13/16 KVM: arm64: Advertise AFP and RPRES to protected VMs
In reply to Fuad TabbaAdvertise FEAT_AFP and FEAT_RPRES to protected VMs. Both are controlled through FPCR, which EL2 switches with the rest of the FP state.
--- arch/arm64/kvm/hyp/nvhe/sys_regs.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/kvm/hyp/nvhe/sys_regs.c +2 -0
@@ -169,6 +169,7 @@ static const struct pvm_ftr_bits pvmid_aa64mmfr1[] = {MAX_FEAT (ID_AA64MMFR1_EL1 ,PAN ,PAN3 ),MAX_FEAT (ID_AA64MMFR1_EL1 , SpecSEI,IMP ),MAX_FEAT (ID_AA64MMFR1_EL1 ,ETS ,IMP ), +MAX_FEAT (ID_AA64MMFR1_EL1 ,AFP ,IMP ),MAX_FEAT (ID_AA64MMFR1_EL1 ,CMOW ,IMP ), FEAT_END };
@@ -212,6 +213,7 @@ static const struct pvm_ftr_bits pvmid_aa64isar1[] = { };static const struct pvm_ftr_bits pvmid_aa64isar2[] = { +MAX_FEAT (ID_AA64ISAR2_EL1 ,RPRES ,IMP ),MAX_FEAT_FUNC (ID_AA64ISAR2_EL1 ,GPA3 ,IMP , vm_has_ptrauth),MAX_FEAT_FUNC (ID_AA64ISAR2_EL1 ,APA3 , PAuth, vm_has_ptrauth),MAX_FEAT (ID_AA64ISAR2_EL1 ,MOPS ,IMP ),
Signature · 1 line
2.47.3
Fuad Tabba
reviewerPATCH 14/16 KVM: arm64: Advertise ECBHB, TIDCP1, TTST and LVA to protected VMs
In reply to Fuad TabbaAdvertise FEAT_ECBHB, FEAT_TIDCP1, FEAT_TTST and FEAT_LVA to protected VMs, capping VARange at LVA, since LVA3 requires FEAT_D128. TIDCP1's control, SCTLR_EL1.TIDCP, is switched with the rest of SCTLR_EL1.
--- arch/arm64/kvm/hyp/nvhe/sys_regs.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/kvm/hyp/nvhe/sys_regs.c +4 -0
@@ -170,7 +170,9 @@ static const struct pvm_ftr_bits pvmid_aa64mmfr1[] = {MAX_FEAT (ID_AA64MMFR1_EL1 , SpecSEI,IMP ),MAX_FEAT (ID_AA64MMFR1_EL1 ,ETS ,IMP ),MAX_FEAT (ID_AA64MMFR1_EL1 ,AFP ,IMP ), +MAX_FEAT (ID_AA64MMFR1_EL1 ,TIDCP1 ,IMP ),MAX_FEAT (ID_AA64MMFR1_EL1 ,CMOW ,IMP ), +MAX_FEAT (ID_AA64MMFR1_EL1 ,ECBHB ,IMP ), FEAT_END };
@@ -178,6 +180,8 @@ static const struct pvm_ftr_bits pvmid_aa64mmfr2[] = {MAX_FEAT (ID_AA64MMFR2_EL1 , CnP,IMP ),MAX_FEAT (ID_AA64MMFR2_EL1 ,UAO ,IMP ),MAX_FEAT (ID_AA64MMFR2_EL1 ,IESB ,IMP ), +MAX_FEAT (ID_AA64MMFR2_EL1 , VARange,52 ), + MAX_FEAT_ENUM(ID_AA64MMFR2_EL1, ST, 48_47),MAX_FEAT (ID_AA64MMFR2_EL1 ,AT ,IMP ),MAX_FEAT (ID_AA64MMFR2_EL1 ,IDS ,IMP ), MAX_FEAT(ID_AA64MMFR2_EL1, TTL, IMP),
Signature · 1 line
2.47.3
Fuad Tabba
reviewerPATCH 15/16 KVM: arm64: Advertise FP8 and F16MM to protected VMs
In reply to Fuad TabbaAdvertise the FP8 features and FEAT_F16MM to protected VMs, the ID_AA64FPFR0_EL1 fields a non-protected VM sees. Their instructions only use the SIMD&FP registers and FPMR, which EL2 already switches.
--- arch/arm64/include/asm/kvm_hyp.h | 1 + arch/arm64/kvm/arm.c | 1 + arch/arm64/kvm/hyp/nvhe/sys_regs.c | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-)
arch/arm64/include/asm/kvm_hyp.h +1 -0
@@ -145,6 +145,7 @@ extern u64 kvm_nvhe_sym(id_aa64pfr0_el1_sys_val);extern u64 kvm_nvhe_sym (id_aa64pfr1_el1_sys_val );extern u64 kvm_nvhe_sym (id_aa64pfr2_el1_sys_val );extern u64 kvm_nvhe_sym (id_aa64zfr0_el1_sys_val ); +extern u64 kvm_nvhe_sym (id_aa64fpfr0_el1_sys_val );extern u64 kvm_nvhe_sym (id_aa64isar0_el1_sys_val );extern u64 kvm_nvhe_sym (id_aa64isar1_el1_sys_val );extern u64 kvm_nvhe_sym (id_aa64isar2_el1_sys_val );
arch/arm64/kvm/arm.c +1 -0
@@ -2828,6 +2828,7 @@ static void kvm_hyp_init_symbols(void)kvm_nvhe_sym (id_aa64pfr1_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64PFR1_EL1 );kvm_nvhe_sym (id_aa64pfr2_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64PFR2_EL1 );kvm_nvhe_sym (id_aa64zfr0_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64ZFR0_EL1 ); +kvm_nvhe_sym (id_aa64fpfr0_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64FPFR0_EL1 );kvm_nvhe_sym (id_aa64isar0_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64ISAR0_EL1 );kvm_nvhe_sym (id_aa64isar1_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64ISAR1_EL1 );kvm_nvhe_sym (id_aa64isar2_el1_sys_val) =read_sanitised_ftr_reg (SYS_ID_AA64ISAR2_EL1 );
arch/arm64/kvm/hyp/nvhe/sys_regs.c +17 -1
@@ -24,6 +24,7 @@ u64 id_aa64pfr0_el1_sys_val;u64 id_aa64pfr1_el1_sys_val;u64 id_aa64pfr2_el1_sys_val;u64 id_aa64zfr0_el1_sys_val; +u64 id_aa64fpfr0_el1_sys_val;u64 id_aa64isar0_el1_sys_val;u64 id_aa64isar1_el1_sys_val;u64 id_aa64isar2_el1_sys_val;
@@ -149,6 +150,19 @@ static const struct pvm_ftr_bits pvmid_aa64zfr0[] = {FEAT_END }; +static const struct pvm_ftr_bits pvmid_aa64fpfr0[] = { +MAX_FEAT (ID_AA64FPFR0_EL1 ,F8E5M2 ,IMP ), +MAX_FEAT (ID_AA64FPFR0_EL1 ,F8E4M3 ,IMP ), +MAX_FEAT (ID_AA64FPFR0_EL1 ,F16MM2 ,IMP ), +MAX_FEAT (ID_AA64FPFR0_EL1 ,F8MM4 ,IMP ), +MAX_FEAT (ID_AA64FPFR0_EL1 ,F8MM8 ,IMP ), +MAX_FEAT (ID_AA64FPFR0_EL1 ,F8DP2 ,IMP ), +MAX_FEAT (ID_AA64FPFR0_EL1 ,F8DP4 ,IMP ), +MAX_FEAT (ID_AA64FPFR0_EL1 ,F8FMA ,IMP ), +MAX_FEAT (ID_AA64FPFR0_EL1 ,F8CVT ,IMP ), +FEAT_END +}; +static const struct pvm_ftr_bits pvmid_aa64mmfr0[] = {MAX_FEAT_ENUM (ID_AA64MMFR0_EL1 ,PARANGE ,40 ),MAX_FEAT_ENUM (ID_AA64MMFR0_EL1 ,ASIDBITS ,16 ),
@@ -298,6 +312,8 @@ static u64 pvm_calc_id_reg(const struct kvm_vcpu *vcpu, u32 id)return get_restricted_features (vcpu, id_aa64pfr2_el1_sys_val, pvmid_aa64pfr2);case SYS_ID_AA64ZFR0_EL1 :return get_restricted_features (vcpu, id_aa64zfr0_el1_sys_val, pvmid_aa64zfr0); +case SYS_ID_AA64FPFR0_EL1 : +return get_restricted_features (vcpu, id_aa64fpfr0_el1_sys_val, pvmid_aa64fpfr0);case SYS_ID_AA64ISAR0_EL1 :return id_aa64isar0_el1_sys_val;case SYS_ID_AA64ISAR1_EL1 :
@@ -727,7 +743,7 @@ static const struct sys_reg_desc pvm_sys_reg_descs[] = {AARCH64 (SYS_ID_AA64ZFR0_EL1 ),ID_UNALLOCATED (4 ,5 ),ID_UNALLOCATED (4 ,6 ), -ID_UNALLOCATED (4 ,7 ), +AARCH64 (SYS_ID_AA64FPFR0_EL1 ),AARCH64 (SYS_ID_AA64DFR0_EL1 ),AARCH64 (SYS_ID_AA64DFR1_EL1 ), ID_UNALLOCATED(5,2),
Signature · 1 line
2.47.3
Fuad Tabba
reviewerPATCH 16/16 KVM: arm64: Advertise ECV, HAFT and ETS3 to protected VMs
In reply to Fuad TabbaAdvertise FEAT_ECV, FEAT_HAFT and FEAT_ETS3 to protected VMs, with ECV capped at IMP and HAFDBS at HAFT, since CNTPOFF and HDBSS only add EL2 and EL3 controls. ECV's self-synchronised counter views trap under the same controls as CNTPCT_EL0 and CNTVCT_EL0, which kvm_handle_cntxct() emulates.
--- arch/arm64/kvm/hyp/nvhe/sys_regs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/kvm/hyp/nvhe/sys_regs.c +3 -2
@@ -173,16 +173,17 @@ static const struct pvm_ftr_bits pvmid_aa64mmfr0[] = {MAX_FEAT (ID_AA64MMFR0_EL1 ,TGRAN4 ,IMP ),MAX_FEAT (ID_AA64MMFR0_EL1 ,TGRAN16 ,IMP ),MAX_FEAT (ID_AA64MMFR0_EL1 ,TGRAN64 ,IMP ), +MAX_FEAT (ID_AA64MMFR0_EL1 ,ECV ,IMP ),FEAT_END };static const struct pvm_ftr_bits pvmid_aa64mmfr1[] = { -MAX_FEAT (ID_AA64MMFR1_EL1 ,HAFDBS ,DBM ), +MAX_FEAT (ID_AA64MMFR1_EL1 ,HAFDBS ,HAFT ),MAX_FEAT_ENUM (ID_AA64MMFR1_EL1 , VMIDBits,16 ),MAX_FEAT (ID_AA64MMFR1_EL1 ,HPDS ,HPDS2 ),MAX_FEAT (ID_AA64MMFR1_EL1 ,PAN ,PAN3 ),MAX_FEAT (ID_AA64MMFR1_EL1 , SpecSEI,IMP ), -MAX_FEAT (ID_AA64MMFR1_EL1 ,ETS ,IMP ), +MAX_FEAT (ID_AA64MMFR1_EL1 ,ETS ,ETS3 ),MAX_FEAT (ID_AA64MMFR1_EL1 ,AFP ,IMP ),MAX_FEAT (ID_AA64MMFR1_EL1 ,TIDCP1 ,IMP ), MAX_FEAT(ID_AA64MMFR1_EL1, CMOW, IMP),
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH 04/16] KVM: arm64: Advertise ID_AA64ZFR0_EL1 to protected VMs
In reply to Fuad TabbaThank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [High] KVM: arm64: GPA and GPI exposed without…
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce:
- [High] KVM: arm64: GPA and GPI exposed without vm_has_ptrauth() in pvmid_aa64isar1 [1]
--
commit 2d2ae4f2681e16f1e4bc8fc816b7e7d62dcaf9be
Author: Fuad Tabba <[email protected]>
KVM: arm64: Advertise ID_AA64ZFR0_EL1 to protected VMs
This commit copies the host's sanitised ID_AA64ZFR0_EL1 register value to EL2 and exposes its capped feature fields to protected VMs when SVE is enabled for the guest.
Quoted 4 lines
arch/arm64/kvm/hyp/nvhe/sys_regs.c +0
-0
[ ... ]
Quoted 13 lines
arch/arm64/kvm/hyp/nvhe/sys_regs.c +9
-0@@ -124,6 +125,22 @@ static const struct pvm_ftr_bits pvmid_aa64pfr2[] = {FEAT_END }; +static const struct pvm_ftr_bits pvmid_aa64zfr0[] = { +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 , SVEver, SVE2p3, vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,AES ,AES2 , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 , EltPerm,IMP , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 , BitPerm,IMP , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,BF16 ,EBF16 , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,B16B16 ,B16MM , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,SHA3 ,IMP , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,SM4 ,IMP , vm_has_sve),
arch/arm64/kvm/hyp/nvhe/sys_regs.c static const struct pvm_ftr_bits pvmid_aa64pfr2[] = { · line 146
Quoted 10 lines
arch/arm64/kvm/hyp/nvhe/sys_regs.c +7
-0+MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,I8MM ,IMP , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,F16MM ,IMP , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,F32MM ,IMP , vm_has_sve), +MAX_FEAT_FUNC (ID_AA64ZFR0_EL1 ,F64MM ,IMP , vm_has_sve), +FEAT_END +}; +static const struct pvm_ftr_bits pvmid_aa64mmfr0[] = {MAX_FEAT_ENUM (ID_AA64MMFR0_EL1 ,PARANGE ,40 ), MAX_FEAT_ENUM(ID_AA64MMFR0_EL1, ASIDBITS, 16),
[Severity: High]
This problem wasn't introduced by this patch, but should GPA and GPI in pvmid_aa64isar1[] also be gated on vm_has_ptrauth() [1]?
arch/arm64/kvm/hyp/nvhe/sys_regs.c:pvmid_aa64isar1[] {
MAX_FEAT(ID_AA64ISAR1_EL1, DPB, DPB2),
MAX_FEAT_FUNC(ID_AA64ISAR1_EL1, APA, PAuth, vm_has_ptrauth),
MAX_FEAT_FUNC(ID_AA64ISAR1_EL1, API, PAuth, vm_has_ptrauth),
...
MAX_FEAT(ID_AA64ISAR1_EL1, GPA, IMP),
MAX_FEAT(ID_AA64ISAR1_EL1, GPI, IMP),
...
}Unlike APA, API, GPA3 and APA3, the GPA and GPI entries use MAX_FEAT() instead of MAX_FEAT_FUNC(..., vm_has_ptrauth). On a host with generic pointer authentication, a protected VM created without pointer authentication still sees GPA or GPI advertised in ID_AA64ISAR1_EL1 while HCR_EL2.API and HCR_EL2.APK remain clear, so guest generic PAuth instructions or key accesses trap to EL2 and inject an UNDEFINED exception into the guest.
[1] https://sashiko.dev/#/bug/linux-01433c94-7171-4ed8-85e1-6ba36cf8dd5f
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Fuad Tabba
reviewerRe: [PATCH 04/16] KVM: arm64: Advertise ID_AA64ZFR0_EL1 to protected VMs
Quoted 6 lines · On Mon, 9 Nov 2026 at 08:48, <[email protected]> wrote:
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce:
- [High] KVM: arm64: GPA and GPI exposed withoutvm_has_ptrauth()inpvmid_aa64isar1[1]
Fixed here:
https://lore.kernel.org/all/[email protected]/
/fuad
Oliver Upton
maintainerHi Fuad,
Quoted 24 lines · Fuad Tabba
Hi folks,
With most of the groundwork now merged, bringing protected VMs up to the features we support for them in Android turns out not to be a big series. So this folds self-hosted debug [1] and SVE [2], which I posted separately last week, into one series with the rest. Both are small, and keeping them apart would only leave a few conflicts where they add neighbouring lines to the pVM ID-register code. The debug and SVE patches are unchanged from those postings.
01: Self-hosted debug. 02-05: SVE, with EL2 owning a protected vCPU's SVE state. 06-07: Compute a protected vCPU's fine-grained traps at EL2. 08-16: Advertise TCR2, SCTLR2, S1PIE, S1POE, MOPS, FPMR and thefeatures EL2 already handles for non-protected guests.
Tested on QEMU, in hVHE and nVHE, and on FVP for S1POE and the fields QEMU doesn't model (CLRBHB, RPRFM, ECBHB, LSFE, LSUI, HAFT, ETS3 and F16MM). v2 of the pKVM selftests series [3] will cover debug, SVE, MOPS, PIE, POE and FPMR.
Based on Linux 7.4-rc1 (
6628e7d4c6b25); it also applies to 7.4-rc2 (7475ea8b58616).
Quoted 6 lines
Cheers,
/fuad[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
Ok, we really need to slow down the rate of patches here. I had already applied the SVE series locally and now we've got a grab-bag of CPU features in addition to what I was ready to apply.
The whole point of respinning a series is so we can converge on the shape of the feature and get it merged. Adding a whole pile of things that wasn't asked for just muddies the context for us dumb humans and slows down the rate at which you're going to land things upstream.
Going forward, can you please:
- Keep an individual series focused on the original intent. Don't unnecessarily expand scope.
- Only iterate on a couple of series on the list at a time. Sashiko findings are interesting, but you're gonna have to draw a cutline in terms of how many additional patches are going to ride the coattails of any particular series.
You're obviously a very active contributor and reviewer, so I don't anticipate such a rate limit to actually impede your patch velocity.
Sorry, I really do appreciate the amount of work that you're doing to get pKVM in good shape upstream. I just get the sense that Marc and I are going to quickly encounter bandwidth limitations.
Thanks,
Oliver
Fuad Tabba
reviewerHi Oliver,
On Mon, 9 Nov 2026 at 20:20, Oliver Upton <[email protected]> wrote:
[...]
Quoted 8 lines
Ok, we really need to slow down the rate of patches here. I had already applied the SVE series locally and now we've got a grab-bag of CPU features in addition to what I was ready to apply.
The whole point of respinning a series is so we can converge on the shape of the feature and get it merged. Adding a whole pile of things that wasn't asked for just muddies the context for us dumb humans and slows down the rate at which you're going to land things upstream.
I'm sorry. My intent was to make life easier by avoiding conflicts within these series, but I see how it ended up having the opposite effect.
The SVE patches in this series are unchanged from the SVE series [1], so what you applied is still current, and the same goes for the debug patch [2]. I'll hold off on the rest until you've had a chance to deal with those two.
Quoted 10 lines
Going forward, can you please:
- Keep an individual series focused on the original intent. Don't unnecessarily expand scope.
- Only iterate on a couple of series on the list at a time. Sashiko findings are interesting, but you're gonna have to draw a cutline in terms of how many additional patches are going to ride the coattails of any particular series.
Ack.
Quoted 6 lines
You're obviously a very active contributor and reviewer, so I don't anticipate such a rate limit to actually impede your patch velocity.
Sorry, I really do appreciate the amount of work that you're doing to get pKVM in good shape upstream. I just get the sense that Marc and I are going to quickly encounter bandwidth limitations.
I appreciate the work you both do. Other than being more careful with my own patches, let me know if there's anything else I could help to take work off your plate.
Cheers,
/fuad
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Quoted 2 lines
Thanks,
Oliver
Oliver Upton
maintainerRe: [PATCH 07/16] KVM: arm64: Compute a protected vCPU's fine-grained traps at EL2
In reply to Fuad TabbaHi Fuad,
Quoted 17 lines · Fuad Tabba
arch/arm64/kvm/config.c +1
-5+#ifndef __KVM_NVHE_HYPERVISOR__static void __init check_feat_map (const struct reg_bits_to_feat_map *map,int map_size,u64 resx,const char *str) {@@ -1414,11 +1420,6 @@ static void __init check_feat_map(const struct reg_bits_to_feat_map *map, str, mask ^ ~resx); } -static u64 reg_feat_map_bits (const struct reg_bits_to_feat_map *map) -{ -return map->flags &MASKS_POINTER ? (map->masks->mask | map->masks->nmask) : map->bits; -} -static void __init check_reg_desc (const struct reg_feat_map_desc *r) { check_feat_map(r->bit_feat_map, r->bit_feat_map_sz,
arch/arm64/kvm/config.c void __init check_feature_map(void) · line 1455
Quoted 4 lines
arch/arm64/kvm/config.c +1
-0@@ -1451,6 +1452,7 @@ void __init check_feature_map(void)check_reg_desc (&ich_hfgwtr_desc); check_reg_desc(&ich_hfgitr_desc); } +#endif
We already have too much ifdeffery... It isn't mentioned in the changelog but I take it you're doing this to avoid the printk() in check_feat_map()?
If yes then just upgrade that thing to a WARN() and carry on, it only ever runs at init.
Thanks,
Oliver
Fuad Tabba
reviewerRe: [PATCH 07/16] KVM: arm64: Compute a protected vCPU's fine-grained traps at EL2
Hi Oliver,
On Tue, 17 Nov 2026 18:12:47 +0000, Oliver Upton <[email protected]> wrote:
[...]
Quoted 4 lines
Quoted 4 lines
+#ifndef
__KVM_NVHE_HYPERVISOR__
static void__initcheck_feat_map(const structreg_bits_to_feat_map*map,
intmap_size, u64 resx, const char *str)
{
[...]
Quoted 8 lines
Quoted 1 line
+#endif
We already have too much ifdeffery... It isn't mentioned in the changelog but I take it you're doing this to avoid the
printk()incheck_feat_map()?If yes then just upgrade that thing to a
WARN()and carry on, it only ever runs at init.
Yes, it's because of the kvm_err(), as printk() isn't available in the hyp object. WARN() calls __warn_printk(), which isn't available there either. WARN_ON() works, so I'll use that in v2 and drop the ifdef. The warning won't have the register's name or the bits, though.
I'll wait until next week before respinning, in case you or others have more feedback.
Cheers,
/fuad