VFIO fix v4.17
- Revert a pfn page mapping optimization identified as introducing a bad page state regression (Alex Williamson) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (GNU/Linux) iQIcBAABAgAGBQJbEsWYAAoJECObm247sIsi1aUP/ROnej4AhAT8CI9/6YMAdejd M5aJVAGjsa3fcmGmm92IVkNsnYk9cm7YlmwvTVuOq8zoN0ZAuZvBkQwyfdqXoI8M ow1GQkv9kjZA+A1vH+A8HW3Liaf7wqPU0Db5nkypOYlaPPNqSAj2VUmbaiBcq+W+ FEshsiIjshRr+YJxKvV1nCRQGlBPMPxMLqqiufVDJE9cSHwwul8lEBHRg1WRcfpN kKTO+RUEDT99B+HE77icq9l6IVQqnlGMXZ5/ODtpFwhIeQRo1eklspHdajJgUUnT ksQzrFXCgOnkFJt9pCoquPF/aXGhbTHZbEBudwobeNPZiI3Rqri1RlDcSaqdjZbT eJUvHt7xSPv0zbqClUOZmqr1QPEym901jA0NrFaoQLjjA1KpjEUIv7/FEKsaE2w8 N2leTwCo04Atkp+gm9XKzZnsrBLaG5vo4pYJrhv6BTBLrJyHQMnLFjYQCzTaBsjM cnFyv9zlkztSqbLYB9cgSQRNQc8pxfckdPrLhVnrsissLF8Ce5XA3oKzjBu+0Z80 PfvEeA//vzmReYTrm+M0i/gA3whvllEkUMWFMMqH93CtygmyxWrJuLDI+EVg1pbK ZnwaPnl9q12dPM3MtIefbqXiHSj5rmvHS966oppY/KSUcyM6iEU5XIOZYjfXkluh W5fYxvPyBE+AvtYwr0wa =Qb4S -----END PGP SIGNATURE----- Merge tag 'vfio-v4.17' of git://github.com/awilliam/linux-vfio Pull VFIO fix from Alex Williamson: "Revert a pfn page mapping optimization identified as introducing a bad page state regression (Alex Williamson)" * tag 'vfio-v4.17' of git://github.com/awilliam/linux-vfio: Revert "vfio/type1: Improve memory pinning process for raw PFN mapping"
This commit is contained in:
commit
7172a69c10
@ -404,6 +404,7 @@ static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr,
|
||||
{
|
||||
unsigned long pfn = 0;
|
||||
long ret, pinned = 0, lock_acct = 0;
|
||||
bool rsvd;
|
||||
dma_addr_t iova = vaddr - dma->vaddr + dma->iova;
|
||||
|
||||
/* This code path is only user initiated */
|
||||
@ -414,23 +415,14 @@ static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (is_invalid_reserved_pfn(*pfn_base)) {
|
||||
struct vm_area_struct *vma;
|
||||
|
||||
down_read(¤t->mm->mmap_sem);
|
||||
vma = find_vma_intersection(current->mm, vaddr, vaddr + 1);
|
||||
pinned = min_t(long, npage, vma_pages(vma));
|
||||
up_read(¤t->mm->mmap_sem);
|
||||
return pinned;
|
||||
}
|
||||
|
||||
pinned++;
|
||||
rsvd = is_invalid_reserved_pfn(*pfn_base);
|
||||
|
||||
/*
|
||||
* Reserved pages aren't counted against the user, externally pinned
|
||||
* pages are already counted against the user.
|
||||
*/
|
||||
if (!vfio_find_vpfn(dma, iova)) {
|
||||
if (!rsvd && !vfio_find_vpfn(dma, iova)) {
|
||||
if (!lock_cap && current->mm->locked_vm + 1 > limit) {
|
||||
put_pfn(*pfn_base, dma->prot);
|
||||
pr_warn("%s: RLIMIT_MEMLOCK (%ld) exceeded\n", __func__,
|
||||
@ -450,12 +442,13 @@ static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr,
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
if (pfn != *pfn_base + pinned) {
|
||||
if (pfn != *pfn_base + pinned ||
|
||||
rsvd != is_invalid_reserved_pfn(pfn)) {
|
||||
put_pfn(pfn, dma->prot);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!vfio_find_vpfn(dma, iova)) {
|
||||
if (!rsvd && !vfio_find_vpfn(dma, iova)) {
|
||||
if (!lock_cap &&
|
||||
current->mm->locked_vm + lock_acct + 1 > limit) {
|
||||
put_pfn(pfn, dma->prot);
|
||||
@ -473,8 +466,10 @@ out:
|
||||
|
||||
unpin_out:
|
||||
if (ret) {
|
||||
for (pfn = *pfn_base ; pinned ; pfn++, pinned--)
|
||||
put_pfn(pfn, dma->prot);
|
||||
if (!rsvd) {
|
||||
for (pfn = *pfn_base ; pinned ; pfn++, pinned--)
|
||||
put_pfn(pfn, dma->prot);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user