From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 47B721F8C8 for ; Fri, 17 Sep 2021 17:03:29 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 30F8D385BF81 for ; Fri, 17 Sep 2021 17:03:28 +0000 (GMT) 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 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-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: , Cc: Florian Weimer , GNU C Library , Andrew Waterman Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" 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