[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230609085214.31071-8-yi-de.wu@mediatek.com>
Date: Fri, 9 Jun 2023 16:52:12 +0800
From: Yi-De Wu <yi-de.wu@...iatek.com>
To: Yingshiuan Pan <yingshiuan.pan@...iatek.com>,
Ze-Yu Wang <ze-yu.wang@...iatek.com>,
Yi-De Wu <yi-de.wu@...iatek.com>,
Jonathan Corbet <corbet@....net>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>, Arnd Bergmann <arnd@...db.de>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>
CC: <linux-doc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-arch@...r.kernel.org>, <linux-mediatek@...ts.infradead.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Rob Herring <robh+dt@...nel.org>,
Conor Dooley <conor.dooley@...rochip.com>,
Conor Dooley <conor+dt@...nel.org>,
Trilok Soni <quic_tsoni@...cinc.com>,
David Bradil <dbrazdil@...gle.com>,
Jade Shih <jades.shih@...iatek.com>,
Miles Chen <miles.chen@...iatek.com>,
Ivan Tseng <ivan.tseng@...iatek.com>,
My Chuang <my.chuang@...iatek.com>,
Shawn Hsiao <shawn.hsiao@...iatek.com>,
PeiLun Suei <peilun.suei@...iatek.com>,
Liju Chen <liju-clr.chen@...iatek.com>,
Willix Yeh <chi-shen.yeh@...iatek.com>
Subject: [PATCH v4 7/9] virt: geniezone: Add memory region support
From: "Jerry Wang" <ze-yu.wang@...iatek.com>
Hypervisor might need to know the precise purpose of each memory
region, so that it can provide specific memory protection. We add a new
uapi to pass address and size of a memory region and its purpose.
Signed-off-by: Jerry Wang <ze-yu.wang@...iatek.com>
Signed-off-by: Liju-clr Chen <liju-clr.chen@...iatek.com>
Signed-off-by: Yi-De Wu <yi-de.wu@...iatek.com>
---
arch/arm64/geniezone/gzvm_arch_common.h | 2 ++
arch/arm64/geniezone/vm.c | 9 +++++++++
drivers/virt/geniezone/gzvm_vm.c | 1 +
include/linux/gzvm_drv.h | 2 ++
4 files changed, 14 insertions(+)
diff --git a/arch/arm64/geniezone/gzvm_arch_common.h b/arch/arm64/geniezone/gzvm_arch_common.h
index 5affa28b935a..5cfeb4df84c5 100644
--- a/arch/arm64/geniezone/gzvm_arch_common.h
+++ b/arch/arm64/geniezone/gzvm_arch_common.h
@@ -23,6 +23,7 @@ enum {
GZVM_FUNC_CREATE_DEVICE,
GZVM_FUNC_PROBE,
GZVM_FUNC_ENABLE_CAP,
+ GZVM_FUNC_MEMREGION_PURPOSE,
NR_GZVM_FUNC
};
@@ -46,6 +47,7 @@ enum {
#define MT_HVC_GZVM_CREATE_DEVICE GZVM_HCALL_ID(GZVM_FUNC_CREATE_DEVICE)
#define MT_HVC_GZVM_PROBE GZVM_HCALL_ID(GZVM_FUNC_PROBE)
#define MT_HVC_GZVM_ENABLE_CAP GZVM_HCALL_ID(GZVM_FUNC_ENABLE_CAP)
+#define MT_HVC_GZVM_MEMREGION_PURPOSE GZVM_HCALL_ID(GZVM_FUNC_MEMREGION_PURPOSE)
#define GIC_V3_NR_LRS 16
/**
diff --git a/arch/arm64/geniezone/vm.c b/arch/arm64/geniezone/vm.c
index 9f1f14f71b99..e19a66d6a75d 100644
--- a/arch/arm64/geniezone/vm.c
+++ b/arch/arm64/geniezone/vm.c
@@ -97,6 +97,15 @@ int gzvm_arch_destroy_vm(gzvm_id_t vm_id)
0, 0, &res);
}
+int gzvm_arch_memregion_purpose(struct gzvm *gzvm, struct gzvm_userspace_memory_region *mem)
+{
+ struct arm_smccc_res res;
+
+ return gzvm_hypcall_wrapper(MT_HVC_GZVM_MEMREGION_PURPOSE, gzvm->vm_id,
+ mem->guest_phys_addr, mem->memory_size,
+ mem->flags, 0, 0, 0, &res);
+}
+
static int gzvm_vm_arch_enable_cap(struct gzvm *gzvm, struct gzvm_enable_cap *cap,
struct arm_smccc_res *res)
{
diff --git a/drivers/virt/geniezone/gzvm_vm.c b/drivers/virt/geniezone/gzvm_vm.c
index ba5412acfa7d..3b1cb715ef34 100644
--- a/drivers/virt/geniezone/gzvm_vm.c
+++ b/drivers/virt/geniezone/gzvm_vm.c
@@ -248,6 +248,7 @@ gzvm_vm_ioctl_set_memory_region(struct gzvm *gzvm,
memslot->vma = vma;
memslot->flags = mem->flags;
memslot->slot_id = mem->slot;
+ gzvm_arch_memregion_purpose(gzvm, mem);
return register_memslot_addr_range(gzvm, memslot);
}
diff --git a/include/linux/gzvm_drv.h b/include/linux/gzvm_drv.h
index f0a172fb0dd8..288a339bf382 100644
--- a/include/linux/gzvm_drv.h
+++ b/include/linux/gzvm_drv.h
@@ -145,6 +145,8 @@ void gzvm_sync_hwstate(struct gzvm_vcpu *vcpu);
extern struct miscdevice *gzvm_debug_dev;
+int gzvm_arch_memregion_purpose(struct gzvm *gzvm, struct gzvm_userspace_memory_region *mem);
+
int gzvm_init_ioeventfd(struct gzvm *gzvm);
int gzvm_ioeventfd(struct gzvm *gzvm, struct gzvm_ioeventfd *args);
bool gzvm_ioevent_write(struct gzvm_vcpu *vcpu, __u64 addr, int len,
--
2.18.0
Powered by blists - more mailing lists