[PATCH] virt: acrn: support EPT unmapping for RAM


Li, Fei1
 

On Wed, May 18, 2022 at 04:02:16PM +0300, Yonghua Huang wrote:
acrn_vm_memseg_unmap can't do EPT unmapping for memory
type of ACRN_MEMMAP_RAM, while such kind of unmapping
is required for case that user memory pages are taggeg
with VM_PFNMAP flag.

This patch fixes logic to support EPT unmapping for memory
region with type of ACRN_MEMMAP_RAM.
Hi Yonghua

IMHO, you could only unmap the ACRN_MEMMAP_RAM memory region which
Page-ranges managed without "struct page", just pure PFN (VM_PFNMAP
set in vm_flags).

Thanks.


Signed-off-by: Yonghua Huang <yonghua.huang@...>
---
drivers/virt/acrn/mm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/virt/acrn/mm.c b/drivers/virt/acrn/mm.c
index 3b1b1e7a844b..1d0b15933e1d 100644
--- a/drivers/virt/acrn/mm.c
+++ b/drivers/virt/acrn/mm.c
@@ -131,7 +131,8 @@ int acrn_vm_memseg_unmap(struct acrn_vm *vm, struct acrn_vm_memmap *memmap)
{
int ret;

- if (memmap->type != ACRN_MEMMAP_MMIO) {
+ if ((memmap->type != ACRN_MEMMAP_RAM)
+ && (memmap->type != ACRN_MEMMAP_MMIO)) {
dev_dbg(acrn_dev.this_device,
"Invalid memmap type: %u\n", memmap->type);
return -EINVAL;
--
2.25.1






Yonghua Huang
 

acrn_vm_memseg_unmap can't do EPT unmapping for memory
type of ACRN_MEMMAP_RAM, while such kind of unmapping
is required for case that user memory pages are taggeg
with VM_PFNMAP flag.

This patch fixes logic to support EPT unmapping for memory
region with type of ACRN_MEMMAP_RAM.

Signed-off-by: Yonghua Huang <yonghua.huang@...>
---
drivers/virt/acrn/mm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/virt/acrn/mm.c b/drivers/virt/acrn/mm.c
index 3b1b1e7a844b..1d0b15933e1d 100644
--- a/drivers/virt/acrn/mm.c
+++ b/drivers/virt/acrn/mm.c
@@ -131,7 +131,8 @@ int acrn_vm_memseg_unmap(struct acrn_vm *vm, struct acrn_vm_memmap *memmap)
{
int ret;

- if (memmap->type != ACRN_MEMMAP_MMIO) {
+ if ((memmap->type != ACRN_MEMMAP_RAM)
+ && (memmap->type != ACRN_MEMMAP_MMIO)) {
dev_dbg(acrn_dev.this_device,
"Invalid memmap type: %u\n", memmap->type);
return -EINVAL;
--
2.25.1