From patchwork Mon Oct 26 23:02:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 11858967 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BD05697 for ; Mon, 26 Oct 2020 23:03:54 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1C98220708 for ; Mon, 26 Oct 2020 23:03:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="td8C3JZ+"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="nGr05oxD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C98220708 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wX4g/n6Z4vxFkVtoaai8oo26/fP6F8kk0A+XsmapyyU=; b=td8C3JZ+t42jYE9JYqpuhrzG4 mf/Cyo+A34YAryyjJ0WDmJm+tlQtkguSCgdrAi0i9m5xvsxFET+HAp02yWKh4dNV1x1FSRYvzS4/h eLBjlmfQ3qmmCW7AOqwHU0JtVkosQDjljJPFBvpo9PPSGHRXUAwC8L1Jdk9jTxselPR8xSnRWZiJz PM2YlEJvLc7D1eMDhuD3w16L86NeGguAdgOVRf9zRyy1pdWtr6zLzXIcpObNv1LnfQ557Idrq83EV dRnIUFsIvavBFOWvmCvPeoscvnVkj1crBbLS7OrJUVO3/OU0WFY9zDvp3RcFq+dTxdqVptvB17q95 LjIWwpkyA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXBWV-0004Hv-KO; Mon, 26 Oct 2020 23:03:31 +0000 Received: from esa6.hgst.iphmx.com ([216.71.154.45]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXBWS-0004FU-Ay for linux-riscv@lists.infradead.org; Mon, 26 Oct 2020 23:03:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1603753408; x=1635289408; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Qmlk0Pnoc73PLeMzxCGZ41KUAZ0XJ8ZZaWUmbVJfPT0=; b=nGr05oxDAK6SRe7L7o1giKU1GJuN/1wDt6UpyPcYMwzGiDbNCVn3Jas8 C7rWDC0lAKjCVjADONzoQTYpDq5AUGTNYO+dhqbDNJBsApSIv8jvsg1ZL RU3/nobD5FMZ2k3NJwx1BEde/T9oy5Gfq5OThiRZwe6cSGSoKCH+WXQda 2kPPEDzScTwjpc2hMdq7+reRiFHvtVgaBg7FM4IXejGhxVN0SwEsVG6z2 o3SSsreUZvNH8XtK83CNdDidTNESY/VNJHnP7lt23/8LIe6fgXwhVjC+g A6+Cml40M8I34uazxz9OngDliKt61AZr1YuXRQsOAfQ+GpvwabO8ZjIWp A==; IronPort-SDR: JybhKPbwUi/q9fGONsYOeF/38aYwXWBa5uJtb/Y1EvUxqi+u/0Y2wm/lhLJgB4UR2aiwBOv4vW l3ApnDplRsZZx+azT1MoIzF+XCBslSC+ay04xht2qVX7bx3MSjjOIEnmE86rzQFSgx+GoEkQRs RttASlhJq4ZZ8RsyaRJRI0uxRXOmxkoajSiY5dMfebzmp7PTLBY84j8c1WzH28wekiXAwbmUB1 H6hF2AahkCfeVbWPNAIjPwy/qWb3Fe52LbS3baXCDuiY0fjR3gAtZFfc4CTknO2ITlDcxRbIbq QtI= X-IronPort-AV: E=Sophos;i="5.77,421,1596470400"; d="scan'208";a="152152906" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 27 Oct 2020 07:03:23 +0800 IronPort-SDR: Tpcus0rX16e4qgtbXcdZdBeFOG1T6Zg8N83jXFLUk3LPYmFifOthq2plK4SHViNbDmZQ6i1Lh8 LUQCBq6AtyWkG4vl1cO1s/n8422erEiTSRrgtK60jzcY35aOrbaNASElmyzB+XB0rYFn7/C45Z qyoJhhP2uu+D+bCiyp8yea7M+ZZg15R1jhtXx0s7WGu26muiQfQAHWRe29m/cxwIsTbloNQkx9 5jgejPdPMcAg6jW+VZNpy83oy9KALuxI6bnHbH+1nTUXijsxw1AyV1pZGy1wh23Gg+xqL7/VuT ZZ9sOmrtOa+0MTbHhXA4fcfz Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2020 15:48:34 -0700 IronPort-SDR: w0qKrqk4Ps76VXo2fhQqnJ3FzMjkvDA5n76UhstySma3ZkkQkkND11NhJZJe1RlXHu/OQkarV/ 5eJJS29Zjj//2bfffUYVZXW2/yuSD0isOWFHbB8RAWw1+v7/ODIlLVksfre4BHHKG/C4su00sv EAC/XmNixR8peOtynxZ0tW4ZofnRxUZ5ok6zjykyuVEQPSkyAFY4IZSWqNz+XVT+JZAK6I8bpi YWP1fNPizwdXJD1KYcY1PiwAqN04YYwkFs6RUTz+WYH+vwTMz3OLF7cwaI9wldwepnoJKem0cx 6Ho= WDCIronportException: Internal Received: from 8223p12.ad.shared (HELO jedi-01.hgst.com) ([10.86.60.110]) by uls-op-cesaip02.wdc.com with ESMTP; 26 Oct 2020 16:03:24 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [PATCH v2 1/6] RISC-V: Move __start_kernel to .head.text Date: Mon, 26 Oct 2020 16:02:49 -0700 Message-Id: <20201026230254.911912-2-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026230254.911912-1-atish.patra@wdc.com> References: <20201026230254.911912-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201026_190328_503890_B35AEB06 X-CRM114-Status: GOOD ( 13.15 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.45 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Albert Ou , Kees Cook , Anup Patel , linux-riscv@lists.infradead.org, Atish Patra , Palmer Dabbelt , Zong Li , Paul Walmsley , Greentime Hu , Andrew Morton , Borislav Petkov , Michel Lespinasse , Ard Biesheuvel , Mike Rapoport Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org Currently, __start_kernel is kept in _init while _start is in head section. This may result in "relocation truncated to fit error" if _init section is moved far from head. It also makes sense to keep entire head.S in one section. Keep __start_kernel in head section rather than _init. Signed-off-by: Atish Patra --- arch/riscv/kernel/head.S | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index 11e2a4fe66e0..45dbdae930bf 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S @@ -177,7 +177,6 @@ setup_trap_vector: END(_start) - __INIT ENTRY(_start_kernel) /* Mask all interrupts */ csrw CSR_IE, zero From patchwork Mon Oct 26 23:02:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 11858963 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E41514C0 for ; Mon, 26 Oct 2020 23:03:51 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 12B3620780 for ; Mon, 26 Oct 2020 23:03:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="R2N4oQv0"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="JXSoMBF4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 12B3620780 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jItsVKgw3M8EfidQQEWfLINsB65ulKh31mJBLTzxhDI=; b=R2N4oQv042pLH7TrdlwNl7i50 JjJy5OvLFC7t//03XjlRdVlWhM7FNziOhNkUx4TR4LRsdhYbQzg1uMxn7yAmZXSXldhIR6W2JsZTO jEOLLZl8TALQpLU/nc9Hx27O2pnp9vVLtXNjp0bi1hXSf09zSdDG99wlmmlgTwsxi58Z8opCAtLlc b5eYKGc/KQEhrPrF8/K3XPpKjb/ubPyDnL4Pe2wxp1arN3ruor691TL7rSFM9u9RbJUiSaE0C4H52 +5ywoRk22VlNHevpvSo7+Ciak7INBHIQGNvR6n69NNMsPvEHvhzlw/63bQ/dm8p6jMNjN6vCogORd SDruDBTMw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXBWX-0004Ij-0J; Mon, 26 Oct 2020 23:03:33 +0000 Received: from esa6.hgst.iphmx.com ([216.71.154.45]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXBWS-0004G3-NQ for linux-riscv@lists.infradead.org; Mon, 26 Oct 2020 23:03:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1603753408; x=1635289408; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AVRSSDssQdWbrcRKwBjC+hUtmkwJEL8J+eqHnYnc5QE=; b=JXSoMBF4ncwPVXLxewMSTeYsKp0BzDGS31RbupMBJvpJXzJAd/M1iJmL TBSJVfuyzHcCdd1Il/SovevTs8tWGJHiD5H6/jgM9WngeEiBJfRRrAJEi zz2z/CTcvEF8uUNS/NeXxi9zHprzolNuwagt8HIJQ4im6++Z+V4MYBBFa rIwOLsRyNRuPQd+uavq+ecYDaII6BW0AQgMPlbBFs20+h4l9ug/5r8lvq vkaGEWWmHJy+Y7uFf/H59nyE+YyVgl5VWIXxeq+lTsBLThebrhcfNR5rF mX+GKYLwKesukjd5kivkf/O4bChtj+Zk5mjygV0JXnu8/qKTgdKGgFb2c g==; IronPort-SDR: 4YNJctnRQh5CAun/n5enQjM7oquvPrOE3nkGFW+C5QqyuTdTfMuPC9ObswJdNtZwfXOZSP5M47 iBPtDJ5kPm5b5SYNOuUKAQ4oE8q8nZ2FxIJT8P6gv9OeHvvG5/KH6gbbwAscyn4o7xOmg7CKr0 jtoKxdwABk51IwBt/KNR8GAxr+yFheq2GxCKokyowKQ7NR10DGS87oI72liz3W2KnjsAvP2g2P zQWDZ1IVj6vcGosiDETTFL931i534FP9dlQ6Qj75JQ8WbRCsmrMJkEqLHGdpQpPCOjvKI/c+F5 vTk= X-IronPort-AV: E=Sophos;i="5.77,421,1596470400"; d="scan'208";a="152152907" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 27 Oct 2020 07:03:24 +0800 IronPort-SDR: rJJ/C8JZke0ThawF2PuVIjlUTsSDKbnB73s5tnzsxw/p0QX5zEUP6q14uvBl6dU4RoaituDCkX n8z2GJl3XoFXVFB9aMQAACJSppt4l3VQkYp+g4VAc9icZSGARojUqMHmfIZ2GUtB9AoDv5tyj0 q2xQFgoW//H8fhLERqeSoNYn04PByFAqa6rpWjZc2LLmNIyjNFqnHY5Pt/73yZyqdvLYuwrNUC olBFQjlaaXPsankbmZBSYN4NJX37cZjcNTKQ2CpkOEMM+CinKrHXsShQEx6J5FIysSY33/fvhQ ypYbSqAvYJ5rr0SpmaSNGvdH Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2020 15:48:35 -0700 IronPort-SDR: 3Ij9aVJeppLgiNBWU3i6/X2lSE43Hhk1vz4ATQcxpjVCxcKhKrhmo10TYjsLHqnNpODk0WtNen Jk3krrwCqPcL89Wud7ibOl0NwE8tiPXGwsV+VOBu7+XKdtCGk/wxHi26nHu4oq3DgH1BoSgD/M yerK255lPug90GLaMc/tBilGkgTn2lyb38VH4Cd9zyBbfIniEjmkrpqFWHyXEDr+ZTPAFpzKMm x+t6xCJh33r7HlknIojBzHJXHJZ+dw0Lj9+d9N04W6lg2IfrWFFKMUVNhjjU6p4QVZ/yqZzPjo I/U= WDCIronportException: Internal Received: from 8223p12.ad.shared (HELO jedi-01.hgst.com) ([10.86.60.110]) by uls-op-cesaip02.wdc.com with ESMTP; 26 Oct 2020 16:03:24 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] RISC-V: Initialize SBI early Date: Mon, 26 Oct 2020 16:02:50 -0700 Message-Id: <20201026230254.911912-3-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026230254.911912-1-atish.patra@wdc.com> References: <20201026230254.911912-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201026_190328_882682_FE50A426 X-CRM114-Status: GOOD ( 12.31 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.45 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Albert Ou , Kees Cook , Anup Patel , linux-riscv@lists.infradead.org, Atish Patra , Palmer Dabbelt , Zong Li , Paul Walmsley , Greentime Hu , Andrew Morton , Borislav Petkov , Michel Lespinasse , Ard Biesheuvel , Mike Rapoport Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org Currently, SBI is initialized towards the end of arch setup. This prevents the set memory operations to be invoked earlier as it requires a full tlb flush. Initialize SBI as early as possible. Signed-off-by: Atish Patra --- arch/riscv/kernel/setup.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index c424cc6dd833..7d6a04ae3929 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -89,6 +89,9 @@ void __init setup_arch(char **cmdline_p) pr_err("No DTB found in kernel mappings\n"); #endif +#if IS_ENABLED(CONFIG_RISCV_SBI) + sbi_init(); +#endif #ifdef CONFIG_SWIOTLB swiotlb_init(1); #endif @@ -97,10 +100,6 @@ void __init setup_arch(char **cmdline_p) kasan_init(); #endif -#if IS_ENABLED(CONFIG_RISCV_SBI) - sbi_init(); -#endif - #ifdef CONFIG_SMP setup_smp(); #endif From patchwork Mon Oct 26 23:02:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 11858961 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E03AC697 for ; Mon, 26 Oct 2020 23:03:50 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E26520780 for ; Mon, 26 Oct 2020 23:03:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="xYC8Kiam"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="IGlvH/He" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E26520780 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LLvjP6UUF+mN2NFHQ/w8mCLk894u/K6BT448BmhIzQ4=; b=xYC8KiamK0TAM3BY6T9hRqDcY wB95sKdyXf2pP404bJ28keqaeUu59O9F12gNLiMlaDSXue16RKAyMMcv91I0NOptDVGZZsOEC5q5e zF2nqG23tJt41TlS7tm/muslXV3klrPXdtdWyMWbNMn5yzKEUozzBfqDJ8/l4J5RI09A3eI3N2iHd rKoweCxhcX3fgQwwHpcmS+lWa+zvBMr4TDQJpKG3IbWMJiMuc1HwIBfoIVJNE/S0CaH4aFslFFYWV dNwCUzN/Y2iQdsb0gxaLHWXD8duKjsagaZj0Pubwqjvz8RjdfdzyRVOA9z7oOSvRWik1T2Q/doFJo SsgbTSlNg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXBWY-0004J6-7l; Mon, 26 Oct 2020 23:03:34 +0000 Received: from esa6.hgst.iphmx.com ([216.71.154.45]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXBWT-0004FU-At for linux-riscv@lists.infradead.org; Mon, 26 Oct 2020 23:03:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1603753409; x=1635289409; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rpPh1ri27/mV4Lq6GihXSvX59Cmyy4U53NNqLUWVVFg=; b=IGlvH/HeG+LtRaV9YRN/VJ92x3cba2Xbt5IlgvhW6e+2kqLjoheazKa4 sW1k4tE7X3IClbO8GZrCFtEWXWaw9Z10Up+X6W49lJYIho/4KKBhLxPr2 +SCivaneKgpreYsC5Y8azdPya3U/n+E6tRaDB0Ng+h9KlEA4yLVQqFKuW 5EV34s13VQxzRapuie7tGx1zyifO+6Q5LDaThml/ORK27gZ6YyBj0KtL6 GHRilGu/kY2wjPWoyrDcf4iHq4r9f1cDqC8idZ7XZfadax/iMkDzWSvxc h3S4iEtcZS0Q5No2RWoGmOeTp52XEQEbzIpu4vPsmBPYFAqNY7Yvtel/0 w==; IronPort-SDR: upmBvvWfa2b8MmYHtzqu/BqkOl1YAZk4qwb3OWmRVkBz8Q8KNLXxZyJtY64PG/zF08rvh/1ZYP eovKyM4rqIXsWEQeZSixcDrHE288ygjSxu/f+cXPkVfHxCPMN9tpkTqQgBIfsHe8Y0BHaCOc8/ H1knVJMdHIOeCfezAL5il2HBu/Vym8HSP4WMEa6m622CDWZS5oefiHvEmWwI65GZcaPoKObN4B GJY7amcMkWsk0AGmo7dnQY0jxcqcEaGcsiKs8/iV8DsGM6MhpQ3Cgu/fZbCNR/A83dQTFTtHi9 w90= X-IronPort-AV: E=Sophos;i="5.77,421,1596470400"; d="scan'208";a="152152909" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 27 Oct 2020 07:03:24 +0800 IronPort-SDR: LUcWKsGyxMhMy14zInqMDnSWvfLodcW3JZm43fD96zVbcHRGq/jkMyPQqmKawb3/LQH2EKNkH6 68itcHUR8Xwwv5Vo/ao/+1tgsmQFo+r8v44sW7uMNA0ifzfNDS5w5hhrR4yQGlaxdrzwim8RBe bIu9SGubi5/WfG5pmuBdctXpWGyr3ahj7O4Z/z3AzIvgp9VndisL9xZGGOrv1Pc82IALWjlrDX wSvQpsoUO/jqBe5rRTNxSiGlVEu2VVYYkXXfaRrnHfol12PqMWCBve/MdFLrLdrbM2gHsPxczG cRcC19KGip4DdpqeSITONqGB Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2020 15:48:35 -0700 IronPort-SDR: rriut/QXTurmMnXEV+/wkdh18jeVeIaUuF5OpX2DpiAjha4uQ2m8xvQ2+CYVPztIlri/dGG9Fx sn4DjUGAMl9xld4i92d4WY0ChJTrDHbpMX+/nWTBiwVYjSvhmt8dWvvRfITcAe8aHbsJflfw31 X7bMdmMoJiKhs3WflXZAL19ePomMnN9ectpJbqja3ffpDKFD6UTBM+ZaybUNAdN7ZoQ4QlFV6l 1tP01QkDPJPYD5O1x+9fKaT5edDaRfBK6oaYcjCM8Jv0VUQ424prp5C290AGcHQRTt2fhXTuUe LPU= WDCIronportException: Internal Received: from 8223p12.ad.shared (HELO jedi-01.hgst.com) ([10.86.60.110]) by uls-op-cesaip02.wdc.com with ESMTP; 26 Oct 2020 16:03:25 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [PATCH v2 3/6] RISC-V: Enforce protections for kernel sections early Date: Mon, 26 Oct 2020 16:02:51 -0700 Message-Id: <20201026230254.911912-4-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026230254.911912-1-atish.patra@wdc.com> References: <20201026230254.911912-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201026_190329_555710_AE8BAB41 X-CRM114-Status: GOOD ( 16.68 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.45 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Albert Ou , Kees Cook , Anup Patel , linux-riscv@lists.infradead.org, Atish Patra , Palmer Dabbelt , Zong Li , Paul Walmsley , Greentime Hu , Andrew Morton , Borislav Petkov , Michel Lespinasse , Ard Biesheuvel , Mike Rapoport Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org Currently, all memblocks are mapped with PAGE_KERNEL_EXEC and the strict permissions are only enforced after /init starts. This leaves the kernel vulnerable from possible buggy built-in modules. Apply permissions to individual sections as early as possible. Signed-off-by: Atish Patra --- arch/riscv/include/asm/set_memory.h | 2 ++ arch/riscv/kernel/setup.c | 2 ++ arch/riscv/mm/init.c | 11 +++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/set_memory.h b/arch/riscv/include/asm/set_memory.h index 4c5bae7ca01c..4cc3a4e2afd3 100644 --- a/arch/riscv/include/asm/set_memory.h +++ b/arch/riscv/include/asm/set_memory.h @@ -15,11 +15,13 @@ int set_memory_ro(unsigned long addr, int numpages); int set_memory_rw(unsigned long addr, int numpages); int set_memory_x(unsigned long addr, int numpages); int set_memory_nx(unsigned long addr, int numpages); +void protect_kernel_text_data(void); #else static inline int set_memory_ro(unsigned long addr, int numpages) { return 0; } static inline int set_memory_rw(unsigned long addr, int numpages) { return 0; } static inline int set_memory_x(unsigned long addr, int numpages) { return 0; } static inline int set_memory_nx(unsigned long addr, int numpages) { return 0; } +static inline void protect_kernel_text_data(void) {}; #endif int set_direct_map_invalid_noflush(struct page *page); diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index 7d6a04ae3929..b722c5bf892c 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -92,6 +93,7 @@ void __init setup_arch(char **cmdline_p) #if IS_ENABLED(CONFIG_RISCV_SBI) sbi_init(); #endif + protect_kernel_text_data(); #ifdef CONFIG_SWIOTLB swiotlb_init(1); #endif diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index ea933b789a88..5f196f8158d4 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -608,7 +608,7 @@ static inline void setup_vm_final(void) #endif /* CONFIG_MMU */ #ifdef CONFIG_STRICT_KERNEL_RWX -void mark_rodata_ro(void) +void protect_kernel_text_data(void) { unsigned long text_start = (unsigned long)_text; unsigned long text_end = (unsigned long)_etext; @@ -617,9 +617,16 @@ void mark_rodata_ro(void) unsigned long max_low = (unsigned long)(__va(PFN_PHYS(max_low_pfn))); set_memory_ro(text_start, (text_end - text_start) >> PAGE_SHIFT); - set_memory_ro(rodata_start, (data_start - rodata_start) >> PAGE_SHIFT); set_memory_nx(rodata_start, (data_start - rodata_start) >> PAGE_SHIFT); set_memory_nx(data_start, (max_low - data_start) >> PAGE_SHIFT); +} + +void mark_rodata_ro(void) +{ + unsigned long rodata_start = (unsigned long)__start_rodata; + unsigned long data_start = (unsigned long)_data; + + set_memory_ro(rodata_start, (data_start - rodata_start) >> PAGE_SHIFT); debug_checkwx(); } From patchwork Mon Oct 26 23:02:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 11858957 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 02FB2697 for ; Mon, 26 Oct 2020 23:03:38 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A5CAE20708 for ; Mon, 26 Oct 2020 23:03:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="X0mvMGeV"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="URJjjHRL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5CAE20708 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=K4aClDeRkTGSHM6Q3W9Eo4LL84FjDanPKTlxKTMYT2Y=; b=X0mvMGeVLhaZowgqwRF0Oy00W Ro3DTyI28iAxiYsgQk7tOKFm6yRviAAo61fD4CxEw0kAPfJGvb2M95clzrlSGqoJejHLAMO33adTG WzEJi2IwBvyKp0jyWLDkXQVeXiXA3fXO2Fdf40zfHtdT7iaNSu7soNx9r0g9RwD0XtCEe0iWXYDCy VYekhBN4Fw2wC4eplt45X+fkkuE3+0tF41fE6RupWyY7GQUxknVYOAdyLwNWiBCZAHnTUQfmeiFwO uJGDjjkmP20pBxhl9RJJaYWtr+NA0KJF8Lz94t4taxRSf6lJ+VMb32ZlXsCufd4x+h9vJjOLs35ef rTVgylhTg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXBWZ-0004Jf-BW; Mon, 26 Oct 2020 23:03:35 +0000 Received: from esa6.hgst.iphmx.com ([216.71.154.45]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXBWT-0004G3-Pa for linux-riscv@lists.infradead.org; Mon, 26 Oct 2020 23:03:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1603753409; x=1635289409; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BXRrXHASEZw+q5AEH6JXn4IG5K15cGG21TkLjxF25TY=; b=URJjjHRLy8KmQfGlwj/WBLzTx4gHsfdUY8YsCSHPkMnU6I/nuYRNK6Ga bFb3AWymzww5MFphpcpliqhWOgO7o5ggmA/PU54Lw0bMOPZCA+rynjwXo 3S+KsjpSiGmSEq4q8fjZfKa2ErdI+J5zImh2i5Z1BSB+TnBH9I45lN6AP EaBFxk2EkIUlP/6LoKRzLmneYZf5HJVBOKW7pRcr48ZJbX1nj95w972SA FMJjzWioIkGlR3K+L4I9r0w+HJgzqTJHIS+DZnLF3LQWEoRJaPGrzgi1+ 80pshfjh4GMd0a9tcSQj/wSS17P3kJQ49XhDYEw61qpuk61DCWKl4XwXz A==; IronPort-SDR: QJtG6KvnHciweTON41ovUFASCfAMlNSE35baDpF5gZo80LXmQZYFWDxGQuqCn75wzVDRu9qTha OVLwC/ghV4iZnQszcl4+JLFqr+xcefARIea4vQbe+lD+SBXej8h1etv6Sn/BGlDI4z218G7Ies gd0hxcq0cfi9vgrb1zOrwHQ3BNrmw1FOuOApx6fEUAqtSs9ucezKvJJyeyy4ZszU3ckY0J9G4I rZTBTHkd6wGgYuvcq+3IiRVQtXPfxkXXzpIkQfnrpQpkW9rJ6S8VzSZ3Su4XpXi4pT/fHmnS9y bsg= X-IronPort-AV: E=Sophos;i="5.77,421,1596470400"; d="scan'208";a="152152912" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 27 Oct 2020 07:03:25 +0800 IronPort-SDR: oz9iIUPO41YXmSe5lIg1FWt9CkcMbjZjMOQWhQN3Eu+YCvga4haAmUvFUzr/dCRkEcGOibXBfo eM/I7m5DAnRSaeBbbs1FXY8Pmgw/I4NoLQ7/N5vBqPpbV6i20QzmfCUhUoleEfOnhjpM7M5NKq GcrT+a43FwhHMDO3722Gh76G8hGmXJ/TQpNUrJLD6d6F2rao3fIRtOs4X6DwAsP3T4TKHwjDaT 8s8oMKCFFJGKKBsgvzcRbxR8SYhbYY+IoKN5H3LmowqOqe/EqvmOOs8j862dIJx/SQsGrd5KNW OJ+6YOzCjCoSwS47k5WebISH Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2020 15:48:36 -0700 IronPort-SDR: nc5o0tmxjzldhTvYndCLRMxDkR7DVB0Qk9xsu3nOE77OHiF++vF7uzB8dkN6FOL63EaQPgW6vg 32Ps9rMRe6NjHIcHRp5jbx3Fek2i+PHg9bgM/sHhvhKm4Md89MmIf3oyZeyDszhniw1Vs1X25M OlI0GIJkCqeeclxiq3vzCN9bZC15BwvNL5vcbuD1e7UMTO2rDsIYlNsUJfTOQ3loffL7C1jBXK u9QjFn66K/qD/FBZsbsXUkxk7teb0SZUKmIJ96W9LgSUVq77xPrfBzq/ABINxmwTYilVzPaYOF RYQ= WDCIronportException: Internal Received: from 8223p12.ad.shared (HELO jedi-01.hgst.com) ([10.86.60.110]) by uls-op-cesaip02.wdc.com with ESMTP; 26 Oct 2020 16:03:25 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] RISC-V: Align the .init.text section Date: Mon, 26 Oct 2020 16:02:52 -0700 Message-Id: <20201026230254.911912-5-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026230254.911912-1-atish.patra@wdc.com> References: <20201026230254.911912-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201026_190330_004554_38C54A71 X-CRM114-Status: GOOD ( 14.66 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.45 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Albert Ou , Kees Cook , Anup Patel , linux-riscv@lists.infradead.org, Atish Patra , Palmer Dabbelt , Zong Li , Paul Walmsley , Greentime Hu , Andrew Morton , Borislav Petkov , Michel Lespinasse , Ard Biesheuvel , Mike Rapoport , Jim Wilson Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org In order to improve kernel text protection, we need separate .init.text/ .init.data/.text in separate sections. However, RISC-V linker relaxation code is not aware of any alignment between sections. As a result, it may relax any RISCV_CALL relocations between sections to JAL without realizing that an inter section alignment may move the address farther. That may lead to a relocation truncated fit error. However, linker relaxation code is aware of the individual section alignments. The detailed discussion on this issue can be found here. https://github.com/riscv/riscv-gnu-toolchain/issues/738 Keep the .init.text section aligned so that linker relaxation will take that as a hint while relaxing inter section calls. Here are the code size changes for each section because of this change. section change in size (in bytes) .head.text +4 .text +40 .init.text +6530 .exit.text +84 The only significant increase in size happened for .init.text because all intra relocations also use 2MB alignment. Suggested-by: Jim Wilson Signed-off-by: Atish Patra --- arch/riscv/kernel/vmlinux.lds.S | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S index 3ffbd6cbdb86..cacd7898ba7f 100644 --- a/arch/riscv/kernel/vmlinux.lds.S +++ b/arch/riscv/kernel/vmlinux.lds.S @@ -30,7 +30,13 @@ SECTIONS . = ALIGN(PAGE_SIZE); __init_begin = .; - INIT_TEXT_SECTION(PAGE_SIZE) + __init_text_begin = .; + .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) ALIGN(SECTION_ALIGN) { \ + _sinittext = .; \ + INIT_TEXT \ + _einittext = .; \ + } + . = ALIGN(8); __soc_early_init_table : { __soc_early_init_table_start = .; From patchwork Mon Oct 26 23:02:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 11858965 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CEAA592C for ; Mon, 26 Oct 2020 23:03:51 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 984E420708 for ; Mon, 26 Oct 2020 23:03:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tormdiD4"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="TINKrKy1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 984E420708 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=oywE//1iXDBCyZMx/g2q51Gaz+jyhPQi+ZXU++cKzDw=; b=tormdiD4MrtCitBw7gI19k1yX QoRXXSgmXFbYBSCnc/8iMMZfO9Pqq19sern8kdCtQfMSKoBHmyHpdRBDtf5HX8gbZAlyfrHivX0wm zkpY7xzgZ0OHlaoFladcnJPJSojoMl+0gUeqV0bIlmBRFngaGP3j0Owje1pHFagZTsqi7g5+r3gd7 ISEhANtyxlX301o1K28/yYIdBq652NzL0QSBGqhs1vNVJ0OrPhxuBQNRXLbh/l6q144HKBmBLfklM LOHVxqzca6fYMg7AA4XMaO8Pr3ov3xDYHtqmtjCKxEsovZf2SC8BX2f1MoGNWIVVI8nitiQVuE4Vv pVqjtr42Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXBWa-0004KB-4Y; Mon, 26 Oct 2020 23:03:36 +0000 Received: from esa6.hgst.iphmx.com ([216.71.154.45]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXBWU-0004H6-Er for linux-riscv@lists.infradead.org; Mon, 26 Oct 2020 23:03:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1603753410; x=1635289410; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iPUv/PUCUw9poafNmoCWlV7tTLouxKtDuq6y3HZQDjc=; b=TINKrKy1j7UvdoiLMTeHUQ/tMBzQuLtdTEH/fWFrgO6GS+tfZcEZ8JHu Cl2FOprdMaFJ02crvI0iY3uM/H++1sZNJlYKC81UfIWEROxDKgp0pdDI4 I6QBWtOpDcvdfYolhms30rt3tqELl2JP1csmhLb78lJbIgcwbZkAu0D0M 0hblQSEchmVhvcSFc3cket/LBv6gEqdvViw+5WKkCsT5sKuBEmjZ5N8Mo 6BaHAosKbWj4CtithfGsVHfyhVkX0czQFMHbgAWBkfUNdLyj+svAGcBaF /L1NRhojdJC+/A7+0TRv7wF65E3xRBRVb1jPZdwTp024gNcjRa6N//K/Z Q==; IronPort-SDR: CsILWxdqzjyqU2FwYLjPK+jZdSUoiFWfCLCK+zomYaBEEBdHYGDeaNr7VvK9zze/GpA6btdait F1JdnNzUJfawMwtwWVtbM80tYohxjLjTkce7af85Ed+TPHgSzENYmGcC6ODWnQ8/RUXMWmX19Z sHcoBfNu6L8r42mWepVbU0Iwl9uNPRG3jHzlJ8w8gSj+DWbjwfR8WWgSnONL6BjmJA88gqBS1q M/Bwcdr2OMD5ks7Gp2TfMj/7ykp/9agc8yDoViH+z7+v/8XjJohC59tKu6NIkStZgO3jdA79cN fMM= X-IronPort-AV: E=Sophos;i="5.77,421,1596470400"; d="scan'208";a="152152914" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 27 Oct 2020 07:03:25 +0800 IronPort-SDR: 3u2+d01NfPNLyJepvSU9gqztIqwBrsJhqYka2NFJ9fpUx5JTnhNRJABKy6ymocr+VACsvFbW0b 6IrLWS8PlkhTEoMNENQpQZY/Dg3kkiMoplXxpCudshL4S7UCtXcY4cloLua+RDS0oHtpSFbVzU Y+X7uqSvXZrCUQOkIV5UCjT224FgPTw2OAhCeEAyTTPpgudiMZjzE9YrQNgG4A+BLF2tUVsuBR BImVlogyHkN9O4t2kyVGoYGTNHNi5bqZhvUwAY1RNzRvcA+vQD0w7T2SoaguxxMPOwTACcF/d3 Z+sMS87NekBWHXBRqTecgl0W Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2020 15:48:36 -0700 IronPort-SDR: ey/+IpD7q+PZFkntsCEL5kRkGMghTUQ92D4aSwCY0hicm+MUionuNfl6dBlx3Gh91OzXB6oKuq FIrt8TuWoscWKGL5FZGzu4oj0jqXFxfqAjrHGnQLM0h4LD3Er1WjUcaV2wAoJI00VcLs3/mXyS /Prep/fH4qGRAmABa+qjbQbvBrGkfszca5mZUfa2SOTn3Nb0sYaGlEKe6wEY2Vo3ZSHVRn7fll 21NHZZZaa3XJN3YV/d0MMiVrPYSdIbcOhg7XGcbFSgMmsM0NEy7Y5E1i8priVbwPj6Z7qmOgj+ tBg= WDCIronportException: Internal Received: from 8223p12.ad.shared (HELO jedi-01.hgst.com) ([10.86.60.110]) by uls-op-cesaip02.wdc.com with ESMTP; 26 Oct 2020 16:03:26 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [PATCH v2 5/6] RISC-V: Protect .init.text & .init.data Date: Mon, 26 Oct 2020 16:02:53 -0700 Message-Id: <20201026230254.911912-6-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026230254.911912-1-atish.patra@wdc.com> References: <20201026230254.911912-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201026_190330_837440_84C45BC2 X-CRM114-Status: GOOD ( 19.16 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.45 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Albert Ou , Kees Cook , Anup Patel , linux-riscv@lists.infradead.org, Atish Patra , Palmer Dabbelt , Zong Li , Paul Walmsley , Greentime Hu , Andrew Morton , Borislav Petkov , Michel Lespinasse , Ard Biesheuvel , Mike Rapoport Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org Currently, .init.text & .init.data are intermixed which makes it impossible apply different permissions to them. .init.data shouldn't need exec permissions while .init.text shouldn't have write permission. Keep them in separate sections so that different permissions are applied to each section. This improves the kernel protection under CONFIG_STRICT_KERNEL_RWX. We also need to restore the permissions for the entire _init section after it is freed so that those pages can be used for other purpose. Signed-off-by: Atish Patra --- arch/riscv/include/asm/sections.h | 2 ++ arch/riscv/include/asm/set_memory.h | 2 ++ arch/riscv/kernel/setup.c | 9 +++++ arch/riscv/kernel/vmlinux.lds.S | 51 ++++++++++++++++------------- arch/riscv/mm/init.c | 8 ++++- arch/riscv/mm/pageattr.c | 6 ++++ 6 files changed, 54 insertions(+), 24 deletions(-) diff --git a/arch/riscv/include/asm/sections.h b/arch/riscv/include/asm/sections.h index 3a9971b1210f..1595c5b60cfd 100644 --- a/arch/riscv/include/asm/sections.h +++ b/arch/riscv/include/asm/sections.h @@ -9,5 +9,7 @@ extern char _start[]; extern char _start_kernel[]; +extern char __init_data_begin[], __init_data_end[]; +extern char __init_text_begin[], __init_text_end[]; #endif /* __ASM_SECTIONS_H */ diff --git a/arch/riscv/include/asm/set_memory.h b/arch/riscv/include/asm/set_memory.h index 4cc3a4e2afd3..913429c9c1ae 100644 --- a/arch/riscv/include/asm/set_memory.h +++ b/arch/riscv/include/asm/set_memory.h @@ -15,6 +15,7 @@ int set_memory_ro(unsigned long addr, int numpages); int set_memory_rw(unsigned long addr, int numpages); int set_memory_x(unsigned long addr, int numpages); int set_memory_nx(unsigned long addr, int numpages); +int set_memory_default(unsigned long addr, int numpages); void protect_kernel_text_data(void); #else static inline int set_memory_ro(unsigned long addr, int numpages) { return 0; } @@ -22,6 +23,7 @@ static inline int set_memory_rw(unsigned long addr, int numpages) { return 0; } static inline int set_memory_x(unsigned long addr, int numpages) { return 0; } static inline int set_memory_nx(unsigned long addr, int numpages) { return 0; } static inline void protect_kernel_text_data(void) {}; +static inline int set_memory_default(unsigned long addr, int numpages) { return 0; } #endif int set_direct_map_invalid_noflush(struct page *page); diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index b722c5bf892c..abfbdc8cfef3 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -123,3 +123,12 @@ static int __init topology_init(void) return 0; } subsys_initcall(topology_init); + +void free_initmem(void) +{ + unsigned long init_begin = (unsigned long)__init_begin; + unsigned long init_end = (unsigned long)__init_end; + + set_memory_default(init_begin, (init_end - init_begin) >> PAGE_SHIFT); + free_initmem_default(POISON_FREE_INITMEM); +} diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S index cacd7898ba7f..0a1874e48e8a 100644 --- a/arch/riscv/kernel/vmlinux.lds.S +++ b/arch/riscv/kernel/vmlinux.lds.S @@ -29,6 +29,26 @@ SECTIONS HEAD_TEXT_SECTION . = ALIGN(PAGE_SIZE); + .text : { + _text = .; + _stext = .; + TEXT_TEXT + SCHED_TEXT + CPUIDLE_TEXT + LOCK_TEXT + KPROBES_TEXT + ENTRY_TEXT + IRQENTRY_TEXT + SOFTIRQENTRY_TEXT + *(.fixup) + _etext = .; + } + +#ifdef CONFIG_EFI + . = ALIGN(PECOFF_SECTION_ALIGNMENT); + __pecoff_text_end = .; +#endif + . = ALIGN(SECTION_ALIGN); __init_begin = .; __init_text_begin = .; .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) ALIGN(SECTION_ALIGN) { \ @@ -53,35 +73,20 @@ SECTIONS { EXIT_TEXT } + + __init_text_end = .; + . = ALIGN(SECTION_ALIGN); + /* Start of init data section */ + __init_data_begin = .; + INIT_DATA_SECTION(16) .exit.data : { EXIT_DATA } PERCPU_SECTION(L1_CACHE_BYTES) - __init_end = .; - . = ALIGN(SECTION_ALIGN); - .text : { - _text = .; - _stext = .; - TEXT_TEXT - SCHED_TEXT - CPUIDLE_TEXT - LOCK_TEXT - KPROBES_TEXT - ENTRY_TEXT - IRQENTRY_TEXT - SOFTIRQENTRY_TEXT - *(.fixup) - _etext = .; - } - -#ifdef CONFIG_EFI - . = ALIGN(PECOFF_SECTION_ALIGNMENT); - __pecoff_text_end = .; -#endif - - INIT_DATA_SECTION(16) + __init_data_end = .; + __init_end = .; /* Start of data section */ _sdata = .; diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 5f196f8158d4..1bb3821d81d5 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -610,13 +610,19 @@ static inline void setup_vm_final(void) #ifdef CONFIG_STRICT_KERNEL_RWX void protect_kernel_text_data(void) { - unsigned long text_start = (unsigned long)_text; + unsigned long text_start = (unsigned long)_start; unsigned long text_end = (unsigned long)_etext; + unsigned long init_text_start = (unsigned long)__init_text_begin; + unsigned long init_text_end = (unsigned long)__init_text_end; + unsigned long init_data_start = (unsigned long)__init_data_begin; + unsigned long init_data_end = (unsigned long)__init_data_end; unsigned long rodata_start = (unsigned long)__start_rodata; unsigned long data_start = (unsigned long)_data; unsigned long max_low = (unsigned long)(__va(PFN_PHYS(max_low_pfn))); + set_memory_ro(init_text_start, (init_text_end - init_text_start) >> PAGE_SHIFT); set_memory_ro(text_start, (text_end - text_start) >> PAGE_SHIFT); + set_memory_nx(init_data_start, (init_data_end - init_data_start) >> PAGE_SHIFT); set_memory_nx(rodata_start, (data_start - rodata_start) >> PAGE_SHIFT); set_memory_nx(data_start, (max_low - data_start) >> PAGE_SHIFT); } diff --git a/arch/riscv/mm/pageattr.c b/arch/riscv/mm/pageattr.c index 19fecb362d81..04f3fc16aa9c 100644 --- a/arch/riscv/mm/pageattr.c +++ b/arch/riscv/mm/pageattr.c @@ -128,6 +128,12 @@ static int __set_memory(unsigned long addr, int numpages, pgprot_t set_mask, return ret; } +int set_memory_default(unsigned long addr, int numpages) +{ + return __set_memory(addr, numpages, __pgprot(_PAGE_KERNEL), + __pgprot(_PAGE_EXEC)); +} + int set_memory_ro(unsigned long addr, int numpages) { return __set_memory(addr, numpages, __pgprot(_PAGE_READ), From patchwork Mon Oct 26 23:02:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 11858959 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA26E697 for ; Mon, 26 Oct 2020 23:03:38 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 738AA20708 for ; Mon, 26 Oct 2020 23:03:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0aEtXH3V"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="P7imCxg+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 738AA20708 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fXVyYS2t9va4G58pC03VA4d9ZBiDIWidqr+XRUr8uOM=; b=0aEtXH3VAgmEBQKzqXhgabfRE V2/Yqid/iy8LtCw6WoK+IVDI0gOLkgqLP2ChmPXt/RfAxTA+A3xxvMKazG/ygUYBu1vPG3HUQz/de bcSLaUFmCBulOt7OZR90WhPVW0D8wAdA/xmh6FX8AwRnN6My2vAB54m9VcZ00hokRdPWtSF8kzQNY 2H/DkxGNMtg8XXR/w/9+i13bwLOrTP3sj5oJxGkMjrzESGKfJU65gkd8/EuLSbTq+If+fmG5nBq52 BXgpz9qxiE1Fju1w5btn8AE1Y97YALESFOPRdOm7uZIEmXlm/OayEkYwZMCQZMW6MyUxcagLM+Sib /7oyW5gOg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXBWa-0004Ka-Lz; Mon, 26 Oct 2020 23:03:36 +0000 Received: from esa6.hgst.iphmx.com ([216.71.154.45]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXBWV-0004FU-0j for linux-riscv@lists.infradead.org; Mon, 26 Oct 2020 23:03:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1603753411; x=1635289411; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ySjO0ROtxsgulKuASejfUOnFI2wPdTDF4D2jhNgjeiY=; b=P7imCxg+9oBiw8aBtRk+L6Zz8THT17cCHNj7XjaKdrZmC2+KBGDAvFWO 5V/fRypY/s9wxrudt5RjyPOp87Ob7g+gSuRQ9v2Ickh6Dl0cg/bmflozp nlSCPgJUH0uCTqgckGDx9Kg+EdFOUmnUNTFlItmvIOJIYmaDjqe58y+HC ej8tpDrRJdN3oAN6uc5hYyO5kMWuiFVJibm/bKr+5oJgimJ9DsG2bA4f+ jKvLQRQCI5MidMbWd1/oj0QSwCNghHSUahIwFeQjZjwy0Do2Wn7AyjwHz Pimf0/AVzQYqo8BacBX5cUK7OXAkBRsTu6BUIu/h6VPuvV/t7ZwQp9z8R Q==; IronPort-SDR: PT0RiwbgnnB9A6wwG+sCRTPlsjfPISJwc8M+pA4S6cjb6g/gX+CxZDF5bjLlqnkTWQiYX2pzM7 oy40QCbgnrOmeGDuoRhTSdYyZ4yxn/8MGgWB7Mo7ASVn/rRoeSGkcUjDsDZ1i3vGEcW3It9BJJ xoamU0sMqFCB/KXU9pOVY7ZWo9e/fTAAl59xrdy9nnLDHTSmOxqnxIugOPx36qVNglEGPVoRp3 PcLgXDjtPzOvLJp0XI9G/dGNZ0zs2mZyt2jKX6+XcufPL6perAaPdrPzUAa5YOsoImLBpZsT5d ogU= X-IronPort-AV: E=Sophos;i="5.77,421,1596470400"; d="scan'208";a="152152918" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 27 Oct 2020 07:03:26 +0800 IronPort-SDR: ZbbpiJxajYyqZgq/FisScuJrRZsjrqlKTSHhQnmaz5I2bxr8Q/Q13rQQ+52de0CtGTdgnVXive f7e/l3eRWTzARcycqNkGjCUHbg25Lr5CkXXYOeafY1cnnz3cLPy1D53MkmPQ9RDajUYFYvhxJq /LDSLVmZiWjquoJBfjk4NUyfaczNQ7Ttnee0ZhyENiPr0n9B2fhJa07FPYS9R1t7ReBR/TZydI UKxgygabdrP3YNvguDZCWoy6tI9mvzSWi0cMxM5SA6Uv9Qq3W1TqnD7rxSnMUDViRrpoS/F7gU WcKtaoA+nEMc+wxCU8YiHZdf Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2020 15:48:37 -0700 IronPort-SDR: ZIK6pBlHow57hiV8D7ho7M4zJo6JZXmXc68rJru36zg2zepGnFLYfk0rMM063VRf2xcII5Vlm6 k22KEvndaC4UkvZdmPy7PsVD3hmZnU/emkdOcOh9ZfogHtkgStZuny0fTzU6a6UKM//grYrAnu g2DxU2TKr9SHf2reP/hg81Iij6L7dTzG1xKtuyPaToFyfsS8Ud3UlSpzrBY8RZEc9935R2b6nJ OLPJbTTgczk/7d57STXaSaoAVH2omOc9iwiC6afLAGgmwM3l5XwA5ZkyLRltkHkbZ7/aPO0BEN FHg= WDCIronportException: Internal Received: from 8223p12.ad.shared (HELO jedi-01.hgst.com) ([10.86.60.110]) by uls-op-cesaip02.wdc.com with ESMTP; 26 Oct 2020 16:03:26 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [PATCH v2 6/6] RISC-V: Move dynamic relocation section under __init Date: Mon, 26 Oct 2020 16:02:54 -0700 Message-Id: <20201026230254.911912-7-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026230254.911912-1-atish.patra@wdc.com> References: <20201026230254.911912-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201026_190331_505428_453BB9CC X-CRM114-Status: GOOD ( 12.45 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.45 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Albert Ou , Kees Cook , Anup Patel , linux-riscv@lists.infradead.org, Atish Patra , Palmer Dabbelt , Zong Li , Paul Walmsley , Greentime Hu , Andrew Morton , Borislav Petkov , Michel Lespinasse , Ard Biesheuvel , Mike Rapoport Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org Dynamic relocation section are only required during boot. Those sections can be freed after init. Thus, it can be moved to __init section. Signed-off-by: Atish Patra --- arch/riscv/kernel/vmlinux.lds.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S index 0a1874e48e8a..64c5e74008b7 100644 --- a/arch/riscv/kernel/vmlinux.lds.S +++ b/arch/riscv/kernel/vmlinux.lds.S @@ -85,6 +85,10 @@ SECTIONS } PERCPU_SECTION(L1_CACHE_BYTES) + .rel.dyn : { + *(.rel.dyn*) + } + __init_data_end = .; __init_end = .; @@ -116,10 +120,6 @@ SECTIONS BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0) - .rel.dyn : { - *(.rel.dyn*) - } - #ifdef CONFIG_EFI . = ALIGN(PECOFF_SECTION_ALIGNMENT); __pecoff_data_virt_size = ABSOLUTE(. - __pecoff_text_end);