OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Raymond Mao <raymondmaoca@gmail.com>
To: opensbi@lists.infradead.org
Cc: anup.patel@oss.qualcomm.com, scott@riscstar.com,
	raymond.mao@riscstar.com, robin.randhawa@sifive.com,
	samuel.holland@sifive.com, peter.lin@sifive.com
Subject: [PATCH v3 5/5] [NOT-FOR-UPSTREAM] platform: virt: add QEMU WorldGuard overlay
Date: Fri,  4 Sep 2026 12:29:15 -0400	[thread overview]
Message-ID: <20260904162915.1092353-6-raymondmaoca@gmail.com> (raw)
In-Reply-To: <20260904162915.1092353-1-raymondmaoca@gmail.com>

From: Raymond Mao <raymond.mao@riscstar.com>

Add a QEMU virt device-tree overlay that describes OpenSBI domain
WorldGuard metadata and checker permission policy for the current
test and demo flow.

Signed-off-by: Raymond Mao <raymond.mao@riscstar.com>
---
 .../generic/virt/qemu-virt-wg-overlay.dts     | 198 ++++++++++++++++++
 1 file changed, 198 insertions(+)
 create mode 100644 platform/generic/virt/qemu-virt-wg-overlay.dts

diff --git a/platform/generic/virt/qemu-virt-wg-overlay.dts b/platform/generic/virt/qemu-virt-wg-overlay.dts
new file mode 100644
index 00000000..e629df89
--- /dev/null
+++ b/platform/generic/virt/qemu-virt-wg-overlay.dts
@@ -0,0 +1,198 @@
+// SPDX-License-Identifier: BSD-2-Clause
+/dts-v1/;
+/plugin/;
+
+/*
+ * Test-only overlay for exercising WorldGuard domain metadata and
+ * WorldGuard checker access-controller rules.
+ *
+ * This overlay adds:
+ * 1. OpenSBI domain metadata for domain-local WID policy
+ * 2. access-controllers partition metadata and consumer references
+ *
+ * The base DTB is expected to already provide:
+ * - WorldGuard checker nodes
+ * - /cpus worlds properties
+ * - per-hart worlds properties
+ *
+ * Usage:
+ * Domain hart phandles are filled in after merge because fdtoverlay does not
+ * reliably resolve CPU-node references against QEMU dumpdtb output here.
+ * See below steps for filling the domain hart phandles (assume the dumped dtb
+ * and merged dtb are represented by 'qemu.dtb' and 'qemu-merged.dtb'
+ * respectively):
+ *   cpu0_phandle=$(fdtget -t x qemu.dtb /cpus/cpu@0 phandle)
+ *   cpu1_phandle=$(fdtget -t x qemu.dtb /cpus/cpu@1 phandle)
+ *   fdtput -t x qemu-merged.dtb /chosen/opensbi-domains/domain@0 \
+ *     possible-harts "$cpu0_phandle" "$cpu1_phandle"
+ *   fdtput -t x qemu-merged.dtb /chosen/opensbi-domains/domain@0 \
+ *     boot-hart "$cpu0_phandle"
+ *   fdtput -t x qemu-merged.dtb /chosen/opensbi-domains/domain@1 \
+ *     possible-harts "$cpu1_phandle"
+ *   fdtput -t x qemu-merged.dtb /chosen/opensbi-domains/domain@1 \
+ *     boot-hart "$cpu1_phandle"
+ */
+/ {
+	fragment@0 {
+		target-path = "/chosen";
+		__overlay__ {
+			opensbi,worldguard-sbiunit;
+			opensbi-domains {
+				compatible = "opensbi,domain,config";
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				memregion0: memregion@0 {
+					compatible = "opensbi,domain,memregion";
+					base = <0x00000000 0x80000000>;
+					order = <0x1f>;
+				};
+
+				guest0: domain@0 {
+					compatible = "opensbi,domain,instance";
+					regions = <&memregion0 0x3f>;
+					next-addr = <0x00000000 0x80200000>;
+					next-arg1 = <0x00000000 0x82200000>;
+					next-mode = <0x1>;
+
+					hw-isolation {
+						worldguard {
+							compatible = "sifive,wgchecker2";
+							worldguard,wid = <0>;
+							worldguard,widlist = <0 1 3>;
+						};
+					};
+				};
+
+				guest1: domain@1 {
+					compatible = "opensbi,domain,instance";
+					regions = <&memregion0 0x3f>;
+					next-addr = <0x00000000 0x80200000>;
+					next-mode = <0x1>;
+
+					hw-isolation {
+						worldguard {
+							compatible = "sifive,wgchecker2";
+							worldguard,wid = <1>;
+							worldguard,widlist = <1 3>;
+						};
+					};
+				};
+			};
+		};
+	};
+
+	fragment@1 {
+		target-path = "/cpus/cpu@0";
+		__overlay__ {
+			opensbi-domain = <&guest0>;
+		};
+	};
+
+	fragment@2 {
+		target-path = "/cpus/cpu@1";
+		__overlay__ {
+			opensbi-domain = <&guest0>;
+		};
+	};
+
+	fragment@3 {
+		target-path = "/memory@80000000";
+		__overlay__ {
+			access-controllers =
+				<0x100 0x0>,
+				<0x100 0x1>,
+				<0x100 0x2>;
+		};
+	};
+
+	fragment@4 {
+		target-path = "/flash@20000000";
+		__overlay__ {
+			access-controllers = <0x101 0x0>;
+		};
+	};
+
+	fragment@5 {
+		target-path = "/soc/serial@10000000";
+		__overlay__ {
+			access-controllers = <0x102 0x0>;
+		};
+	};
+
+	fragment@6 {
+		target-path = "/soc/wgchecker@6000000";
+		__overlay__ {
+			compatible = "qemu,wgchecker2", "sifive,wgchecker2";
+			#access-controller-cells = <1>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			phandle = <0x100>;
+			linux,phandle = <0x100>;
+
+			partition@0 {
+				reg = <0>;
+				sifive,wg-region =
+					<0x00000000 0x80000000 0x00000000 0x40000000>;
+				sifive,slot-permissions = <0x00000000 0x000000cf>;
+				sifive,slot-config = <0x0f>;
+			};
+
+			partition@1 {
+				reg = <1>;
+				sifive,wg-region =
+					<0x00000000 0xc0000000 0x00000000 0x01000000>;
+				sifive,slot-permissions = <0x00000000 0x000000cc>;
+				sifive,slot-config = <0x0f>;
+			};
+
+			partition@2 {
+				reg = <2>;
+				sifive,wg-region =
+					<0x00000000 0xc1000000 0x00000000 0x3f000000>;
+				sifive,slot-permissions = <0x00000000 0x000000cf>;
+				sifive,slot-config = <0x0f>;
+			};
+		};
+	};
+
+	fragment@7 {
+		target-path = "/soc/wgchecker@6001000";
+		__overlay__ {
+			compatible = "qemu,wgchecker2", "sifive,wgchecker2";
+			#access-controller-cells = <1>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			phandle = <0x101>;
+			linux,phandle = <0x101>;
+
+			partition@0 {
+				reg = <0>;
+				sifive,wg-region =
+					<0x00000000 0x20000000 0x00000000 0x04000000>;
+				sifive,slot-permissions = <0x00000000 0x000000c3>;
+				sifive,slot-config = <0x0f>;
+			};
+		};
+	};
+
+	fragment@8 {
+		target-path = "/soc/wgchecker@6002000";
+		__overlay__ {
+			compatible = "qemu,wgchecker2", "sifive,wgchecker2";
+			#access-controller-cells = <1>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			phandle = <0x102>;
+			linux,phandle = <0x102>;
+
+			partition@0 {
+				reg = <0>;
+				sifive,wg-region =
+					<0x00000000 0x10000000 0x00000000 0x00001000>;
+				sifive,slot-permissions = <0x00000000 0x000000c0>;
+				sifive,slot-config = <0x0f>;
+			};
+		};
+	};
+};
-- 
2.25.1


-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

      parent reply	other threads:[~2026-09-04 16:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 16:29 [PATCH v3 0/5] Add WorldGuard support with SiFive WG checker Raymond Mao
2026-09-04 16:29 ` [PATCH v3 1/5] lib: utils: fdt: add generic domain and property parsing helpers Raymond Mao
2026-09-04 16:29 ` [PATCH v3 2/5] hart: add WorldGuard CSR IDs and hart extension flags Raymond Mao
2026-09-04 16:29 ` [PATCH v3 3/5] docs: document WorldGuard DT bindings Raymond Mao
2026-09-04 16:29 ` [PATCH v3 4/5] platform: generic: add WorldGuard checker support Raymond Mao
2026-09-04 16:29 ` Raymond Mao [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260904162915.1092353-6-raymondmaoca@gmail.com \
    --to=raymondmaoca@gmail.com \
    --cc=anup.patel@oss.qualcomm.com \
    --cc=opensbi@lists.infradead.org \
    --cc=peter.lin@sifive.com \
    --cc=raymond.mao@riscstar.com \
    --cc=robin.randhawa@sifive.com \
    --cc=samuel.holland@sifive.com \
    --cc=scott@riscstar.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox