linux-stable/arch/arm64/kvm
Quentin Perret 56961c6331 KVM: arm64: Prevent kmemleak from accessing pKVM memory
Commit a7259df767 ("memblock: make memblock_find_in_range method
private") changed the API using which memory is reserved for the pKVM
hypervisor. However, memblock_phys_alloc() differs from the original API in
terms of kmemleak semantics -- the old one didn't report the reserved
regions to kmemleak while the new one does. Unfortunately, when protected
KVM is enabled, all kernel accesses to pKVM-private memory result in a
fatal exception, which can now happen because of kmemleak scans:

$ echo scan > /sys/kernel/debug/kmemleak
[   34.991354] kvm [304]: nVHE hyp BUG at: [<ffff800008fa3750>] __kvm_nvhe_handle_host_mem_abort+0x270/0x290!
[   34.991580] kvm [304]: Hyp Offset: 0xfffe8be807e00000
[   34.991813] Kernel panic - not syncing: HYP panic:
[   34.991813] PS:600003c9 PC:0000f418011a3750 ESR:00000000f2000800
[   34.991813] FAR:ffff000439200000 HPFAR:0000000004792000 PAR:0000000000000000
[   34.991813] VCPU:0000000000000000
[   34.993660] CPU: 0 PID: 304 Comm: bash Not tainted 5.19.0-rc2 #102
[   34.994059] Hardware name: linux,dummy-virt (DT)
[   34.994452] Call trace:
[   34.994641]  dump_backtrace.part.0+0xcc/0xe0
[   34.994932]  show_stack+0x18/0x6c
[   34.995094]  dump_stack_lvl+0x68/0x84
[   34.995276]  dump_stack+0x18/0x34
[   34.995484]  panic+0x16c/0x354
[   34.995673]  __hyp_pgtable_total_pages+0x0/0x60
[   34.995933]  scan_block+0x74/0x12c
[   34.996129]  scan_gray_list+0xd8/0x19c
[   34.996332]  kmemleak_scan+0x2c8/0x580
[   34.996535]  kmemleak_write+0x340/0x4a0
[   34.996744]  full_proxy_write+0x60/0xbc
[   34.996967]  vfs_write+0xc4/0x2b0
[   34.997136]  ksys_write+0x68/0xf4
[   34.997311]  __arm64_sys_write+0x20/0x2c
[   34.997532]  invoke_syscall+0x48/0x114
[   34.997779]  el0_svc_common.constprop.0+0x44/0xec
[   34.998029]  do_el0_svc+0x2c/0xc0
[   34.998205]  el0_svc+0x2c/0x84
[   34.998421]  el0t_64_sync_handler+0xf4/0x100
[   34.998653]  el0t_64_sync+0x18c/0x190
[   34.999252] SMP: stopping secondary CPUs
[   35.000034] Kernel Offset: disabled
[   35.000261] CPU features: 0x800,00007831,00001086
[   35.000642] Memory Limit: none
[   35.001329] ---[ end Kernel panic - not syncing: HYP panic:
[   35.001329] PS:600003c9 PC:0000f418011a3750 ESR:00000000f2000800
[   35.001329] FAR:ffff000439200000 HPFAR:0000000004792000 PAR:0000000000000000
[   35.001329] VCPU:0000000000000000 ]---

Fix this by explicitly excluding the hypervisor's memory pool from
kmemleak like we already do for the hyp BSS.

Cc: Mike Rapoport <rppt@kernel.org>
Fixes: a7259df767 ("memblock: make memblock_find_in_range method private")
Signed-off-by: Quentin Perret <qperret@google.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20220616161135.3997786-1-qperret@google.com
2022-06-17 09:48:38 +01:00
..
hyp KVM: arm64: Remove redundant hyp_assert_lock_held() assertions 2022-06-09 13:24:02 +01:00
vgic KVM: arm64: Replace vgic_v3_uaccess_read_pending with vgic_uaccess_read_pending 2022-06-08 10:16:15 +01:00
.gitignore
Kconfig
Makefile KVM: arm64: pmu: Restore compilation when HW_PERF_EVENTS isn't selected 2022-05-16 13:42:41 +01:00
arch_timer.c KVM: arm64: Warn if accessing timer pending state outside of vcpu context 2022-06-08 10:16:23 +01:00
arm.c KVM: arm64: Prevent kmemleak from accessing pKVM memory 2022-06-17 09:48:38 +01:00
debug.c
fpsimd.c KVM: arm64: Always start with clearing SME flag on load 2022-06-07 14:31:30 +01:00
guest.c KVM: arm64: Setup a framework for hypercall bitmap firmware registers 2022-05-03 21:30:19 +01:00
handle_exit.c S390: 2022-05-26 14:20:14 -07:00
hypercalls.c KVM: arm64: Fix hypercall bitmap writeback when vcpus have already run 2022-05-16 17:40:48 +01:00
inject_fault.c arm64 updates for 5.19: 2022-05-23 21:06:11 -07:00
irq.h
mmio.c KVM: arm64: Generalise VM features into a set of flags 2022-03-18 14:02:33 +00:00
mmu.c Merge branch kvm-arm64/hyp-stack-guard into kvmarm-master/next 2022-05-04 09:42:37 +01:00
pkvm.c
pmu-emul.c Merge branch kvm-arm64/per-vcpu-host-pmu-data into kvmarm-master/next 2022-05-16 17:48:36 +01:00
pmu.c KVM: arm64: Pass pmu events to hyp via vcpu 2022-05-15 11:26:41 +01:00
psci.c Merge branch kvm-arm64/psci-suspend into kvmarm-master/next 2022-05-16 17:48:20 +01:00
pvtime.c
reset.c KVM: arm64: mixed-width check should be skipped for uninitialized vCPUs 2022-04-06 12:29:45 +01:00
sys_regs.c S390: 2022-05-26 14:20:14 -07:00
sys_regs.h KVM: arm64: Hide AArch32 PMU registers when not available 2022-05-03 11:17:41 +01:00
trace.h
trace_arm.h
trace_handle_exit.h
trng.c
va_layout.c
vgic-sys-reg-v3.c
vmid.c KVM: arm64: Fix inconsistent indenting 2022-06-07 15:27:05 +01:00