AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/11/12 01:58 flow patch-triage
3m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "KMSANReasoning": "",
  "NeedsKMSAN": false,
  "Reasoning": "The patch series modifies documentation and ARM64-specific KVM/pKVM hypervisor code under arch/arm64. Because the target architecture is amd64, all modified executable paths are exclusive to ARM64 and cannot be compiled or executed on amd64.",
  "WorthFuzzing": false
}

1/1 2026/11/12 01:58 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 6c0529b2ec062261c6ac940f8f6834d3c1ff753f\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Thu Nov 12 01:58:12 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/Documentation/virt/kvm/arm/pkvm.rst b/Documentation/virt/kvm/arm/pkvm.rst\nindex b75bb8ad6f26dc..c59e598645b1b8 100644\n--- a/Documentation/virt/kvm/arm/pkvm.rst\n+++ b/Documentation/virt/kvm/arm/pkvm.rst\n@@ -134,9 +134,9 @@ A protected VM boots from a single primary vCPU. Before the first\n * Set the primary vCPU's boot state with ``KVM_SET_ONE_REG``: the kernel\n   entry address in ``PC`` and the DTB pointer in ``x0``.\n \n-``PC`` and ``x0`` are the only registers EL2 takes from the host. Other\n-pre-run writes are accepted, but the guest starts from the state the\n-hypervisor resets it to.\n+``PC``, ``x0`` and the SVE vector lengths (``KVM_REG_ARM64_SVE_VLS``) are\n+the only registers EL2 takes from the host. Other pre-run writes are\n+accepted, but the guest starts from the state the hypervisor resets it to.\n \n Secondary vCPUs are started by the guest itself through PSCI ``CPU_ON``\n (see `Power state`_), which supplies their entry point and context ID.\n@@ -241,10 +241,9 @@ Other interface differences\n Debug\n -----\n \n-Hardware-assisted debugging is not available to protected guests.\n-``MDSCR_EL1``, ``OSLAR_EL1``, ``OSLSR_EL1``, ``OSDLR_EL1``, and breakpoint\n-and watchpoint 0 are RAZ/WI; any other debug register access takes an\n-undefined instruction exception.\n+A protected guest can use self-hosted debug (breakpoints, watchpoints and\n+single-step) as a non-protected guest can. ``KVM_SET_GUEST_DEBUG`` returns\n+``-EPERM`` for a protected VM.\n \n Resources\n =========\ndiff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h\nindex 97332ffcb1300e..82ba4bb9573f19 100644\n--- a/arch/arm64/include/asm/kvm_host.h\n+++ b/arch/arm64/include/asm/kvm_host.h\n@@ -1748,7 +1748,7 @@ static inline bool kvm_arch_has_irq_bypass(void)\n }\n \n void kvm_idregs_enforce_dependencies(struct kvm *kvm);\n-void compute_fgu(struct kvm *kvm, enum fgt_group_id fgt);\n+void kvm_init_fgu(struct kvm *kvm);\n struct resx get_reg_fixed_bits(struct kvm *kvm, enum vcpu_sysreg reg);\n void check_feature_map(void);\n void kvm_vcpu_load_fgt(struct kvm_vcpu *vcpu);\ndiff --git a/arch/arm64/include/asm/kvm_hyp.h b/arch/arm64/include/asm/kvm_hyp.h\nindex b0e42be3d9eef9..09b19f2c3c0908 100644\n--- a/arch/arm64/include/asm/kvm_hyp.h\n+++ b/arch/arm64/include/asm/kvm_hyp.h\n@@ -144,19 +144,25 @@ void __noreturn __host_enter(struct kvm_cpu_context *host_ctxt);\n extern u64 kvm_nvhe_sym(id_aa64pfr0_el1_sys_val);\n extern u64 kvm_nvhe_sym(id_aa64pfr1_el1_sys_val);\n extern u64 kvm_nvhe_sym(id_aa64pfr2_el1_sys_val);\n+extern u64 kvm_nvhe_sym(id_aa64zfr0_el1_sys_val);\n+extern u64 kvm_nvhe_sym(id_aa64fpfr0_el1_sys_val);\n extern u64 kvm_nvhe_sym(id_aa64isar0_el1_sys_val);\n extern u64 kvm_nvhe_sym(id_aa64isar1_el1_sys_val);\n extern u64 kvm_nvhe_sym(id_aa64isar2_el1_sys_val);\n+extern u64 kvm_nvhe_sym(id_aa64isar3_el1_sys_val);\n extern u64 kvm_nvhe_sym(id_aa64mmfr0_el1_sys_val);\n extern u64 kvm_nvhe_sym(id_aa64mmfr1_el1_sys_val);\n extern u64 kvm_nvhe_sym(id_aa64mmfr2_el1_sys_val);\n+extern u64 kvm_nvhe_sym(id_aa64mmfr3_el1_sys_val);\n extern u64 kvm_nvhe_sym(id_aa64smfr0_el1_sys_val);\n+extern u64 kvm_nvhe_sym(id_aa64dfr0_el1_sys_val);\n \n extern unsigned long kvm_nvhe_sym(__icache_flags);\n extern unsigned int kvm_nvhe_sym(kvm_arm_vmid_bits);\n extern enum mitigation_state kvm_nvhe_sym(spectre_v2_state);\n extern enum mitigation_state kvm_nvhe_sym(spectre_v4_state);\n extern enum mitigation_state kvm_nvhe_sym(spectre_bhb_state);\n+extern unsigned int kvm_nvhe_sym(kvm_sve_max_vl);\n extern unsigned int kvm_nvhe_sym(kvm_host_sve_max_vl);\n extern unsigned long kvm_nvhe_sym(hyp_nr_cpus);\n extern unsigned int kvm_nvhe_sym(hyp_gicv3_nr_lr);\ndiff --git a/arch/arm64/include/asm/kvm_pkvm.h b/arch/arm64/include/asm/kvm_pkvm.h\nindex fd042d2b54624c..5f1b3308b42e13 100644\n--- a/arch/arm64/include/asm/kvm_pkvm.h\n+++ b/arch/arm64/include/asm/kvm_pkvm.h\n@@ -40,6 +40,7 @@ static inline bool kvm_pkvm_ext_allowed(struct kvm *kvm, long ext)\n \tcase KVM_CAP_MAX_VCPU_ID:\n \tcase KVM_CAP_MSI_DEVID:\n \tcase KVM_CAP_ARM_VM_IPA_SIZE:\n+\tcase KVM_CAP_ARM_SVE:\n \tcase KVM_CAP_ARM_PTRAUTH_ADDRESS:\n \tcase KVM_CAP_ARM_PTRAUTH_GENERIC:\n \tcase KVM_CAP_ONE_REG:\ndiff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c\nindex 157bf4b8120201..6cc65ee4c6f2af 100644\n--- a/arch/arm64/kvm/arm.c\n+++ b/arch/arm64/kvm/arm.c\n@@ -2827,13 +2827,18 @@ static void kvm_hyp_init_symbols(void)\n \tkvm_nvhe_sym(id_aa64pfr0_el1_sys_val) = get_hyp_id_aa64pfr0_el1();\n \tkvm_nvhe_sym(id_aa64pfr1_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64PFR1_EL1);\n \tkvm_nvhe_sym(id_aa64pfr2_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64PFR2_EL1);\n+\tkvm_nvhe_sym(id_aa64zfr0_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64ZFR0_EL1);\n+\tkvm_nvhe_sym(id_aa64fpfr0_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64FPFR0_EL1);\n \tkvm_nvhe_sym(id_aa64isar0_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64ISAR0_EL1);\n \tkvm_nvhe_sym(id_aa64isar1_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64ISAR1_EL1);\n \tkvm_nvhe_sym(id_aa64isar2_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64ISAR2_EL1);\n+\tkvm_nvhe_sym(id_aa64isar3_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64ISAR3_EL1);\n \tkvm_nvhe_sym(id_aa64mmfr0_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1);\n \tkvm_nvhe_sym(id_aa64mmfr1_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64MMFR1_EL1);\n \tkvm_nvhe_sym(id_aa64mmfr2_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64MMFR2_EL1);\n+\tkvm_nvhe_sym(id_aa64mmfr3_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64MMFR3_EL1);\n \tkvm_nvhe_sym(id_aa64smfr0_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64SMFR0_EL1);\n+\tkvm_nvhe_sym(id_aa64dfr0_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64DFR0_EL1);\n \tkvm_nvhe_sym(__icache_flags) = __icache_flags;\n \tkvm_nvhe_sym(kvm_arm_vmid_bits) = kvm_arm_vmid_bits;\n \ndiff --git a/arch/arm64/kvm/config.c b/arch/arm64/kvm/config.c\nindex adaf26ab93b857..27ee8188fd76db 100644\n--- a/arch/arm64/kvm/config.c\n+++ b/arch/arm64/kvm/config.c\n@@ -1395,6 +1395,12 @@ static const struct reg_bits_to_feat_map ich_hfgitr_feat_map[] = {\n static const DECLARE_FEAT_MAP_FGT(ich_hfgitr_desc, ich_hfgitr_masks,\n \t\t\t\t  ich_hfgitr_feat_map, FEAT_GCIE);\n \n+static u64 reg_feat_map_bits(const struct reg_bits_to_feat_map *map)\n+{\n+\treturn map-\u003eflags \u0026 MASKS_POINTER ? (map-\u003emasks-\u003emask | map-\u003emasks-\u003enmask) : map-\u003ebits;\n+}\n+\n+#ifndef __KVM_NVHE_HYPERVISOR__\n static void __init check_feat_map(const struct reg_bits_to_feat_map *map,\n \t\t\t\t  int map_size, u64 resx, const char *str)\n {\n@@ -1414,11 +1420,6 @@ static void __init check_feat_map(const struct reg_bits_to_feat_map *map,\n \t\t\tstr, mask ^ ~resx);\n }\n \n-static u64 reg_feat_map_bits(const struct reg_bits_to_feat_map *map)\n-{\n-\treturn map-\u003eflags \u0026 MASKS_POINTER ? (map-\u003emasks-\u003emask | map-\u003emasks-\u003enmask) : map-\u003ebits;\n-}\n-\n static void __init check_reg_desc(const struct reg_feat_map_desc *r)\n {\n \tcheck_feat_map(r-\u003ebit_feat_map, r-\u003ebit_feat_map_sz,\n@@ -1451,6 +1452,7 @@ void __init check_feature_map(void)\n \tcheck_reg_desc(\u0026ich_hfgwtr_desc);\n \tcheck_reg_desc(\u0026ich_hfgitr_desc);\n }\n+#endif\n \n static const struct reg_feat_map_desc *idreg_feat_maps[] = {\n \t\u0026id_aa64mmfr3_el1_desc,\n@@ -1586,7 +1588,7 @@ static u64 compute_fgu_bits(struct kvm *kvm, const struct reg_feat_map_desc *r)\n \treturn resx.res0 | resx.res1;\n }\n \n-void compute_fgu(struct kvm *kvm, enum fgt_group_id fgt)\n+static void compute_fgu(struct kvm *kvm, enum fgt_group_id fgt)\n {\n \tu64 val = 0;\n \n@@ -1630,6 +1632,24 @@ void compute_fgu(struct kvm *kvm, enum fgt_group_id fgt)\n \tkvm-\u003earch.fgu[fgt] = val;\n }\n \n+void kvm_init_fgu(struct kvm *kvm)\n+{\n+\tif (test_bit(KVM_ARCH_FLAG_FGU_INITIALIZED, \u0026kvm-\u003earch.flags))\n+\t\treturn;\n+\n+\tcompute_fgu(kvm, HFGRTR_GROUP);\n+\tcompute_fgu(kvm, HFGITR_GROUP);\n+\tcompute_fgu(kvm, HDFGRTR_GROUP);\n+\tcompute_fgu(kvm, HAFGRTR_GROUP);\n+\tcompute_fgu(kvm, HFGRTR2_GROUP);\n+\tcompute_fgu(kvm, HFGITR2_GROUP);\n+\tcompute_fgu(kvm, HDFGRTR2_GROUP);\n+\tcompute_fgu(kvm, ICH_HFGRTR_GROUP);\n+\tcompute_fgu(kvm, ICH_HFGITR_GROUP);\n+\n+\tset_bit(KVM_ARCH_FLAG_FGU_INITIALIZED, \u0026kvm-\u003earch.flags);\n+}\n+\n struct resx get_reg_fixed_bits(struct kvm *kvm, enum vcpu_sysreg reg)\n {\n \tstruct resx resx;\ndiff --git a/arch/arm64/kvm/hyp/include/nvhe/pkvm.h b/arch/arm64/kvm/hyp/include/nvhe/pkvm.h\nindex 0261b2bc681f77..993d54ce444089 100644\n--- a/arch/arm64/kvm/hyp/include/nvhe/pkvm.h\n+++ b/arch/arm64/kvm/hyp/include/nvhe/pkvm.h\n@@ -130,6 +130,7 @@ void put_pkvm_hyp_vm(struct pkvm_hyp_vm *hyp_vm);\n bool kvm_handle_pvm_hvc64(struct kvm_vcpu *vcpu, u64 *exit_code);\n bool kvm_handle_pvm_sysreg(struct kvm_vcpu *vcpu, u64 *exit_code);\n bool kvm_handle_pvm_restricted(struct kvm_vcpu *vcpu, u64 *exit_code);\n+void kvm_load_pvm_debug(struct kvm_vcpu *vcpu);\n void kvm_init_pvm_id_regs(struct kvm_vcpu *vcpu);\n void kvm_reset_pvm_sys_regs(struct kvm_vcpu *vcpu);\n int kvm_check_pvm_sysreg_table(void);\ndiff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Makefile\nindex 56a7e2c05f73aa..06d7d8618d89f0 100644\n--- a/arch/arm64/kvm/hyp/nvhe/Makefile\n+++ b/arch/arm64/kvm/hyp/nvhe/Makefile\n@@ -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\n \t cache.o setup.o mm.o mem_protect.o sys_regs.o pkvm.o stacktrace.o ffa.o\n hyp-obj-y += ../vgic-v3-sr.o ../aarch32.o ../vgic-v2-cpuif-proxy.o ../entry.o \\\n \t ../hyp-entry.o ../exception.o ../pgtable.o ../vgic-v5-sr.o\n+hyp-obj-y += ../../config.o\n hyp-obj-y += ../../../kernel/smccc-call.o\n hyp-obj-$(CONFIG_LIST_HARDENED) += list_debug.o\n hyp-obj-$(CONFIG_NVHE_EL2_TRACING) += clock.o trace.o events.o\ndiff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c\nindex 179d7c8277b883..57c3f7a2d4b148 100644\n--- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c\n+++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c\n@@ -482,7 +482,7 @@ static void __hyp_sve_save_guest(struct kvm_vcpu *vcpu)\n \t * on the VL, so use a consistent (i.e., the maximum) guest VL.\n \t */\n \tsve_cond_update_zcr_vq(vcpu_sve_max_vq(vcpu) - 1, SYS_ZCR_EL2);\n-\tsve_save_state(kern_hyp_va(vcpu-\u003earch.sve_state), true);\n+\tsve_save_state(vcpu-\u003earch.sve_state, true);\n \tfpsimd_save_common(\u0026vcpu-\u003earch.ctxt.fp_regs);\n \twrite_sysreg_s(sve_vq_from_vl(kvm_host_sve_max_vl) - 1, SYS_ZCR_EL2);\n }\n@@ -531,7 +531,7 @@ static void fpsimd_sve_sync(struct kvm_vcpu *vcpu)\n \telse\n \t\tfpsimd_save_state(\u0026vcpu-\u003earch.ctxt.fp_regs);\n \n-\thas_fpmr = kvm_has_fpmr(kern_hyp_va(vcpu-\u003ekvm));\n+\thas_fpmr = kvm_has_fpmr(vcpu-\u003ekvm);\n \tif (has_fpmr)\n \t\t__vcpu_assign_sys_reg(vcpu, FPMR, read_sysreg_s(SYS_FPMR));\n \n@@ -837,6 +837,8 @@ DEFINE_KVM_HOST_HCALL(void, __pkvm_vcpu_load,\n \t\thyp_vcpu-\u003evcpu.arch.hcr_el2 \u0026= ~(HCR_EL2_TWE | HCR_EL2_TWI);\n \t\thyp_vcpu-\u003evcpu.arch.hcr_el2 |= hcr_el2 \u0026 (HCR_EL2_TWE | HCR_EL2_TWI);\n \n+\t\tkvm_load_pvm_debug(\u0026hyp_vcpu-\u003evcpu);\n+\n \t\t/* HPMN == 0 is reserved without FEAT_HPMN0. */\n \t\tif (pmuv3_implemented(SYS_FIELD_GET(ID_AA64DFR0_EL1, PMUVer, dfr0)))\n \t\t\tu64p_replace_bits(\u0026hyp_vcpu-\u003evcpu.arch.mdcr_el2,\ndiff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c\nindex fc0475f0877d19..465d963d6ff57b 100644\n--- a/arch/arm64/kvm/hyp/nvhe/pkvm.c\n+++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c\n@@ -30,6 +30,7 @@ unsigned long __icache_flags;\n /* Used by kvm_get_vttbr(). */\n unsigned int kvm_arm_vmid_bits;\n \n+unsigned int kvm_sve_max_vl;\n unsigned int kvm_host_sve_max_vl;\n \n /*\n@@ -123,8 +124,11 @@ static void pvm_init_traps_mdcr(struct kvm_vcpu *vcpu)\n \t\tval \u0026= ~(MDCR_EL2_HPME | MDCR_EL2_MTPME);\n \t}\n \n-\tif (!kvm_has_feat(kvm, ID_AA64DFR0_EL1, DebugVer, IMP))\n-\t\tval |= MDCR_EL2_TDRA | MDCR_EL2_TDA;\n+\t/*\n+\t * Keep TDA set even when the guest owns debug: it also traps the DCC\n+\t * and the claim tags, which the world switch doesn't switch.\n+\t */\n+\tval |= MDCR_EL2_TDRA | MDCR_EL2_TDA;\n \n \tif (!kvm_has_feat(kvm, ID_AA64DFR0_EL1, DoubleLock, IMP))\n \t\tval |= MDCR_EL2_TDOSA;\n@@ -202,6 +206,8 @@ static int pkvm_vcpu_init_traps(struct pkvm_hyp_vcpu *hyp_vcpu)\n \tpvm_init_traps_hcr(vcpu);\n \tpvm_init_traps_mdcr(vcpu);\n \tvcpu_set_hcrx(vcpu);\n+\tkvm_init_fgu(vcpu-\u003ekvm);\n+\tkvm_vcpu_load_fgt(vcpu);\n \n \treturn 0;\n }\n@@ -476,7 +482,7 @@ static void unpin_host_vcpu(struct kvm_vcpu *host_vcpu)\n \t\thyp_unpin_shared_mem(host_vcpu, host_vcpu + 1);\n }\n \n-static void unpin_host_sve_state(struct pkvm_hyp_vcpu *hyp_vcpu)\n+static void teardown_sve_state(struct pkvm_hyp_vcpu *hyp_vcpu)\n {\n \tvoid *sve_state;\n \n@@ -484,8 +490,10 @@ static void unpin_host_sve_state(struct pkvm_hyp_vcpu *hyp_vcpu)\n \tif (!sve_state)\n \t\treturn;\n \n-\thyp_unpin_shared_mem(sve_state,\n-\t\t\t     sve_state + vcpu_sve_state_size(\u0026hyp_vcpu-\u003evcpu));\n+\tif (pkvm_hyp_vcpu_is_protected(hyp_vcpu))\n+\t\thyp_free(sve_state);\n+\telse\n+\t\thyp_unpin_shared_mem(sve_state, sve_state + vcpu_sve_state_size(\u0026hyp_vcpu-\u003evcpu));\n }\n \n static void unpin_host_vcpus(struct pkvm_hyp_vcpu *hyp_vcpus[],\n@@ -500,7 +508,7 @@ static void unpin_host_vcpus(struct pkvm_hyp_vcpu *hyp_vcpus[],\n \t\t\tcontinue;\n \n \t\tunpin_host_vcpu(hyp_vcpu-\u003ehost_vcpu);\n-\t\tunpin_host_sve_state(hyp_vcpu);\n+\t\tteardown_sve_state(hyp_vcpu);\n \t}\n }\n \n@@ -543,18 +551,25 @@ static int pkvm_vcpu_init_sve(struct pkvm_hyp_vcpu *hyp_vcpu, struct kvm_vcpu *h\n \t\treturn 0;\n \t}\n \n-\t/* Limit guest vector length to the maximum supported by the host. */\n-\tsve_max_vl = min(READ_ONCE(host_vcpu-\u003earch.sve_max_vl), kvm_host_sve_max_vl);\n-\tsve_state = kern_hyp_va(READ_ONCE(host_vcpu-\u003earch.sve_state));\n-\n-\tif (!sve_vl_valid(sve_max_vl) || !sve_state)\n+\tsve_max_vl = READ_ONCE(host_vcpu-\u003earch.sve_max_vl);\n+\tif (!sve_vl_valid(sve_max_vl) || sve_max_vl \u003e kvm_sve_max_vl)\n \t\treturn -EINVAL;\n \n \tsve_state_size = sve_state_size_from_vl(sve_max_vl);\n \n-\tret = hyp_pin_shared_mem(sve_state, sve_state + sve_state_size);\n-\tif (ret)\n-\t\treturn ret;\n+\tif (pkvm_hyp_vcpu_is_protected(hyp_vcpu)) {\n+\t\tsve_state = hyp_alloc(sve_state_size);\n+\t\tif (!sve_state)\n+\t\t\treturn hyp_alloc_errno();\n+\t} else {\n+\t\tsve_state = kern_hyp_va(READ_ONCE(host_vcpu-\u003earch.sve_state));\n+\t\tif (!sve_state)\n+\t\t\treturn -EINVAL;\n+\n+\t\tret = hyp_pin_shared_mem(sve_state, sve_state + sve_state_size);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n \n \tvcpu-\u003earch.sve_state = sve_state;\n \tvcpu-\u003earch.sve_max_vl = sve_max_vl;\n@@ -643,7 +658,7 @@ static int init_pkvm_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu,\n done:\n \tif (ret) {\n \t\tunpin_host_vcpu(host_vcpu);\n-\t\tunpin_host_sve_state(hyp_vcpu);\n+\t\tteardown_sve_state(hyp_vcpu);\n \t}\n \treturn ret;\n }\n@@ -1015,7 +1030,7 @@ int __pkvm_init_vcpu(pkvm_handle_t handle, struct kvm_vcpu *host_vcpu)\n \tret = register_hyp_vcpu(hyp_vm, hyp_vcpu);\n \tif (ret) {\n \t\tunpin_host_vcpu(host_vcpu);\n-\t\tunpin_host_sve_state(hyp_vcpu);\n+\t\tteardown_sve_state(hyp_vcpu);\n \t\tgoto unclaim;\n \t}\n \tgoto unlock;\n@@ -1243,8 +1258,12 @@ int pkvm_reset_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu)\n \t\t\t    PSCI_0_2_AFFINITY_LEVEL_ON) != PSCI_0_2_AFFINITY_LEVEL_ON_PENDING)\n \t\treturn -ECANCELED;\n \n+\tif (vcpu_has_sve(\u0026hyp_vcpu-\u003evcpu))\n+\t\tmemset(hyp_vcpu-\u003evcpu.arch.sve_state, 0, vcpu_sve_state_size(\u0026hyp_vcpu-\u003evcpu));\n+\n \tkvm_reset_vcpu_core(\u0026hyp_vcpu-\u003evcpu);\n \tkvm_reset_pvm_sys_regs(\u0026hyp_vcpu-\u003evcpu);\n+\tkvm_load_pvm_debug(\u0026hyp_vcpu-\u003evcpu);\n \n \t/* Must be done after resetting sys registers. */\n \tkvm_reset_vcpu_psci(\u0026hyp_vcpu-\u003evcpu, reset_state);\ndiff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c\nindex 89fb9dd351ad5d..0626f4203ba6db 100644\n--- a/arch/arm64/kvm/hyp/nvhe/switch.c\n+++ b/arch/arm64/kvm/hyp/nvhe/switch.c\n@@ -230,6 +230,7 @@ static const exit_handler_fn pvm_exit_handlers[] = {\n \t[ESR_ELx_EC_WFx]\t\t= kvm_handle_pvm_wfx,\n \t[ESR_ELx_EC_HVC64]\t\t= kvm_handle_pvm_hvc64,\n \t[ESR_ELx_EC_SYS64]\t\t= kvm_handle_pvm_sys64,\n+\t[ESR_ELx_EC_SVE]\t\t= kvm_handle_pvm_fpsimd,\n \t[ESR_ELx_EC_FP_ASIMD]\t\t= kvm_handle_pvm_fpsimd,\n \t[ESR_ELx_EC_IABT_LOW]\t\t= kvm_hyp_handle_iabt_low,\n \t[ESR_ELx_EC_DABT_LOW]\t\t= kvm_hyp_handle_dabt_low,\ndiff --git a/arch/arm64/kvm/hyp/nvhe/sys_regs.c b/arch/arm64/kvm/hyp/nvhe/sys_regs.c\nindex 32e82653ebf7e7..4ab0ee50eea200 100644\n--- a/arch/arm64/kvm/hyp/nvhe/sys_regs.c\n+++ b/arch/arm64/kvm/hyp/nvhe/sys_regs.c\n@@ -10,6 +10,8 @@\n #include \u003casm/kvm_mmu.h\u003e\n \n #include \u003chyp/adjust_pc.h\u003e\n+#include \u003chyp/debug-sr.h\u003e\n+#include \u003chyp/sysreg-sr.h\u003e\n \n #include \u003cnvhe/pkvm.h\u003e\n \n@@ -21,13 +23,18 @@\n u64 id_aa64pfr0_el1_sys_val;\n u64 id_aa64pfr1_el1_sys_val;\n u64 id_aa64pfr2_el1_sys_val;\n+u64 id_aa64zfr0_el1_sys_val;\n+u64 id_aa64fpfr0_el1_sys_val;\n u64 id_aa64isar0_el1_sys_val;\n u64 id_aa64isar1_el1_sys_val;\n u64 id_aa64isar2_el1_sys_val;\n+u64 id_aa64isar3_el1_sys_val;\n u64 id_aa64mmfr0_el1_sys_val;\n u64 id_aa64mmfr1_el1_sys_val;\n u64 id_aa64mmfr2_el1_sys_val;\n+u64 id_aa64mmfr3_el1_sys_val;\n u64 id_aa64smfr0_el1_sys_val;\n+u64 id_aa64dfr0_el1_sys_val;\n \n struct pvm_ftr_bits {\n \tbool\t\tsign;\n@@ -55,6 +62,13 @@ struct pvm_ftr_bits {\n #define MAX_FEAT_ENUM(id, fld, max)\t\t\t\t\t\t\\\n \t__MAX_FEAT_FUNC(id, fld, max, NULL, false)\n \n+#define MAX_FEAT_PASSTHRU(id, fld)\t\t\t\t\t\t\\\n+\t{\t\t\t\t\t\t\t\t\t\\\n+\t\t.shift = id##_##fld##_SHIFT,\t\t\t\t\t\\\n+\t\t.width = id##_##fld##_WIDTH,\t\t\t\t\t\\\n+\t\t.max_val = GENMASK(id##_##fld##_WIDTH - 1, 0),\t\t\t\\\n+\t}\n+\n #define FEAT_END {\t.width = 0,\t}\n \n static bool vm_has_ptrauth(const struct kvm *kvm)\n@@ -72,6 +86,11 @@ static bool vm_has_sve(const struct kvm *kvm)\n \treturn system_supports_sve() \u0026\u0026 kvm_vcpu_has_feature(kvm, KVM_ARM_VCPU_SVE);\n }\n \n+static bool vm_has_s1poe(const struct kvm *kvm)\n+{\n+\treturn system_supports_poe();\n+}\n+\n /*\n  * Definitions for features to be allowed or restricted for protected guests.\n  *\n@@ -111,6 +130,36 @@ static const struct pvm_ftr_bits pvmid_aa64pfr1[] = {\n \n static const struct pvm_ftr_bits pvmid_aa64pfr2[] = {\n \tMAX_FEAT(ID_AA64PFR2_EL1, GCIE, NI),\n+\tMAX_FEAT(ID_AA64PFR2_EL1, FPMR, IMP),\n+\tFEAT_END\n+};\n+\n+static const struct pvm_ftr_bits pvmid_aa64zfr0[] = {\n+\tMAX_FEAT_FUNC(ID_AA64ZFR0_EL1, SVEver, SVE2p3, vm_has_sve),\n+\tMAX_FEAT_FUNC(ID_AA64ZFR0_EL1, AES, AES2, vm_has_sve),\n+\tMAX_FEAT_FUNC(ID_AA64ZFR0_EL1, EltPerm, IMP, vm_has_sve),\n+\tMAX_FEAT_FUNC(ID_AA64ZFR0_EL1, BitPerm, IMP, vm_has_sve),\n+\tMAX_FEAT_FUNC(ID_AA64ZFR0_EL1, BF16, EBF16, vm_has_sve),\n+\tMAX_FEAT_FUNC(ID_AA64ZFR0_EL1, B16B16, B16MM, vm_has_sve),\n+\tMAX_FEAT_FUNC(ID_AA64ZFR0_EL1, SHA3, IMP, vm_has_sve),\n+\tMAX_FEAT_FUNC(ID_AA64ZFR0_EL1, SM4, IMP, vm_has_sve),\n+\tMAX_FEAT_FUNC(ID_AA64ZFR0_EL1, I8MM, IMP, vm_has_sve),\n+\tMAX_FEAT_FUNC(ID_AA64ZFR0_EL1, F16MM, IMP, vm_has_sve),\n+\tMAX_FEAT_FUNC(ID_AA64ZFR0_EL1, F32MM, IMP, vm_has_sve),\n+\tMAX_FEAT_FUNC(ID_AA64ZFR0_EL1, F64MM, IMP, vm_has_sve),\n+\tFEAT_END\n+};\n+\n+static const struct pvm_ftr_bits pvmid_aa64fpfr0[] = {\n+\tMAX_FEAT(ID_AA64FPFR0_EL1, F8E5M2, IMP),\n+\tMAX_FEAT(ID_AA64FPFR0_EL1, F8E4M3, IMP),\n+\tMAX_FEAT(ID_AA64FPFR0_EL1, F16MM2, IMP),\n+\tMAX_FEAT(ID_AA64FPFR0_EL1, F8MM4, IMP),\n+\tMAX_FEAT(ID_AA64FPFR0_EL1, F8MM8, IMP),\n+\tMAX_FEAT(ID_AA64FPFR0_EL1, F8DP2, IMP),\n+\tMAX_FEAT(ID_AA64FPFR0_EL1, F8DP4, IMP),\n+\tMAX_FEAT(ID_AA64FPFR0_EL1, F8FMA, IMP),\n+\tMAX_FEAT(ID_AA64FPFR0_EL1, F8CVT, IMP),\n \tFEAT_END\n };\n \n@@ -124,17 +173,21 @@ static const struct pvm_ftr_bits pvmid_aa64mmfr0[] = {\n \tMAX_FEAT(ID_AA64MMFR0_EL1, TGRAN4, IMP),\n \tMAX_FEAT(ID_AA64MMFR0_EL1, TGRAN16, IMP),\n \tMAX_FEAT(ID_AA64MMFR0_EL1, TGRAN64, IMP),\n+\tMAX_FEAT(ID_AA64MMFR0_EL1, ECV, IMP),\n \tFEAT_END\n };\n \n static const struct pvm_ftr_bits pvmid_aa64mmfr1[] = {\n-\tMAX_FEAT(ID_AA64MMFR1_EL1, HAFDBS, DBM),\n+\tMAX_FEAT(ID_AA64MMFR1_EL1, HAFDBS, HAFT),\n \tMAX_FEAT_ENUM(ID_AA64MMFR1_EL1, VMIDBits, 16),\n \tMAX_FEAT(ID_AA64MMFR1_EL1, HPDS, HPDS2),\n \tMAX_FEAT(ID_AA64MMFR1_EL1, PAN, PAN3),\n \tMAX_FEAT(ID_AA64MMFR1_EL1, SpecSEI, IMP),\n-\tMAX_FEAT(ID_AA64MMFR1_EL1, ETS, IMP),\n+\tMAX_FEAT(ID_AA64MMFR1_EL1, ETS, ETS3),\n+\tMAX_FEAT(ID_AA64MMFR1_EL1, AFP, IMP),\n+\tMAX_FEAT(ID_AA64MMFR1_EL1, TIDCP1, IMP),\n \tMAX_FEAT(ID_AA64MMFR1_EL1, CMOW, IMP),\n+\tMAX_FEAT(ID_AA64MMFR1_EL1, ECBHB, IMP),\n \tFEAT_END\n };\n \n@@ -142,6 +195,8 @@ static const struct pvm_ftr_bits pvmid_aa64mmfr2[] = {\n \tMAX_FEAT(ID_AA64MMFR2_EL1, CnP, IMP),\n \tMAX_FEAT(ID_AA64MMFR2_EL1, UAO, IMP),\n \tMAX_FEAT(ID_AA64MMFR2_EL1, IESB, IMP),\n+\tMAX_FEAT(ID_AA64MMFR2_EL1, VARange, 52),\n+\tMAX_FEAT_ENUM(ID_AA64MMFR2_EL1, ST, 48_47),\n \tMAX_FEAT(ID_AA64MMFR2_EL1, AT, IMP),\n \tMAX_FEAT(ID_AA64MMFR2_EL1, IDS, IMP),\n \tMAX_FEAT(ID_AA64MMFR2_EL1, TTL, IMP),\n@@ -150,6 +205,14 @@ static const struct pvm_ftr_bits pvmid_aa64mmfr2[] = {\n \tFEAT_END\n };\n \n+static const struct pvm_ftr_bits pvmid_aa64mmfr3[] = {\n+\tMAX_FEAT(ID_AA64MMFR3_EL1, TCRX, IMP),\n+\tMAX_FEAT(ID_AA64MMFR3_EL1, SCTLRX, IMP),\n+\tMAX_FEAT(ID_AA64MMFR3_EL1, S1PIE, IMP),\n+\tMAX_FEAT_FUNC(ID_AA64MMFR3_EL1, S1POE, IMP, vm_has_s1poe),\n+\tFEAT_END\n+};\n+\n static const struct pvm_ftr_bits pvmid_aa64isar1[] = {\n \tMAX_FEAT(ID_AA64ISAR1_EL1, DPB, DPB2),\n \tMAX_FEAT_FUNC(ID_AA64ISAR1_EL1, APA, PAuth, vm_has_ptrauth),\n@@ -169,23 +232,39 @@ static const struct pvm_ftr_bits pvmid_aa64isar1[] = {\n };\n \n static const struct pvm_ftr_bits pvmid_aa64isar2[] = {\n+\tMAX_FEAT(ID_AA64ISAR2_EL1, RPRES, IMP),\n \tMAX_FEAT_FUNC(ID_AA64ISAR2_EL1, GPA3, IMP, vm_has_ptrauth),\n \tMAX_FEAT_FUNC(ID_AA64ISAR2_EL1, APA3, PAuth, vm_has_ptrauth),\n+\tMAX_FEAT(ID_AA64ISAR2_EL1, MOPS, IMP),\n+\tMAX_FEAT(ID_AA64ISAR2_EL1, BC, IMP),\n+\tMAX_FEAT(ID_AA64ISAR2_EL1, CLRBHB, IMP),\n+\tMAX_FEAT(ID_AA64ISAR2_EL1, RPRFM, IMP),\n+\tMAX_FEAT(ID_AA64ISAR2_EL1, CSSC, CMPBR),\n+\tMAX_FEAT(ID_AA64ISAR2_EL1, LUT, LUT6),\n \tMAX_FEAT(ID_AA64ISAR2_EL1, ATS1A, IMP),\n \tFEAT_END\n };\n \n-/*\n- * None of the features in ID_AA64DFR0_EL1 nor ID_AA64MMFR4_EL1 are supported.\n- * However, both have Not-Implemented values that are non-zero. Define them\n- * so they can be used when getting the value of these registers.\n- */\n-#define ID_AA64DFR0_EL1_NONZERO_NI\t\t\t\t\t\\\n-(\t\t\t\t\t\t\t\t\t\\\n-\tSYS_FIELD_PREP_ENUM(ID_AA64DFR0_EL1, DoubleLock, NI)\t|\t\\\n-\tSYS_FIELD_PREP_ENUM(ID_AA64DFR0_EL1, MTPMU, NI)\t\t\t\\\n-)\n+static const struct pvm_ftr_bits pvmid_aa64isar3[] = {\n+\tMAX_FEAT(ID_AA64ISAR3_EL1, FAMINMAX, IMP),\n+\tMAX_FEAT(ID_AA64ISAR3_EL1, LSFE, IMP),\n+\tMAX_FEAT(ID_AA64ISAR3_EL1, LSUI, IMP),\n+\tMAX_FEAT(ID_AA64ISAR3_EL1, FPRCVT, IMP),\n+\tFEAT_END\n+};\n \n+/* DoubleLock and MTPMU are hidden, but their Not-Implemented values are non-zero. */\n+static const struct pvm_ftr_bits pvmid_aa64dfr0[] = {\n+\tMAX_FEAT(ID_AA64DFR0_EL1, DebugVer, V8P8),\n+\tMAX_FEAT_PASSTHRU(ID_AA64DFR0_EL1, BRPs),\n+\tMAX_FEAT_PASSTHRU(ID_AA64DFR0_EL1, WRPs),\n+\tMAX_FEAT_PASSTHRU(ID_AA64DFR0_EL1, CTX_CMPs),\n+\tMAX_FEAT(ID_AA64DFR0_EL1, DoubleLock, NI),\n+\tMAX_FEAT(ID_AA64DFR0_EL1, MTPMU, NI),\n+\tFEAT_END\n+};\n+\n+/* ID_AA64MMFR4_EL1 is hidden, but its Not-Implemented value is non-zero. */\n #define ID_AA64MMFR4_EL1_NONZERO_NI\t\t\t\t\t\\\n \tSYS_FIELD_PREP_ENUM(ID_AA64MMFR4_EL1, E2H0, NI)\n \n@@ -232,20 +311,28 @@ static u64 pvm_calc_id_reg(const struct kvm_vcpu *vcpu, u32 id)\n \t\treturn get_restricted_features(vcpu, id_aa64pfr1_el1_sys_val, pvmid_aa64pfr1);\n \tcase SYS_ID_AA64PFR2_EL1:\n \t\treturn get_restricted_features(vcpu, id_aa64pfr2_el1_sys_val, pvmid_aa64pfr2);\n+\tcase SYS_ID_AA64ZFR0_EL1:\n+\t\treturn get_restricted_features(vcpu, id_aa64zfr0_el1_sys_val, pvmid_aa64zfr0);\n+\tcase SYS_ID_AA64FPFR0_EL1:\n+\t\treturn get_restricted_features(vcpu, id_aa64fpfr0_el1_sys_val, pvmid_aa64fpfr0);\n \tcase SYS_ID_AA64ISAR0_EL1:\n \t\treturn id_aa64isar0_el1_sys_val;\n \tcase SYS_ID_AA64ISAR1_EL1:\n \t\treturn get_restricted_features(vcpu, id_aa64isar1_el1_sys_val, pvmid_aa64isar1);\n \tcase SYS_ID_AA64ISAR2_EL1:\n \t\treturn get_restricted_features(vcpu, id_aa64isar2_el1_sys_val, pvmid_aa64isar2);\n+\tcase SYS_ID_AA64ISAR3_EL1:\n+\t\treturn get_restricted_features(vcpu, id_aa64isar3_el1_sys_val, pvmid_aa64isar3);\n \tcase SYS_ID_AA64MMFR0_EL1:\n \t\treturn get_restricted_features(vcpu, id_aa64mmfr0_el1_sys_val, pvmid_aa64mmfr0);\n \tcase SYS_ID_AA64MMFR1_EL1:\n \t\treturn get_restricted_features(vcpu, id_aa64mmfr1_el1_sys_val, pvmid_aa64mmfr1);\n \tcase SYS_ID_AA64MMFR2_EL1:\n \t\treturn get_restricted_features(vcpu, id_aa64mmfr2_el1_sys_val, pvmid_aa64mmfr2);\n+\tcase SYS_ID_AA64MMFR3_EL1:\n+\t\treturn get_restricted_features(vcpu, id_aa64mmfr3_el1_sys_val, pvmid_aa64mmfr3);\n \tcase SYS_ID_AA64DFR0_EL1:\n-\t\treturn ID_AA64DFR0_EL1_NONZERO_NI;\n+\t\treturn get_restricted_features(vcpu, id_aa64dfr0_el1_sys_val, pvmid_aa64dfr0);\n \tcase SYS_ID_AA64MMFR4_EL1:\n \t\treturn ID_AA64MMFR4_EL1_NONZERO_NI;\n \tdefault:\n@@ -372,6 +459,179 @@ static bool pvm_idst_access(struct kvm_vcpu *vcpu,\n \treturn false;\n }\n \n+static void pvm_set_external_mdscr(struct kvm_vcpu *vcpu, u64 mdscr)\n+{\n+\tvcpu-\u003earch.external_mdscr_el1 = mdscr \u0026 ~(MDSCR_EL1_SS | MDSCR_EL1_MDE | MDSCR_EL1_KDE);\n+}\n+\n+/* KVM_SET_GUEST_DEBUG fails for a protected vCPU, so only the OS Lock makes it HOST_OWNED. */\n+static int pvm_debug_owner(struct kvm_vcpu *vcpu, u64 mdscr)\n+{\n+\tif (kvm_vcpu_os_lock_enabled(vcpu))\n+\t\treturn VCPU_DEBUG_HOST_OWNED;\n+\n+\tif (mdscr \u0026 (MDSCR_EL1_KDE | MDSCR_EL1_MDE))\n+\t\treturn VCPU_DEBUG_GUEST_OWNED;\n+\n+\treturn VCPU_DEBUG_FREE;\n+}\n+\n+/* Trap handlers run after entry has loaded the debug state. */\n+static void pvm_debug_switch_owner(struct kvm_vcpu *vcpu, int new)\n+{\n+\t*ctxt_mdscr_el1(\u0026vcpu-\u003earch.ctxt) = read_sysreg(mdscr_el1);\n+\n+\t__debug_switch_to_host_common(vcpu);\n+\tvcpu-\u003earch.debug_owner = new;\n+\t__debug_switch_to_guest_common(vcpu);\n+\n+\twrite_sysreg(*ctxt_mdscr_el1(\u0026vcpu-\u003earch.ctxt), mdscr_el1);\n+}\n+\n+static void pvm_debug_set_guest_ownership(struct kvm_vcpu *vcpu)\n+{\n+\tif (kvm_debug_regs_in_use(vcpu))\n+\t\treturn;\n+\n+\tpvm_debug_switch_owner(vcpu, VCPU_DEBUG_GUEST_OWNED);\n+}\n+\n+/* Runs before the world switch, which loads the debug state that debug_owner selects. */\n+void kvm_load_pvm_debug(struct kvm_vcpu *vcpu)\n+{\n+\tu64 mdscr = __vcpu_sys_reg(vcpu, MDSCR_EL1);\n+\n+\tvcpu-\u003earch.debug_owner = pvm_debug_owner(vcpu, mdscr);\n+\n+\tif (kvm_host_owns_debug_regs(vcpu))\n+\t\tpvm_set_external_mdscr(vcpu, mdscr);\n+}\n+\n+static bool pvm_trap_dbg_wb_reg(struct kvm_vcpu *vcpu, struct sys_reg_params *p,\n+\t\t\t\tconst struct sys_reg_desc *r)\n+{\n+\tstruct kvm_guest_debug_arch *dbg = \u0026vcpu-\u003earch.vcpu_debug_state;\n+\tu64 *reg;\n+\n+\tswitch (r-\u003eOp2) {\n+\tcase 0b100:\n+\t\treg = \u0026dbg-\u003edbg_bvr[r-\u003eCRm];\n+\t\tbreak;\n+\tcase 0b101:\n+\t\treg = \u0026dbg-\u003edbg_bcr[r-\u003eCRm];\n+\t\tbreak;\n+\tcase 0b110:\n+\t\treg = \u0026dbg-\u003edbg_wvr[r-\u003eCRm];\n+\t\tbreak;\n+\tdefault:\n+\t\treg = \u0026dbg-\u003edbg_wcr[r-\u003eCRm];\n+\t}\n+\n+\tif (p-\u003eis_write)\n+\t\t*reg = p-\u003eregval;\n+\telse\n+\t\tp-\u003eregval = *reg;\n+\n+\t/* Guest-owned registers are live: __debug_switch_to_host() overwrites memory with them. */\n+\tif (p-\u003eis_write \u0026\u0026 kvm_guest_owns_debug_regs(vcpu))\n+\t\t__debug_restore_state(dbg, \u0026vcpu-\u003earch.ctxt);\n+\n+\tpvm_debug_set_guest_ownership(vcpu);\n+\treturn true;\n+}\n+\n+/* Outside HOST_OWNED, use the live register: __sysreg_save_state_nvhe() overwrites memory. */\n+static u64 pvm_read_mdscr(struct kvm_vcpu *vcpu)\n+{\n+\tif (kvm_host_owns_debug_regs(vcpu))\n+\t\treturn __vcpu_sys_reg(vcpu, MDSCR_EL1);\n+\n+\treturn read_sysreg(mdscr_el1);\n+}\n+\n+static bool pvm_trap_mdscr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,\n+\t\t\t   const struct sys_reg_desc *r)\n+{\n+\tif (!p-\u003eis_write) {\n+\t\tp-\u003eregval = pvm_read_mdscr(vcpu);\n+\t} else if (kvm_host_owns_debug_regs(vcpu)) {\n+\t\t__vcpu_assign_sys_reg(vcpu, MDSCR_EL1, p-\u003eregval);\n+\t\tpvm_set_external_mdscr(vcpu, p-\u003eregval);\n+\t\twrite_sysreg(vcpu-\u003earch.external_mdscr_el1, mdscr_el1);\n+\t} else {\n+\t\twrite_sysreg(p-\u003eregval, mdscr_el1);\n+\t}\n+\n+\tpvm_debug_set_guest_ownership(vcpu);\n+\treturn true;\n+}\n+\n+/* __debug_restore_state() loads MDCCINT_EL1 from memory, so keep memory current. */\n+static bool pvm_trap_mdccint(struct kvm_vcpu *vcpu, struct sys_reg_params *p,\n+\t\t\t     const struct sys_reg_desc *r)\n+{\n+\tif (p-\u003eis_write) {\n+\t\t__vcpu_assign_sys_reg(vcpu, MDCCINT_EL1, p-\u003eregval);\n+\t\tif (kvm_debug_regs_in_use(vcpu))\n+\t\t\twrite_sysreg(p-\u003eregval, mdccint_el1);\n+\t} else {\n+\t\tp-\u003eregval = __vcpu_sys_reg(vcpu, MDCCINT_EL1);\n+\t}\n+\n+\tpvm_debug_set_guest_ownership(vcpu);\n+\treturn true;\n+}\n+\n+static bool pvm_trap_oslar(struct kvm_vcpu *vcpu, struct sys_reg_params *p,\n+\t\t\t   const struct sys_reg_desc *r)\n+{\n+\tint new_owner;\n+\tu64 mdscr;\n+\n+\tif (!p-\u003eis_write) {\n+\t\tinject_undef64(vcpu);\n+\t\treturn false;\n+\t}\n+\n+\tmdscr = pvm_read_mdscr(vcpu);\n+\n+\tif (p-\u003eregval \u0026 OSLAR_EL1_OSLK)\n+\t\t__vcpu_rmw_sys_reg(vcpu, OSLSR_EL1, |=, OSLSR_EL1_OSLK);\n+\telse\n+\t\t__vcpu_rmw_sys_reg(vcpu, OSLSR_EL1, \u0026=, ~OSLSR_EL1_OSLK);\n+\n+\tnew_owner = pvm_debug_owner(vcpu, mdscr);\n+\tif (new_owner == VCPU_DEBUG_HOST_OWNED)\n+\t\tpvm_set_external_mdscr(vcpu, mdscr);\n+\n+\tif (new_owner != vcpu-\u003earch.debug_owner)\n+\t\tpvm_debug_switch_owner(vcpu, new_owner);\n+\n+\treturn true;\n+}\n+\n+static bool pvm_trap_oslsr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,\n+\t\t\t   const struct sys_reg_desc *r)\n+{\n+\tif (p-\u003eis_write) {\n+\t\tinject_undef64(vcpu);\n+\t\treturn false;\n+\t}\n+\n+\tp-\u003eregval = __vcpu_sys_reg(vcpu, OSLSR_EL1);\n+\treturn true;\n+}\n+\n+/* As the host's trap_dbgauthstatus_el1(). */\n+static bool pvm_trap_dbgauthstatus(struct kvm_vcpu *vcpu, struct sys_reg_params *p,\n+\t\t\t\t   const struct sys_reg_desc *r)\n+{\n+\tif (!p-\u003eis_write)\n+\t\tp-\u003eregval = read_sysreg(dbgauthstatus_el1);\n+\n+\treturn true;\n+}\n+\n /* Mark the specified system register as an AArch32 feature id register. */\n #define AARCH32(REG) { SYS_DESC(REG), .access = pvm_access_id_aarch32 }\n \n@@ -391,6 +651,12 @@ static bool pvm_idst_access(struct kvm_vcpu *vcpu,\n /* Mark the specified system register as Read-As-Zero/Write-Ignored */\n #define RAZ_WI(REG) { SYS_DESC(REG), .access = pvm_access_raz_wi }\n \n+#define DBG_WB(n)\t\t\t\t\t\t\t\\\n+\t{ SYS_DESC(SYS_DBGBVRn_EL1(n)), .access = pvm_trap_dbg_wb_reg },\t\\\n+\t{ SYS_DESC(SYS_DBGBCRn_EL1(n)), .access = pvm_trap_dbg_wb_reg },\t\\\n+\t{ SYS_DESC(SYS_DBGWVRn_EL1(n)), .access = pvm_trap_dbg_wb_reg },\t\\\n+\t{ SYS_DESC(SYS_DBGWCRn_EL1(n)), .access = pvm_trap_dbg_wb_reg }\n+\n /* Mark the specified system register as not being handled in hyp. */\n #define HOST_HANDLED(REG) { SYS_DESC(REG), .access = NULL }\n \n@@ -404,15 +670,36 @@ static bool pvm_idst_access(struct kvm_vcpu *vcpu,\n static const struct sys_reg_desc pvm_sys_reg_descs[] = {\n \t/* Cache maintenance by set/way operations are restricted. */\n \n-\t/* Debug and Trace Registers are restricted. */\n-\tRAZ_WI(SYS_DBGBVRn_EL1(0)),\n-\tRAZ_WI(SYS_DBGBCRn_EL1(0)),\n-\tRAZ_WI(SYS_DBGWVRn_EL1(0)),\n-\tRAZ_WI(SYS_DBGWCRn_EL1(0)),\n-\tRAZ_WI(SYS_MDSCR_EL1),\n-\tRAZ_WI(SYS_OSLAR_EL1),\n-\tRAZ_WI(SYS_OSLSR_EL1),\n+\t/* Debug registers */\n+\tDBG_WB(0),\n+\tDBG_WB(1),\n+\t{ SYS_DESC(SYS_MDCCINT_EL1), .access = pvm_trap_mdccint },\n+\t{ SYS_DESC(SYS_MDSCR_EL1), .access = pvm_trap_mdscr },\n+\tDBG_WB(2),\n+\tDBG_WB(3),\n+\tDBG_WB(4),\n+\tDBG_WB(5),\n+\tDBG_WB(6),\n+\tDBG_WB(7),\n+\tDBG_WB(8),\n+\tDBG_WB(9),\n+\tDBG_WB(10),\n+\tDBG_WB(11),\n+\tDBG_WB(12),\n+\tDBG_WB(13),\n+\tDBG_WB(14),\n+\tDBG_WB(15),\n+\tRAZ_WI(SYS_MDRAR_EL1),\n+\t{ SYS_DESC(SYS_OSLAR_EL1), .access = pvm_trap_oslar },\n+\t{ SYS_DESC(SYS_OSLSR_EL1), .access = pvm_trap_oslsr },\n \tRAZ_WI(SYS_OSDLR_EL1),\n+\tRAZ_WI(SYS_DBGPRCR_EL1),\n+\tRAZ_WI(SYS_DBGCLAIMSET_EL1),\n+\tRAZ_WI(SYS_DBGCLAIMCLR_EL1),\n+\t{ SYS_DESC(SYS_DBGAUTHSTATUS_EL1), .access = pvm_trap_dbgauthstatus },\n+\tRAZ_WI(SYS_MDCCSR_EL0),\n+\tRAZ_WI(SYS_DBGDTR_EL0),\n+\tRAZ_WI(SYS_DBGDTRTX_EL0),\n \n \t/* Group 1 ID registers */\n \tHOST_HANDLED(SYS_REVIDR_EL1),\n@@ -457,7 +744,7 @@ static const struct sys_reg_desc pvm_sys_reg_descs[] = {\n \tAARCH64(SYS_ID_AA64ZFR0_EL1),\n \tID_UNALLOCATED(4,5),\n \tID_UNALLOCATED(4,6),\n-\tID_UNALLOCATED(4,7),\n+\tAARCH64(SYS_ID_AA64FPFR0_EL1),\n \tAARCH64(SYS_ID_AA64DFR0_EL1),\n \tAARCH64(SYS_ID_AA64DFR1_EL1),\n \tID_UNALLOCATED(5,2),\n@@ -469,7 +756,7 @@ static const struct sys_reg_desc pvm_sys_reg_descs[] = {\n \tAARCH64(SYS_ID_AA64ISAR0_EL1),\n \tAARCH64(SYS_ID_AA64ISAR1_EL1),\n \tAARCH64(SYS_ID_AA64ISAR2_EL1),\n-\tID_UNALLOCATED(6,3),\n+\tAARCH64(SYS_ID_AA64ISAR3_EL1),\n \tID_UNALLOCATED(6,4),\n \tID_UNALLOCATED(6,5),\n \tID_UNALLOCATED(6,6),\n@@ -477,14 +764,12 @@ static const struct sys_reg_desc pvm_sys_reg_descs[] = {\n \tAARCH64(SYS_ID_AA64MMFR0_EL1),\n \tAARCH64(SYS_ID_AA64MMFR1_EL1),\n \tAARCH64(SYS_ID_AA64MMFR2_EL1),\n-\tID_UNALLOCATED(7,3),\n+\tAARCH64(SYS_ID_AA64MMFR3_EL1),\n \tID_UNALLOCATED(7,4),\n \tID_UNALLOCATED(7,5),\n \tID_UNALLOCATED(7,6),\n \tID_UNALLOCATED(7,7),\n \n-\t/* Scalable Vector Registers are restricted. */\n-\n \tHOST_HANDLED(SYS_ICC_PMR_EL1),\n \n \tRAZ_WI(SYS_ERRIDR_EL1),\n@@ -559,22 +844,32 @@ static const struct sys_reg_desc_reset pvm_sys_reg_reset_vals[] = {\n \tRESET_UNKNOWN(TPIDR_EL1),\n \tRESET_ZERO(CNTKCTL_EL1),\n \tRESET_UNKNOWN(PAR_EL1),\n+\tRESET_ZERO(MDCCINT_EL1),\n+\tRESET_VAL(OSLSR_EL1, OSLSR_EL1_OSLM_IMPLEMENTED),\n \tRESET_ZERO(DISR_EL1),\n \tRESET_ZERO(CPACR_EL1),\n \tRESET_VAL(CONTEXTIDR_EL1, 0x00000000dbadc0deULL),\n \tRESET_VAL(SCTLR_EL1, 0x00C50078ULL),\n+\tRESET_ZERO(SCTLR2_EL1),\n \tRESET_ZERO(TCR_EL1),\n+\tRESET_ZERO(TCR2_EL1),\n+\tRESET_UNKNOWN(PIR_EL1),\n+\tRESET_UNKNOWN(PIRE0_EL1),\n+\tRESET_UNKNOWN(POR_EL1),\n+\tRESET_UNKNOWN(POR_EL0),\n \tRESET_UNKNOWN(AFSR0_EL1),\n \tRESET_UNKNOWN(AFSR1_EL1),\n \tRESET_UNKNOWN(ESR_EL1),\n \tRESET_UNKNOWN(MAIR_EL1),\n \tRESET_ZERO(AMAIR_EL1),\n \tRESET_ZERO(MDSCR_EL1),\n+\tRESET_ZERO(ZCR_EL1),\n \tRESET_ZERO(CNTV_CTL_EL0),\n \tRESET_UNKNOWN(TTBR0_EL1),\n \tRESET_UNKNOWN(TTBR1_EL1),\n \tRESET_UNKNOWN(FAR_EL1),\n \tRESET_VAL(VBAR_EL1, 0x1de7ec7edbadc000ULL),\n+\tRESET_ZERO(FPMR),\n };\n \n void kvm_reset_pvm_sys_regs(struct kvm_vcpu *vcpu)\n@@ -586,6 +881,8 @@ void kvm_reset_pvm_sys_regs(struct kvm_vcpu *vcpu)\n \n \t\tr-\u003ereset(vcpu, r);\n \t}\n+\n+\tmemset(\u0026vcpu-\u003earch.vcpu_debug_state, 0, sizeof(vcpu-\u003earch.vcpu_debug_state));\n }\n \n /*\ndiff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c\nindex 10eb7249aa9e88..aaaa1b8634ba41 100644\n--- a/arch/arm64/kvm/reset.c\n+++ b/arch/arm64/kvm/reset.c\n@@ -52,6 +52,8 @@ int __init kvm_arm_init_sve(void)\n \t\tif (WARN_ON(kvm_sve_max_vl \u003e VL_ARCH_MAX))\n \t\t\tkvm_sve_max_vl = VL_ARCH_MAX;\n \n+\t\tkvm_nvhe_sym(kvm_sve_max_vl) = kvm_sve_max_vl;\n+\n \t\t/*\n \t\t * Don't even try to make use of vector lengths that\n \t\t * aren't available on all CPUs, for now:\ndiff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c\nindex 850eba167aad6a..bcec0a7d2b2f5a 100644\n--- a/arch/arm64/kvm/sys_regs.c\n+++ b/arch/arm64/kvm/sys_regs.c\n@@ -5841,22 +5841,7 @@ void kvm_calculate_traps(struct kvm_vcpu *vcpu)\n \tvcpu_set_hcr(vcpu);\n \tvcpu_set_ich_hcr(vcpu);\n \tvcpu_set_hcrx(vcpu);\n-\n-\tif (test_bit(KVM_ARCH_FLAG_FGU_INITIALIZED, \u0026kvm-\u003earch.flags))\n-\t\tgoto out;\n-\n-\tcompute_fgu(kvm, HFGRTR_GROUP);\n-\tcompute_fgu(kvm, HFGITR_GROUP);\n-\tcompute_fgu(kvm, HDFGRTR_GROUP);\n-\tcompute_fgu(kvm, HAFGRTR_GROUP);\n-\tcompute_fgu(kvm, HFGRTR2_GROUP);\n-\tcompute_fgu(kvm, HFGITR2_GROUP);\n-\tcompute_fgu(kvm, HDFGRTR2_GROUP);\n-\tcompute_fgu(kvm, ICH_HFGRTR_GROUP);\n-\tcompute_fgu(kvm, ICH_HFGITR_GROUP);\n-\n-\tset_bit(KVM_ARCH_FLAG_FGU_INITIALIZED, \u0026kvm-\u003earch.flags);\n-out:\n+\tkvm_init_fgu(kvm);\n \tmutex_unlock(\u0026kvm-\u003earch.config_lock);\n }\n \n"
}

2/1 2026/11/12 01:58 agent patch-evaluator
3m Model:
core

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch series modifies documentation and ARM64-specific KVM/pKVM hypervisor code under arch/arm64. Because the target architecture is amd64, all modified executable paths are exclusive to ARM64 and cannot be compiled or executed on amd64.",
  "WorthFuzzing": false
}

Instruction:
You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.

================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.

- REACHABILITY IS THE PRIMARY GATE:
  Fuzzing can only discover bugs in code that can actually execute in standard virtualized
  environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
  If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
  regardless of whether it adds assertions or complex logic.

- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
  Patch authors routinely label changes as "cleanups", "refactorings", or state
  "No functional change intended". Do NOT take these claims at face value.
  Code refactorings that rearrange logic, introduce helper functions, or alter state management
  in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
  If reachable executable code is modified or refactored, it MUST be fuzzed.

- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
  When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
  BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
  Even if the author believes the invariant always holds, fuzzing is essential to verify whether
  an unusual sequence of operations can violate it.

================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:

- Non-kernel and non-executable changes:
  * Modifications to Documentation/, comments, or spelling fixes.
  * User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
    that do not affect the compiled kernel image (vmlinux) or kernel modules.
  * Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
    that do not alter control flow or data structures.
  * Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
  * Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
    ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
  * Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
    physical PCI hot-unplug or manual sysfs driver unbinding.
  * Code paths exclusive to architectures other than the target architecture.

================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
  * Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
    BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
  * Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
  * Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
  * Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).

================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:

- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
  Do NOT list generic, ubiquitous functions called by almost every program in the corpus
  (including, but not limited to: general memory allocators and deallocators, page fault
  and trap handlers, or core synchronization primitives; this is not an exhaustive list).
  Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
  which severely dilutes fuzzing effort away from the actual changes.

- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
  List functions that specifically implement the logic being added or altered, or direct API entrypoints
  for the subsystem feature under review.

- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
  Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
  distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
  If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
  functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).

================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit 6c0529b2ec062261c6ac940f8f6834d3c1ff753f
Author: syz-cluster <triage@syzkaller.com>
Date:   Thu Nov 12 01:58:12 2026 +0000

    syz-cluster: applied patch under review

diff --git a/Documentation/virt/kvm/arm/pkvm.rst b/Documentation/virt/kvm/arm/pkvm.rst
index b75bb8ad6f26dc..c59e598645b1b8 100644
--- a/Documentation/virt/kvm/arm/pkvm.rst
+++ b/Documentation/virt/kvm/arm/pkvm.rst
@@ -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.
@@ -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
 =========
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 97332ffcb1300e..82ba4bb9573f19 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -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);
diff --git a/arch/arm64/include/asm/kvm_hyp.h b/arch/arm64/include/asm/kvm_hyp.h
index b0e42be3d9eef9..09b19f2c3c0908 100644
--- a/arch/arm64/include/asm/kvm_hyp.h
+++ b/arch/arm64/include/asm/kvm_hyp.h
@@ -144,19 +144,25 @@ 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_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);
+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);
+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);
 
 extern unsigned long kvm_nvhe_sym(__icache_flags);
 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);
diff --git a/arch/arm64/include/asm/kvm_pkvm.h b/arch/arm64/include/asm/kvm_pkvm.h
index fd042d2b54624c..5f1b3308b42e13 100644
--- a/arch/arm64/include/asm/kvm_pkvm.h
+++ b/arch/arm64/include/asm/kvm_pkvm.h
@@ -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:
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 157bf4b8120201..6cc65ee4c6f2af 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -2827,13 +2827,18 @@ 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_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);
+	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);
+	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;
 	kvm_nvhe_sym(kvm_arm_vmid_bits) = kvm_arm_vmid_bits;
 
diff --git a/arch/arm64/kvm/config.c b/arch/arm64/kvm/config.c
index adaf26ab93b857..27ee8188fd76db 100644
--- a/arch/arm64/kvm/config.c
+++ b/arch/arm64/kvm/config.c
@@ -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,
@@ -1586,7 +1588,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 +1632,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;
diff --git a/arch/arm64/kvm/hyp/include/nvhe/pkvm.h b/arch/arm64/kvm/hyp/include/nvhe/pkvm.h
index 0261b2bc681f77..993d54ce444089 100644
--- a/arch/arm64/kvm/hyp/include/nvhe/pkvm.h
+++ b/arch/arm64/kvm/hyp/include/nvhe/pkvm.h
@@ -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);
diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Makefile
index 56a7e2c05f73aa..06d7d8618d89f0 100644
--- a/arch/arm64/kvm/hyp/nvhe/Makefile
+++ b/arch/arm64/kvm/hyp/nvhe/Makefile
@@ -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
diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
index 179d7c8277b883..57c3f7a2d4b148 100644
--- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
+++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
@@ -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));
 
@@ -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,
diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c
index fc0475f0877d19..465d963d6ff57b 100644
--- a/arch/arm64/kvm/hyp/nvhe/pkvm.c
+++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c
@@ -30,6 +30,7 @@ unsigned long __icache_flags;
 /* Used by kvm_get_vttbr(). */
 unsigned int kvm_arm_vmid_bits;
 
+unsigned int kvm_sve_max_vl;
 unsigned int kvm_host_sve_max_vl;
 
 /*
@@ -123,8 +124,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;
@@ -202,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;
 }
@@ -476,7 +482,7 @@ static void unpin_host_vcpu(struct kvm_vcpu *host_vcpu)
 		hyp_unpin_shared_mem(host_vcpu, host_vcpu + 1);
 }
 
-static void unpin_host_sve_state(struct pkvm_hyp_vcpu *hyp_vcpu)
+static void teardown_sve_state(struct pkvm_hyp_vcpu *hyp_vcpu)
 {
 	void *sve_state;
 
@@ -484,8 +490,10 @@ static void unpin_host_sve_state(struct pkvm_hyp_vcpu *hyp_vcpu)
 	if (!sve_state)
 		return;
 
-	hyp_unpin_shared_mem(sve_state,
-			     sve_state + vcpu_sve_state_size(&hyp_vcpu->vcpu));
+	if (pkvm_hyp_vcpu_is_protected(hyp_vcpu))
+		hyp_free(sve_state);
+	else
+		hyp_unpin_shared_mem(sve_state, sve_state + vcpu_sve_state_size(&hyp_vcpu->vcpu));
 }
 
 static void unpin_host_vcpus(struct pkvm_hyp_vcpu *hyp_vcpus[],
@@ -500,7 +508,7 @@ static void unpin_host_vcpus(struct pkvm_hyp_vcpu *hyp_vcpus[],
 			continue;
 
 		unpin_host_vcpu(hyp_vcpu->host_vcpu);
-		unpin_host_sve_state(hyp_vcpu);
+		teardown_sve_state(hyp_vcpu);
 	}
 }
 
@@ -543,18 +551,25 @@ static int pkvm_vcpu_init_sve(struct pkvm_hyp_vcpu *hyp_vcpu, struct kvm_vcpu *h
 		return 0;
 	}
 
-	/* Limit guest vector length to the maximum supported by the host. */
-	sve_max_vl = min(READ_ONCE(host_vcpu->arch.sve_max_vl), kvm_host_sve_max_vl);
-	sve_state = kern_hyp_va(READ_ONCE(host_vcpu->arch.sve_state));
-
-	if (!sve_vl_valid(sve_max_vl) || !sve_state)
+	sve_max_vl = READ_ONCE(host_vcpu->arch.sve_max_vl);
+	if (!sve_vl_valid(sve_max_vl) || sve_max_vl > kvm_sve_max_vl)
 		return -EINVAL;
 
 	sve_state_size = sve_state_size_from_vl(sve_max_vl);
 
-	ret = hyp_pin_shared_mem(sve_state, sve_state + sve_state_size);
-	if (ret)
-		return ret;
+	if (pkvm_hyp_vcpu_is_protected(hyp_vcpu)) {
+		sve_state = hyp_alloc(sve_state_size);
+		if (!sve_state)
+			return hyp_alloc_errno();
+	} else {
+		sve_state = kern_hyp_va(READ_ONCE(host_vcpu->arch.sve_state));
+		if (!sve_state)
+			return -EINVAL;
+
+		ret = hyp_pin_shared_mem(sve_state, sve_state + sve_state_size);
+		if (ret)
+			return ret;
+	}
 
 	vcpu->arch.sve_state = sve_state;
 	vcpu->arch.sve_max_vl = sve_max_vl;
@@ -643,7 +658,7 @@ static int init_pkvm_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu,
 done:
 	if (ret) {
 		unpin_host_vcpu(host_vcpu);
-		unpin_host_sve_state(hyp_vcpu);
+		teardown_sve_state(hyp_vcpu);
 	}
 	return ret;
 }
@@ -1015,7 +1030,7 @@ int __pkvm_init_vcpu(pkvm_handle_t handle, struct kvm_vcpu *host_vcpu)
 	ret = register_hyp_vcpu(hyp_vm, hyp_vcpu);
 	if (ret) {
 		unpin_host_vcpu(host_vcpu);
-		unpin_host_sve_state(hyp_vcpu);
+		teardown_sve_state(hyp_vcpu);
 		goto unclaim;
 	}
 	goto unlock;
@@ -1243,8 +1258,12 @@ int pkvm_reset_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu)
 			    PSCI_0_2_AFFINITY_LEVEL_ON) != PSCI_0_2_AFFINITY_LEVEL_ON_PENDING)
 		return -ECANCELED;
 
+	if (vcpu_has_sve(&hyp_vcpu->vcpu))
+		memset(hyp_vcpu->vcpu.arch.sve_state, 0, vcpu_sve_state_size(&hyp_vcpu->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);
diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c
index 89fb9dd351ad5d..0626f4203ba6db 100644
--- a/arch/arm64/kvm/hyp/nvhe/switch.c
+++ b/arch/arm64/kvm/hyp/nvhe/switch.c
@@ -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,
diff --git a/arch/arm64/kvm/hyp/nvhe/sys_regs.c b/arch/arm64/kvm/hyp/nvhe/sys_regs.c
index 32e82653ebf7e7..4ab0ee50eea200 100644
--- a/arch/arm64/kvm/hyp/nvhe/sys_regs.c
+++ b/arch/arm64/kvm/hyp/nvhe/sys_regs.c
@@ -10,6 +10,8 @@
 #include <asm/kvm_mmu.h>
 
 #include <hyp/adjust_pc.h>
+#include <hyp/debug-sr.h>
+#include <hyp/sysreg-sr.h>
 
 #include <nvhe/pkvm.h>
 
@@ -21,13 +23,18 @@
 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;
+u64 id_aa64isar3_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;
 
 struct pvm_ftr_bits {
 	bool		sign;
@@ -55,6 +62,13 @@ struct pvm_ftr_bits {
 #define MAX_FEAT_ENUM(id, fld, max)						\
 	__MAX_FEAT_FUNC(id, fld, max, NULL, false)
 
+#define MAX_FEAT_PASSTHRU(id, fld)						\
+	{									\
+		.shift = id##_##fld##_SHIFT,					\
+		.width = id##_##fld##_WIDTH,					\
+		.max_val = GENMASK(id##_##fld##_WIDTH - 1, 0),			\
+	}
+
 #define FEAT_END {	.width = 0,	}
 
 static bool vm_has_ptrauth(const struct kvm *kvm)
@@ -72,6 +86,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.
  *
@@ -111,6 +130,36 @@ 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
+};
+
+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_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
 };
 
@@ -124,17 +173,21 @@ 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),
+	MAX_FEAT(ID_AA64MMFR1_EL1, ECBHB, IMP),
 	FEAT_END
 };
 
@@ -142,6 +195,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),
@@ -150,6 +205,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),
@@ -169,23 +232,39 @@ 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),
+	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
 };
 
-/*
- * None of the features in ID_AA64DFR0_EL1 nor ID_AA64MMFR4_EL1 are supported.
- * However, both have Not-Implemented values that are non-zero. Define them
- * so they can be used when getting the value of these registers.
- */
-#define ID_AA64DFR0_EL1_NONZERO_NI					\
-(									\
-	SYS_FIELD_PREP_ENUM(ID_AA64DFR0_EL1, DoubleLock, NI)	|	\
-	SYS_FIELD_PREP_ENUM(ID_AA64DFR0_EL1, MTPMU, NI)			\
-)
+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),
+	MAX_FEAT_PASSTHRU(ID_AA64DFR0_EL1, BRPs),
+	MAX_FEAT_PASSTHRU(ID_AA64DFR0_EL1, WRPs),
+	MAX_FEAT_PASSTHRU(ID_AA64DFR0_EL1, CTX_CMPs),
+	MAX_FEAT(ID_AA64DFR0_EL1, DoubleLock, NI),
+	MAX_FEAT(ID_AA64DFR0_EL1, MTPMU, NI),
+	FEAT_END
+};
+
+/* ID_AA64MMFR4_EL1 is hidden, but its Not-Implemented value is non-zero. */
 #define ID_AA64MMFR4_EL1_NONZERO_NI					\
 	SYS_FIELD_PREP_ENUM(ID_AA64MMFR4_EL1, E2H0, NI)
 
@@ -232,20 +311,28 @@ 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_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:
 		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:
 		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 ID_AA64DFR0_EL1_NONZERO_NI;
+		return get_restricted_features(vcpu, id_aa64dfr0_el1_sys_val, pvmid_aa64dfr0);
 	case SYS_ID_AA64MMFR4_EL1:
 		return ID_AA64MMFR4_EL1_NONZERO_NI;
 	default:
@@ -372,6 +459,179 @@ static bool pvm_idst_access(struct kvm_vcpu *vcpu,
 	return false;
 }
 
+static void pvm_set_external_mdscr(struct kvm_vcpu *vcpu, u64 mdscr)
+{
+	vcpu->arch.external_mdscr_el1 = mdscr & ~(MDSCR_EL1_SS | MDSCR_EL1_MDE | MDSCR_EL1_KDE);
+}
+
+/* KVM_SET_GUEST_DEBUG fails for a protected vCPU, so only the OS Lock makes it HOST_OWNED. */
+static int pvm_debug_owner(struct kvm_vcpu *vcpu, u64 mdscr)
+{
+	if (kvm_vcpu_os_lock_enabled(vcpu))
+		return VCPU_DEBUG_HOST_OWNED;
+
+	if (mdscr & (MDSCR_EL1_KDE | MDSCR_EL1_MDE))
+		return VCPU_DEBUG_GUEST_OWNED;
+
+	return VCPU_DEBUG_FREE;
+}
+
+/* Trap handlers run after entry has loaded the debug state. */
+static void pvm_debug_switch_owner(struct kvm_vcpu *vcpu, int new)
+{
+	*ctxt_mdscr_el1(&vcpu->arch.ctxt) = read_sysreg(mdscr_el1);
+
+	__debug_switch_to_host_common(vcpu);
+	vcpu->arch.debug_owner = new;
+	__debug_switch_to_guest_common(vcpu);
+
+	write_sysreg(*ctxt_mdscr_el1(&vcpu->arch.ctxt), mdscr_el1);
+}
+
+static void pvm_debug_set_guest_ownership(struct kvm_vcpu *vcpu)
+{
+	if (kvm_debug_regs_in_use(vcpu))
+		return;
+
+	pvm_debug_switch_owner(vcpu, VCPU_DEBUG_GUEST_OWNED);
+}
+
+/* Runs before the world switch, which loads the debug state that debug_owner selects. */
+void kvm_load_pvm_debug(struct kvm_vcpu *vcpu)
+{
+	u64 mdscr = __vcpu_sys_reg(vcpu, MDSCR_EL1);
+
+	vcpu->arch.debug_owner = pvm_debug_owner(vcpu, mdscr);
+
+	if (kvm_host_owns_debug_regs(vcpu))
+		pvm_set_external_mdscr(vcpu, mdscr);
+}
+
+static bool pvm_trap_dbg_wb_reg(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
+				const struct sys_reg_desc *r)
+{
+	struct kvm_guest_debug_arch *dbg = &vcpu->arch.vcpu_debug_state;
+	u64 *reg;
+
+	switch (r->Op2) {
+	case 0b100:
+		reg = &dbg->dbg_bvr[r->CRm];
+		break;
+	case 0b101:
+		reg = &dbg->dbg_bcr[r->CRm];
+		break;
+	case 0b110:
+		reg = &dbg->dbg_wvr[r->CRm];
+		break;
+	default:
+		reg = &dbg->dbg_wcr[r->CRm];
+	}
+
+	if (p->is_write)
+		*reg = p->regval;
+	else
+		p->regval = *reg;
+
+	/* Guest-owned registers are live: __debug_switch_to_host() overwrites memory with them. */
+	if (p->is_write && kvm_guest_owns_debug_regs(vcpu))
+		__debug_restore_state(dbg, &vcpu->arch.ctxt);
+
+	pvm_debug_set_guest_ownership(vcpu);
+	return true;
+}
+
+/* Outside HOST_OWNED, use the live register: __sysreg_save_state_nvhe() overwrites memory. */
+static u64 pvm_read_mdscr(struct kvm_vcpu *vcpu)
+{
+	if (kvm_host_owns_debug_regs(vcpu))
+		return __vcpu_sys_reg(vcpu, MDSCR_EL1);
+
+	return read_sysreg(mdscr_el1);
+}
+
+static bool pvm_trap_mdscr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
+			   const struct sys_reg_desc *r)
+{
+	if (!p->is_write) {
+		p->regval = pvm_read_mdscr(vcpu);
+	} else if (kvm_host_owns_debug_regs(vcpu)) {
+		__vcpu_assign_sys_reg(vcpu, MDSCR_EL1, p->regval);
+		pvm_set_external_mdscr(vcpu, p->regval);
+		write_sysreg(vcpu->arch.external_mdscr_el1, mdscr_el1);
+	} else {
+		write_sysreg(p->regval, mdscr_el1);
+	}
+
+	pvm_debug_set_guest_ownership(vcpu);
+	return true;
+}
+
+/* __debug_restore_state() loads MDCCINT_EL1 from memory, so keep memory current. */
+static bool pvm_trap_mdccint(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
+			     const struct sys_reg_desc *r)
+{
+	if (p->is_write) {
+		__vcpu_assign_sys_reg(vcpu, MDCCINT_EL1, p->regval);
+		if (kvm_debug_regs_in_use(vcpu))
+			write_sysreg(p->regval, mdccint_el1);
+	} else {
+		p->regval = __vcpu_sys_reg(vcpu, MDCCINT_EL1);
+	}
+
+	pvm_debug_set_guest_ownership(vcpu);
+	return true;
+}
+
+static bool pvm_trap_oslar(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
+			   const struct sys_reg_desc *r)
+{
+	int new_owner;
+	u64 mdscr;
+
+	if (!p->is_write) {
+		inject_undef64(vcpu);
+		return false;
+	}
+
+	mdscr = pvm_read_mdscr(vcpu);
+
+	if (p->regval & OSLAR_EL1_OSLK)
+		__vcpu_rmw_sys_reg(vcpu, OSLSR_EL1, |=, OSLSR_EL1_OSLK);
+	else
+		__vcpu_rmw_sys_reg(vcpu, OSLSR_EL1, &=, ~OSLSR_EL1_OSLK);
+
+	new_owner = pvm_debug_owner(vcpu, mdscr);
+	if (new_owner == VCPU_DEBUG_HOST_OWNED)
+		pvm_set_external_mdscr(vcpu, mdscr);
+
+	if (new_owner != vcpu->arch.debug_owner)
+		pvm_debug_switch_owner(vcpu, new_owner);
+
+	return true;
+}
+
+static bool pvm_trap_oslsr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
+			   const struct sys_reg_desc *r)
+{
+	if (p->is_write) {
+		inject_undef64(vcpu);
+		return false;
+	}
+
+	p->regval = __vcpu_sys_reg(vcpu, OSLSR_EL1);
+	return true;
+}
+
+/* As the host's trap_dbgauthstatus_el1(). */
+static bool pvm_trap_dbgauthstatus(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
+				   const struct sys_reg_desc *r)
+{
+	if (!p->is_write)
+		p->regval = read_sysreg(dbgauthstatus_el1);
+
+	return true;
+}
+
 /* Mark the specified system register as an AArch32 feature id register. */
 #define AARCH32(REG) { SYS_DESC(REG), .access = pvm_access_id_aarch32 }
 
@@ -391,6 +651,12 @@ static bool pvm_idst_access(struct kvm_vcpu *vcpu,
 /* Mark the specified system register as Read-As-Zero/Write-Ignored */
 #define RAZ_WI(REG) { SYS_DESC(REG), .access = pvm_access_raz_wi }
 
+#define DBG_WB(n)							\
+	{ SYS_DESC(SYS_DBGBVRn_EL1(n)), .access = pvm_trap_dbg_wb_reg },	\
+	{ SYS_DESC(SYS_DBGBCRn_EL1(n)), .access = pvm_trap_dbg_wb_reg },	\
+	{ SYS_DESC(SYS_DBGWVRn_EL1(n)), .access = pvm_trap_dbg_wb_reg },	\
+	{ SYS_DESC(SYS_DBGWCRn_EL1(n)), .access = pvm_trap_dbg_wb_reg }
+
 /* Mark the specified system register as not being handled in hyp. */
 #define HOST_HANDLED(REG) { SYS_DESC(REG), .access = NULL }
 
@@ -404,15 +670,36 @@ static bool pvm_idst_access(struct kvm_vcpu *vcpu,
 static const struct sys_reg_desc pvm_sys_reg_descs[] = {
 	/* Cache maintenance by set/way operations are restricted. */
 
-	/* Debug and Trace Registers are restricted. */
-	RAZ_WI(SYS_DBGBVRn_EL1(0)),
-	RAZ_WI(SYS_DBGBCRn_EL1(0)),
-	RAZ_WI(SYS_DBGWVRn_EL1(0)),
-	RAZ_WI(SYS_DBGWCRn_EL1(0)),
-	RAZ_WI(SYS_MDSCR_EL1),
-	RAZ_WI(SYS_OSLAR_EL1),
-	RAZ_WI(SYS_OSLSR_EL1),
+	/* Debug registers */
+	DBG_WB(0),
+	DBG_WB(1),
+	{ SYS_DESC(SYS_MDCCINT_EL1), .access = pvm_trap_mdccint },
+	{ SYS_DESC(SYS_MDSCR_EL1), .access = pvm_trap_mdscr },
+	DBG_WB(2),
+	DBG_WB(3),
+	DBG_WB(4),
+	DBG_WB(5),
+	DBG_WB(6),
+	DBG_WB(7),
+	DBG_WB(8),
+	DBG_WB(9),
+	DBG_WB(10),
+	DBG_WB(11),
+	DBG_WB(12),
+	DBG_WB(13),
+	DBG_WB(14),
+	DBG_WB(15),
+	RAZ_WI(SYS_MDRAR_EL1),
+	{ SYS_DESC(SYS_OSLAR_EL1), .access = pvm_trap_oslar },
+	{ SYS_DESC(SYS_OSLSR_EL1), .access = pvm_trap_oslsr },
 	RAZ_WI(SYS_OSDLR_EL1),
+	RAZ_WI(SYS_DBGPRCR_EL1),
+	RAZ_WI(SYS_DBGCLAIMSET_EL1),
+	RAZ_WI(SYS_DBGCLAIMCLR_EL1),
+	{ SYS_DESC(SYS_DBGAUTHSTATUS_EL1), .access = pvm_trap_dbgauthstatus },
+	RAZ_WI(SYS_MDCCSR_EL0),
+	RAZ_WI(SYS_DBGDTR_EL0),
+	RAZ_WI(SYS_DBGDTRTX_EL0),
 
 	/* Group 1 ID registers */
 	HOST_HANDLED(SYS_REVIDR_EL1),
@@ -457,7 +744,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),
@@ -469,7 +756,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),
@@ -477,14 +764,12 @@ 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),
 	ID_UNALLOCATED(7,7),
 
-	/* Scalable Vector Registers are restricted. */
-
 	HOST_HANDLED(SYS_ICC_PMR_EL1),
 
 	RAZ_WI(SYS_ERRIDR_EL1),
@@ -559,22 +844,32 @@ static const struct sys_reg_desc_reset pvm_sys_reg_reset_vals[] = {
 	RESET_UNKNOWN(TPIDR_EL1),
 	RESET_ZERO(CNTKCTL_EL1),
 	RESET_UNKNOWN(PAR_EL1),
+	RESET_ZERO(MDCCINT_EL1),
+	RESET_VAL(OSLSR_EL1, OSLSR_EL1_OSLM_IMPLEMENTED),
 	RESET_ZERO(DISR_EL1),
 	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),
 	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),
 	RESET_UNKNOWN(FAR_EL1),
 	RESET_VAL(VBAR_EL1, 0x1de7ec7edbadc000ULL),
+	RESET_ZERO(FPMR),
 };
 
 void kvm_reset_pvm_sys_regs(struct kvm_vcpu *vcpu)
@@ -586,6 +881,8 @@ void kvm_reset_pvm_sys_regs(struct kvm_vcpu *vcpu)
 
 		r->reset(vcpu, r);
 	}
+
+	memset(&vcpu->arch.vcpu_debug_state, 0, sizeof(vcpu->arch.vcpu_debug_state));
 }
 
 /*
diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c
index 10eb7249aa9e88..aaaa1b8634ba41 100644
--- a/arch/arm64/kvm/reset.c
+++ b/arch/arm64/kvm/reset.c
@@ -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:
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 850eba167aad6a..bcec0a7d2b2f5a 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -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);
 }
 

3/2 2026/11/12 01:58 llm patch-evaluator
1m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 20258
							output: 17
							thoughts: 421
						

Thoughts:
**Analyzing This Patch Series**

Okay, so the user wants me to take a look at this patch series for syzkaller fuzzing. First thing's first, gotta confirm the target architecture.  "Target architecture: amd64" - got it.  But hold on, let me double-check that... yep, still "Target architecture: amd64."  Important to be sure!

Now, let's see what this patch series actually *touches*. Okay, here's the file list: `Documentation/virt/kvm/arm/pkvm.rst`, a bunch of files under `arch/arm64/include/asm/`, `arch/arm64/kvm/`, and `arch/arm64/kvm/hyp/nvhe/`.  Hmm, almost *everything* is under `arch/arm64/` and the `Documentation` directory. That's immediately interesting.

Alright, now let's go over to Section 2 - Unreachable execution paths. Code paths exclusive to architectures other than the target architecture.

Let's do a double check here:
Target architecture: amd64
Files modified:
`Documentation/virt/kvm/arm/pkvm.rst`
`arch/arm64/...`

I need to be 100% certain there aren't any sneaky changes hiding outside of `arch/arm64/` or the `Documentation` directory.  I'm going to pull up the git diff or `git show` right now to be absolutely sure. Gotta be thorough with this kind of thing, no room for assumptions.



4/2 2026/11/12 01:59 tool grepper
0m Args:
{
  "Expression": "diff --git"
}

Results:
{
  "Output": "Documentation/bpf/drgn.rst=99=For example, to print ``struct bpf_prog_aux`` for BPF program id 53077:\n--\nDocumentation/bpf/drgn.rst-103-    % git diff\nDocumentation/bpf/drgn.rst:104:    diff --git a/tools/bpf_inspect.py b/tools/bpf_inspect.py\nDocumentation/bpf/drgn.rst-105-    index 650e228..aea2357 100755\n--\nDocumentation/dev-tools/checkuapi.rst=54=won't break userspace::\n--\nDocumentation/dev-tools/checkuapi.rst-69-      *  comp2_t is 24-bit with 5-bit base 2 exponent and 20 bit fraction\nDocumentation/dev-tools/checkuapi.rst:70:    diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h\nDocumentation/dev-tools/checkuapi.rst-71-    EOF\n--\nDocumentation/dev-tools/checkuapi.rst=310=Consider this change::\n--\nDocumentation/dev-tools/checkuapi.rst-312-    cat \u003c\u003c 'EOF' | patch -l -p1\nDocumentation/dev-tools/checkuapi.rst:313:    diff --git a/include/uapi/asm-generic/Kbuild b/include/uapi/asm-generic/Kbuild\nDocumentation/dev-tools/checkuapi.rst-314-    index ebb180aac74e..a9c88b0a8b3b 100644\n--\nDocumentation/doc-guide/contributing.rst=84=looked like this::\n--\nDocumentation/doc-guide/contributing.rst-102-\nDocumentation/doc-guide/contributing.rst:103:  diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c\nDocumentation/doc-guide/contributing.rst-104-  index 57f6944d65a6..00c9b80b3d33 100644\n--\nDocumentation/mm/transhuge.rst=73=change::\nDocumentation/mm/transhuge.rst-74-\nDocumentation/mm/transhuge.rst:75:\tdiff --git a/mm/mremap.c b/mm/mremap.c\nDocumentation/mm/transhuge.rst-76-\t--- a/mm/mremap.c\n--\nDocumentation/translations/it_IT/doc-guide/contributing.rst=91=patch risultante era questa::\n--\nDocumentation/translations/it_IT/doc-guide/contributing.rst-109-\nDocumentation/translations/it_IT/doc-guide/contributing.rst:110:  diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c\nDocumentation/translations/it_IT/doc-guide/contributing.rst-111-  index 57f6944d65a6..00c9b80b3d33 100644\n--\nDocumentation/translations/zh_CN/doc-guide/contributing.rst=36=C代码编译器发出的警告常常会被视为误报,从而导致出现了旨在让编译器闭嘴的补丁。\n--\nDocumentation/translations/zh_CN/doc-guide/contributing.rst-86-\nDocumentation/translations/zh_CN/doc-guide/contributing.rst:87:  diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c\nDocumentation/translations/zh_CN/doc-guide/contributing.rst-88-  index 57f6944d65a6..00c9b80b3d33 100644\n--\nscripts/checkpatch.pl=2680=sub process {\n--\nscripts/checkpatch.pl-2853-\t\t    ($line =~ /^rename (?:from|to) \\S+\\s*$/ ||\nscripts/checkpatch.pl:2854:\t\t     $line =~ /^diff --git a\\/[\\w\\/\\.\\_\\-]+ b\\/\\S+\\s*$/))) {\nscripts/checkpatch.pl-2855-\t\t\t$is_patch = 1;\n--\nscripts/checkpatch.pl-2911-\t\t# extract the filename as it passes\nscripts/checkpatch.pl:2912:\t\tif ($line =~ /^diff --git.*?(\\S+)$/) {\nscripts/checkpatch.pl-2913-\t\t\t$realfile = $1;\n--\nscripts/get_maintainer.pl=552=foreach my $file (@ARGV) {\n--\nscripts/get_maintainer.pl-601-\t\tpush(@files, $filename);\nscripts/get_maintainer.pl:602:\t    } elsif (m/^diff --git a\\/(\\S+) b\\/(\\S+)\\s*$/) {\nscripts/get_maintainer.pl-603-\t\tmy $filename1 = $1;\n"
}

5/2 2026/11/12 01:59 llm patch-evaluator
1m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 22331
							output: 87
							thoughts: 1316
						

Thoughts:
**Analysis of the Provided Patch for Fuzzing Eligibility**

Okay, let's break this down. My initial thought was to use `git` directly, either via commands or by reading the commit information, but then I realized we've got the diff right here. No need to go hunting for the git CLI. The prompt contains the complete patch, which makes things simpler.

Now, let's verify. The target architecture is x86_64 (amd64), and the patch touches these files: `Documentation/virt/kvm/arm/pkvm.rst` and code specifically for ARM64 KVM (`arch/arm64/...`). According to the criteria, we only set `WorthFuzzing=false` if the changes fall into certain categories. The relevant section tells us to return false only if the changes are either non-kernel and non-executable (like documentation), or involve unreachable execution paths.

Looking at this, every single modified file is either documentation or ARM64 code. Since the target is amd64, this ARM64 code is never going to be compiled or executed on an amd64 kernel. This means the code is structurally unreachable on the target.

I've got to double-check my work.  We need `WorthFuzzing: false`, and the `EnableConfigs` and `FocusSymbols` lists must be empty, which they are. The reasoning should be concise. Let me formulate that: "The patch only modifies Documentation and KVM code under arch/arm64 (specifically arm64 pKVM/SVE/debug handling). Since the target architecture is amd64, all modified code paths are exclusive to ARM64 and structurally unreachable on amd64." That covers it.

Let's quickly check what `set-results` accepts as parameters. We already know it needs `EnableConfigs: []` (or an empty array), and `FocusSymbols: []` (or an empty array), along with `Reasoning` and `WorthFuzzing: false`. We're good to go there.

One final sanity check, anything shared between architectures? The files are: `Documentation/virt/kvm/arm/pkvm.rst`, `arch/arm64/include/asm/kvm_host.h`, `arch/arm64/include/asm/kvm_hyp.h`, `arch/arm64/include/asm/kvm_pkvm.h`, `arch/arm64/kvm/arm.c`, `arch/arm64/kvm/config.c`, `arch/arm64/kvm/hyp/include/nvhe/pkvm.h`, `arch/arm64/kvm/hyp/nvhe/Makefile`, `arch/arm64/kvm/hyp/nvhe/hyp-main.c`, `arch/arm64/kvm/hyp/nvhe/pkvm.c`, `arch/arm64/kvm/hyp/nvhe/switch.c`, `arch/arm64/kvm/hyp/nvhe/sys_regs.c`, `arch/arm64/kvm/reset.c`, `arch/arm64/kvm/sys_regs.c`.  Nope, none of these will be compiled on the amd64.  So, yes, `WorthFuzzing` is definitively `false`.

Time to call `set-results`.



6/2 2026/11/12 02:01 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "The patch series modifies documentation and ARM64-specific KVM/pKVM hypervisor code under arch/arm64. Because the target architecture is amd64, all modified executable paths are exclusive to ARM64 and cannot be compiled or executed on amd64.",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch series modifies documentation and ARM64-specific KVM/pKVM hypervisor code under arch/arm64. Because the target architecture is amd64, all modified executable paths are exclusive to ARM64 and cannot be compiled or executed on amd64.",
  "WorthFuzzing": false
}

7/1 2026/11/12 02:01 action If
0m Args:
{
  "WorthFuzzing": false
}

Results:
null

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)