Skip to content

Commit 75c8f38

Browse files
committed
Merge tag 'kvmarm-fixes-6.11-2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into for-next/fixes
KVM/arm64 fixes for 6.11, round #2 - Don't drop references on LPIs that weren't visited by the vgic-debug iterator - Cure lock ordering issue when unregistering vgic redistributors - Fix for misaligned stage-2 mappings when VMs are backed by hugetlb pages - Treat SGI registers as UNDEFINED if a VM hasn't been configured for GICv3 * tag 'kvmarm-fixes-6.11-2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm: KVM: arm64: Make ICC_*SGI*_EL1 undef in the absence of a vGICv3 KVM: arm64: Ensure canonical IPA is hugepage-aligned when handling fault KVM: arm64: vgic: Don't hold config_lock while unregistering redistributors KVM: arm64: vgic-debug: Don't put unmarked LPIs KVM: arm64: vgic: Hold config_lock while tearing down a CPU interface KVM: selftests: arm64: Correct feature test for S1PIE in get-reg-list KVM: arm64: Tidying up PAuth code in KVM KVM: arm64: vgic-debug: Exit the iterator properly w/o LPI KVM: arm64: Enforce dependency on an ARMv8.4-aware toolchain docs: KVM: Fix register ID of SPSR_FIQ KVM: arm64: vgic: fix unexpected unlock sparse warnings KVM: arm64: fix kdoc warnings in W=1 builds KVM: arm64: fix override-init warnings in W=1 builds KVM: arm64: free kvm->arch.nested_mmus with kvfree()
2 parents f75c235 + 3e6245e commit 75c8f38

File tree

20 files changed

+75
-41
lines changed

20 files changed

+75
-41
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/mmu.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,8 +1540,15 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
15401540
vma_pagesize = min(vma_pagesize, (long)max_map_size);
15411541
}
15421542

1543-
if (vma_pagesize == PMD_SIZE || vma_pagesize == PUD_SIZE)
1543+
/*
1544+
* Both the canonical IPA and fault IPA must be hugepage-aligned to
1545+
* ensure we find the right PFN and lay down the mapping in the right
1546+
* place.
1547+
*/
1548+
if (vma_pagesize == PMD_SIZE || vma_pagesize == PUD_SIZE) {
15441549
fault_ipa &= ~(vma_pagesize - 1);
1550+
ipa &= ~(vma_pagesize - 1);
1551+
}
15451552

15461553
gfn = ipa >> PAGE_SHIFT;
15471554
mte_allowed = kvm_vma_mte_allowed(vma);

0 commit comments

Comments
 (0)