Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5553261rdb; Wed, 13 Dec 2023 12:00:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IEnBfXTM0vJsqaK5vVkpYqSAjYC99D6YtEsydzfRFKIKsQaN1q2+9wBx8keImHsYESMkD+G X-Received: by 2002:a17:903:187:b0:1d0:7165:3fa0 with SMTP id z7-20020a170903018700b001d071653fa0mr5093304plg.1.1702497647329; Wed, 13 Dec 2023 12:00:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702497647; cv=none; d=google.com; s=arc-20160816; b=F0XY8NOqZqkaP3G/Q5wGt5XqGr9MYxhaf+FmUmKmB/4cWUmc7QqvgLCIKxHjn2F9PU wUVPHbvjqT6WNZFEPU4EtT91X7skQyPfI+GpFG8pwjqRb3X8xak19XVjk02744hYrHpI eKPYswfiH7Nwf7ACenJt9WPxnl0Kkuz32LAmyPUrN4D8LmJtDe5JqOIn86zB9r0GtShR LSFdR6ToY/j7kAsW6N7T/kXzJbvXWNziyS5Bl+sSnZrbc0YtogYVxmtGV8fhpdf8XQsF JSSlqg3l8IsZsJZxnx61YMa3AJOHL5akBCXmViLRI7fdaSo+Zhn29TdSvhos1boUg/ud Kw/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=s31Qnl2jy9dVbfR9SU0O1e0gpO4gYzM2ckO1KK9cNWQ=; fh=txQbuk242FAPPEhu1HwwgZJLRYSPZEMBV0FwN7E4ncU=; b=n6oVdAcXfWYunsQdzyuGuB76NmvdACt8rQ6xvOJOb18aTg1guiWP/63n0y1PNdyOLR QxYdxPwjyWiqHX4xc7zYJM8w/2ssY59MhxXDcWaLeCTma5c5JtEXq3uLVe3L8a39XUoN uSeP29VZx9ck0A0zXI/m7d/T5JIVzPwdAEdsurV4Dsr0EvWZeT3erfbrqIHA5DE6ukjm nAiJcHSRDlixoDeoh35VmZZ5xfBqNvdne2UuSF1y/PtjZakhQ4TP+XiY7iIilYIviHVg l2FWYpndvZdB/oyfUdJryLoXy1VnbvF1HKwy8bsfuzX8cvRO2QRzwaoP6Qg4EAtN56Lx 7Xqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=jH6SPAsq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id e5-20020a17090301c500b001b894687ec9si9673173plh.462.2023.12.13.12.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 12:00:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=jH6SPAsq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 5B7D78092480; Wed, 13 Dec 2023 12:00:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229671AbjLMT7x (ORCPT + 99 others); Wed, 13 Dec 2023 14:59:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442230AbjLMT7v (ORCPT ); Wed, 13 Dec 2023 14:59:51 -0500 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E301B118 for ; Wed, 13 Dec 2023 11:59:56 -0800 (PST) Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-dbccfd048d4so959307276.3 for ; Wed, 13 Dec 2023 11:59:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1702497596; x=1703102396; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=s31Qnl2jy9dVbfR9SU0O1e0gpO4gYzM2ckO1KK9cNWQ=; b=jH6SPAsqxum5r3bxOr50QI5W87HWpirYc1yAIgS/RNk9lEb5qFNA6PDAz2emVohfq1 gOwnW748Yc7xrx+hYRlaJMmMhMj4iEBIn1WM2oDG2dl/x1xnY3WsP8v7ITohdLywlGd8 HGs2IvZ/FY9gTmgtVvecABlfpLXjRNz/FDTKUDSuL6/m4SMJBIAVzfqgMX6LeqDNWNuM 73UkEIW4t49gpM0cixQTLOGffy9lfjQmwzbmxDaTGBmxQcsyTusofHLMOfFlP7SfKkMn BnDkfhGMO1ql5kdAQqUyYWJEmdzxqY4hriswEuWn8AqPsYBZLyEtrRFur1hvPEm9fZFt wEwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702497596; x=1703102396; h=content-transfer-encoding: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=s31Qnl2jy9dVbfR9SU0O1e0gpO4gYzM2ckO1KK9cNWQ=; b=JGJMb7t5DlBwJFv495z+bhDzMOdXs1dank26zPV3Wz5gabbmWUHceLkRB9WI1ozLz9 l//CKT/1kq5UbVMiDMHlu+skU7rGu2/pUUMSUELRUXJ3IaU794qJ6S3N1MYHjgLuRvA6 5MukDViGTQjWULW/9C9/0DeIRap4Be/NjtcA4pSuzJu7q5SyFwGm3JmH/LWqZn6pABR0 eUG1vIkrDXVvr2jZFjICzvyjihgZc4XNKllzHXua9gDdPYJHUK0QIDh/GKSyeRoe5ti6 cNxjj4gG7scJhU0Cn2wnF0pC6CCWggK5T+YvJS279GwgsO1ia1nIWMdfOR9iXNSIB3C8 u/Zg== X-Gm-Message-State: AOJu0YxmUgIqOrpbAkJ5AGYQ3ZcL6ZdM5qRnrs9NanYNsh4/Hg3hHMee 7aHcKOyxyiVWErr5VCOWyr8NsK6ZP/7L8d74xWwjWg== X-Received: by 2002:a25:6ac4:0:b0:db7:dacf:3fb6 with SMTP id f187-20020a256ac4000000b00db7dacf3fb6mr4418808ybc.99.1702497596004; Wed, 13 Dec 2023 11:59:56 -0800 (PST) MIME-Version: 1.0 References: <20231122-arm64-gcs-v7-0-201c483bd775@kernel.org> <20231122-arm64-gcs-v7-20-201c483bd775@kernel.org> In-Reply-To: <20231122-arm64-gcs-v7-20-201c483bd775@kernel.org> From: Deepak Gupta Date: Wed, 13 Dec 2023 11:59:45 -0800 Message-ID: Subject: Re: [PATCH v7 20/39] arm64/gcs: Context switch GCS state for EL0 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" , Ard Biesheuvel , Szabolcs Nagy , "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Florian Weimer , Christian Brauner , Thiago Jung Bauermann , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, 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 pete.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 (pete.vger.email [0.0.0.0]); Wed, 13 Dec 2023 12:00:24 -0800 (PST) On Wed, Nov 22, 2023 at 1:45=E2=80=AFAM Mark Brown wro= te: > + > +/* > + * Apply the GCS mode configured for the specified task to the > + * hardware. > + */ > +void gcs_set_el0_mode(struct task_struct *task) > +{ > + u64 gcscre0_el1 =3D GCSCRE0_EL1_nTR; > + > + if (task->thread.gcs_el0_mode & PR_SHADOW_STACK_ENABLE) > + gcscre0_el1 |=3D GCSCRE0_EL1_RVCHKEN | GCSCRE0_EL1_PCRSEL= ; If the intent is to disable, is the GCS stack freed or kept around? I expect if libc is taking the decision to disable, kernel should free it u= p. Is it freed in some other flow? > + > + if (task->thread.gcs_el0_mode & PR_SHADOW_STACK_WRITE) > + gcscre0_el1 |=3D GCSCRE0_EL1_STREn; > + > + if (task->thread.gcs_el0_mode & PR_SHADOW_STACK_PUSH) > + gcscre0_el1 |=3D GCSCRE0_EL1_PUSHMEn; > + > + write_sysreg_s(gcscre0_el1, SYS_GCSCRE0_EL1); > +}