History

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull kvm fixes from Paolo Bonzini: - PAE and PKU bugfixes for x86 - selftests fix for new binutils - MMU notifier fix for arm64 * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: KVM: arm64: Only reschedule if MMU_NOTIFIER_RANGE_BLOCKABLE is not set KVM: Pass MMU notifier range flags to kvm_unmap_hva_range() kvm: x86: Toggling CR4.PKE does not load PDPTEs in PAE mode kvm: x86: Toggling CR4.SMAP does not load PDPTEs in PAE mode KVM: x86: fix access code passed to gva_to_gpa selftests: kvm: Use a shorter encoding to clear RAX

Linus Torvalds committed 6 years ago

Commit b2d9e992 parents 9e574b7 b53313712 files · +36 −18Browse files

Unified · Split

12 files
  1. arch/arm64/include/asm/kvm_host.h +1 −1
  2. arch/arm64/kvm/mmu.c +14 −5
  3. arch/mips/include/asm/kvm_host.h +1 −1
  4. arch/mips/kvm/mmu.c +2 −1
  5. arch/powerpc/include/asm/kvm_host.h +2 −1
  6. arch/powerpc/kvm/book3s.c +2 −1
  7. arch/powerpc/kvm/e500_mmu_host.c +2 −1
  8. arch/x86/include/asm/kvm_host.h +2 −1
  9. arch/x86/kvm/mmu/mmu.c +2 −1
  10. arch/x86/kvm/x86.c +4 −2
  11. tools/testing/selftests/kvm/x86_64/debug_regs.c +2 −2
  12. virt/kvm/kvm_main.c +2 −1
arch/arm64/include/asm/kvm_host.h+1−1
@@ -473,7 +473,7 @@ int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu, · 472 unmodified lines
473473
474474 #define KVM_ARCH_WANT_MMU_NOTIFIER
475475 int kvm_unmap_hva_range(struct kvm *kvm,
476− unsigned long start, unsigned long end);
476+ unsigned long start, unsigned long end, unsigned flags);
477477 int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
478478 int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
479479 int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
arch/arm64/kvm/mmu.c+14−5
@@ -343,7 +343,8 @@ static void unmap_stage2_p4ds(struct kvm_s2_mmu *mmu, pgd_t *pgd, · 342 unmodified lines
343343 * destroying the VM), otherwise another faulting VCPU may come in and mess
344344 * with things behind our backs.
345345 */
346−static void unmap_stage2_range(struct kvm_s2_mmu *mmu, phys_addr_t start, u64 size)
346+static void __unmap_stage2_range(struct kvm_s2_mmu *mmu, phys_addr_t start, u64 size,
347+ bool may_block)
347348 {
348349 struct kvm *kvm = mmu->kvm;
349350 pgd_t *pgd;
@@ -369,11 +370,16 @@ static void unmap_stage2_range(struct kvm_s2_mmu *mmu, phys_addr_t start, u64 si · 19 unmodified lines
369370 * If the range is too large, release the kvm->mmu_lock
370371 * to prevent starvation and lockup detector warnings.
371372 */
372− if (next != end)
373+ if (may_block && next != end)
373374 cond_resched_lock(&kvm->mmu_lock);
374375 } while (pgd++, addr = next, addr != end);
375376 }
376377
378+static void unmap_stage2_range(struct kvm_s2_mmu *mmu, phys_addr_t start, u64 size)
379+{
380+ __unmap_stage2_range(mmu, start, size, true);
381+}
382+
377383 static void stage2_flush_ptes(struct kvm_s2_mmu *mmu, pmd_t *pmd,
378384 phys_addr_t addr, phys_addr_t end)
379385 {
@@ -2208,18 +2214,21 @@ static int handle_hva_to_gpa(struct kvm *kvm, · 1828 unmodified lines
22082214
22092215 static int kvm_unmap_hva_handler(struct kvm *kvm, gpa_t gpa, u64 size, void *data)
22102216 {
2211− unmap_stage2_range(&kvm->arch.mmu, gpa, size);
2217+ unsigned flags = *(unsigned *)data;
2218+ bool may_block = flags & MMU_NOTIFIER_RANGE_BLOCKABLE;
2219+
2220+ __unmap_stage2_range(&kvm->arch.mmu, gpa, size, may_block);
22122221 return 0;
22132222 }
22142223
22152224 int kvm_unmap_hva_range(struct kvm *kvm,
2216− unsigned long start, unsigned long end)
2225+ unsigned long start, unsigned long end, unsigned flags)
22172226 {
22182227 if (!kvm->arch.mmu.pgd)
22192228 return 0;
22202229
22212230 trace_kvm_unmap_hva_range(start, end);
2222− handle_hva_to_gpa(kvm, start, end, &kvm_unmap_hva_handler, NULL);
2231+ handle_hva_to_gpa(kvm, start, end, &kvm_unmap_hva_handler, &flags);
22232232 return 0;
22242233 }
22252234
arch/mips/include/asm/kvm_host.h+1−1
@@ -969,7 +969,7 @@ enum kvm_mips_fault_result kvm_trap_emul_gva_fault(struct kvm_vcpu *vcpu, · 968 unmodified lines
969969
970970 #define KVM_ARCH_WANT_MMU_NOTIFIER
971971 int kvm_unmap_hva_range(struct kvm *kvm,
972− unsigned long start, unsigned long end);
972+ unsigned long start, unsigned long end, unsigned flags);
973973 int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
974974 int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
975975 int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
arch/mips/kvm/mmu.c+2−1
@@ -486,7 +486,8 @@ static int kvm_unmap_hva_handler(struct kvm *kvm, gfn_t gfn, gfn_t gfn_end, · 485 unmodified lines
486486 return 1;
487487 }
488488
489−int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end)
489+int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end,
490+ unsigned flags)
490491 {
491492 handle_hva_to_gpa(kvm, start, end, &kvm_unmap_hva_handler, NULL);
492493
arch/powerpc/include/asm/kvm_host.h+2−1
@@ -58,7 +58,8 @@ · 57 unmodified lines
5858 #define KVM_ARCH_WANT_MMU_NOTIFIER
5959
6060 extern int kvm_unmap_hva_range(struct kvm *kvm,
61− unsigned long start, unsigned long end);
61+ unsigned long start, unsigned long end,
62+ unsigned flags);
6263 extern int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
6364 extern int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
6465 extern int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
arch/powerpc/kvm/book3s.c+2−1
@@ -834,7 +834,8 @@ void kvmppc_core_commit_memory_region(struct kvm *kvm, · 833 unmodified lines
834834 kvm->arch.kvm_ops->commit_memory_region(kvm, mem, old, new, change);
835835 }
836836
837−int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end)
837+int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end,
838+ unsigned flags)
838839 {
839840 return kvm->arch.kvm_ops->unmap_hva_range(kvm, start, end);
840841 }
arch/powerpc/kvm/e500_mmu_host.c+2−1
@@ -734,7 +734,8 @@ static int kvm_unmap_hva(struct kvm *kvm, unsigned long hva) · 733 unmodified lines
734734 return 0;
735735 }
736736
737−int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end)
737+int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end,
738+ unsigned flags)
738739 {
739740 /* kvm_unmap_hva flushes everything anyways */
740741 kvm_unmap_hva(kvm, start);
arch/x86/include/asm/kvm_host.h+2−1
@@ -1596,7 +1596,8 @@ asmlinkage void kvm_spurious_fault(void); · 1595 unmodified lines
15961596 _ASM_EXTABLE(666b, 667b)
15971597
15981598 #define KVM_ARCH_WANT_MMU_NOTIFIER
1599−int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end);
1599+int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end,
1600+ unsigned flags);
16001601 int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
16011602 int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
16021603 int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
arch/x86/kvm/mmu/mmu.c+2−1
@@ -1916,7 +1916,8 @@ static int kvm_handle_hva(struct kvm *kvm, unsigned long hva, · 1915 unmodified lines
19161916 return kvm_handle_hva_range(kvm, hva, hva + 1, data, handler);
19171917 }
19181918
1919−int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end)
1919+int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end,
1920+ unsigned flags)
19201921 {
19211922 return kvm_handle_hva_range(kvm, start, end, 0, kvm_unmap_rmapp);
19221923 }
arch/x86/kvm/x86.c+4−2
@@ -975,7 +975,7 @@ int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) · 974 unmodified lines
975975 {
976976 unsigned long old_cr4 = kvm_read_cr4(vcpu);
977977 unsigned long pdptr_bits = X86_CR4_PGE | X86_CR4_PSE | X86_CR4_PAE |
978− X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_PKE;
978+ X86_CR4_SMEP;
979979
980980 if (kvm_valid_cr4(vcpu, cr4))
981981 return 1;
@@ -10751,9 +10751,11 @@ EXPORT_SYMBOL_GPL(kvm_spec_ctrl_test_value); · 9769 unmodified lines
1075110751 void kvm_fixup_and_inject_pf_error(struct kvm_vcpu *vcpu, gva_t gva, u16 error_code)
1075210752 {
1075310753 struct x86_exception fault;
10754+ u32 access = error_code &
10755+ (PFERR_WRITE_MASK | PFERR_FETCH_MASK | PFERR_USER_MASK);
1075410756
1075510757 if (!(error_code & PFERR_PRESENT_MASK) ||
10756− vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, error_code, &fault) != UNMAPPED_GVA) {
10758+ vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, access, &fault) != UNMAPPED_GVA) {
1075710759 /*
1075810760 * If vcpu->arch.walk_mmu->gva_to_gpa succeeded, the page
1075910761 * tables probably do not match the TLB. Just proceed
tools/testing/selftests/kvm/x86_64/debug_regs.c+2−2
@@ -40,11 +40,11 @@ static void guest_code(void) · 39 unmodified lines
4040
4141 /* Single step test, covers 2 basic instructions and 2 emulated */
4242 asm volatile("ss_start: "
43− "xor %%rax,%%rax\n\t"
43+ "xor %%eax,%%eax\n\t"
4444 "cpuid\n\t"
4545 "movl $0x1a0,%%ecx\n\t"
4646 "rdmsr\n\t"
47− : : : "rax", "ecx");
47+ : : : "eax", "ebx", "ecx", "edx");
4848
4949 /* DR6.BD test */
5050 asm volatile("bd_start: mov %%dr0, %%rax" : : : "rax");
virt/kvm/kvm_main.c+2−1
@@ -482,7 +482,8 @@ static int kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn, · 481 unmodified lines
482482 * count is also read inside the mmu_lock critical section.
483483 */
484484 kvm->mmu_notifier_count++;
485− need_tlb_flush = kvm_unmap_hva_range(kvm, range->start, range->end);
485+ need_tlb_flush = kvm_unmap_hva_range(kvm, range->start, range->end,
486+ range->flags);
486487 need_tlb_flush |= kvm->tlbs_dirty;
487488 /* we've to flush the tlb before the pages can be freed */
488489 if (need_tlb_flush)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t