Skip to content

Commit ca052cf

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull kvm fixes from Paolo Bonzini: "ARM: - Fix unexpected sign extension of KVM_ARM_DEVICE_ID_MASK - Tidy-up handling of AArch32 on asymmetric systems x86: - Fix 'missing ENDBR' BUG for fastop functions Generic: - Some cleanup and static analyzer patches - More fixes to KVM_CREATE_VM unwind paths" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: KVM: Drop unnecessary initialization of "ops" in kvm_ioctl_create_device() KVM: Drop unnecessary initialization of "npages" in hva_to_pfn_slow() x86/kvm: Fix "missing ENDBR" BUG for fastop functions x86/kvm: Simplify FOP_SETCC() x86/ibt, objtool: Add IBT_NOSEAL() KVM: Rename mmu_notifier_* to mmu_invalidate_* KVM: Rename KVM_PRIVATE_MEM_SLOTS to KVM_INTERNAL_MEM_SLOTS KVM: MIPS: remove unnecessary definition of KVM_PRIVATE_MEM_SLOTS KVM: Move coalesced MMIO initialization (back) into kvm_create_vm() KVM: Unconditionally get a ref to /dev/kvm module when creating a VM KVM: Properly unwind VM creation if creating debugfs fails KVM: arm64: Reject 32bit user PSTATE on asymmetric systems KVM: arm64: Treat PMCR_EL1.LC as RES1 on asymmetric systems KVM: arm64: Fix compile error due to sign extension
2 parents 42c54d5 + 959d6c4 commit ca052cf

File tree

25 files changed

+157
-156
lines changed

25 files changed

+157
-156
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,10 @@ bool kvm_arm_vcpu_is_finalized(struct kvm_vcpu *vcpu);
929929
(system_supports_mte() && \
930930
test_bit(KVM_ARCH_FLAG_MTE_ENABLED, &(kvm)->arch.flags))
931931

932+
#define kvm_supports_32bit_el0() \
933+
(system_supports_32bit_el0() && \
934+
!static_branch_unlikely(&arm64_mismatched_32bit_el0))
935+
932936
int kvm_trng_call(struct kvm_vcpu *vcpu);
933937
#ifdef CONFIG_KVM
934938
extern phys_addr_t hyp_mem_base;

arch/arm64/include/uapi/asm/kvm.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ struct kvm_regs {
7575

7676
/* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */
7777
#define KVM_ARM_DEVICE_TYPE_SHIFT 0
78-
#define KVM_ARM_DEVICE_TYPE_MASK (0xffff << KVM_ARM_DEVICE_TYPE_SHIFT)
78+
#define KVM_ARM_DEVICE_TYPE_MASK GENMASK(KVM_ARM_DEVICE_TYPE_SHIFT + 15, \
79+
KVM_ARM_DEVICE_TYPE_SHIFT)
7980
#define KVM_ARM_DEVICE_ID_SHIFT 16
80-
#define KVM_ARM_DEVICE_ID_MASK (0xffff << KVM_ARM_DEVICE_ID_SHIFT)
81+
#define KVM_ARM_DEVICE_ID_MASK GENMASK(KVM_ARM_DEVICE_ID_SHIFT + 15, \
82+
KVM_ARM_DEVICE_ID_SHIFT)
8183

8284
/* Supported device IDs */
8385
#define KVM_ARM_DEVICE_VGIC_V2 0

arch/arm64/kvm/arm.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,7 @@ static bool vcpu_mode_is_bad_32bit(struct kvm_vcpu *vcpu)
757757
if (likely(!vcpu_mode_is_32bit(vcpu)))
758758
return false;
759759

760-
return !system_supports_32bit_el0() ||
761-
static_branch_unlikely(&arm64_mismatched_32bit_el0);
760+
return !kvm_supports_32bit_el0();
762761
}
763762

764763
/**

arch/arm64/kvm/guest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
242242
u64 mode = (*(u64 *)valp) & PSR_AA32_MODE_MASK;
243243
switch (mode) {
244244
case PSR_AA32_MODE_USR:
245-
if (!system_supports_32bit_el0())
245+
if (!kvm_supports_32bit_el0())
246246
return -EINVAL;
247247
break;
248248
case PSR_AA32_MODE_FIQ:

arch/arm64/kvm/mmu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ transparent_hugepage_adjust(struct kvm *kvm, struct kvm_memory_slot *memslot,
993993
* THP doesn't start to split while we are adjusting the
994994
* refcounts.
995995
*
996-
* We are sure this doesn't happen, because mmu_notifier_retry
996+
* We are sure this doesn't happen, because mmu_invalidate_retry
997997
* was successful and we are holding the mmu_lock, so if this
998998
* THP is trying to split, it will be blocked in the mmu
999999
* notifier before touching any of the pages, specifically
@@ -1188,9 +1188,9 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
11881188
return ret;
11891189
}
11901190

1191-
mmu_seq = vcpu->kvm->mmu_notifier_seq;
1191+
mmu_seq = vcpu->kvm->mmu_invalidate_seq;
11921192
/*
1193-
* Ensure the read of mmu_notifier_seq happens before we call
1193+
* Ensure the read of mmu_invalidate_seq happens before we call
11941194
* gfn_to_pfn_prot (which calls get_user_pages), so that we don't risk
11951195
* the page we just got a reference to gets unmapped before we have a
11961196
* chance to grab the mmu_lock, which ensure that if the page gets
@@ -1246,7 +1246,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
12461246
else
12471247
write_lock(&kvm->mmu_lock);
12481248
pgt = vcpu->arch.hw_mmu->pgt;
1249-
if (mmu_notifier_retry(kvm, mmu_seq))
1249+
if (mmu_invalidate_retry(kvm, mmu_seq))
12501250
goto out_unlock;
12511251

12521252
/*

arch/arm64/kvm/sys_regs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ static void reset_pmcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
652652
*/
653653
val = ((pmcr & ~ARMV8_PMU_PMCR_MASK)
654654
| (ARMV8_PMU_PMCR_MASK & 0xdecafbad)) & (~ARMV8_PMU_PMCR_E);
655-
if (!system_supports_32bit_el0())
655+
if (!kvm_supports_32bit_el0())
656656
val |= ARMV8_PMU_PMCR_LC;
657657
__vcpu_sys_reg(vcpu, r->reg) = val;
658658
}
@@ -701,7 +701,7 @@ static bool access_pmcr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
701701
val = __vcpu_sys_reg(vcpu, PMCR_EL0);
702702
val &= ~ARMV8_PMU_PMCR_MASK;
703703
val |= p->regval & ARMV8_PMU_PMCR_MASK;
704-
if (!system_supports_32bit_el0())
704+
if (!kvm_supports_32bit_el0())
705705
val |= ARMV8_PMU_PMCR_LC;
706706
__vcpu_sys_reg(vcpu, PMCR_EL0) = val;
707707
kvm_pmu_handle_pmcr(vcpu, val);

arch/mips/include/asm/kvm_host.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@
8484

8585

8686
#define KVM_MAX_VCPUS 16
87-
/* memory slots that does not exposed to userspace */
88-
#define KVM_PRIVATE_MEM_SLOTS 0
8987

9088
#define KVM_HALT_POLL_NS_DEFAULT 500000
9189

arch/mips/kvm/mmu.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -615,17 +615,17 @@ static int kvm_mips_map_page(struct kvm_vcpu *vcpu, unsigned long gpa,
615615
* Used to check for invalidations in progress, of the pfn that is
616616
* returned by pfn_to_pfn_prot below.
617617
*/
618-
mmu_seq = kvm->mmu_notifier_seq;
618+
mmu_seq = kvm->mmu_invalidate_seq;
619619
/*
620-
* Ensure the read of mmu_notifier_seq isn't reordered with PTE reads in
621-
* gfn_to_pfn_prot() (which calls get_user_pages()), so that we don't
620+
* Ensure the read of mmu_invalidate_seq isn't reordered with PTE reads
621+
* in gfn_to_pfn_prot() (which calls get_user_pages()), so that we don't
622622
* risk the page we get a reference to getting unmapped before we have a
623-
* chance to grab the mmu_lock without mmu_notifier_retry() noticing.
623+
* chance to grab the mmu_lock without mmu_invalidate_retry() noticing.
624624
*
625625
* This smp_rmb() pairs with the effective smp_wmb() of the combination
626626
* of the pte_unmap_unlock() after the PTE is zapped, and the
627627
* spin_lock() in kvm_mmu_notifier_invalidate_<page|range_end>() before
628-
* mmu_notifier_seq is incremented.
628+
* mmu_invalidate_seq is incremented.
629629
*/
630630
smp_rmb();
631631

@@ -638,7 +638,7 @@ static int kvm_mips_map_page(struct kvm_vcpu *vcpu, unsigned long gpa,
638638

639639
spin_lock(&kvm->mmu_lock);
640640
/* Check if an invalidation has taken place since we got pfn */
641-
if (mmu_notifier_retry(kvm, mmu_seq)) {
641+
if (mmu_invalidate_retry(kvm, mmu_seq)) {
642642
/*
643643
* This can happen when mappings are changed asynchronously, but
644644
* also synchronously if a COW is triggered by

arch/powerpc/include/asm/kvm_book3s_64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ static inline pte_t *find_kvm_host_pte(struct kvm *kvm, unsigned long mmu_seq,
666666
VM_WARN(!spin_is_locked(&kvm->mmu_lock),
667667
"%s called with kvm mmu_lock not held \n", __func__);
668668

669-
if (mmu_notifier_retry(kvm, mmu_seq))
669+
if (mmu_invalidate_retry(kvm, mmu_seq))
670670
return NULL;
671671

672672
pte = __find_linux_pte(kvm->mm->pgd, ea, NULL, hshift);

arch/powerpc/kvm/book3s_64_mmu_host.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte,
9090
unsigned long pfn;
9191

9292
/* used to check for invalidations in progress */
93-
mmu_seq = kvm->mmu_notifier_seq;
93+
mmu_seq = kvm->mmu_invalidate_seq;
9494
smp_rmb();
9595

9696
/* Get host physical address for gpa */
@@ -151,7 +151,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte,
151151
cpte = kvmppc_mmu_hpte_cache_next(vcpu);
152152

153153
spin_lock(&kvm->mmu_lock);
154-
if (!cpte || mmu_notifier_retry(kvm, mmu_seq)) {
154+
if (!cpte || mmu_invalidate_retry(kvm, mmu_seq)) {
155155
r = -EAGAIN;
156156
goto out_unlock;
157157
}

0 commit comments

Comments
 (0)