From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id 2C2DB3858D1E for ; Fri, 23 Dec 2022 19:42:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2C2DB3858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pj1-x1031.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso9655689pjt.0 for ; Fri, 23 Dec 2022 11:42:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=GMGcXWg/9VSqvsLgeD+24GVNZfVQVo5EdFEoV4EOZQU=; b=iE9/8BXbfBdMg6SOF31aFBhvC1wxPhvJW/GKwALYr7byIwbUzEQ1k3EhX6iOJ13oKZ JdOsK5Hxg8cHxN6fwr7qJnsyAPmo67YQ7VjaLGsijPJsdBoJaB0cHR4zC5WTNrp0DU4p Gso1Uj/YeTuc+wsm4Yj/TpoHNCCkdwSnKEebAlX61Wyqjd/F07hw81HMjdBy2ZHPo2B/ XYu6IfcyZ1zjdAKStKQIrFX9ayE+vfQDxjoUsXx8A4FhVVMvCDY7rPbiidi99arTX5B3 BpgtdZNsF0/4kbZBbmddWEMKtcQHgjjIA/LSmnGUTOznKVwdpoWfzBgerS8m10PLiBMM DQYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GMGcXWg/9VSqvsLgeD+24GVNZfVQVo5EdFEoV4EOZQU=; b=WGGb8gJGo7vzxj3kqC2xMswaAucJwvuwC2mbH0pqoAZExlMTt0JRFEQk5sb9Ywox2Z L1NuwTzTRlrYSAt+wDehCxULttF+jwcjKtMrHcvPaa1w7a0SmAHjeqNNMEQcfR+8LLQ+ Ln+xJZxMclbzj/BNPMzdFXwPOCdl9oyiqm10w9lXwKD9d+/9bhwJ7D0enO3y7MnjkJlB znKfxfMep2LxjFEDv5CZFpxiPsMjpB6ZBicTO+sLfmommETDuudig+aw3RMfCdhAi+ia b7OFwPznxQlH27LJIc9MZRp06ZA5vDyWPBX2qMBVLgqdni3RMnh8MoG4AZonE5bEZvm3 jLhA== X-Gm-Message-State: AFqh2ko4VmSwt/atI1Zaser75nquLB7Z18yEcxdpgL/fG2UpDyBIbrGP T3NyKKGbrMPYS+haMnzGzfWJyQ== X-Google-Smtp-Source: AMrXdXuEwFw+81xptC8OZYxx39EK6393vWlNr4zEycvkzKxOzvNey9po4b6lBzC9T9wpBqKsDomykg== X-Received: by 2002:a17:902:ee13:b0:189:13df:9d86 with SMTP id z19-20020a170902ee1300b0018913df9d86mr13068324plb.14.1671824568169; Fri, 23 Dec 2022 11:42:48 -0800 (PST) Received: from [192.168.50.116] (c-24-4-73-83.hsd1.ca.comcast.net. [24.4.73.83]) by smtp.gmail.com with ESMTPSA id w15-20020a1709026f0f00b0018699e6afd8sm2697085plk.265.2022.12.23.11.42.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Dec 2022 11:42:47 -0800 (PST) Message-ID: <3274f2e3-ec6d-98a6-add4-eeb78f003a05@rivosinc.com> Date: Fri, 23 Dec 2022 11:42:46 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: Adding V-ext regs to signal context w/o expanding kernel struct sigcontext to avoid glibc ABI break Content-Language: en-US To: Vincent Chen 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 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> From: Vineet Gupta In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,NICE_REPLY_A,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no 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 12/22/22 18:27, Vincent Chen wrote: > If I understand correctly, in your patch, the kernel uses rt_sigframe > to back up all register contexts in the user space, including RVV > registers. Discussing this all moot point but still... > Therefore, the user program needs to reserve enough memory > space for the kernel, which enough size of this memory space is the > sizeof(rt_sigframe) plus rvv_sc_size. In my patch, rt_sigframe has the c99 flexible array. So it doesn't add any extra space on its own. The total size increase is same whether we add it to kernel sigcontext or rt_sigframe. And since glibc sigcontext is not changed, application is unaware of rvv_sc_size in either case. > However, the rvv_sc_size is > unexpected to existing RISC-V programs. Again not sure how it is different in both cases. > Therefore, some memory of the > existing program may be corrupted by the kernel when the kernel backs > up the RVV registers context. kernel builds signal frame on top of existing user stack. setup_rt_frame     get_sigframe           sp = regs->sp; So it can't possibly corrupt any existing user stack area. Sure when expanding the stack user stack rlimit etc may hit when doing put_user. But again that is same for both approaches. FWIW kernel with my patch can be found below: it survives full glibc testsuite run w/o any regression so it definitely works w/o any obvious user memory corruption. git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/linux.git #rvv-v13.2-use-rt_sigframe -Vineet