diff mbox series

[v3,49/52] xen/mpu: enable device passthrough in MPU system

Message ID 20230626033443.2943270-50-Penny.Zheng@arm.com (mailing list archive)
State New, archived
Headers show
Series xen/arm: Add Armv8-R64 MPU support to Xen - Part#1 | expand

Commit Message

Penny Zheng June 26, 2023, 3:34 a.m. UTC
In order to enable device passthrough in MPU system, we only need to
provide p2m_mmio_direct_dev permission set up.

Signed-off-by: Penny Zheng <penny.zheng@arm.com>
Signed-off-by: Wei Chen <wei.chen@arm.com>
---
v3:
- new commit
---
 xen/arch/arm/mpu/p2m.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/xen/arch/arm/mpu/p2m.c b/xen/arch/arm/mpu/p2m.c
index e21b76813d..a68a06105f 100644
--- a/xen/arch/arm/mpu/p2m.c
+++ b/xen/arch/arm/mpu/p2m.c
@@ -185,11 +185,15 @@  static void p2m_set_permission(pr_t *region, p2m_type_t t)
         region->prbar.reg.ap = AP_RO_ALL;
         break;
 
+    case p2m_mmio_direct_dev:
+        region->prbar.reg.xn = XN_P2M_ENABLED;
+        region->prbar.reg.ap = AP_RW_ALL;
+        break;
+
     case p2m_max_real_type:
         BUG();
         break;
 
-    case p2m_mmio_direct_dev:
     case p2m_mmio_direct_nc:
     case p2m_mmio_direct_c:
     case p2m_iommu_map_ro:
@@ -233,6 +237,11 @@  static inline pr_t region_to_p2m_entry(mfn_t smfn, unsigned long nr_mfn,
         prlar.reg.ai = MT_NORMAL;
         break;
 
+    case p2m_mmio_direct_dev:
+        prbar.reg.sh = LPAE_SH_OUTER;
+        prlar.reg.ai = MT_DEVICE_nGnRE;
+        break;
+
     default:
         panic(XENLOG_G_ERR "p2m: UNIMPLEMENTED p2m type in MPU system\n");
         break;