Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4183B606A322 for ; Wed, 2 Dec 2026 03:40:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=EE+liz+O; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=i7QVZQ4h; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=Chosl1w1 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=SwhMPspZlH8/q7T7As2Y4PzLjSJ491AX0r6u+iaiMqo=; b=EE+liz+O1ZOHOQkG5e5VkOwqxz Vn4XHC6TaahggGHY9msCOHC5E18AwGgJSvgVlqzCwzxrLSKszLAMWDAY4xPY7q1g+EuPzAsMrcXGR sJaGnSYhlW4mzSsa/h0xyD2zCa/Iy8X6o7fWBRDek+sFjsdRcF/mX82DPmctLW5UJNvL34OnUGCMu 9o6CrCXmmeS3LklrJJbitQKuzzU2SPWhSCm28M2ho14bjvKJoJ2AFbxgE5ZvUmAWBqq7AnM5wOXoy zmijNPn1sT9xXCIwJCZrZWcLKVvh3OXEEozPemTcXWDyhJyDOosSiZFUxYNLvBLQ1pKVt3x5BFnJI EVsZ8SjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYbD1-0000000A7QG-0ANa; Wed, 02 Dec 2026 03:40:43 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYbCz-0000000A7Q1-0glH for opensbi@bombadil.infradead.org; Wed, 02 Dec 2026 03:40:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=gjIEvLUNtMNpcog8D+/Pa1qxFZOy6E5HPwQP52P+jsU=; b=i7QVZQ4hIIvDpIsDor+KdtlUX9 cJemeYahsCB24qDl9o32qx48gjyHDyO1ItII95d3bn5z8PIGO4dR3Myz6astp4c0iC8JbkJHbK6nw 3ZPsaYBIFnxqfElmfj1bmvsJWRT418kEgIm3zp1DrJ4SXC7yaxy3mpCvBoWkWVJMkK9H23+csaOOc szOmgFy9rZ0z/boQVqr4a3AXsXiHCLm+hvWonwNZrKjOExZ0ti8YKj+EDQJ+G9KRiW8S8EuRlkwir kx3Kc9w9Pe79aI57q6J89x9W+ENnaVeEbYkwLGYmLTh+JnUOX1HuuRXWWmr8gqSrVwV7+/ooFKxbS MSuVZl0w==; Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by desiato.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYbCu-0000000BlK7-2nLR for opensbi@lists.infradead.org; Wed, 02 Dec 2026 03:40:39 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-2f04e3bf46dso93891365ad.2 for ; Tue, 01 Dec 2026 19:40:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1796182833; x=1796787633; darn=lists.infradead.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=gjIEvLUNtMNpcog8D+/Pa1qxFZOy6E5HPwQP52P+jsU=; b=Chosl1w1KtsPHGwL/jhiI/1JzLCnBUkcj8QOk6GBpY5B3WUEOjiC2nJ9vec4ycLYzX UaQg99KXr76pFpa7vSZFgQn5BTBPdWOUEyAbfSkDxIuE+td8kYtpUaVYIrvbBLjs23y1 EeUv9YdFbnjSU4Y2RVfgOx4ck962LgRKfqObQssbu+hrQchQocjbZVajfYwFZiSjTIVo IroZKphg+PNQQQQfet+FFOYeaRvgLXom/E9VQj3FlVCrWPaNl7r6hIkqnDFmnMYGLvM/ sueyCIHSTL7rMP5Veni5yTKCdI4FNuUnBz+H8e0jbKSy+M4JHec8QBbaeU1MrWje8epl NyGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796182833; x=1796787633; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=gjIEvLUNtMNpcog8D+/Pa1qxFZOy6E5HPwQP52P+jsU=; b=SXDDJW7XEwYSyjgVFs9l7XiWaGDU1emqQJNwAOsJxnpWWJcUiKWchEtd5YZvJm3Ctp X0PpH/mrpMhrTFAuMJRe/CliL7SfRCtLxAIM5pKCFIJyllbNZ05WHQbC5MYu8riUR6JH dGPq+Ck0T0NkfeOmZ1QilHzeafFajfEkwh4FXnz5x8bfoM2td+j75FcfgkrkK+TkhXZw fE1lquWyQHvqZhHGDX2TjOz+Oxi8tqXmEaTr97ULNstFthxQ7MF+Q0ZCcZZNs1sMgF5u n1yTOaQ0y3xmh3w66mrEU/0eMbMRo1N2lJ51qhQFEMq1tGk9PYWOKlbo9LyXkn2DnIho bUWQ== X-Gm-Message-State: APuU4Z/4rb71ugAwW573fBTT8j/CTO4ajxoSol3fGEzYjI2wR5TFT8Wz tT29XN13cghvCOF7bX18qBVou69sNEQRusRYQutowpNshZBjCoeC9KStfPLKRywoFRo= X-Gm-Gg: AZFdTZfvAcZlCrjwkFOMhfledYMYfNpmuucUiDmwaSON7NGcgB20hqrk+C+mxbxLq5c fo8dEgvJRmVyw5FmllyTeav5kB1KrZNToo0K3isbepy4yd+9YmCQgZfOZmEAi3QkJAp5Dy3pOHR HYZZfJX/HL5nM/qHf8BKvyX2ad1KFo1tFBh232EtpXU3458KFiwJP0QEI8cgWa/Di2vxx+Ogxr3 w0YWSga39P2kreP9Fxpe0qbs4jQIPlVuNUejkdRAnl6mOO8oCjZI3c/0SZcBlDfHID5YkkjhLdy gjDYyoGO95dZs9/jBGUBvgcMs9EHjuLw84wiBCwHTiQn4QxbcZBnQPNzUjgVpVFr1PlzA2KkfLR z3/Gjrl0LuyuAs5QYBSdu7xS6G3VBhqwmG+RvIkg+7dpo6GskXwQVtLvi7Z/lLYjqLh77ipsSIV qP9swlEvr+3s+ShjFkcTA7OrFLVMdxyGSJsHme8rr2w2ruaQE9WodzSJ33rQxl3puC5Fw4oyuaM +M75iqQ3+aMj0yHrW+/0Ub040x/odZMTQHIJbOIoBe1TGx+Th4Mf4qLija+ovqaV8TtOQY0jH+m LfmzkuZ6S3bj+/PjT67LfzEyxQ== X-Received: by 2002:a17:902:cf09:b0:2f1:751e:906a with SMTP id d9443c01a7336-2f1751e9230mr13113725ad.27.1796182833204; Tue, 01 Dec 2026 19:40:33 -0800 (PST) Received: from plin-1878 ([136.226.240.169]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f1542d2db2sm35502035ad.36.2026.12.01.19.40.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 19:40:32 -0800 (PST) Date: Wed, 2 Dec 2026 11:40:27 +0800 From: Yu-Chien Peter Lin To: Raymond Mao Cc: opensbi@lists.infradead.org, anup.patel@oss.qualcomm.com, scott@riscstar.com, raymond.mao@riscstar.com, robin.randhawa@sifive.com, samuel.holland@sifive.com, zong.li@sifive.com, greentime.hu@sifive.com Subject: Re: [PATCH v3 0/5] Add WorldGuard support with SiFive WG checker Message-ID: References: <20260904162915.1092353-1-raymondmaoca@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261202_034037_532179_6545E43A X-CRM114-Status: GOOD ( 29.44 ) X-Spam-Score: -0.2 (/) X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "opensbi" X-Spam-Status: No, score=-8.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Hi Raymond, On Thu, Oct 29, 2026 at 12:28:57PM +0800, Yu-Chien Peter Lin wrote: > Hi Raymond, > > On Fri, Sep 04, 2026 at 12:29:10PM -0400, Raymond Mao wrote: > > From: Raymond Mao > > > > This series adds WorldGuard support according to the wgchecker2 DT- > > binding proposal from SiFive [1] with QEMU virt integration. > > > > The implementation: > > - reuse sbi_hart_protection for hart-local runtime reconfiguration > > - reuse sbi_domain_data for per-domain WorldGuard state > > - keep WorldGuard-specific setup and checker programming in platform > > code > > > > At boot, the generic platform code invokes a QEMU virt WorldGuard > > setup path which: > > - parses wgchecker2 checker instances > > - parses provider partition@N entries and programs checker MMIO > > - parses per-hart CPU defaults from /cpus > > - parses per-domain WorldGuard metadata under hw-isolation > > > > Checker programming is provider-driven. Consumer-side > > access-controllers references are carried for DT-binding alignment. > > > > During domain transitions, the WorldGuard hart protection > > implementation reprograms MLWID and, when available, MLWIDLIST, > > MWIDDELEG, and SLWID. > > > > The series is split as follows: > > 1. add reusable FDT helpers needed by the WorldGuard parser > > 2. add WorldGuard CSR definitions and hart extension flags > > 3. document the current DT layout consumed by the implementation > > 4. add the wgchecker2 / WorldGuard runtime and QEMU virt integration > > > > Tested with: > > - QEMU riscv-wg-v4-260821 [2] with arg 'worlds=on' and the merged > > WorldGuard test DTB. > > > > [1] dt-bindings: riscv: Add RISC-V Worlds and SiFive WorldGuard DT > > bindings > > https://lore.kernel.org/linux-devicetree/20260812122131.1534906-1-peter.lin@sifive.com/ > > [2] https://github.com/cwshu/qemu/tree/riscv-wg-v4-260821 > > Thanks for working on this series. Could we align the implementation with > the DT proposal on a few key points? > > 1. Domain WIDs should use wid / widdeleg directly under domain nodes, not > hw-isolation with sifive,wgchecker2. > My patches already handle the WID assignment and switching. > https://patchwork.ozlabs.org/project/opensbi/patch/20261027083509.1076577-10-peter.lin@sifive.com/ > 2. wgChecker is a static firewall configured once at boot; by design it does > not support efficient dynamic reconfiguration. > 3. Unlike sequential first-match PMP, wgChecker slots are strictly accretive > (parallel OR), so overlapping rules cannot restrict access. i.e. > > /* PMP (Priority-based, sequential): */ > for (i = N-1; i >= 0; i--) { > if (pmp[i].matches(addr)) > return pmp[i].perm; // FIRST match wins > } > > /* wgChecker (Strictly accretive, parallel): */ > perm = NO_ACCESS; > for (i = 0; i < nslots; i++) { > if (slot[i].matches(addr)) > perm |= slot[i].perm[wid]; // OR all matches > } > if (perm allows access) > grant_access(); > > The wgChecker driver should automatically select between NAPOT and TOR > encoding to minimize slot usage. Just add one more suggestion: Because slots are accretive, overlapping partitions cannot be used to tighten access. They would only widen it. The driver should treat this as a partition conflict and fail early during DT parsing. Also, FYI: the Worlds-based domain support has now been merged, so you can continue with your wgChecker driver support on top of it. Best regards, Peter Lin > > 4. OpenSBI should support use cases below and dump the wgChecker slot info at boot: > > ======================================================================== > Use Case 1: Single-Slot Peripheral Protection (Full Subordinate Range) > ======================================================================== > > 0x001c_1000 +---------------------------------------------------+ > | partition@0 : [0x001c_1000, 0x001c_2000) | > | serial@1c1000 | WID 0,3 RW (perm 0xc3, cfg 0x1f) | > | Slot00..01 : A=TOR (Slot00 base, Slot01 top) | > 0x001c_2000 +---------------------------------------------------+ > > uart: serial@1c1000 { > reg = <0x001c1000 0x1000>; > access-controllers = <&wgc0 0>; > }; > > wgc0: access-controller@1c2000 { > compatible = "qemu,wgchecker2", "sifive,wgchecker2"; > reg = <0x0 0x001c2000 0x0 0x1000>; > #access-controller-cells = <1>; > #address-cells = <1>; > #size-cells = <0>; > > partition@0 { > reg = <0>; > sifive,wg-region = <0x0 0x001c1000 0x0 0x00001000>; > sifive,slot-permissions = <0x0 0x000000c3>; > sifive,slot-config = <0x1f>; > }; > }; > > Expected OpenSBI boot dump: > wgChecker Base : 0x1c2000 > wgChecker Slot00 : 0x00000000001c1000-.................. 00: A:0 ER:1 EW:1 IR:1 IW:1 L:0 > wgChecker Slot01 : ..................-0x00000000001c2000 c3: A:1 ER:1 EW:1 IR:1 IW:1 L:1 > wgChecker Slot Usage : 1 (total), 1 (used), 0 (free) > > ======================================================================== > Use Case 2: Multi-Region Peripheral Protection (Disjoint Register Groups) > ======================================================================== > > 0x0001_0000 +---------------------------------------------------+ > | partition@0 : [0x0001_0000, 0x0001_8000) (32 KiB) | > | reg[0] m_mode | WID 3 RW (perm 0xc0) | Slot01 | > 0x0001_8000 +---------------------------------------------------+ > : (unreferenced) : > 0x00a0_0000 +---------------------------------------------------+ > | partition@1 : [0x00a0_0000, 0x00a0_4000) (16 KiB) | > | reg[1] s_mode | WID 0,3 RW (perm 0xc3) | Slot02 | > 0x00a0_4000 +---------------------------------------------------+ > > device@10000 { > reg = <0x0 0x00010000 0x0 0x8000>, > <0x0 0x00a00000 0x0 0x4000>; > reg-names = "m_mode", "s_mode"; > access-controllers = <&wgc1 0>, <&wgc1 1>; > }; > > wgc1: access-controller@35000 { > compatible = "qemu,wgchecker2", "sifive,wgchecker2"; > reg = <0x0 0x00035000 0x0 0x1000>; > #access-controller-cells = <1>; > #address-cells = <1>; > #size-cells = <0>; > > partition@0 { > reg = <0>; > sifive,wg-region = <0x0 0x00010000 0x0 0x00008000>; > sifive,slot-permissions = <0x0 0x000000c0>; > sifive,slot-config = <0x0f>; > }; > partition@1 { > reg = <1>; > sifive,wg-region = <0x0 0x00a00000 0x0 0x00004000>; > sifive,slot-permissions = <0x0 0x000000c3>; > sifive,slot-config = <0x0f>; > }; > }; > > Expected OpenSBI boot dump: > wgChecker Base : 0x35000 > wgChecker Slot00 : 0x0000000000000000-.................. 00: A:0 ER:1 EW:1 IR:1 IW:1 L:0 > wgChecker Slot01 : 0x0000000000010000-0x0000000000018000 c0: A:3 ER:1 EW:1 IR:1 IW:1 L:0 > wgChecker Slot02 : 0x0000000000a00000-0x0000000000a04000 c3: A:3 ER:1 EW:1 IR:1 IW:1 L:0 > wgChecker Slot04 : ..................-0x0000000001000000 00: A:0 ER:0 EW:0 IR:0 IW:0 L:0 > wgChecker Slot Usage : 4 (total), 2 (used), 2 (free) > > ======================================================================== > Use Case 3: Multi-Domain DRAM Spatial Partitioning (Hybrid NAPOT + TOR) > ======================================================================== > > OpenSBI: WID3 > Linux : WID0 > OP-TEE : WID1 > > 0x8000_0000 +---------------------------------------------------+ > | partition@0 : [0x8000_0000, 0xC000_0000) (1024M) | > | Linux / OpenSBI | WID 0,1,3 RW (0xcf) | Slot01 A:3| > 0xC000_0000 +---------------------------------------------------+ > | partition@1 : [0xC000_0000, 0xC100_0000) (16M) | > | OP-TEE / OpenSBI| WID 1,3 RW (0xcc) | Slot02 A:3| > 0xC100_0000 +---------------------------------------------------+ > | partition@2 : [0xC100_0000, 0x1_0000_0000) (1008M)| > | Linux / OpenSBI | WID 0,1,3 RW (0xcf) | Slot03..04| > 0x1_0000_0000 +-------------------------------------------------+ > > memory: memory@80000000 { > reg = <0x0 0x80000000 0x0 0x80000000>; > access-controllers = <&wgc2 0>, <&wgc2 1>, <&wgc2 2>; > }; > > wgc2: access-controller@50000000 { > compatible = "qemu,wgchecker2", "sifive,wgchecker2"; > reg = <0x0 0x50000000 0x0 0x1000>; > #access-controller-cells = <1>; > #address-cells = <1>; > #size-cells = <0>; > > partition@0 { > reg = <0>; > sifive,wg-region = <0x0 0x80000000 0x0 0x40000000>; > sifive,slot-permissions = <0x0 0x000000cf>; > sifive,slot-config = <0x0f>; > }; > partition@1 { > reg = <1>; > sifive,wg-region = <0x0 0xc0000000 0x0 0x01000000>; > sifive,slot-permissions = <0x0 0x000000cc>; > sifive,slot-config = <0x0f>; > }; > partition@2 { > reg = <2>; > sifive,wg-region = <0x0 0xc1000000 0x0 0x3f000000>; > sifive,slot-permissions = <0x0 0x000000cf>; > sifive,slot-config = <0x0f>; > }; > }; > > Expected OpenSBI boot dump: > wgChecker Base : 0x50000000 > wgChecker Slot00 : 0x0000000000000000-.................. 00: A:0 ER:1 EW:1 IR:1 IW:1 L:0 > wgChecker Slot01 : 0x0000000080000000-0x00000000c0000000 cf: A:3 ER:1 EW:1 IR:1 IW:1 L:0 > wgChecker Slot02 : 0x00000000c0000000-0x00000000c1000000 cc: A:3 ER:1 EW:1 IR:1 IW:1 L:0 > wgChecker Slot03 : 0x00000000c1000000-.................. 00: A:0 > wgChecker Slot04 : ..................-0x0000000100000000 cf: A:1 ER:1 EW:1 IR:1 IW:1 L:0 > wgChecker Slot16 : ..................-0x0000000100000000 00: A:0 ER:0 EW:0 IR:0 IW:0 L:0 > wgChecker Slot Usage : 16 (total), 4 (used), 12 (free) > > Best regards, > Peter Lin -- opensbi mailing list opensbi@lists.infradead.org http://lists.infradead.org/mailman/listinfo/opensbi