Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5222441ybf; Wed, 4 Mar 2020 20:03:03 -0800 (PST) X-Google-Smtp-Source: ADFU+vsDXS/m89uYYqR+qP1wWrGwZnExh7gBlLDmwKX2eLsJne9jh4Meca/GlIzeMMRVpGSM4CCV X-Received: by 2002:a9d:740d:: with SMTP id n13mr5218755otk.140.1583380983244; Wed, 04 Mar 2020 20:03:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583380983; cv=none; d=google.com; s=arc-20160816; b=SaIFIvFbtBh7U0jlQS4hQNwQQoc4J+2W3iWGOJxzidnWwX5F/EvzyRdYsAfurvmIvf rT9sArFFGgfbkvctHBKiOnyBwsLsL/V3Xfv9RMcA3L4LEn3FHNR0hPtTFUImUFxjfoht DyAjEeafDzz06NIoSKTj86dDNduGd4Ecnu2kV2dbx4uLmNj7tD8ED9sOM4uaj88cXGqA 2t6dbKkMNrzp42YnVvh2dbr+WNF1QNdj2Bm7fqA5RPlmWUtLpQAVuL9I7OLgylhaM4or g3o9cgCkV46JB/IQmwhA4nsST6Qk9mx5PT8WIXTdSZ0Kmv/jzwYwTlL/14tTxzj/wYSe 7BUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=9VU+lVbHX0qAw8bXtTYx7XdwXh/+wKdP6K88dg5a7UM=; b=q1YJfKHZ605jy3qR9J3hWb2srVm+0X/znryMfRSNSc1eQ+cLQxjXJeWwLJV7KL9tGM 5wfnwA6tjHmXCOj3lr3fyvLmmignNVD+c2npgHv7vcM3wYvxNLdDNp9t/VePUIxT/79z 4Nv9CPQC2MobiK3OLwVW4z90G8siGwEojKXQ71Dq6KpVYMIXDuU5SlTkRPhcpL5LHIND ThRM5AfwN9MX+0kQXAHKA7rqBv2TfHfepaTrkh9bIVkIyb2z0VPixBvQKSRGScpx5KfI bMQYePhPBu7uZBYqNqSsN/4gQCpsxV5iTOmj8VH7PFcLH100oDnR+1yST9QbpknRzxz/ Fd4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m8f1Lpzo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c11si2499356oic.20.2020.03.04.20.02.50; Wed, 04 Mar 2020 20:03:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m8f1Lpzo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726049AbgCEEBT (ORCPT + 99 others); Wed, 4 Mar 2020 23:01:19 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:40440 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbgCEEBT (ORCPT ); Wed, 4 Mar 2020 23:01:19 -0500 Received: by mail-lj1-f193.google.com with SMTP id 143so4445011ljj.7 for ; Wed, 04 Mar 2020 20:01:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=9VU+lVbHX0qAw8bXtTYx7XdwXh/+wKdP6K88dg5a7UM=; b=m8f1LpzoYDlsqPhFGG0BvlCvNoSoVC6VdZ+wMBtBZ7sIxYiA3QyplOfaFWVZVdoTEi iS+0bM+SdOGRNLGNrc+89EpUjiv+4YEv7Ht47ocfGFo9s3WSwwWJ/n9OKEZb1TlYzKek ZQJxY4D8/lOfjukIL4HuQZTE1Kv+OQZr0tCcAU8ladJb2WVB0UbMCrruHms/41KyyQiR T6PZXM01KDvH9tLYxktX/Pi98Ajf8VKpAhqA6ucQ6ufxa9Y8svUOXon8/reAGeqxKsKl uH7LkhJ5KWmwxj02gYMqgweVS/f8j/IcgHs4lFAo6VA8PzsIr6AJ5CDe1ipv7ll2YzDB Otkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=9VU+lVbHX0qAw8bXtTYx7XdwXh/+wKdP6K88dg5a7UM=; b=eG2vQsgte2R4/nL4InZ9wF7qHToOavaCYogVVdquj87Zi5KvXBln5KqHyjyQDVfbTb dnhaUtJfoN6I5l8D4r6IB4o6HRgqKboQU6m8BzuLDzgfex80BdsPgz7DiBnRVtHzk+8y RLLL5z1zHDtmZhGHQQsyGzMOVIqmfeX6RMRVpYgTV1kCnXLZieRO6lr7e6K4ZM4v29nc 9FH0Zw0gpVJASKuEI7zE66ocvXbU4pujgPVszbUEIXuS08FDM7l9dUwlP0VJdp97t0Xv +l6cFr+h7CYshGhX3PRLok9c5raCc3mQ/9t02XELEXJcy8xwnp832eUWS6Y5YoYoXkPk Y8BQ== X-Gm-Message-State: ANhLgQ3wD4WuctnOiSTg9/ntUnILReHLeoOIX/bjxkp90QhwgEgT0Dto Auj0oGv3DdwmqniADrUJ1YsdQbsJFKKRrof01dw= X-Received: by 2002:a2e:b0c4:: with SMTP id g4mr3907216ljl.83.1583380875979; Wed, 04 Mar 2020 20:01:15 -0800 (PST) MIME-Version: 1.0 References: <20200217083223.2011-5-zong.li@sifive.com> In-Reply-To: From: Zong Li Date: Thu, 5 Mar 2020 12:01:04 +0800 Message-ID: Subject: Re: [PATCH 4/8] riscv: move exception table immediately after RO_DATA To: Palmer Dabbelt Cc: Zong Li , linux-riscv , Albert Ou , Linux Kernel Mailing List , Paul Walmsley Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Palmer Dabbelt =E6=96=BC 2020=E5=B9=B43=E6=9C=885=E6= =97=A5 =E9=80=B1=E5=9B=9B =E4=B8=8A=E5=8D=888:58=E5=AF=AB=E9=81=93=EF=BC=9A > > On Mon, 17 Feb 2020 00:32:19 PST (-0800), zong.li@sifive.com wrote: > > Move EXCEPTION_TABLE immediately after RO_DATA. Make it easy to set the > > attribution of the sections which should be read-only at a time. > > Move .sdata to indicate the start of data section with write permission= . > > This patch is prepared for STRICT_KERNEL_RWX support. > > > > Signed-off-by: Zong Li > > --- > > arch/riscv/kernel/vmlinux.lds.S | 8 +++++--- > > 1 file changed, 5 insertions(+), 3 deletions(-) > > > > diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinu= x.lds.S > > index 1e0193ded420..4ba8a5397e8b 100644 > > --- a/arch/riscv/kernel/vmlinux.lds.S > > +++ b/arch/riscv/kernel/vmlinux.lds.S > > @@ -9,6 +9,7 @@ > > #include > > #include > > #include > > +#include > > > > OUTPUT_ARCH(riscv) > > ENTRY(_start) > > @@ -52,12 +53,15 @@ SECTIONS > > } > > > > /* Start of data section */ > > - _sdata =3D .; > > RO_DATA(L1_CACHE_BYTES) > > .srodata : { > > *(.srodata*) > > } > > > > + EXCEPTION_TABLE(0x10) > > + > > + _sdata =3D .; > > + > > RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) > > .sdata : { > > __global_pointer$ =3D . + 0x800; > > @@ -69,8 +73,6 @@ SECTIONS > > > > BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0) > > > > - EXCEPTION_TABLE(0x10) > > - > > .rel.dyn : { > > *(.rel.dyn*) > > } > > As far as I can tell this is OK: core_kernel_data() explicitly says that = RODATA > may or may not be between _sdata and _edata. That said, I think we shoul= d add > __start_rodata and __end_rodata atomicly with this change (around RO_DATA= and > .srodata). > OK, I'll move _sdata back. Actually, here I need a symbol to specify the start address at writable data (RW_DATA), thus, I could remove the executable permission of .data section (from this symbol), and make .rodata, .srodata and __ex_table read-only at a time (from __start_rodata to this symbol). So even if we use __end_rodata to wrap .srodata together with .rodata, exception table still be excluded, and we have no idea where is the .data section start address. Do you think it would be OK if we use _data to specify the start address at writable data? If it's OK, whether we still need to add __end_rodata after .srodata?