Skip to content

Commit 747cfbf

Browse files
committed
Merge tag 'kvmarm-fixes-6.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
KVM/arm64 fixes for 6.11, round #1 - Use kvfree() for the kvmalloc'd nested MMUs array - Set of fixes to address warnings in W=1 builds - Make KVM depend on assembler support for ARMv8.4 - Fix for vgic-debug interface for VMs without LPIs - Actually check ID_AA64MMFR3_EL1.S1PIE in get-reg-list selftest - Minor code / comment cleanups for configuring PAuth traps - Take kvm->arch.config_lock to prevent destruction / initialization race for a vCPU's CPUIF which may lead to a UAF
2 parents 92b6c2f + 9eb1813 commit 747cfbf

File tree

18 files changed

+42
-36
lines changed

18 files changed

+42
-36
lines changed

Documentation/virt/kvm/api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2592,7 +2592,7 @@ Specifically:
25922592
0x6030 0000 0010 004a SPSR_ABT 64 spsr[KVM_SPSR_ABT]
25932593
0x6030 0000 0010 004c SPSR_UND 64 spsr[KVM_SPSR_UND]
25942594
0x6030 0000 0010 004e SPSR_IRQ 64 spsr[KVM_SPSR_IRQ]
2595-
0x6060 0000 0010 0050 SPSR_FIQ 64 spsr[KVM_SPSR_FIQ]
2595+
0x6030 0000 0010 0050 SPSR_FIQ 64 spsr[KVM_SPSR_FIQ]
25962596
0x6040 0000 0010 0054 V0 128 fp_regs.vregs[0] [1]_
25972597
0x6040 0000 0010 0058 V1 128 fp_regs.vregs[1] [1]_
25982598
...

arch/arm64/include/asm/kvm_ptrauth.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ alternative_else_nop_endif
104104

105105
#define __ptrauth_save_key(ctxt, key) \
106106
do { \
107-
u64 __val; \
107+
u64 __val; \
108108
__val = read_sysreg_s(SYS_ ## key ## KEYLO_EL1); \
109109
ctxt_sys_reg(ctxt, key ## KEYLO_EL1) = __val; \
110110
__val = read_sysreg_s(SYS_ ## key ## KEYHI_EL1); \

arch/arm64/kvm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ if VIRTUALIZATION
1919

2020
menuconfig KVM
2121
bool "Kernel-based Virtual Machine (KVM) support"
22+
depends on AS_HAS_ARMV8_4
2223
select KVM_COMMON
2324
select KVM_GENERIC_HARDWARE_ENABLING
2425
select KVM_GENERIC_MMU_NOTIFIER

arch/arm64/kvm/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ include $(srctree)/virt/kvm/Makefile.kvm
1010
obj-$(CONFIG_KVM) += kvm.o
1111
obj-$(CONFIG_KVM) += hyp/
1212

13+
CFLAGS_sys_regs.o += -Wno-override-init
14+
CFLAGS_handle_exit.o += -Wno-override-init
15+
1316
kvm-y += arm.o mmu.o mmio.o psci.o hypercalls.o pvtime.o \
1417
inject_fault.o va_layout.o handle_exit.o \
1518
guest.o debug.o reset.o sys_regs.o stacktrace.o \

arch/arm64/kvm/arm.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ static int kvm_arm_default_max_vcpus(void)
164164
/**
165165
* kvm_arch_init_vm - initializes a VM data structure
166166
* @kvm: pointer to the KVM struct
167+
* @type: kvm device type
167168
*/
168169
int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
169170
{
@@ -521,10 +522,10 @@ void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu)
521522

522523
static void vcpu_set_pauth_traps(struct kvm_vcpu *vcpu)
523524
{
524-
if (vcpu_has_ptrauth(vcpu)) {
525+
if (vcpu_has_ptrauth(vcpu) && !is_protected_kvm_enabled()) {
525526
/*
526-
* Either we're running running an L2 guest, and the API/APK
527-
* bits come from L1's HCR_EL2, or API/APK are both set.
527+
* Either we're running an L2 guest, and the API/APK bits come
528+
* from L1's HCR_EL2, or API/APK are both set.
528529
*/
529530
if (unlikely(vcpu_has_nv(vcpu) && !is_hyp_ctxt(vcpu))) {
530531
u64 val;
@@ -541,16 +542,10 @@ static void vcpu_set_pauth_traps(struct kvm_vcpu *vcpu)
541542
* Save the host keys if there is any chance for the guest
542543
* to use pauth, as the entry code will reload the guest
543544
* keys in that case.
544-
* Protected mode is the exception to that rule, as the
545-
* entry into the EL2 code eagerly switch back and forth
546-
* between host and hyp keys (and kvm_hyp_ctxt is out of
547-
* reach anyway).
548545
*/
549-
if (is_protected_kvm_enabled())
550-
return;
551-
552546
if (vcpu->arch.hcr_el2 & (HCR_API | HCR_APK)) {
553547
struct kvm_cpu_context *ctxt;
548+
554549
ctxt = this_cpu_ptr_hyp_sym(kvm_hyp_ctxt);
555550
ptrauth_save_keys(ctxt);
556551
}

arch/arm64/kvm/hyp/include/hyp/switch.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <asm/kvm_hyp.h>
2828
#include <asm/kvm_mmu.h>
2929
#include <asm/kvm_nested.h>
30-
#include <asm/kvm_ptrauth.h>
3130
#include <asm/fpsimd.h>
3231
#include <asm/debug-monitors.h>
3332
#include <asm/processor.h>

arch/arm64/kvm/hyp/nvhe/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ HOST_EXTRACFLAGS += -I$(objtree)/include
2020
lib-objs := clear_page.o copy_page.o memcpy.o memset.o
2121
lib-objs := $(addprefix ../../../lib/, $(lib-objs))
2222

23+
CFLAGS_switch.nvhe.o += -Wno-override-init
24+
2325
hyp-obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o hyp-init.o host.o \
2426
hyp-main.o hyp-smp.o psci-relay.o early_alloc.o page_alloc.o \
2527
cache.o setup.o mm.o mem_protect.o sys_regs.o pkvm.o stacktrace.o ffa.o

arch/arm64/kvm/hyp/nvhe/switch.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,8 @@ static void __pmu_switch_to_host(struct kvm_vcpu *vcpu)
173173
static bool kvm_handle_pvm_sys64(struct kvm_vcpu *vcpu, u64 *exit_code)
174174
{
175175
/*
176-
* Make sure we handle the exit for workarounds and ptrauth
177-
* before the pKVM handling, as the latter could decide to
178-
* UNDEF.
176+
* Make sure we handle the exit for workarounds before the pKVM
177+
* handling, as the latter could decide to UNDEF.
179178
*/
180179
return (kvm_hyp_handle_sysreg(vcpu, exit_code) ||
181180
kvm_handle_pvm_sysreg(vcpu, exit_code));

arch/arm64/kvm/hyp/vhe/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
asflags-y := -D__KVM_VHE_HYPERVISOR__
77
ccflags-y := -D__KVM_VHE_HYPERVISOR__
88

9+
CFLAGS_switch.o += -Wno-override-init
10+
911
obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o
1012
obj-y += ../vgic-v3-sr.o ../aarch32.o ../vgic-v2-cpuif-proxy.o ../entry.o \
1113
../fpsimd.o ../hyp-entry.o ../exception.o

arch/arm64/kvm/nested.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ void kvm_arch_flush_shadow_all(struct kvm *kvm)
786786
if (!WARN_ON(atomic_read(&mmu->refcnt)))
787787
kvm_free_stage2_pgd(mmu);
788788
}
789-
kfree(kvm->arch.nested_mmus);
789+
kvfree(kvm->arch.nested_mmus);
790790
kvm->arch.nested_mmus = NULL;
791791
kvm->arch.nested_mmus_size = 0;
792792
kvm_uninit_stage2_mmu(kvm);

0 commit comments

Comments
 (0)