[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BYAPR11MB354489435A1AE48DB753B2B0F70C9@BYAPR11MB3544.namprd11.prod.outlook.com>
Date: Fri, 11 Mar 2022 06:14:26 +0000
From: "Huang, Yonghua" <yonghua.huang@...el.com>
To: "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"stable@...r.kernel.org" <stable@...r.kernel.org>,
"Chatre, Reinette" <reinette.chatre@...el.com>,
"Wang, Zhi A" <zhi.a.wang@...el.com>,
"Wang, Yu1" <yu1.wang@...el.com>, "Li, Fei1" <fei1.li@...el.com>,
"Huang, Yonghua" <yonghua.huang@...el.com>
Subject: RE: [PATCH] virt: acrn: obtain pa from VMA with PFNMAP flag
Hello Greg,
Can you kindly help review this patch? Thank you😊
-Yonghua
> -----Original Message-----
> From: Huang, Yonghua <yonghua.huang@...el.com>
> Sent: Monday, February 28, 2022 10:22
> To: gregkh@...uxfoundation.org
> Cc: linux-kernel@...r.kernel.org; stable@...r.kernel.org; Chatre, Reinette
> <reinette.chatre@...el.com>; Wang, Zhi A <zhi.a.wang@...el.com>; Wang,
> Yu1 <yu1.wang@...el.com>; Li, Fei1 <fei1.li@...el.com>; Huang, Yonghua
> <yonghua.huang@...el.com>; Li, Fei1 <fei1.li@...el.com>
> Subject: [PATCH] virt: acrn: obtain pa from VMA with PFNMAP flag
>
> acrn_vm_ram_map can't pin the user pages with VM_PFNMAP flag by
> calling get_user_pages_fast(), the PA(physical pages) may be mapped by
> kernel driver and set PFNMAP flag.
>
> This patch fixes logic to setup EPT mapping for PFN mapped RAM region by
> checking the memory attribute before adding EPT mapping for them.
>
> Fixes: 88f537d5e8dd ("virt: acrn: Introduce EPT mapping management")
> Signed-off-by: Yonghua Huang <yonghua.huang@...el.com>
> Signed-off-by: Fei Li <fei1.li@...el.com>
> ---
> drivers/virt/acrn/mm.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/drivers/virt/acrn/mm.c b/drivers/virt/acrn/mm.c index
> c4f2e15c8a2b..3b1b1e7a844b 100644
> --- a/drivers/virt/acrn/mm.c
> +++ b/drivers/virt/acrn/mm.c
> @@ -162,10 +162,34 @@ int acrn_vm_ram_map(struct acrn_vm *vm, struct
> acrn_vm_memmap *memmap)
> void *remap_vaddr;
> int ret, pinned;
> u64 user_vm_pa;
> + unsigned long pfn;
> + struct vm_area_struct *vma;
>
> if (!vm || !memmap)
> return -EINVAL;
>
> + mmap_read_lock(current->mm);
> + vma = vma_lookup(current->mm, memmap->vma_base);
> + if (vma && ((vma->vm_flags & VM_PFNMAP) != 0)) {
> + if ((memmap->vma_base + memmap->len) > vma->vm_end)
> {
> + mmap_read_unlock(current->mm);
> + return -EINVAL;
> + }
> +
> + ret = follow_pfn(vma, memmap->vma_base, &pfn);
> + mmap_read_unlock(current->mm);
> + if (ret < 0) {
> + dev_dbg(acrn_dev.this_device,
> + "Failed to lookup PFN at VMA:%pK.\n", (void
> *)memmap->vma_base);
> + return ret;
> + }
> +
> + return acrn_mm_region_add(vm, memmap->user_vm_pa,
> + PFN_PHYS(pfn), memmap->len,
> + ACRN_MEM_TYPE_WB, memmap->attr);
> + }
> + mmap_read_unlock(current->mm);
> +
> /* Get the page number of the map region */
> nr_pages = memmap->len >> PAGE_SHIFT;
> pages = vzalloc(nr_pages * sizeof(struct page *));
>
> base-commit: 73878e5eb1bd3c9656685ca60bc3a49d17311e0c
> --
> 2.25.1
Powered by blists - more mailing lists