Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3163659rdb; Sat, 9 Dec 2023 14:28:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVJkphWTfNr75UW+jW8oVF2rdaaksixBahlsUJP1cXdGQU1e1fNDts5/dxlXeuFLoY8xuo X-Received: by 2002:a05:6870:a54e:b0:1fb:75a:6d33 with SMTP id p14-20020a056870a54e00b001fb075a6d33mr2816096oal.90.1702160920351; Sat, 09 Dec 2023 14:28:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702160920; cv=none; d=google.com; s=arc-20160816; b=NCIYsQ7XppQlbRWxHr92bC1Qc9dTrg0/jsLUnEKdr5qVJKfUo8FrKIGtC+eiq97ki+ KfxvmZsmKksHfsnvIUWUTiD43i9lXSEtMGJg2R3nf+Ppw0XjbMyIm3ykhYgXIMKIso6C Cx3DOBDAwCORrBumTATYg1FJqqOQg/dOh2T+pWbvnqZr8UUdVA6ktrrg1wJgiPaD4+/L 2o0Oqw/2zytpzGbnxkAPw6whzidMgC/4urMDL/gnNDFVKicSGQdSzxkxmT1m8us/TvfT U8I/x3jdg76JJn/uC77ZFo/DYFRwwVt1+GPWgTVDpaC+0BA7gW6UIz5L6bdrvh+A8ehN WYzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:in-reply-to:subject :cc:to:from:user-agent:references:dkim-signature; bh=GIZ+mcVI5qd9xzhqd2Lq/djPmsscI/1vsqmZHAfk8NA=; fh=2nPFT/KTslTQ686WgFSojEEZau7G7tqoQ5Zr2uSyW1U=; b=q3pbTcWDBjKD3oJ4nwcMf1m5DrQTWOFOlWrVYaZyU5g7XRycEByQpdv5Jge+lbjh/g mmI19HDoTlxn0LxRtrMxOzBGmV1cytBzHOjnIWgMvqfyhhoEHqrDIrFlYqA7t6Ct/Pud hAJvn3bWy8yr+7cUvdj6YxgfIGa18Q/TUSm03wa4C2PBcDx4ltca0gtFCzMGitA60DgH dxtmbW4Fd5LKlaDihvTdLT0iNkZkXnvrzHFyolBdSY7Gt+hRdEt9ABr4yEFkzbiNaYfC nFqMroOFwIEn2WZeJOBhK8M9g27c5WaUyHqcCCg0f2FYHXbkJzODqo86YUCW3VNqae7L 8P2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p9DCWxDY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id c9-20020a63d509000000b0057d7cff25besi3502379pgg.829.2023.12.09.14.28.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 14:28:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p9DCWxDY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id E2BE7805F2CC; Sat, 9 Dec 2023 14:28:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229518AbjLIW2T (ORCPT + 99 others); Sat, 9 Dec 2023 17:28:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbjLIW2S (ORCPT ); Sat, 9 Dec 2023 17:28:18 -0500 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA5E6100 for ; Sat, 9 Dec 2023 14:28:24 -0800 (PST) Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3b8958b32a2so2463620b6e.2 for ; Sat, 09 Dec 2023 14:28:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702160904; x=1702765704; darn=vger.kernel.org; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :user-agent:references:from:to:cc:subject:date:message-id:reply-to; bh=GIZ+mcVI5qd9xzhqd2Lq/djPmsscI/1vsqmZHAfk8NA=; b=p9DCWxDYC+nU3o7gjWxDHNHSfBEM7bYidKRtAZY+E/dEXZN97n3jp8E6Rc2dujZM4D SsYd9ylFbbOp/XIIzKaa4/Zgf3pvN16Hydic0pikAlhBMxZWHrCW2O0KmjD+tPCTeNof erPBXmZp6fgX70njfyCnjVcirM8gB1D8oMP4xhfqxblsmR3PzxXEGWG679A9oXVYvkOx /X8RHPaadhSq9KTtwsdT5Wz783W+ILD02kJvg7E57qPN5PtTBLidE+9d+wZse5jVNLDb +IoeJl/fyymQ4uzCe3asTM9GxZh2DxhPL3e1BDji8dq3QTo1riT+uN2BLv+lNdERK+p+ DlHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702160904; x=1702765704; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=GIZ+mcVI5qd9xzhqd2Lq/djPmsscI/1vsqmZHAfk8NA=; b=jkuPRYPJEQXN7IcVrjHS9kdxkVhAP7uUZ4AHhQ44XOU0rb+NUIEFBVqRFLMfSvxFHr GZbFZXPxjqXcZzdxbA1IPN01aDEIOvF+pAvf72NLt0MAW9HGI6ohVYE2Z9e8w5MV3RYz cGGYBhpbCrgwmTykVZ5oFqfcJYvAYhzbdg2O3PfNMAKxtEwVtQLTp84CIjj4VAmCaBeb p5ss+uHE98B367J9QbOCE8KUSa/QJZlhATbFKiKXyzDHfB9GA40YPK1r8sowq3uIclGX 4yts6/1C/wP2Lt0113yBvoUw+n0K7Z5LSY12Hb7KG0IoqueqNN/i29/B9XK9YqlpfD8X Gs/Q== X-Gm-Message-State: AOJu0YxHiHNM9qwq1GvEjoVATibTrmoG6tNY2AZwbBJq18NpKWzmmh4q UAunfkVdF1S/JBDfBkZeL4luoA== X-Received: by 2002:a05:6808:21a6:b0:3b9:e87b:d963 with SMTP id be38-20020a05680821a600b003b9e87bd963mr2922446oib.85.1702160903962; Sat, 09 Dec 2023 14:28:23 -0800 (PST) Received: from localhost ([2804:14d:7e39:8470:ded6:9593:9f4f:5c29]) by smtp.gmail.com with ESMTPSA id h17-20020aa786d1000000b006ce7ed5ba42sm3794269pfo.171.2023.12.09.14.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 14:28:23 -0800 (PST) References: <20231122-arm64-gcs-v7-0-201c483bd775@kernel.org> <20231122-arm64-gcs-v7-25-201c483bd775@kernel.org> User-agent: mu4e 1.10.8; emacs 29.1 From: Thiago Jung Bauermann To: Mark Brown Cc: Catalin Marinas , Will Deacon , Jonathan Corbet , Andrew Morton , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Arnd Bergmann , Oleg Nesterov , Eric Biederman , Kees Cook , Shuah Khan , "Rick P. Edgecombe" , Deepak Gupta , Ard Biesheuvel , Szabolcs Nagy , "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Florian Weimer , Christian Brauner , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH v7 25/39] arm64/signal: Expose GCS state in signal frames In-reply-to: <20231122-arm64-gcs-v7-25-201c483bd775@kernel.org> Date: Sat, 09 Dec 2023 19:28:21 -0300 Message-ID: <87sf4bf1tm.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Sat, 09 Dec 2023 14:28:37 -0800 (PST) Mark Brown writes: > +static int preserve_gcs_context(struct gcs_context __user *ctx) > +{ > + int err = 0; > + u64 gcspr; > + > + /* > + * We will add a cap token to the frame, include it in the > + * GCSPR_EL0 we report to support stack switching via > + * sigreturn. > + */ > + gcs_preserve_current_state(); > + gcspr = current->thread.gcspr_el0; > + if (task_gcs_el0_enabled(current)) > + gcspr -= 8; > + > + __put_user_error(GCS_MAGIC, &ctx->head.magic, err); > + __put_user_error(sizeof(*ctx), &ctx->head.size, err); > + __put_user_error(gcspr, &ctx->gcspr, err); > + __put_user_error(current->thread.gcs_el0_mode, > + &ctx->features_enabled, err); Other preserve__context() functions zero the reserved fields in ctx. I suggest doing the same here. It helps with backward compatibility. > + > + return err; > +} -- Thiago