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.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 0E2371F8C8 for ; Thu, 16 Sep 2021 08:03:19 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 01589385781A for ; Thu, 16 Sep 2021 08:03:18 +0000 (GMT) Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 9727A3858D3C for ; Thu, 16 Sep 2021 08:03:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9727A3858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pg1-x532.google.com with SMTP id h3so5389655pgb.7 for ; Thu, 16 Sep 2021 01:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fZgoNoigLlNwwgF5D1MC4XhV4itkvtfjK76qT5RoPuo=; b=gPPAxxYQXSd3Oc5dH0JoZCjOERm6GTqEGn33GKZXRlPfthJsVktvzCkZp7355cxJLu sOx9acbgwhEIJGrkzEuIKhevyR63Gx/Nj01tmAyM4u/x7S7Ew4Q36HIHTP4At2jSCIFR +SuOhGXRL6S6oQnZg6GdJCiT67Bnf+ONHxM9H3VW1qfGKBIKZ18a1d9xosUHw2LFuGay XPreK/XlmcZDb4G2Vk9jcNvp8vRex4DF+I3KXYTl3RsgLiK9tE0nZPuwQBsnv9V1Rp4J ojJBk5oVr/dWBB8ezYSBDAVql9L/Y213IPdA8a75gLMj73YOBDP/IFvHou9ovOu39c7d 7sbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fZgoNoigLlNwwgF5D1MC4XhV4itkvtfjK76qT5RoPuo=; b=54BXe4tPK8bp6dyQ439WiO65ReE2XAQzBD4PCaFlR08FgOY5EvjGmzBy7M684Zwrbw 0UIzxqY9FL0MxNTivubLcWXNflV4/yyWLEX52XI8iUXLavKTmc6jI0fQzBh4zcj0j+gO Hg2//4wIou39XAkmH27ZzroNaFh6uIIsUPoLrKi77PdRletUZiBkxpadRYO6a5lhaGWU qmDEB1hCT1eArl/+NAMoCegaYzdTTzlFsYCfHelgUrTiIt4Sir2fyIMiRDOcF2Y1LAt4 DL0WDhPDs3HjUwktkkd7cu444IYdzqAJPIw8jnS7jZwaWnAjm5p830DVHtoEOLoMPPm8 kgBA== X-Gm-Message-State: AOAM53046WFdhGklwszcdMpMNzuy51X0NvZpt3pwLxYYU7OuUZMPOcbM qXN4bpIFbXEPT8Jnw1dHBtXsaPWmtKX7vs8n1DGFpg== X-Google-Smtp-Source: ABdhPJywx3ZzAx1V/MjKxo7ambBBMk22gXHGe/ESWUb9bHYOjWxa0cAMJ8XdtDtKzZE2sjuPamqmPIHqoR7ECZzMzdg= X-Received: by 2002:a63:2d86:: with SMTP id t128mr3875619pgt.316.1631779381552; Thu, 16 Sep 2021 01:03:01 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <20210913135247.GL13220@brightrain.aerifal.cx> From: Vincent Chen Date: Thu, 16 Sep 2021 16:02:50 +0800 Message-ID: Subject: Re: [RFC patch 2/5] RISC-V: Reserve about 5K space in mcontext_t to support future ISA expansion. To: Rich Felker Content-Type: text/plain; charset="UTF-8" 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 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. > > This shouldn't be necessary if the additional vector registers are > > caller-saved. Here I am a little confused about the usage of struct mcontext_t. As far as I know, the struct mcontext_t is used to save the machine-specific information in user context operation. Therefore, in this case, the struct mcontext_t is allowed to reserve the space only for saving caller-saved registers. However, in the signal handler, the user seems to be allowed to use uc_mcontext whose data type is struct mcontext_t to access the content of the signal context. In this case, the struct mcontext_t may need to be the same as the struct sigcontext defined at kernel. However, it will have a conflict with your suggestion because the struct sigcontext cannot just reserve a space for saving caller-saved registers. Could you help me point out my misunderstanding? Thank you. > Indeed, that was my first thought when I saw this too. Any late > additions to the register file must be call-clobbered or else they are > a new ABI. And mcontext_t does not need to represent any > call-clobbered state. > > Rich