2019-03-29 14:12:17 +08:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-10-11 02:06:46 +08:00
|
|
|
From: Fei Jiang <fei.jiang@intel.com>
|
|
|
|
Date: Tue, 31 Jul 2018 12:06:29 +0800
|
2019-03-29 14:12:17 +08:00
|
|
|
Subject: [PATCH] drm/i915/gvt: implement gfn_to_mfn with identical 1:1 mapping
|
|
|
|
check
|
2018-10-11 02:06:46 +08:00
|
|
|
|
|
|
|
If hypervisor is implementing identical 1:1 memory mapping for sos kernel,
|
|
|
|
sos gpa equals to hpa, so we don't need call hypercall for gfn_to_mfn.
|
|
|
|
Currently this is a hack solution in function is_identical_mmap, later
|
|
|
|
hypervisor will provide one hypercall to let SOS query such kind of info.
|
|
|
|
|
|
|
|
V2: add error handling, if map_guest_phys fail, still call vhm_gpa2hpa
|
|
|
|
|
|
|
|
Signed-off-by: Fei Jiang <fei.jiang@intel.com>
|
|
|
|
---
|
|
|
|
drivers/gpu/drm/i915/gvt/acrngt.c | 22 +++++++++++++++++++++-
|
|
|
|
1 file changed, 21 insertions(+), 1 deletion(-)
|
|
|
|
|
|
|
|
diff --git a/drivers/gpu/drm/i915/gvt/acrngt.c b/drivers/gpu/drm/i915/gvt/acrngt.c
|
2020-10-27 02:14:06 +08:00
|
|
|
index c6fff10a1679..abde541b76f8 100644
|
2018-10-11 02:06:46 +08:00
|
|
|
--- a/drivers/gpu/drm/i915/gvt/acrngt.c
|
|
|
|
+++ b/drivers/gpu/drm/i915/gvt/acrngt.c
|
|
|
|
@@ -787,13 +787,33 @@ static int acrngt_write_gpa(unsigned long handle, unsigned long gpa,
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
+static bool is_identical_mmap(void)
|
|
|
|
+{
|
|
|
|
+ /* todo: need add hypercall to get such info from hypervisor */
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static unsigned long acrngt_gfn_to_pfn(unsigned long handle, unsigned long gfn)
|
|
|
|
{
|
|
|
|
unsigned long hpa;
|
|
|
|
struct acrngt_hvm_dev *info = (struct acrngt_hvm_dev *)handle;
|
|
|
|
+
|
|
|
|
gvt_dbg_core("convert gfn 0x%lx to pfn\n", gfn);
|
|
|
|
+ if (is_identical_mmap()) {
|
|
|
|
+ void *va = NULL;
|
|
|
|
+
|
|
|
|
+ va = map_guest_phys(info->vm_id, gfn << PAGE_SHIFT,
|
|
|
|
+ 1 << PAGE_SHIFT);
|
|
|
|
+ if (!va) {
|
|
|
|
+ gvt_err("GVT: can not map gfn = 0x%lx!!!\n", gfn);
|
|
|
|
+ hpa = vhm_vm_gpa2hpa(info->vm_id, gfn << PAGE_SHIFT);
|
|
|
|
+ } else {
|
|
|
|
+ hpa = virt_to_phys(va);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ hpa = vhm_vm_gpa2hpa(info->vm_id, gfn << PAGE_SHIFT);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- hpa = vhm_vm_gpa2hpa(info->vm_id, gfn << PAGE_SHIFT);
|
|
|
|
return hpa >> PAGE_SHIFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2019-04-08 18:08:36 +08:00
|
|
|
https://clearlinux.org
|
2018-10-11 02:06:46 +08:00
|
|
|
|