From patchwork Mon Jan 9 08:40:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Chauhan X-Patchwork-Id: 1723203 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) 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=) 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=FPANbaCd; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=lMi8736O; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Nr6qb2zn1z23fc for ; Mon, 9 Jan 2023 19:41:31 +1100 (AEDT) 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=cREgFR2728C/4amwh7RNwsVQFLYZiT07mniVLKowOjI=; b=FPANbaCdQLQCXq VBErCPK8n3n6znbiNbYht1bHHRYXzVH7YkQru7H0li/ciPbebz6yKT/eFshAqY2KAiKakUilNkxqx BZEo2IC/kDm2UW7hrfIVF4zA1TbHDHdKqUCC2PsY21w8dyPbbLINyrX5FsPT2uH9tECdW41bfQmkN JLUPpTQtbWcHiq8OHjnnGkiOey28B/b/to1Ddrn6VgJjvJDSF70Zh5AmUh51bA1RF9QALh9AerSIT YrLk+xqVxDFjxKIguE/MKNdFYlxLNrJZsJ/oMJxPHpCuc2MViq2fY87i19SetIX6QxPCEPgKVM6JL EnaMBikc3aUhd7QvmVzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEniV-000Qjc-4u; Mon, 09 Jan 2023 08:41:15 +0000 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEniM-000Qey-Sb for opensbi@lists.infradead.org; Mon, 09 Jan 2023 08:41:11 +0000 Received: by mail-pf1-x430.google.com with SMTP id y5so5570608pfe.2 for ; Mon, 09 Jan 2023 00:41:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i5B1Trs5jKi2bGa8MuC+RpjGIia+tIWXsx3LebU/tM4=; b=lMi8736OTgs1XE4BldddBCsl8+GpQ9QIXHiTKWcxYgHVjqHKsSQ60/xgSC9azvvImT ttcf+n4quPtthEYP57IJkHgt9zw948Zhd5uiPaRrE4Eg+Uz5Xm6iSOyTobqENPQu4YpK YxFT9slb1Nwyv8NFzqtXZN2nYS4XG9pBS8GPfz/U00XZczFt8NYNseD/NQpmS19Uhmdc 7rwTPBMkG0PZlOBBhTzMGi6Alo7tJc4/IeoP1b+bb3y1rwwld2g+rqUlzPkPQwdEhdrA HnLU2a1V58kqIp9KOpyBLyN5ELPSg58A4sgggT2eaQN6LlQkqUe96E8Pa62BJ3loXagI aW3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i5B1Trs5jKi2bGa8MuC+RpjGIia+tIWXsx3LebU/tM4=; b=kwOLB+2xDEtF6uaya9pU1V0ZEL12FjbpQZ1DFUimVDm50XJz4qvZ0a7HwnzS3deG+q RIYdMhC8r768k9h7L203IIgPqzldM9B23rz+AfWHNUPvUw0FxM26mFMe42HVBjTFfKww VHNq5m4fUqQjbGPRDFWKiVwkERP5wX5QHL1HNpvJPcQ+M95UGV8pdZKEchfrNidHoBVx NN7Q3mjJ2ZiJnMbxBORVL3AQD+9lMUbItlXr7yROFgDdndWXvFnn78rduDP9DDFBh7zH HIQl7IN6mcZOEeNRIM1nltVLVnMFeA53hRKkvzBWOrtFJO3xrBn1dabIkDs59L9n/Hvl t31Q== X-Gm-Message-State: AFqh2krjuJvVCB6sBR/7PgHPlmbAcJncTaHmwSk1Fxb4yLi1m7ZVrxsp LxtRqubuwzfO99Vwm7nxiCNve1O6tA0KSarl X-Google-Smtp-Source: AMrXdXtfZ5/JwV+wdZM9K9LwfIicP+KMSB4cTkQxcqk7LNsouhILT+7ISVayiVA7FxIEPb65cn1vsQ== X-Received: by 2002:a62:e507:0:b0:580:c796:d68f with SMTP id n7-20020a62e507000000b00580c796d68fmr58226558pff.24.1673253664506; Mon, 09 Jan 2023 00:41:04 -0800 (PST) Received: from arcolinux.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id w188-20020a6230c5000000b00581f76c1da1sm5434536pfw.191.2023.01.09.00.41.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 00:41:04 -0800 (PST) From: Himanshu Chauhan To: opensbi@lists.infradead.org Cc: Himanshu Chauhan Subject: [PATCH 1/5] firmware: Split RO/RX and RW sections Date: Mon, 9 Jan 2023 14:10:45 +0530 Message-Id: <20230109084049.31828-2-hchauhan@ventanamicro.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230109084049.31828-1-hchauhan@ventanamicro.com> References: <20230109084049.31828-1-hchauhan@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230109_004109_330959_4CBC71F4 X-CRM114-Status: UNSURE ( 8.72 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) 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: Split the RO/RX and RW sections so that they can have independent pmp entries with required permissions. The split size is ensured to be a power-of-2 as required by pmp. _fw_rw_offset symbol marks the beginning of the data section. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:430 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_AU Message has a valid DKIM or DK signature from author's 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 -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 Split the RO/RX and RW sections so that they can have independent pmp entries with required permissions. The split size is ensured to be a power-of-2 as required by pmp. _fw_rw_offset symbol marks the beginning of the data section. Signed-off-by: Himanshu Chauhan Reviewed-by: Anup Patel --- firmware/fw_base.ldS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/firmware/fw_base.ldS b/firmware/fw_base.ldS index 563ae25..5411bbd 100644 --- a/firmware/fw_base.ldS +++ b/firmware/fw_base.ldS @@ -42,6 +42,14 @@ . = ALIGN(0x1000); /* Ensure next section is page aligned */ + /* + * PMP regions must be to be power-of-2. RO/RW will have separate + * regions, so ensure that the split is power-of-2. + */ + . = ALIGN(1 << LOG2CEIL(SIZEOF(.rodata) + SIZEOF(.text))); + + PROVIDE(_fw_rw_offset = (. - _fw_start)); + /* Beginning of the read-write data sections */ .data : From patchwork Mon Jan 9 08:40:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Chauhan X-Patchwork-Id: 1723204 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) 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=) 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=Zn0zslpw; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=PD8WetMq; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Nr6qc3Gt6z23fc for ; Mon, 9 Jan 2023 19:41:32 +1100 (AEDT) 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=a5ItKh8pGhhGdf4RJMTtoKZRMDgmc5hsIDU5hDLYZHM=; b=Zn0zslpw0SH1Ov e0s+J5PxeM/nHqbqA6v2TrFM8pS7MoLQLhEB9r5fqoHPqt1DhGYYP0wLZSI2N+hApEJPe073Inmuw 1jG5lXpLPo/WG/ZcP/B6JpZG77pkvuE77m4kKCV3mVZmoPUuHDkyK+YYTBW6iNSkGtuClyebj4lkA dl7dcuIyfnRRSBJDqU1Cf14GfKcc6dxB4wik5ASD89/fR6rFnD/hEenG8CLEP4n/FE6Ij9KJQ4Yjo i0lONkoXiM4gBgFJ4JMDGdf+hSNVS4V/dZXvbqi374n921E9+DeloXBKehj7UgXdVJre5+w56Gghm 8SqYU7x6Ep0/g5i6FRTw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEniW-000QkO-5G; Mon, 09 Jan 2023 08:41:16 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEniP-000QfQ-4X for opensbi@lists.infradead.org; Mon, 09 Jan 2023 08:41:11 +0000 Received: by mail-pj1-x1032.google.com with SMTP id o13so4517863pjg.2 for ; Mon, 09 Jan 2023 00:41:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OEtorMxn+tSFRQK6pn/ElhV+eQXHKiSb5Zg3gZcUBkM=; b=PD8WetMqPKvarjHdtDDrjGm3JQQGYztDVVMNph1vNjfbST21OF4TcKR2tuU3G6Rz2U 37nXCbXBy27iWrHFgTC6bqycH8fqETXsQaBz8w/wzWjb+A2xT9ssw/fYoY0UtK+BrlV2 Bdqnmc9LLHQUA2ba8XWeiltKyW6ez1A8Wh58MCgLpRwooukhPssoewW2KfCBP2oPTo72 Ai0CAJsfva+lAxS0/4+SJ1KKpLpsr1DBRj5PC7fL3YnFGwGau5YvSgvYD+eZIddoBd8U dHqZspfEnsD9bMJSwoiPrAZ9YDamamWXh5S2d0t9WKw/u8qXYK32nrW/fBjXYRGR2Q9V 0oXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OEtorMxn+tSFRQK6pn/ElhV+eQXHKiSb5Zg3gZcUBkM=; b=0EH4KKnOmZRBCZaoivP7VZjluHrxkipEWPDP96BWo3SGMLlpUmZTTk/y2QkiaiyKUZ ODQOm1E/2xZXpSsJyAeQZ7gOEmogUTbOWAFnHeD2UVGPyj3yaNUIPHHTad5+CqQKQ7la Lljy36WQmZLvmDsDkUtaOTHSUBIpB5nPK6JwsXeAaNXlsQpvBxDoKLdRsQJAFIHOMfsf Z9wkG6Z1KCaEGuDVEmN1KvWcrDIZrQcNpFcvYYfKo55JqNMLRzReg5doBx8+/KyLlh1M cFhL3aUdT6320WbTs5Ekmnjy7ekPt2H2tbQkmNY8A9sqP7WooMeRQ1p498g7nhRbKae7 1GkA== X-Gm-Message-State: AFqh2kqi7I/c/XSpLT9f3X4+jfw/gJnEDsadjd9tx8LirBCbZxu4JuMb E92aY5CUJmdRbPCr5S3sro5NcixgUvzLtPAbfAk= X-Google-Smtp-Source: AMrXdXupapYFXXNdXInY59zc17a2zUaKkELdr7xMVQHXuRt8kEa/t8I47tVofo+wQy3v9PIznlRZAg== X-Received: by 2002:a05:6a20:93a5:b0:b5:e98a:e2d6 with SMTP id x37-20020a056a2093a500b000b5e98ae2d6mr1216617pzh.54.1673253666778; Mon, 09 Jan 2023 00:41:06 -0800 (PST) Received: from arcolinux.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id w188-20020a6230c5000000b00581f76c1da1sm5434536pfw.191.2023.01.09.00.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 00:41:06 -0800 (PST) From: Himanshu Chauhan To: opensbi@lists.infradead.org Cc: Himanshu Chauhan Subject: [PATCH 2/5] firmware: Move dynsym and reladyn sections to RX section Date: Mon, 9 Jan 2023 14:10:46 +0530 Message-Id: <20230109084049.31828-3-hchauhan@ventanamicro.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230109084049.31828-1-hchauhan@ventanamicro.com> References: <20230109084049.31828-1-hchauhan@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230109_004109_709281_473E8FB0 X-CRM114-Status: UNSURE ( 9.50 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) 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 dynsym and reladyn sections are under RW data. They are moved to the Read-only/Executable region. Signed-off-by: Himanshu Chauhan --- firmware/fw_base.ldS | 41 ++++++++++++++++++++++ 1 file changed, 22 insertions(+), 19 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1032 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_AU Message has a valid DKIM or DK signature from author's 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 -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 dynsym and reladyn sections are under RW data. They are moved to the Read-only/Executable region. Signed-off-by: Himanshu Chauhan Reviewed-by: Anup Patel --- firmware/fw_base.ldS | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/firmware/fw_base.ldS b/firmware/fw_base.ldS index 5411bbd..9a1304e 100644 --- a/firmware/fw_base.ldS +++ b/firmware/fw_base.ldS @@ -30,23 +30,39 @@ /* Beginning of the read-only data sections */ + PROVIDE(_rodata_start = .); + .rodata : { - PROVIDE(_rodata_start = .); *(.rodata .rodata.*) . = ALIGN(8); - PROVIDE(_rodata_end = .); } - /* End of the read-only data sections */ - . = ALIGN(0x1000); /* Ensure next section is page aligned */ + .dynsym : { + PROVIDE(__dyn_sym_start = .); + *(.dynsym) + PROVIDE(__dyn_sym_end = .); + } + + .rela.dyn : { + PROVIDE(__rel_dyn_start = .); + *(.rela*) + . = ALIGN(8); + PROVIDE(__rel_dyn_end = .); + } + + PROVIDE(_rodata_end = .); + + /* End of the read-only data sections */ + /* - * PMP regions must be to be power-of-2. RO/RW will have separate + * PMP regions must be to be power-of-2. RX/RW will have separate * regions, so ensure that the split is power-of-2. */ - . = ALIGN(1 << LOG2CEIL(SIZEOF(.rodata) + SIZEOF(.text))); + . = ALIGN(1 << LOG2CEIL((SIZEOF(.rodata) + SIZEOF(.text) + + SIZEOF(.dynsym) + SIZEOF(.rela.dyn)))); PROVIDE(_fw_rw_offset = (. - _fw_start)); @@ -67,19 +83,6 @@ PROVIDE(_data_end = .); } - .dynsym : { - PROVIDE(__dyn_sym_start = .); - *(.dynsym) - PROVIDE(__dyn_sym_end = .); - } - - .rela.dyn : { - PROVIDE(__rel_dyn_start = .); - *(.rela*) - . = ALIGN(8); - PROVIDE(__rel_dyn_end = .); - } - . = ALIGN(0x1000); /* Ensure next section is page aligned */ .bss : From patchwork Mon Jan 9 08:40:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Chauhan X-Patchwork-Id: 1723205 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) 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=) 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=P5xQ6w6G; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=Ta5pofGQ; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Nr6qd3sYgz23fc for ; Mon, 9 Jan 2023 19:41:33 +1100 (AEDT) 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=KoKyOYC6z5nNZtuC6/Tu3/Ej6NzN2IX/fz9K/IuSveo=; b=P5xQ6w6GZgzES4 irUSTDZf5nWxOB4hTX/WAPHQsdDHTvZ4mUBMKBxNZdLYDeTXrn39fb39Sol4v2pKVlDG+T/LuqV+t eXUwV0GZScz3GvFH/IWj3xSvjcecgNFLte+2QmUsAn3PGsyOqHwE3xACX9Stqwea7XZeqceM/TVDT 977Uv0orOjiaizQaomIArrNngx5fGEorKuIQcyAOQL/tVEzZwCnpJwRKqohAhy1W2jTBV5cM9DjNS Sl2KlNAjAWcIp0Q2odqBfyEaYM5kdwaK0fwc5C2WbzT5HtRdL0rJtZdhwZcU1+pgBRom2ioxfafLj X+uQ3dS1NUJiD57Sdn3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEniY-000QlV-6c; Mon, 09 Jan 2023 08:41:18 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEniQ-000QgG-Vr for opensbi@lists.infradead.org; Mon, 09 Jan 2023 08:41:13 +0000 Received: by mail-pf1-x432.google.com with SMTP id c85so2287202pfc.8 for ; Mon, 09 Jan 2023 00:41:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EXNG2vDxC8kYvVc6ntsEQz12NIoYG9f3VUaGuMoH/1U=; b=Ta5pofGQ7bt8w7p29cpF/y9KNaxDZkPU5KwQeG7Cz+d94+aSlPaGGC5YhQ23LHXGLr yVC3o++EgF56ZSAAVfr7Oy/LCevIKcRfaV8hUWI6NfIhlDf/jLtlbc3ZOrM9IDdGJP2E Oln1X/QjHprM8QlI1GiL0o2kSNQ2njNzYpFUKZTqwj3AusdYsUIoDNdgHZfYeYBbYSvJ jX/IIwZcSI5ElVsooVtS0uzzeTJij4VhXQqDEQP6svbf8mSV11kRgl0gDXAEmAFl1h8f HFth5kVDjlnWOExTouvnvjCNc+szgpdaPydG7pIdiOHSl4q/uzFbS2I8TFlqv4SWyb6c xWGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EXNG2vDxC8kYvVc6ntsEQz12NIoYG9f3VUaGuMoH/1U=; b=5oRN+rxyjdhQYibPIXBzY3PF1AcMNbw4EWMTEOKBlsLISAyBEYOybhw0SuZRBdKml2 jMPM5ujzFv0irBTg1MIwd9euzo6A9LazDe5iILeRzJrkFMNz1ftIB08fTgQMopN+Uxq+ pt0jUR3HIdy0L25m1RgDS5J2jKTrDn1fhkxD/Z4SzwZu86FBXHD5o1wUwxotbJVKfQeJ 5psnRljR9fX219bbu5SnR+pVNd15nV5zzEJGAIh0liN0eBNvKzT5iBASHfQe17x50Y0o gSeSfXmrJ03wfpqmKDSN24LQyMrAQQZyjoRL8uoE7sol0duxWjKxKtuDxxULzwNQuTZm Ncxw== X-Gm-Message-State: AFqh2krb+hI8LL8gM87mh2z2ENsLYClZ+ycnwAE/Qll2T/NbFAI0yuow bd08nB/et+DqntzOEDE1OliISWe9uFaU6f4g5UM= X-Google-Smtp-Source: AMrXdXu4QOrWlkXTcej0DIsuvokkI76XQ/3HL8bHaLRy47uZt19GOwqE6uQrF6sl5hDcIv6L6lkPLA== X-Received: by 2002:aa7:9ac8:0:b0:588:4e84:5b67 with SMTP id x8-20020aa79ac8000000b005884e845b67mr3752534pfp.30.1673253668850; Mon, 09 Jan 2023 00:41:08 -0800 (PST) Received: from arcolinux.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id w188-20020a6230c5000000b00581f76c1da1sm5434536pfw.191.2023.01.09.00.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 00:41:08 -0800 (PST) From: Himanshu Chauhan To: opensbi@lists.infradead.org Cc: Himanshu Chauhan Subject: [PATCH 3/5] firmware: Add RW section offset in scratch Date: Mon, 9 Jan 2023 14:10:47 +0530 Message-Id: <20230109084049.31828-4-hchauhan@ventanamicro.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230109084049.31828-1-hchauhan@ventanamicro.com> References: <20230109084049.31828-1-hchauhan@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230109_004111_085861_81F7D12B X-CRM114-Status: GOOD ( 10.60 ) X-Spam-Score: -0.2 (/) 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: Add the RW section offset, provided by _fw_rw_offset symbol, to the scratch structure. This will be used to program separate pmp entry for RW section. Signed-off-by: Himanshu Chauhan --- firmware/fw_base.S | 5 +++++ include/sbi/sbi_scratch.h | 24 ++++++++++++++ 2 files changed, 19 insertions(+), 10 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:432 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_AU Message has a valid DKIM or DK signature from author's 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 -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 Add the RW section offset, provided by _fw_rw_offset symbol, to the scratch structure. This will be used to program separate pmp entry for RW section. Signed-off-by: Himanshu Chauhan Reviewed-by: Anup Patel --- firmware/fw_base.S | 5 +++++ include/sbi/sbi_scratch.h | 24 ++++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index 3f622b3..ce1f782 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -298,6 +298,11 @@ _scratch_init: sub a5, t3, a4 REG_S a4, SBI_SCRATCH_FW_START_OFFSET(tp) REG_S a5, SBI_SCRATCH_FW_SIZE_OFFSET(tp) + + /* Store R/W section's offset in scratch space */ + lla a4, _fw_rw_offset + REG_S a4, SBI_SCRATCH_FW_RW_OFFSET(tp) + /* Store next arg1 in scratch space */ MOV_3R s0, a0, s1, a1, s2, a2 call fw_next_arg1 diff --git a/include/sbi/sbi_scratch.h b/include/sbi/sbi_scratch.h index 40a3bc9..2966188 100644 --- a/include/sbi/sbi_scratch.h +++ b/include/sbi/sbi_scratch.h @@ -18,26 +18,28 @@ #define SBI_SCRATCH_FW_START_OFFSET (0 * __SIZEOF_POINTER__) /** Offset of fw_size member in sbi_scratch */ #define SBI_SCRATCH_FW_SIZE_OFFSET (1 * __SIZEOF_POINTER__) +/** Offset (in sbi_scratch) of the R/W Offset */ +#define SBI_SCRATCH_FW_RW_OFFSET (2 * __SIZEOF_POINTER__) /** Offset of next_arg1 member in sbi_scratch */ -#define SBI_SCRATCH_NEXT_ARG1_OFFSET (2 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_NEXT_ARG1_OFFSET (3 * __SIZEOF_POINTER__) /** Offset of next_addr member in sbi_scratch */ -#define SBI_SCRATCH_NEXT_ADDR_OFFSET (3 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_NEXT_ADDR_OFFSET (4 * __SIZEOF_POINTER__) /** Offset of next_mode member in sbi_scratch */ -#define SBI_SCRATCH_NEXT_MODE_OFFSET (4 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_NEXT_MODE_OFFSET (5 * __SIZEOF_POINTER__) /** Offset of warmboot_addr member in sbi_scratch */ -#define SBI_SCRATCH_WARMBOOT_ADDR_OFFSET (5 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_WARMBOOT_ADDR_OFFSET (6 * __SIZEOF_POINTER__) /** Offset of platform_addr member in sbi_scratch */ -#define SBI_SCRATCH_PLATFORM_ADDR_OFFSET (6 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_PLATFORM_ADDR_OFFSET (7 * __SIZEOF_POINTER__) /** Offset of hartid_to_scratch member in sbi_scratch */ -#define SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET (7 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET (8 * __SIZEOF_POINTER__) /** Offset of trap_exit member in sbi_scratch */ -#define SBI_SCRATCH_TRAP_EXIT_OFFSET (8 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_TRAP_EXIT_OFFSET (9 * __SIZEOF_POINTER__) /** Offset of tmp0 member in sbi_scratch */ -#define SBI_SCRATCH_TMP0_OFFSET (9 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_TMP0_OFFSET (10 * __SIZEOF_POINTER__) /** Offset of options member in sbi_scratch */ -#define SBI_SCRATCH_OPTIONS_OFFSET (10 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_OPTIONS_OFFSET (11 * __SIZEOF_POINTER__) /** Offset of extra space in sbi_scratch */ -#define SBI_SCRATCH_EXTRA_SPACE_OFFSET (11 * __SIZEOF_POINTER__) +#define SBI_SCRATCH_EXTRA_SPACE_OFFSET (12 * __SIZEOF_POINTER__) /** Maximum size of sbi_scratch (4KB) */ #define SBI_SCRATCH_SIZE (0x1000) @@ -53,6 +55,8 @@ struct sbi_scratch { unsigned long fw_start; /** Size (in bytes) of firmware linked to OpenSBI library */ unsigned long fw_size; + /** Offset (in bytes) of the R/W section */ + unsigned long fw_rw_offset; /** Arg1 (or 'a1' register) of next booting stage for this HART */ unsigned long next_arg1; /** Address of next booting stage for this HART */ From patchwork Mon Jan 9 08:40:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Chauhan X-Patchwork-Id: 1723206 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) 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=) 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=TwgMLHgP; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=KBClp6KX; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Nr6qf6HjKz23fc for ; Mon, 9 Jan 2023 19:41:34 +1100 (AEDT) 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=m3A0BhbFhyE0jXwvAz4qCP4vuTXdIBe61ZbzGs4+4d8=; b=TwgMLHgPfsVuI6 18lzSUfT1a+7Bxpzc7lhKWRJwCKlPaXXoBFhCA6ZEnXOdV69Y5FikTjUGd+Zs/1WgIdEmnHdMQZiA dnoPEIs5hsvol6kI6RzkLlFWHOdyz9y/RYdNEBkihUPXQHCph2F0F9HyC90iq9JR1Yv4qclBXhSJp x/GaIf6VGzs6pEN4/L7iXBnoAG9a+Lql3V2l2fghaN1HpveouWfzcDqe/du5FKlOJokYGoRecBhy1 PnJM4SP6Znpv2U9yy/EqEKhwFfT+MOqa4++njVTEajrTaTnt6XTQD+6taFqWxj2qp+/QhQ2rqZvIQ 4gJfdY2GTrJKtYna5uyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEnia-000QnQ-Ft; Mon, 09 Jan 2023 08:41:20 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEniU-000Qhk-3l for opensbi@lists.infradead.org; Mon, 09 Jan 2023 08:41:15 +0000 Received: by mail-pf1-x42e.google.com with SMTP id c9so5568059pfj.5 for ; Mon, 09 Jan 2023 00:41:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fCXrZY3AGa9S2T42DjYTFvXnMbNMQROYsSAmQ8uAMpY=; b=KBClp6KXLXbxUAofd9L+eGpofN+ESuOwIR43i+BadbddFuJ14ONsDn1K5XPKE6o9eg vxTZSUk4OInBGUCN2bzgPgpxckUIR6n3EWWHbZeVyp4LUmg3euGmAtUJT8Ka06nBoc22 m0BtaN0RRq6FzCLkPmezAotWk9zIvqXzLDyRzSM1gzV+uBD4lZpy88nX9lw8roSOUDQp CkBgO8K+IZt6JxbuNQzgh+O32eLYdf4k7ZAdTYEDxaHx5E3D/9Ry3VT1mhVr50nvKDF1 gmm+aEZcoYk9DzWgEc2nt7iZIAo6clXqUOgjJ68dKbFYAXDt0rtiTcrlF6xY7u/R/5XC 4UQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fCXrZY3AGa9S2T42DjYTFvXnMbNMQROYsSAmQ8uAMpY=; b=e+hQFMdYZGKD8F2dsCO92YhbvycvmjQQVQ6uzXf26TLTSd8xc5tqTvqk6UMwixbnRf Xkn45ld8XGdTDT7BpDSooG5HP/Gtv2QWe5x/YBCfC9sooFeXLGytbSzi4Q3z15cMz+qA JOMlkLkxc8q2iBjGFoQTw6csvOwwv/DX4u6Q6+l7ngiPQRSbZIl5ZiG5fKNFCij84elV adDjftDa4C/LF2My5JTu2KwL2tOvj4YqZpNusQKjuHiq2MmpvWYdtmM3vdG46+rhx7ZA UkNvcddlJbP4Cdx0qZHRxsLMq6DQRbsLCH1+PBWw7nvnsOE2wipWxU2HQYRShlRPHdqX Q48A== X-Gm-Message-State: AFqh2krbntv9eSvWsMtjPSDWoPTYBcpX6tbLKBiXx5AfKjlv0Q5Q3yqP CFCcVdZua18regyWxRecUd02/nrODwZazqwA X-Google-Smtp-Source: AMrXdXtG7oHByJSZseku/vjfPTRvyDju7fPGIA15Ra4/p+h8TeYH9gLp2On1N0Lq8bLz67yl3/KNiw== X-Received: by 2002:a62:ee0e:0:b0:578:f6f:efab with SMTP id e14-20020a62ee0e000000b005780f6fefabmr69737430pfi.11.1673253670859; Mon, 09 Jan 2023 00:41:10 -0800 (PST) Received: from arcolinux.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id w188-20020a6230c5000000b00581f76c1da1sm5434536pfw.191.2023.01.09.00.41.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 00:41:10 -0800 (PST) From: Himanshu Chauhan To: opensbi@lists.infradead.org Cc: Himanshu Chauhan Subject: [PATCH 4/5] lib: sbi: Print the RW section offset Date: Mon, 9 Jan 2023 14:10:48 +0530 Message-Id: <20230109084049.31828-5-hchauhan@ventanamicro.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230109084049.31828-1-hchauhan@ventanamicro.com> References: <20230109084049.31828-1-hchauhan@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230109_004114_270369_166D26C3 X-CRM114-Status: UNSURE ( 7.11 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) 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: Print the RW section offset when firmware base and size is being printed. Signed-off-by: Himanshu Chauhan --- lib/sbi/sbi_init.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c index 259a191..e353c33 100644 --- a/lib/sbi/sbi_init.c +++ b/lib/sbi/sbi_init.c @@ -108,6 +108,7 @@ static void sbi_boot_print_general(struct sbi_s [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:42e 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_AU Message has a valid DKIM or DK signature from author's 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 -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 Print the RW section offset when firmware base and size is being printed. Signed-off-by: Himanshu Chauhan Reviewed-by: Anup Patel --- lib/sbi/sbi_init.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c index 259a191..e353c33 100644 --- a/lib/sbi/sbi_init.c +++ b/lib/sbi/sbi_init.c @@ -108,6 +108,7 @@ static void sbi_boot_print_general(struct sbi_scratch *scratch) sbi_printf("Firmware Base : 0x%lx\n", scratch->fw_start); sbi_printf("Firmware Size : %d KB\n", (u32)(scratch->fw_size / 1024)); + sbi_printf("Firmware RW Offset : 0x%lx\n", scratch->fw_rw_offset); /* SBI details */ sbi_printf("Runtime SBI Version : %d.%d\n", From patchwork Mon Jan 9 08:40:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Chauhan X-Patchwork-Id: 1723207 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) 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=) 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=j/Heg3q0; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=MiVwAFVR; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Nr6qk5nhRz23fc for ; Mon, 9 Jan 2023 19:41:38 +1100 (AEDT) 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=2rNeQirHMgWvLREkyWrbQsg3GgLmYhWryAFHqh7id/w=; b=j/Heg3q0IK8oHR 9tR0uo4aV1KIhem89rtCxOPUG61wlTLrULnfZdz3YMR6SiEgISFi9lYcNfq8bvByW+abYVNTJO9nY M3O4leqqv7eVXtRMQp2SvanuKuDdO4QUeJlK5gqhAVOOP0JW0Q9MwG9w1a1laTmHKQm15tSfBOohr 93sFZjkTE5E1wd06abvHv3MRjQYp1i5n0gpfGfw3F9mH2T7gLzLDJWUryGU6hoPtwF0fipUe0VdGr hp5/RoXHoy1FwIlfm+BGj/rGT2BsYwJkd1JpBelXsTsDvK2gUbfGoOFaVJuNLDIyvrn8oY3JmB/Is rEGv6g1Nwvnhaolq4yBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEnie-000QqK-9u; Mon, 09 Jan 2023 08:41:24 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEniX-000Qik-02 for opensbi@lists.infradead.org; Mon, 09 Jan 2023 08:41:18 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d3so8735842plr.10 for ; Mon, 09 Jan 2023 00:41:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fMt3YRZPDKTq5EAqANqVimFBvtXCfqDWjPd8/rHIQuY=; b=MiVwAFVRruwPcz4V+nyFMRP11UQBjgTkkfDoR6Ua823sYlSKDI6zs+i/EENCnBnIJt fDxxomLeHKgm6uFnu3gygQ7V9dx8JmmQ/NUvTIeWZYA0cY6MqxK+V4NjzHr9DPMBFtOq NePcgtxHFOs9fUuOe/ccmZ03v982o3GJsNVnoUrtmXtAUKzM9aqvvLpaMD5r9JF2RyL2 sDx4pY3db6CqAq/hwrGR8ybKIn+Bk9taH+ZhP9oA2hB/cymb/FQzIB+rZVsSafCxFGJ6 1oiarbEsVvfjb720zC+aoWbV7bQSXshyPsm8Yqw4z9JeKkEAoD0Fh/nB8qijcyFk6Vlc EmoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fMt3YRZPDKTq5EAqANqVimFBvtXCfqDWjPd8/rHIQuY=; b=Ys/fhau6duQ84RWhrh11+eo9Ui6lqjEtO9IS7oXytxO2PVoAQxbW2OzRYWMCHXpVpB Xut/l7hHjHKfj7c6GZpacE2PXBcrExaO+YtFs4jtWih0xEyBAcq8fl0Jyc7W2e4qB7Og ZUh+Jlez+WR7rxynuzxvHkw6tdS/464HXs79m1UfjC+d8BH6RIb5hnU4sYJdb090DkOo tSuKFkmEeTmHjpUWxnL47LKnO/7Wy+FCIaitIH2cxGRVJmVc4wx3NocahEk9awfWmse4 ML32TpwwHBOCWTvDXwXWq/xsXa4TEzEGxGIpDFwWlC8sepESX6SliqdZBvo47Rr3QIqy fSHg== X-Gm-Message-State: AFqh2kriCMGA5e8+6UKHo36ZU69QqQxyR72JLmnKr1lzLqoOe+lvdTYN FxtPC9JI8M6vva5VRsZApHRGN6TdH8nlaUY44Qk= X-Google-Smtp-Source: AMrXdXuBqNqhVWQqD++47nLK+fmmhMt0nBjHStmB/rIQrO72MrE0mZGZYXfabeFXzEmy3z2TVWhrWw== X-Received: by 2002:a05:6a20:c508:b0:af:82aa:49e with SMTP id gm8-20020a056a20c50800b000af82aa049emr62099145pzb.2.1673253672832; Mon, 09 Jan 2023 00:41:12 -0800 (PST) Received: from arcolinux.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id w188-20020a6230c5000000b00581f76c1da1sm5434536pfw.191.2023.01.09.00.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 00:41:12 -0800 (PST) From: Himanshu Chauhan To: opensbi@lists.infradead.org Cc: Himanshu Chauhan Subject: [PATCH 5/5] lib: sbi: Program separate pmp entries for text and data Date: Mon, 9 Jan 2023 14:10:49 +0530 Message-Id: <20230109084049.31828-6-hchauhan@ventanamicro.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230109084049.31828-1-hchauhan@ventanamicro.com> References: <20230109084049.31828-1-hchauhan@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230109_004117_093392_B8165BD9 X-CRM114-Status: UNSURE ( 8.70 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) 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: Add two entries: 1. TEXT: fw_start to _fw_rw_offset with RX permissions 2. DATA: _fw_rw_offset to fw_size with RW permissions These permissions are still not enforced from M-mode but lay the ground work for enforcing them for M-mode. SU-mode don't have any access to these regions. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:62d 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_AU Message has a valid DKIM or DK signature from author's 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 -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 Add two entries: 1. TEXT: fw_start to _fw_rw_offset with RX permissions 2. DATA: _fw_rw_offset to fw_size with RW permissions These permissions are still not enforced from M-mode but lay the ground work for enforcing them for M-mode. SU-mode don't have any access to these regions. Sample output: Domain0 Region01 : 0x0000000080000000-0x000000008001ffff M: (R,X) S/U: () Domain0 Region02 : 0x0000000080020000-0x000000008003ffff M: (R,W) S/U: () Signed-off-by: Himanshu Chauhan --- lib/sbi/sbi_domain.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c index f6addc4..8730c2c 100644 --- a/lib/sbi/sbi_domain.c +++ b/lib/sbi/sbi_domain.c @@ -638,11 +638,18 @@ int sbi_domain_init(struct sbi_scratch *scratch, u32 cold_hartid) const struct sbi_platform *plat = sbi_platform_ptr(scratch); /* Root domain firmware memory region */ - sbi_domain_memregion_init(scratch->fw_start, scratch->fw_size, - SBI_DOMAIN_MEMREGION_M_RWX, + sbi_domain_memregion_init(scratch->fw_start, scratch->fw_rw_offset, + (SBI_DOMAIN_MEMREGION_M_READABLE | + SBI_DOMAIN_MEMREGION_M_EXECUTABLE), &root_fw_region); domain_memregion_initfw(&root_memregs[root_memregs_count++]); + sbi_domain_memregion_init((scratch->fw_start + scratch->fw_rw_offset), + (scratch->fw_size - scratch->fw_rw_offset), + (SBI_DOMAIN_MEMREGION_M_READABLE | + SBI_DOMAIN_MEMREGION_M_WRITABLE), + &root_memregs[root_memregs_count++]); + /* Root domain allow everything memory region */ sbi_domain_memregion_init(0, ~0UL, (SBI_DOMAIN_MEMREGION_READABLE |