From patchwork Mon Aug 17 14:30:23 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 2287056 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=JRZjwp8q; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=XYMZCh3X; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hNwKg2SKwz1xvW for ; Tue, 18 Aug 2026 00:32:55 +1000 (AEST) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qTWTIZgy4WGbUrh9AN6DtrLiMi0VsZps4llqlFUQcKc=; b=JRZjwp8qZmVsCr +Jn9U6+YvwEmkn9CDLfVWeYlLrPdQlk+j79408GoSNrvXOrP5jYoGyEC7mIA/0rdA1xf9HsKdxFbQ 9TwLtXi0tRFQXGehHpYugIQ3ncsFnp1honyQj251ZcYwFFhBu/I3hKgG2OeerkZL9gAsqP+FakiXy uWHa0bnhVWaQUBp7Br0PlaqDnxY+HvG6iHSHZ76p/FeVQOMR69nP0TPGkcp3KVz1qZl7kF0j68an5 SuSFF8irpEaz2ysMIYSqZpT/A0fCb6H623oPxcnJHgBCdQtZq5+Ytkh1BTuXLQ/KJS2DtaOIXUX5l 0pPtn1ctXXlPrbYdsQmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wvyOO-00000006JI3-2yZc; Mon, 17 Aug 2026 14:32:48 +0000 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wvyOM-00000006JGD-04ad for opensbi@lists.infradead.org; Mon, 17 Aug 2026 14:32:48 +0000 Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67HD66oH2749151; Mon, 17 Aug 2026 14:31:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=vCG0NvBEVuv nYvl7rg+XKEAkMT0rGjG4SA1V9la7Ulg=; b=XYMZCh3XAD7mKqrNpx0hmZ9uDYK df2cqe3QvjWi6pkLW+E1c9N465yrilBFRpPDrV9bFjea7B+f7Yu8ERZoBGjFGBN/ yanMm6ChrN79lCRqjc+fuQ2yJT7DcLPpAZVIebyzKqIhQ6S1Q3vn7tX4nRPYAoWO 1lUI9q1lVASfLDYgs1K/FXbl2VfdT5Fi1MVgpD/yfmBJOSaeFLR91GW88v7hajSx fwU3XBNVAQV0OUldzNNxarz2wdS8Pf+CwldW6qkFfIlaNUW17GkKhOSBDsBXGpci AWp6ER5CnkEDkuZnQMTuUJt8R+EDLcWm1h77Cr0ilmpAjVRoKwsCwEer83Q== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g3y7799d2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Aug 2026 14:31:42 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.18.1.7/8.18.1.7) with ESMTP id 67HEVceH009496; Mon, 17 Aug 2026 14:31:38 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 4g2h6j63j5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Aug 2026 14:31:38 +0000 (GMT) Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 67HEVcge009477; Mon, 17 Aug 2026 14:31:38 GMT Received: from hu-devc-blr-u24-a.qualcomm.com (hu-anuppate-blr.qualcomm.com [10.131.36.165]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 67HEVcEO009472 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Aug 2026 14:31:38 +0000 (GMT) Received: by hu-devc-blr-u24-a.qualcomm.com (Postfix, from userid 486687) id 51BB321A0D; Mon, 17 Aug 2026 20:01:37 +0530 (+0530) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Samuel Holland , Anup Patel , opensbi@lists.infradead.org, Anup Patel , Pawandeep Oza Subject: [PATCH v2 1/3] lib: sbi_domain: Check possible harts in sbi_domain_context_enter/exit() Date: Mon, 17 Aug 2026 20:00:23 +0530 Message-ID: <20260817143025.3068512-2-anup.patel@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260817143025.3068512-1-anup.patel@oss.qualcomm.com> References: <20260817143025.3068512-1-anup.patel@oss.qualcomm.com> MIME-Version: 1.0 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODE3MDExMSBTYWx0ZWRfX/QqgTgQHsnb7 ISzEmLPrC+/vgX7+8QtAzazpKkTL1HlOQWGU4ayWDq07ZgoyH+KbvwBnv6kEgUiLeelTLz6ZPfx yuKYXC4s/IqhySqGm8iTTCERiTFnDX1JK7fUcy+7hCehj4Irci5r90tljd+Fa7LegZRHo/c+Zaa 3g5X75OuTHRqmUMwBxiootyMzhY3l2hbOpG7X95eGVUShdXrFDSOTRzlxC2hPaZiOw83e6eRJ12 QSH/1PL757rfrMSQK8uysMAE0oTPJPKlJq9CgEj3OvRge0YZ2dwkp6iwArla5xzElXG1aSgqiB4 y376cAtZuatWiSk1I2D6PQK1Lgq+WVRtoRmz2lk6neR1r4q+3DXbj8p5xm2Agugcp7keVzkjGm0 pditUo+JSMmfXIdDQKQcjDwnpZcoyYzN/w6Xz7TA+C9F3rdSgVsxwhAHKni8PxWQQMbaQCdTQIm /R+tj9EvGFb0r+bMxxg== X-Proofpoint-ORIG-GUID: RBAi61vOFuQsQJmDbNPZISaKxH4C3Wpf X-Proofpoint-Spam-Info: AW1haW4tMjYwODE3MDExMSBTYWx0ZWRfX/QOEm76g/6hU zg2Lz6PGi4lhhOWTpTHX+vQ6Wj4FAF43yZKQONSLgSv9kVqQJt/4bix4NC5suOKmeV+Ny0TCyuv F2whCgjvlauGZzqZ96ukJvC6fmZzUUY= X-Proofpoint-GUID: RBAi61vOFuQsQJmDbNPZISaKxH4C3Wpf X-Authority-Analysis: v=2.4 cv=WNhPmHsR c=1 sm=1 tr=0 ts=6a831b4e cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=Sv0fKeRqtYgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=GowCY4pPMrDu7OKEMqwA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-17_01,2026-08-12_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 phishscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 bulkscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608170111 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260817_073246_169912_C8ABC40F X-CRM114-Status: GOOD ( 14.48 ) X-Spam-Score: -2.7 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When context switching to a domain the current hart MUST be part of the possible harts of that domain. Add appropriate checks in sbi_domain_context_enter/exit() along these lines. Signed-off-by: Anup Patel Reviewed-by: Pawandeep Oza Tested-by: Pawandeep Oza --- lib/sbi/sbi_domain_con [...] Content analysis details: (-2.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [205.220.180.131 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 DMARC_PASS DMARC pass policy X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When context switching to a domain the current hart MUST be part of the possible harts of that domain. Add appropriate checks in sbi_domain_context_enter/exit() along these lines. Signed-off-by: Anup Patel Reviewed-by: Pawandeep Oza Tested-by: Pawandeep Oza Reviewed-by: Yu-Chien Peter Lin --- lib/sbi/sbi_domain_context.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/sbi/sbi_domain_context.c b/lib/sbi/sbi_domain_context.c index 0861d541..837ff54f 100644 --- a/lib/sbi/sbi_domain_context.c +++ b/lib/sbi/sbi_domain_context.c @@ -231,18 +231,23 @@ int sbi_domain_context_enter(struct sbi_domain *dom) int rc; struct hart_context *dom_ctx; struct hart_context *ctx = hart_context_thishart_get(); + u32 hartindex = current_hartindex(); /* Target domain must not be same as the current domain */ if (!dom || dom == sbi_domain_thishart_ptr()) return SBI_EINVAL; + /* Target domain must have current hart as a possible harts */ + if (!sbi_hartmask_test_hartindex(hartindex, dom->possible_harts)) + return SBI_EINVAL; + /* * If it's first time to call `enter` on the current hart, no * context allocated before. Allocate context for each valid * domain on the current hart. */ if (!ctx) { - rc = hart_context_init(current_hartindex()); + rc = hart_context_init(hartindex); if (rc) return rc; @@ -251,7 +256,7 @@ int sbi_domain_context_enter(struct sbi_domain *dom) return SBI_EINVAL; } - dom_ctx = hart_context_get(dom, current_hartindex()); + dom_ctx = hart_context_get(dom, hartindex); /* Validate the domain context existence */ if (!dom_ctx) return SBI_EINVAL; @@ -276,7 +281,7 @@ int sbi_domain_context_exit(void) * its context on the current hart if valid. */ if (!ctx) { - rc = hart_context_init(current_hartindex()); + rc = hart_context_init(hartindex); if (rc) return rc; @@ -294,6 +299,9 @@ int sbi_domain_context_exit(void) if (dom == &root || dom == sbi_domain_thishart_ptr()) continue; + if (!sbi_hartmask_test_hartindex(hartindex, dom->possible_harts)) + continue; + tmp = hart_context_get(dom, hartindex); if (tmp && !tmp->initialized) { dom_ctx = tmp; From patchwork Mon Aug 17 14:30:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 2287057 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=DznAtlim; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=ZxpbWUlY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hNwKh5Jkkz1xvW for ; Tue, 18 Aug 2026 00:32:56 +1000 (AEST) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=z7Wa9mtGKodTfrDCmiA2jonHwEBhDmhKH/LiD+WEC9Y=; b=DznAtlimnAmF8B FhirnPaq5zBiEfu9TxHteOMxUuqIg7k20Y1py+5u9P7Cw+R6ow8NmmyJfseAXxvAhW+7db/8qcDC0 1j4ud8KtoTLPbaRJO41DVABfZREPf1D4ttj5a8vOW+7ftILS0SrxFxigGmd6NZdc5tlnFD0JEE1xy tx2bXMf9A54UrUreDrXu+rfQymDPjXLLqokKGUn6yTwGuJX9cyGmW3VjxVy6yfWEx/FRhJU+9YJCG BggmS1gZj+W+AnZKzkgcc+RnaLXsJ4rV9tw6ElYSWDVFcXREfP876BVvMJs3UCYy+BLNb/M93s3aS yAIuXriA2bnPoz/ZN4tA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wvyOO-00000006JHp-2dIK; Mon, 17 Aug 2026 14:32:48 +0000 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wvyOL-00000006JFr-1RZ7 for opensbi@lists.infradead.org; Mon, 17 Aug 2026 14:32:47 +0000 Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67HD5vjR2008459; Mon, 17 Aug 2026 14:31:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=XMf6VH+CHLo 9cvatw4nH2sXOu1WNdRm5BtJjp5zrpKI=; b=ZxpbWUlYg55W3TUFOdAvm2VCUsk 0dejZZGFfg4ULEnXmMG+skp+9fNTc0RNXQuIeGIVThX39s6HYQOz74GkLoGMYiqT vUBRtookYcN4nSTF19RrpaVgwgRkXR0sTCSgBHIRZmkNGfZVDlCxuucjrB7p7Rhv L0N6c4doO0Wi53FDlRjiFaJNRomaexJ6XCdAM14XQvDmrltTc9cZ4WBW3qb2sgIm XN9QOjrDfb3VPmm/3CVgY6SMqGxvxjsuDG830utUoZBX8trfTDpOGSH9dD5yIGgE 8au7f6eB6Xg6NmCNxPn+ouibRv7pLaKH8WEysLebsPTQJ0oZGBwiXhaUUZA== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g3xw8hbsv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Aug 2026 14:31:42 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.18.1.7/8.18.1.7) with ESMTP id 67HEVcg4009495; Mon, 17 Aug 2026 14:31:38 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 4g2h6j63j6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Aug 2026 14:31:38 +0000 (GMT) Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 67HEVcmR009476; Mon, 17 Aug 2026 14:31:38 GMT Received: from hu-devc-blr-u24-a.qualcomm.com (hu-anuppate-blr.qualcomm.com [10.131.36.165]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 67HEVcZE009471 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Aug 2026 14:31:38 +0000 (GMT) Received: by hu-devc-blr-u24-a.qualcomm.com (Postfix, from userid 486687) id 5505724A76; Mon, 17 Aug 2026 20:01:37 +0530 (+0530) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Samuel Holland , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH v2 2/3] lib: sbi_domain: Re-work boot-time assignment of HARTs to non-ROOT domains Date: Mon, 17 Aug 2026 20:00:24 +0530 Message-ID: <20260817143025.3068512-3-anup.patel@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260817143025.3068512-1-anup.patel@oss.qualcomm.com> References: <20260817143025.3068512-1-anup.patel@oss.qualcomm.com> MIME-Version: 1.0 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-GUID: AKd7XGMXW33yAehMLguTmfmomcnw8Hc9 X-Proofpoint-Spam-Info: AW1haW4tMjYwODE3MDExMSBTYWx0ZWRfXzXDxXQG7Gz2/ ogcp9LnyEokrNfPpF7ER7jwd1MCd4nVVZlUoFMoAwK5W/RhEmhSzybxlRVlNI/P7BeNKrN2skx7 Wwbi9TMIzRgsWWGE43dXb0Ovjy4DJNY= X-Authority-Analysis: v=2.4 cv=SuCgLvO0 c=1 sm=1 tr=0 ts=6a831b4e cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=Sv0fKeRqtYgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=ZJOUiLeJ6B_-f_V8wgkA:9 X-Proofpoint-ORIG-GUID: AKd7XGMXW33yAehMLguTmfmomcnw8Hc9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODE3MDExMSBTYWx0ZWRfX+4HhlEHJtTKV 9qHVz1tpbJ0/Eppy0jmngOO1dPttPFTuxTFFcxd02sEIAllHTvhRFVBmBjm34O2WNBf5slufILw ZvYtE0yT4PtbxT5HW0WfCEdNZPHSYvkIdiNtDsDJWGaQFHqEXCA6VpSa4RzfRCnqyEJMGErT5rw e079FCWBvdRhJXZdrAXVoliwTBmAzo4+R8yDHn+NNuyHCyLSu/qJtGop9EF4gqGps/gDT+5HkrB WN1qZzxuVkWGlN/c/49NofYRiHvcXj5Zr+O7Furgboms3p5ZqogCK6EBbRDPh0wGRK4bxxs/3xP 8hNvRHO8DPhkwGFKMrtwbIlltQh0iD2tGRBoCMK6S9qpAxtbqvmnEWKnCiHjxbCICFK0TA/pwEh ORi5EgEtOfcjIImBNScUURh3gg1Olw6XsNRrlAK1UxfBRPHvtZ3qF1POXTzfSOtvctpBHwARkKy 1u9fweruPGXX45x8Jbw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-17_01,2026-08-12_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 priorityscore=1501 phishscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608170111 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260817_073245_503658_7042F9C7 X-CRM114-Status: GOOD ( 29.31 ) X-Spam-Score: -2.7 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Assign a non-ROOT domain to a HART on first come first serve basis if the HART is listed as a possible HART of the non-ROOT domain. If no non-ROOT domain list a HART as possible HART then the HART is [...] Content analysis details: (-2.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [205.220.180.131 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 DMARC_PASS DMARC pass policy X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Assign a non-ROOT domain to a HART on first come first serve basis if the HART is listed as a possible HART of the non-ROOT domain. If no non-ROOT domain list a HART as possible HART then the HART is assigned to the ROOT domain. This allows us to drop the OpenSBI specific DT property from each CPU DT node (aka "opensbi-domain" Dt property). Signed-off-by: Anup Patel --- docs/domain_support.md | 20 +++---- include/sbi/sbi_domain.h | 4 +- include/sbi_utils/fdt/fdt_domain.h | 3 +- lib/sbi/sbi_domain.c | 34 ++++++----- lib/utils/fdt/fdt_domain.c | 95 +++--------------------------- 5 files changed, 35 insertions(+), 121 deletions(-) diff --git a/docs/domain_support.md b/docs/domain_support.md index e267a9f7..82f155e1 100644 --- a/docs/domain_support.md +++ b/docs/domain_support.md @@ -207,15 +207,14 @@ The DT properties of a domain instance DT node are as follows: ### Assigning HART To Domain Instance -By default, all HARTs are assigned to **the ROOT domain**. The OpenSBI -platform support can provide the HART to domain instance assignment using -platform specific callback. +At boot-time, a HART is assigned to a non-ROOT domain on first come +first serve basis if the HART is listed as a possible HART of the +non-ROOT domain. If no non-ROOT domain list a HART as possible HART +then the HART is assigned to **the ROOT domain**. -The HART to domain instance assignment can be parsed from the device tree -using optional DT property **opensbi-domain** in each CPU DT node. The -value of DT property **opensbi-domain** is the DT phandle of the domain -instance DT node. If **opensbi-domain** DT property is not specified then -corresponding HART is assigned to **the ROOT domain**. +At runtime, the assignment of a HART can change from one domain to +another domain as long as the HART is listed in possible HARTs of +both domains. ### Domain Configuration Only Accessible to OpenSBI @@ -289,7 +288,6 @@ be done: device_type = "cpu"; reg = <0x00>; compatible = "riscv"; - opensbi-domain = <&tdomain>; ... }; @@ -297,7 +295,6 @@ be done: device_type = "cpu"; reg = <0x01>; compatible = "riscv"; - opensbi-domain = <&udomain>; ... }; @@ -305,7 +302,6 @@ be done: device_type = "cpu"; reg = <0x02>; compatible = "riscv"; - opensbi-domain = <&udomain>; ... }; @@ -313,7 +309,6 @@ be done: device_type = "cpu"; reg = <0x03>; compatible = "riscv"; - opensbi-domain = <&udomain>; ... }; @@ -321,7 +316,6 @@ be done: device_type = "cpu"; reg = <0x04>; compatible = "riscv"; - opensbi-domain = <&udomain>; ... }; }; diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h index 16edd4ce..b6731c04 100644 --- a/include/sbi/sbi_domain.h +++ b/include/sbi/sbi_domain.h @@ -328,12 +328,10 @@ void sbi_domain_dump_all(const char *suffix); /** * Register a new domain * @param dom pointer to domain - * @param assign_mask pointer to HART mask of HARTs assigned to the domain * * @return 0 on success and negative error code on failure */ -int sbi_domain_register(struct sbi_domain *dom, - const struct sbi_hartmask *assign_mask); +int sbi_domain_register(struct sbi_domain *dom); /** * Add a memory range with its flags to the root domain diff --git a/include/sbi_utils/fdt/fdt_domain.h b/include/sbi_utils/fdt/fdt_domain.h index 8c2dee09..a366b271 100644 --- a/include/sbi_utils/fdt/fdt_domain.h +++ b/include/sbi_utils/fdt/fdt_domain.h @@ -50,8 +50,7 @@ int fdt_iterate_each_memregion(void *fdt, int domain_offset, void *opaque, * * This routine: * 1. Disables MMIO devices not accessible to the coldboot HART domain - * 2. Removes "opensbi-domain" DT property from CPU DT nodes - * 3. Removes domain configuration DT node under /chosen DT node + * 2. Removes domain configuration DT node under /chosen DT node * * It is recommended that platform support call this function in * their final_init() platform operation. diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c index fa69170b..af753459 100644 --- a/lib/sbi/sbi_domain.c +++ b/lib/sbi/sbi_domain.c @@ -625,16 +625,14 @@ void sbi_domain_dump_all(const char *suffix) } } -int sbi_domain_register(struct sbi_domain *dom, - const struct sbi_hartmask *assign_mask) +int sbi_domain_register(struct sbi_domain *dom) { - u32 i; - int rc; + u32 i, cold_hartid = current_hartid(); struct sbi_domain *tdom; - u32 cold_hartid = current_hartid(); + int rc; /* Sanity checks */ - if (!dom || !assign_mask || domain_finalized) + if (!dom || domain_finalized) return SBI_EINVAL; /* Check if domain already discovered */ @@ -663,15 +661,21 @@ int sbi_domain_register(struct sbi_domain *dom, /* Clear assigned HARTs of domain */ sbi_hartmask_clear_all(&dom->assigned_harts); - /* Assign domain to HART if HART is a possible HART */ - sbi_hartmask_for_each_hartindex(i, assign_mask) { - if (!sbi_hartmask_test_hartindex(i, dom->possible_harts)) - continue; - + /* + * Assign a non-ROOT domain to a HART on first come first serve + * basis if the HART is listed as a possible HART of the non-ROOT + * domain. If no non-ROOT domain list a HART as possible HART then + * the HART is assigned to the ROOT domain. + */ + sbi_hartmask_for_each_hartindex(i, dom->possible_harts) { tdom = sbi_hartindex_to_domain(i); - if (tdom) - sbi_hartmask_clear_hartindex(i, - &tdom->assigned_harts); + if (tdom) { + if (tdom == &root) + sbi_hartmask_clear_hartindex(i, &tdom->assigned_harts); + else + continue; + } + sbi_update_hartindex_to_domain(i, dom); sbi_hartmask_set_hartindex(i, &dom->assigned_harts); @@ -975,7 +979,7 @@ int sbi_domain_init(struct sbi_scratch *scratch, u32 cold_hartid) sbi_hartmask_set_hartindex(i, root_hmask); /* Finally register the root domain */ - rc = sbi_domain_register(&root, root_hmask); + rc = sbi_domain_register(&root); if (rc) goto fail_free_root_hmask; diff --git a/lib/utils/fdt/fdt_domain.c b/lib/utils/fdt/fdt_domain.c index 61627db3..3857831d 100644 --- a/lib/utils/fdt/fdt_domain.c +++ b/lib/utils/fdt/fdt_domain.c @@ -170,26 +170,11 @@ static int __fixup_disable_devices(void *fdt, int doff, int roff, void fdt_domain_fixup(void *fdt) { - u32 i, dcount; + u32 dcount; int err, poffset, doffset; struct sbi_domain *dom = sbi_domain_thishart_ptr(); struct __fixup_find_domain_offset_info fdo; - /* Remove the domain assignment DT property from CPU DT nodes */ - poffset = fdt_path_offset(fdt, "/cpus"); - if (poffset < 0) - return; - fdt_for_each_subnode(doffset, fdt, poffset) { - err = fdt_parse_hart_id(fdt, doffset, &i); - if (err) - continue; - - if (!fdt_node_is_enabled(fdt, doffset)) - continue; - - fdt_nop_property(fdt, doffset, "opensbi-domain"); - } - /* Skip device disable for root domain */ if (!dom->index) goto skip_device_disable; @@ -315,12 +300,10 @@ static int __fdt_parse_domain(const void *fdt, int domain_offset, void *opaque) const char *inherit; struct sbi_domain *dom; struct sbi_hartmask *mask; - struct sbi_hartmask assign_mask; struct parse_region_data preg; - int *cold_domain_offset = opaque; struct sbi_domain_memregion *reg; int inheritance_mode = FDT_ROOT_REGION_INHERIT_M_ONLY; - int i, err = 0, len, cpus_offset, cpu_offset, doffset; + int i, err = 0, len, cpus_offset, cpu_offset; dom = sbi_zalloc(sizeof(*dom)); if (!dom) @@ -440,7 +423,7 @@ static int __fdt_parse_domain(const void *fdt, int domain_offset, void *opaque) val64 = fdt32_to_cpu(val[0]); val64 = (val64 << 32) | fdt32_to_cpu(val[1]); } else { - val64 = sbi_scratch_thishart_ptr()->next_arg1; + val64 = root.next_arg1; } dom->next_arg1 = val64; @@ -451,8 +434,7 @@ static int __fdt_parse_domain(const void *fdt, int domain_offset, void *opaque) val64 = fdt32_to_cpu(val[0]); val64 = (val64 << 32) | fdt32_to_cpu(val[1]); } else { - if (domain_offset == *cold_domain_offset) - val64 = sbi_scratch_thishart_ptr()->next_addr; + val64 = root.next_addr; } dom->next_addr = val64; @@ -464,8 +446,7 @@ static int __fdt_parse_domain(const void *fdt, int domain_offset, void *opaque) if (val32 != 0x0 && val32 != 0x1) val32 = 0x1; } else { - if (domain_offset == *cold_domain_offset) - val32 = sbi_scratch_thishart_ptr()->next_mode; + val32 = root.next_mode; } dom->next_mode = val32; @@ -490,37 +471,8 @@ static int __fdt_parse_domain(const void *fdt, int domain_offset, void *opaque) goto fail_free_all; } - /* HART to domain assignment mask based on CPU DT nodes */ - sbi_hartmask_clear_all(&assign_mask); - fdt_for_each_subnode(cpu_offset, fdt, cpus_offset) { - err = fdt_parse_hart_id(fdt, cpu_offset, &val32); - if (err) - continue; - - if (SBI_HARTMASK_MAX_BITS <= sbi_hartid_to_hartindex(val32)) - continue; - - if (!fdt_node_is_enabled(fdt, cpu_offset)) - continue; - - /* This is an optional property */ - val = fdt_getprop(fdt, cpu_offset, "opensbi-domain", &len); - if (!val || len < 4) - continue; - - /* However, it should be valid if specified */ - doffset = fdt_node_offset_by_phandle(fdt, fdt32_to_cpu(*val)); - if (doffset < 0) { - err = doffset; - goto fail_free_all; - } - - if (doffset == domain_offset) - sbi_hartmask_set_hartid(val32, &assign_mask); - } - /* Register the domain */ - err = sbi_domain_register(dom, &assign_mask); + err = sbi_domain_register(dom); if (err) goto fail_free_all; @@ -537,43 +489,10 @@ fail_free_domain: int fdt_domains_populate(const void *fdt) { - const u32 *val; - int cold_domain_offset; - u32 hartid, cold_hartid; - int err, len, cpus_offset, cpu_offset; - /* Sanity checks */ if (!fdt) return SBI_EINVAL; - /* Find /cpus DT node */ - cpus_offset = fdt_path_offset(fdt, "/cpus"); - if (cpus_offset < 0) - return cpus_offset; - - /* Find coldboot HART domain DT node offset */ - cold_domain_offset = -1; - cold_hartid = current_hartid(); - fdt_for_each_subnode(cpu_offset, fdt, cpus_offset) { - err = fdt_parse_hart_id(fdt, cpu_offset, &hartid); - if (err) - continue; - - if (hartid != cold_hartid) - continue; - - if (!fdt_node_is_enabled(fdt, cpu_offset)) - continue; - - val = fdt_getprop(fdt, cpu_offset, "opensbi-domain", &len); - if (val && len >= 4) - cold_domain_offset = fdt_node_offset_by_phandle(fdt, - fdt32_to_cpu(*val)); - - break; - } - /* Iterate over each domain in FDT and populate details */ - return fdt_iterate_each_domain_ro(fdt, &cold_domain_offset, - __fdt_parse_domain); + return fdt_iterate_each_domain_ro(fdt, NULL, __fdt_parse_domain); } From patchwork Mon Aug 17 14:30:25 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 2287054 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=NwFn8Iln; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=aKVbNa2N; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hNwJq6PPyz1xvW for ; Tue, 18 Aug 2026 00:32:03 +1000 (AEST) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nFYgcM6nn9nSr4o+9G7xAWHBDABfA/ORiF77Y6BF14g=; b=NwFn8IlnB7eiOs PX2f7iJ3ua/SNhUI2sYL+rAl+HNLMclUoDYbAtpf/N1P0JSFxL1RqBie+DOPzJKGtxDnG65fNntlg 5pJf8n68cebABybz6zY4N+gNHPWGLD2/pqwjj3DKG6YdJ77DNMn8/kDec5r9xny7zUf/q17+HcFvV quLbtOeAxMJha4BlwCUax6geo16XAGXoYZgHLSVrBEaBi83AnAiRE0QT3ro8Tvddal08UWBfcqvsZ ZEGDVIJomK4DCMC2nqUIaDTWv++GZm5ljYL9vfTW676H/ZapmP4y/wMH5xRXUUdPZpV40vVUg66T4 mYjJA0TdUnshnpU80Rug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wvyNS-00000006J66-0x9j; Mon, 17 Aug 2026 14:31:50 +0000 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wvyNP-00000006J5X-0U7s for opensbi@lists.infradead.org; Mon, 17 Aug 2026 14:31:48 +0000 Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67HD6Cx31193618; Mon, 17 Aug 2026 14:31:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=pmoWGoKc9ch 7kzuuJMlvr/iB4GWrRl0g+Q9F9gNVWck=; b=aKVbNa2Nw0U5waRTD+/BJuEeXN/ JnAbnARUsq5M1baBs3oDDkrG2/4/rm295a27/nIiIOR7JUdvX0QYF1KehNoaxitE 280HvRivwCO9BLKf8y3yDVW8amy9cNTxqKX440pH2bVjjin33LDwlLrR+QTdyIuS jXPr48AP3cZK5nIzOMYgNDxx6tLuti34IL5Hl1t4VXy4FRyXSf7r1JHOyA377fGB a6Wih/opbeWQEMc/n1bTCf5oQ478F76PVm+wOx/g+s7svngDKL1TEstTK3NaHFnC yWmBt7Mnrbqo11anfaO9RxEkGYq9d3WE7sEic66FSMPW/mHqZg98/OI6+nw== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g3wke1qd8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Aug 2026 14:31:41 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.18.1.7/8.18.1.7) with ESMTP id 67HEVc5T009494; Mon, 17 Aug 2026 14:31:38 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 4g2h6j63j7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Aug 2026 14:31:38 +0000 (GMT) Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 67HEVcJM009475; Mon, 17 Aug 2026 14:31:38 GMT Received: from hu-devc-blr-u24-a.qualcomm.com (hu-anuppate-blr.qualcomm.com [10.131.36.165]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 67HEVcWZ009474 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Aug 2026 14:31:38 +0000 (GMT) Received: by hu-devc-blr-u24-a.qualcomm.com (Postfix, from userid 486687) id 5843624A7A; Mon, 17 Aug 2026 20:01:37 +0530 (+0530) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Samuel Holland , Anup Patel , opensbi@lists.infradead.org, Anup Patel , Pawandeep Oza Subject: [PATCH v2 3/3] lib: sbi_domain: Introduce domain intialization order Date: Mon, 17 Aug 2026 20:00:25 +0530 Message-ID: <20260817143025.3068512-4-anup.patel@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260817143025.3068512-1-anup.patel@oss.qualcomm.com> References: <20260817143025.3068512-1-anup.patel@oss.qualcomm.com> MIME-Version: 1.0 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODE3MDExMSBTYWx0ZWRfX1TgSZVzKOwoP 76dXracbmcwjD+y7mxIedRotqa1hbigL5L8MKoWuYnpQO57w4HXvRNouk7OsQn2sqZKQ0ldtTZT CTsn6y/vXq8CMYDVlNJIb+X55w+eNekT9SvNuZf86p5wA04fm7LRJuTsoQhj5jGa25NJSnZ++K8 NL4g4LCh021NC656jJg67ICofnyB6t4HgFLY8I60IOw2JEB1PSWgfNemKN/+flHO7tPHkhFpc8v o25Qj3yqJ/0t1I20/SFKjgl3+1kNuvMUg5v9kwwpsDzAa7vQ/tK8sKgMDzywP1ZDFXUOgAZS801 ZHBR7ifqgU5ob/0scKZGkH7CHoJmKEknecdqXBDM8s14qgf996No/I7h9XQ45kOKeq15IsFbJiR Of1B0biI5MW33aWQ3jcRQupsucjVxJZly0CvfT/HzSSmLbroS0185vucMOuNVmWa+0YWuVeH9dE Bm/u5IaXCitUPtIMEOg== X-Authority-Analysis: v=2.4 cv=QetWeMbv c=1 sm=1 tr=0 ts=6a831b4e cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=Sv0fKeRqtYgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=OVUozZ5dJveFW_pSK8cA:9 X-Proofpoint-ORIG-GUID: eiaewmhhif9Jp85iSDo0m755Mh3ahXaL X-Proofpoint-GUID: eiaewmhhif9Jp85iSDo0m755Mh3ahXaL X-Proofpoint-Spam-Info: AW1haW4tMjYwODE3MDExMSBTYWx0ZWRfX9qZwt16MuWtR admGmXz473IJXkhhAmuCAruR+3hie6NCvCxeEeDzV0vzn0lfc8Yx2MknPqUVkoKBqBUb56knpnD hZLcs8uuVk7Wdkb45YURBi5FGSegHRY= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-17_01,2026-08-12_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 adultscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608170111 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260817_073147_278259_3FCD024E X-CRM114-Status: GOOD ( 24.41 ) X-Spam-Score: -2.7 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Currently, the domain initialization order is implied by the order in which domains are populated by sbi_platform_domains_init() from sbi_domain_finalize(). This is not documented anywhere and forces [...] Content analysis details: (-2.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [205.220.180.131 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 DMARC_PASS DMARC pass policy X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Currently, the domain initialization order is implied by the order in which domains are populated by sbi_platform_domains_init() from sbi_domain_finalize(). This is not documented anywhere and forces unecessary ordering between domain DT nodes. To address the above, introduce per-domain 32-bit integer to represent intialization order (aka "init_order") where domain with a lower initialization order will be booted first and two domains must not have same initialization order. For DT based domain creation, new "init-order" DT property can be used in domain DT node to specify the initialization order. The ROOT domain is assumed to have lowest initialization order (aka 0xffffffff). Signed-off-by: Anup Patel Reviewed-by: Pawandeep Oza Tested-by: Pawandeep Oza --- docs/domain_support.md | 5 +++++ include/sbi/sbi_domain.h | 2 ++ lib/sbi/sbi_domain.c | 21 ++++++++++++++------- lib/sbi/sbi_domain_context.c | 17 +++++++++-------- lib/utils/fdt/fdt_domain.c | 8 ++++++++ 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/docs/domain_support.md b/docs/domain_support.md index 82f155e1..655bf474 100644 --- a/docs/domain_support.md +++ b/docs/domain_support.md @@ -39,6 +39,9 @@ has following details: * **index** - Logical index of this domain * **name** - Name of this domain +* **init_order** - Initialization order of this domain. Domain with a + lower initialization order will be booted first and two domains must + not have same initialization order. * **assigned_harts** - HARTs assigned to this domain * **possible_harts** - HARTs possible in this domain * **regions** - Array of memory regions terminated by a memory region @@ -75,6 +78,8 @@ following manner: * **index** - Logical index of the ROOT domain is always zero * **name** - Name of the ROOT domain is "root" +* **init_order** - Initialization order of the ROOT domain is always + 0xffffffff (aka maximum possible 32-bit value) * **assigned_harts** - At boot-time all valid HARTs of a RISC-V platform are assigned the ROOT domain which changes later based on OpenSBI platform support diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h index b6731c04..b35ea99f 100644 --- a/include/sbi/sbi_domain.h +++ b/include/sbi/sbi_domain.h @@ -199,6 +199,8 @@ struct sbi_domain { spinlock_t assigned_harts_lock; /** Name of this domain */ char name[64]; + /** Initialization order of this domain */ + u32 init_order; /** Possible HARTs in this domain */ const struct sbi_hartmask *possible_harts; /** Array of memory regions terminated by a region with order zero */ diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c index af753459..747c346c 100644 --- a/lib/sbi/sbi_domain.c +++ b/lib/sbi/sbi_domain.c @@ -28,6 +28,7 @@ static bool domain_finalized = false; struct sbi_domain root = { .name = "root", + .init_order = -1U, .possible_harts = NULL, .regions = NULL, .system_reset_allowed = true, @@ -537,6 +538,9 @@ void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix) sbi_printf("Domain%d Name %s: %s\n", dom->index, suffix, dom->name); + sbi_printf("Domain%d Init Order %s: 0x%x\n", + dom->index, suffix, dom->init_order); + sbi_printf("Domain%d Boot HART %s: %d\n", dom->index, suffix, dom->boot_hartid); @@ -635,9 +639,14 @@ int sbi_domain_register(struct sbi_domain *dom) if (!dom || domain_finalized) return SBI_EINVAL; - /* Check if domain already discovered */ + /* + * Ensure that: + * 1) Domain not already registered + * 2) Initialization order is unique + */ sbi_domain_for_each(tdom) { - if (tdom == dom) + if (tdom == dom || + tdom->init_order == dom->init_order) return SBI_EALREADY; } @@ -662,15 +671,13 @@ int sbi_domain_register(struct sbi_domain *dom) sbi_hartmask_clear_all(&dom->assigned_harts); /* - * Assign a non-ROOT domain to a HART on first come first serve - * basis if the HART is listed as a possible HART of the non-ROOT - * domain. If no non-ROOT domain list a HART as possible HART then - * the HART is assigned to the ROOT domain. + * Assign HART to a domain with the least initialization order + * where the HART is listed as a possible HART of the domain. */ sbi_hartmask_for_each_hartindex(i, dom->possible_harts) { tdom = sbi_hartindex_to_domain(i); if (tdom) { - if (tdom == &root) + if (tdom->init_order > dom->init_order) sbi_hartmask_clear_hartindex(i, &tdom->assigned_harts); else continue; diff --git a/lib/sbi/sbi_domain_context.c b/lib/sbi/sbi_domain_context.c index 837ff54f..2b504300 100644 --- a/lib/sbi/sbi_domain_context.c +++ b/lib/sbi/sbi_domain_context.c @@ -291,28 +291,29 @@ int sbi_domain_context_exit(void) } dom_ctx = ctx->prev_ctx; + ctx->prev_ctx = NULL; /* If no previous caller context */ if (!dom_ctx) { - /* Try to find next uninitialized user-defined domain's context */ + /* Try to find next uninitialized domain with least initialization order */ + dom_ctx = NULL; sbi_domain_for_each(dom) { - if (dom == &root || dom == sbi_domain_thishart_ptr()) + if (dom == sbi_domain_thishart_ptr()) continue; if (!sbi_hartmask_test_hartindex(hartindex, dom->possible_harts)) continue; tmp = hart_context_get(dom, hartindex); - if (tmp && !tmp->initialized) { + if (tmp && tmp->initialized) + continue; + + if (!dom_ctx || tmp->dom->init_order < dom_ctx->dom->init_order) dom_ctx = tmp; - break; - } } } - - /* Take the root domain context if fail to find */ if (!dom_ctx) - dom_ctx = hart_context_get(&root, hartindex); + return SBI_ENOENT; return switch_to_next_domain_context(ctx, dom_ctx); } diff --git a/lib/utils/fdt/fdt_domain.c b/lib/utils/fdt/fdt_domain.c index 3857831d..a649330c 100644 --- a/lib/utils/fdt/fdt_domain.c +++ b/lib/utils/fdt/fdt_domain.c @@ -330,6 +330,14 @@ static int __fdt_parse_domain(const void *fdt, int domain_offset, void *opaque) sizeof(dom->name)); dom->name[sizeof(dom->name) - 1] = '\0'; + /* Read initalization order */ + val = fdt_getprop(fdt, domain_offset, "init-order", &len); + len = len / sizeof(u32); + if (val && len) + dom->init_order = fdt32_to_cpu(val[0]); + else + dom->init_order = (u32)domain_offset; + /* Setup possible HARTs mask */ SBI_HARTMASK_INIT(mask); dom->possible_harts = mask;