From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe2b.google.com (mail-vs1-xe2b.google.com [IPv6:2607:f8b0:4864:20::e2b]) by sourceware.org (Postfix) with ESMTPS id 77B803858D1E for ; Thu, 22 Dec 2022 03:37:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 77B803858D1E 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-vs1-xe2b.google.com with SMTP id 128so590042vsz.12 for ; Wed, 21 Dec 2022 19:37:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=R/vuKASG7W9bgoDHU50sqLq1DsBHxj4D4/J7WpqGZVw=; b=fxhs6k1yqOJPEMXnjAFGEwzyyQHjKHBEgAjuEM55V6a+RuRG7NNcWN5bnJ8N4niVRh nCC1QK2k+SMts+YQ+TKPb7gx3CIdTvnFQOr8LbDdVziZvGUYWYjsYvlSOj5c+9SwkWE+ 4KBJuLlnFu/ERJ0ifwjRIxnO+waISi7O0Ua02ULVrBZn79gGB9RaNsllI3Cu5+F+tI8m tCxVwsrkLtIY/w7jgwSAiULiWshJjDmhkG2CxYlOY8am/r5ZLtzf/EYuPUjjjJNWj/4W w8GTXXGlzGZjm88fxoMOAwGa1jmWHoikwIdzZI6kPFxXjCgvOSAKVr9gkla4geQhfkiG I0UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=R/vuKASG7W9bgoDHU50sqLq1DsBHxj4D4/J7WpqGZVw=; b=5yRZX68677zywt7sCVe8BjhEwZDJLhfNma15owD4H5lCM+oN1oP4xAOrrcfuoWqMhF stTm8wgztGg99m6YNIQ9y+4GuUFSXn/qUP6UKFekMYgDr8dal8Y4EoQlzrUhoAY/155w EG8+YUMcbizF5VHTf8kNZFfUK1hsZPLQ1SPOxMJbLTf73X8RtZST8G9LcjLC38g/Scb2 s+GepOclCsePa+OPNfxkCbuYthY69fXaQm6kZ6rYsGxEMf9IWLzlGZTJLHRc105dc0JG pnQCbcK5LkApR/YxWx8NrFpf5YEqoQQ7iaHsOi7yT+rppnIK0fT1Fd+ps+LbQgcmBb81 JaxA== X-Gm-Message-State: AFqh2kptGfbClTUrHZ8ilqawQngrl6LqIE2GGW7jiuSWeKC3JrTpiKAU O2Iv68XutGcr7q0HZWdSx2iKopBps1EyRpK6NFux7A== X-Google-Smtp-Source: AMrXdXsKgxNkBo8IUlCPqOpd8FbH8N2IevLDsBsbpBQPxj/k9xUqy2Kn/utTzEaTyjyBxOGA0gq81sEWEUOJgRLNGf4= X-Received: by 2002:a05:6102:510e:b0:3b1:2b83:1861 with SMTP id bm14-20020a056102510e00b003b12b831861mr502162vsb.10.1671680258707; Wed, 21 Dec 2022 19:37:38 -0800 (PST) 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> <87sfy5ndid.fsf@oldenburg.str.redhat.com> <73c0124c-4794-6e40-460c-b26df407f322@rivosinc.com> <50c598a6-e3b3-3062-abe7-23a406067533@rivosinc.com> <7430f494-9b43-5e03-c1e9-6b83e2611a11@rivosinc.com> In-Reply-To: <7430f494-9b43-5e03-c1e9-6b83e2611a11@rivosinc.com> From: Vincent Chen Date: Thu, 22 Dec 2022 11:37:27 +0800 Message-ID: Subject: Re: Adding V-ext regs to signal context w/o expanding kernel struct sigcontext to avoid glibc ABI break To: Vineet Gupta Cc: Florian Weimer , Rich Felker , Andrew Waterman , Palmer Dabbelt , Kito Cheng , =?UTF-8?Q?Christoph_M=C3=BCllner?= , davidlt@rivosinc.com, Arnd Bergmann , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Philipp Tomsich , Szabolcs Nagy , Andy Chiu , Greentime Hu , Aaron Durbin , Andrew de los Reyes , linux-riscv , GNU C Library Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Dec 22, 2022 at 3:52 AM Vineet Gupta wrote: > > > > On 12/21/22 11:45, Vineet Gupta wrote: > > > > 4. Kernel with RVV support + user program using original Glibc sigcontext > > In this case, the kernel needs to save vector registers context to > > memory. The user program may encounter memory issues if the user space > > does not reserve enough memory size for the kernel to create the > > sigcontext. However, we can't seem to avoid this case since there is > > no flexible memory area in struct sigcontext for future expansion. > > This is not an issue, if we don't change sigcontext (in kernel and > glibc) - it is essentially the case of existing binaries. > kernel still saves regs on user stack, in rt_sigframe, its just that > userspace is not able to access them in SA_SIGINFO signal handers. > aarch64 have this implemented this approach and it is likely they can't > do that either for SVE regs. Sorry, I don't clearly describe the case. As you mentioned, the kernel will save the vector registers to the user stack or user-specified memory region by struct rt_sigframe in your patch. But, if there is an existing binary compiled with the original sigcontext.h, it will assume that the kernel only occupies the sizeof(struct sigcontext) to save these registers. It will not aware the RVV extension is supported and not expect that the kernel with RVV support needs an extra huge memory region on its stack or specified memory region to save vector registers context. In this case, the user program will encounter memory corruption issues if the size of the memory region specified by the user program is not enough to store these vector registers' context.