Skip to content

Commit 8aed168

Browse files
committed
Merge tag 'kvmarm-fixes-6.16-4' of https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
KVM/arm64 fixes for 6.16, take kernel-patches#4 - Gracefully fail initialising pKVM if the interrupt controller isn't GICv3 - Also gracefully fail initialising pKVM if the carveout allocation fails - Fix the computing of the minimum MMIO range required for the host on stage-2 fault - Fix the generation of the GICv3 Maintenance Interrupt in nested mode
2 parents 25e8b1d + 0e02219 commit 8aed168

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

arch/arm64/kvm/arm.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,7 +2129,7 @@ static void cpu_hyp_init(void *discard)
21292129

21302130
static void cpu_hyp_uninit(void *discard)
21312131
{
2132-
if (__this_cpu_read(kvm_hyp_initialized)) {
2132+
if (!is_protected_kvm_enabled() && __this_cpu_read(kvm_hyp_initialized)) {
21332133
cpu_hyp_reset();
21342134
__this_cpu_write(kvm_hyp_initialized, 0);
21352135
}
@@ -2345,15 +2345,23 @@ static void __init teardown_hyp_mode(void)
23452345

23462346
free_hyp_pgds();
23472347
for_each_possible_cpu(cpu) {
2348+
if (per_cpu(kvm_hyp_initialized, cpu))
2349+
continue;
2350+
23482351
free_pages(per_cpu(kvm_arm_hyp_stack_base, cpu), NVHE_STACK_SHIFT - PAGE_SHIFT);
2349-
free_pages(kvm_nvhe_sym(kvm_arm_hyp_percpu_base)[cpu], nvhe_percpu_order());
2352+
2353+
if (!kvm_nvhe_sym(kvm_arm_hyp_percpu_base)[cpu])
2354+
continue;
23502355

23512356
if (free_sve) {
23522357
struct cpu_sve_state *sve_state;
23532358

23542359
sve_state = per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->sve_state;
23552360
free_pages((unsigned long) sve_state, pkvm_host_sve_state_order());
23562361
}
2362+
2363+
free_pages(kvm_nvhe_sym(kvm_arm_hyp_percpu_base)[cpu], nvhe_percpu_order());
2364+
23572365
}
23582366
}
23592367

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ static int host_stage2_adjust_range(u64 addr, struct kvm_mem_range *range)
479479
{
480480
struct kvm_mem_range cur;
481481
kvm_pte_t pte;
482+
u64 granule;
482483
s8 level;
483484
int ret;
484485

@@ -496,18 +497,21 @@ static int host_stage2_adjust_range(u64 addr, struct kvm_mem_range *range)
496497
return -EPERM;
497498
}
498499

499-
do {
500-
u64 granule = kvm_granule_size(level);
500+
for (; level <= KVM_PGTABLE_LAST_LEVEL; level++) {
501+
if (!kvm_level_supports_block_mapping(level))
502+
continue;
503+
granule = kvm_granule_size(level);
501504
cur.start = ALIGN_DOWN(addr, granule);
502505
cur.end = cur.start + granule;
503-
level++;
504-
} while ((level <= KVM_PGTABLE_LAST_LEVEL) &&
505-
!(kvm_level_supports_block_mapping(level) &&
506-
range_included(&cur, range)));
506+
if (!range_included(&cur, range))
507+
continue;
508+
*range = cur;
509+
return 0;
510+
}
507511

508-
*range = cur;
512+
WARN_ON(1);
509513

510-
return 0;
514+
return -EINVAL;
511515
}
512516

513517
int host_stage2_idmap_locked(phys_addr_t addr, u64 size,

arch/arm64/kvm/vgic/vgic-v3-nested.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,7 @@ void vgic_v3_nested_update_mi(struct kvm_vcpu *vcpu)
401401
{
402402
bool level;
403403

404-
level = __vcpu_sys_reg(vcpu, ICH_HCR_EL2) & ICH_HCR_EL2_En;
405-
if (level)
406-
level &= vgic_v3_get_misr(vcpu);
404+
level = (__vcpu_sys_reg(vcpu, ICH_HCR_EL2) & ICH_HCR_EL2_En) && vgic_v3_get_misr(vcpu);
407405
kvm_vgic_inject_irq(vcpu->kvm, vcpu,
408406
vcpu->kvm->arch.vgic.mi_intid, level, vcpu);
409407
}

0 commit comments

Comments
 (0)