[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <f5a43fcef278efcf6b2e138644160cf806d5dc51.1607332046.git.yuleixzhang@tencent.com>
Date: Mon, 7 Dec 2020 19:31:26 +0800
From: yulei.kernel@...il.com
To: linux-mm@...ck.org, akpm@...ux-foundation.org,
linux-fsdevel@...r.kernel.org, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, naoya.horiguchi@....com,
viro@...iv.linux.org.uk, pbonzini@...hat.com
Cc: joao.m.martins@...cle.com, rdunlap@...radead.org,
sean.j.christopherson@...el.com, xiaoguangrong.eric@...il.com,
kernellwp@...il.com, lihaiwei.kernel@...il.com,
Yulei Zhang <yuleixzhang@...cent.com>
Subject: [RFC V2 33/37] kvm, x86: enable record_steal_time for dmem
From: Yulei Zhang <yuleixzhang@...cent.com>
Adjust the kvm_map_gfn while using dmemfs to enable
record_steal_time when entering the guest.
Signed-off-by: Yulei Zhang <yuleixzhang@...cent.com>
---
virt/kvm/kvm_main.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 2541a17..500b170 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -51,6 +51,7 @@
#include <linux/io.h>
#include <linux/lockdep.h>
#include <linux/kthread.h>
+#include <linux/dmem.h>
#include <asm/processor.h>
#include <asm/ioctl.h>
@@ -2164,7 +2165,10 @@ static int __kvm_map_gfn(struct kvm_memslots *slots, gfn_t gfn,
hva = kmap(page);
#ifdef CONFIG_HAS_IOMEM
} else if (!atomic) {
- hva = memremap(pfn_to_hpa(pfn), PAGE_SIZE, MEMREMAP_WB);
+ if (is_dmem_pfn(pfn))
+ hva = __va(PFN_PHYS(pfn));
+ else
+ hva = memremap(pfn_to_hpa(pfn), PAGE_SIZE, MEMREMAP_WB);
} else {
return -EINVAL;
#endif
@@ -2214,9 +2218,10 @@ static void __kvm_unmap_gfn(struct kvm_memory_slot *memslot,
kunmap(map->page);
}
#ifdef CONFIG_HAS_IOMEM
- else if (!atomic)
- memunmap(map->hva);
- else
+ else if (!atomic) {
+ if (!is_dmem_pfn(map->pfn))
+ memunmap(map->hva);
+ } else
WARN_ONCE(1, "Unexpected unmapping in atomic context");
#endif
--
1.8.3.1
Powered by blists - more mailing lists