PPC KVM fix for 5.7

- Fix a regression introduced in the last merge window, which results
   in guests in HPT mode dying randomly.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQEcBAABCAAGBQJeni/pAAoJEJ2a6ncsY3GfTRoIANAQjIZi96AfJcfnrYQ4yUF7
 scxawTiJ9VavvsEJLJ7vsozrJ4xxmvmA0fFWC84uw9+BwPqoLFFvZTjazbGEDVvF
 FGwNBR/k7nfFVMIHS3K9iy9KjvYL3xkL26AgFTDJFq8hmOO9pH0txuk4r7SXb+NX
 bGG0mScAD/Dg/HwAHAS6EP3jT35QtGTK62p8foqVTziTNcmBn9Ywtg0lEzAcq2iY
 Y1BUD4Ov3cggshMI9SqHE8Yyq0XA2Wi6ggcyz/gVzvcbdFQmtg57Tri8nN8661LX
 XKh+VTpYSIxNs5GgjwlNesJzJ9h6CSynJF556qrjQ0XsXcNqvn8fcZdNQ+hnRYw=
 =Y19W
 -----END PGP SIGNATURE-----

Merge tag 'kvm-ppc-fixes-5.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc into kvm-master

PPC KVM fix for 5.7

- Fix a regression introduced in the last merge window, which results
  in guests in HPT mode dying randomly.
This commit is contained in:
Paolo Bonzini 2020-04-21 09:39:55 -04:00
commit 00a6a5ef39
2 changed files with 10 additions and 8 deletions

View File

@ -604,18 +604,19 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
*/ */
local_irq_disable(); local_irq_disable();
ptep = __find_linux_pte(vcpu->arch.pgdir, hva, NULL, &shift); ptep = __find_linux_pte(vcpu->arch.pgdir, hva, NULL, &shift);
pte = __pte(0);
if (ptep)
pte = *ptep;
local_irq_enable();
/* /*
* If the PTE disappeared temporarily due to a THP * If the PTE disappeared temporarily due to a THP
* collapse, just return and let the guest try again. * collapse, just return and let the guest try again.
*/ */
if (!ptep) { if (!pte_present(pte)) {
local_irq_enable();
if (page) if (page)
put_page(page); put_page(page);
return RESUME_GUEST; return RESUME_GUEST;
} }
pte = *ptep;
local_irq_enable();
hpa = pte_pfn(pte) << PAGE_SHIFT; hpa = pte_pfn(pte) << PAGE_SHIFT;
pte_size = PAGE_SIZE; pte_size = PAGE_SIZE;
if (shift) if (shift)

View File

@ -815,18 +815,19 @@ int kvmppc_book3s_instantiate_page(struct kvm_vcpu *vcpu,
*/ */
local_irq_disable(); local_irq_disable();
ptep = __find_linux_pte(vcpu->arch.pgdir, hva, NULL, &shift); ptep = __find_linux_pte(vcpu->arch.pgdir, hva, NULL, &shift);
pte = __pte(0);
if (ptep)
pte = *ptep;
local_irq_enable();
/* /*
* If the PTE disappeared temporarily due to a THP * If the PTE disappeared temporarily due to a THP
* collapse, just return and let the guest try again. * collapse, just return and let the guest try again.
*/ */
if (!ptep) { if (!pte_present(pte)) {
local_irq_enable();
if (page) if (page)
put_page(page); put_page(page);
return RESUME_GUEST; return RESUME_GUEST;
} }
pte = *ptep;
local_irq_enable();
/* If we're logging dirty pages, always map single pages */ /* If we're logging dirty pages, always map single pages */
large_enable = !(memslot->flags & KVM_MEM_LOG_DIRTY_PAGES); large_enable = !(memslot->flags & KVM_MEM_LOG_DIRTY_PAGES);