From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from brightrain.aerifal.cx (brightrain.aerifal.cx [216.12.86.13]) by sourceware.org (Postfix) with ESMTPS id E38463858420 for ; Fri, 17 Sep 2021 17:03:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E38463858420 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=libc.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=libc.org Date: Fri, 17 Sep 2021 13:03:15 -0400 From: Rich Felker To: Vincent Chen Cc: Florian Weimer , GNU C Library , Andrew Waterman Subject: Re: [RFC patch 2/5] RISC-V: Reserve about 5K space in mcontext_t to support future ISA expansion. Message-ID: <20210917170314.GR13220@brightrain.aerifal.cx> References: <1631497278-29829-1-git-send-email-vincent.chen@sifive.com> <1631497278-29829-3-git-send-email-vincent.chen@sifive.com> <871r5sd1zq.fsf@oldenburg.str.redhat.com> <20210913135247.GL13220@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Sep 2021 17:03:18 -0000 On Thu, Sep 16, 2021 at 04:02:50PM +0800, Vincent Chen wrote: > On Mon, Sep 13, 2021 at 9:52 PM Rich Felker wrote: > > > > On Mon, Sep 13, 2021 at 03:44:09PM +0200, Florian Weimer via Libc-alpha wrote: > > > * Vincent Chen: > > > > > > > Following the changes of struct sigcontext in Linux to reserve about 5K space > > > > to support future ISA expansion. > > > > --- > > > > sysdeps/unix/sysv/linux/riscv/sys/ucontext.h | 2 ++ > > > > 1 file changed, 2 insertions(+) > > > > > > > > diff --git a/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h b/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h > > > > index cfafa44..80caf07 100644 > > > > --- a/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h > > > > +++ b/sysdeps/unix/sysv/linux/riscv/sys/ucontext.h > > > > @@ -82,6 +82,8 @@ typedef struct mcontext_t > > > > { > > > > __riscv_mc_gp_state __gregs; > > > > union __riscv_mc_fp_state __fpregs; > > > > + /* 5K + 256 reserved for vector state and future expansion. */ > > > > + unsigned char __reserved[5376] __attribute__ ((__aligned__ (16))); > > > > } mcontext_t; > > > > Hi Florian and Rich, > Sorry for the late reply and thank you for reminding me the > modification will cause ABI break. > > > > This changes the size of struct ucontext_t, which is an ABI break > > > (getcontext callers are supposed to provide their own object). > > > > > The riscv vector registers are all caller-saved registers except for > VCSR. Therefore, the struct mcontext_t needs to reserve a space for > it. In addition, RISCV ISA is growing, so I also hope the struct > mcontext_t has a space for future expansion. Based on the above ideas, > I reserved a 5K space here. VCSR is not call-saved (aka 'callee-saved' in alternate notation) either. It's thread-local state that may be changed or left alone by calls, and that sj/lj/ucontext functions can't touch, just like fenv. Saving and restoring it here would be wrong. Rich