Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp876438lqh; Thu, 28 Mar 2024 22:16:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUlvqTJEErq29rHtS0CK8HZBXZaCsm0DmOvEGbdjIdoFqanGwWphaPM3VSxnuPfpEBCU++AGoRNr4awJ6Rg777uVKz9HmNH6PTvLxiPjA== X-Google-Smtp-Source: AGHT+IG+ulHX0kT9SfPzqsHxTqMfUOyBNaO2PVZXhU8aWTMt3rGcQAc0dzbp1vqqiKi9alubBXoJ X-Received: by 2002:a05:6a00:1a8d:b0:6ea:bc26:6b9e with SMTP id e13-20020a056a001a8d00b006eabc266b9emr1484545pfv.11.1711689360914; Thu, 28 Mar 2024 22:16:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711689360; cv=pass; d=google.com; s=arc-20160816; b=IuLsAN4z1QzEPLgGPqH5nZz7lYrF2MchbAxxwTvpfhL3gKYamkdkFV88NuyqB1KOWP GrYuO7TLmdPiPoIbQwz77otoJ4Mw6PHTRJLkSHfLcYfKXitGkNnH+sp1ayA3yQj9QkcO wMsHfh1h5sc0wZLIUyeL5q3BEhLJyxmWbvFnVzlIZysU288TWqFpChjxP06pJmSAWcQ3 jcKhvz5I0st6dOe0+zmRY8Ddykytz9vVMxhGL0C5Qdvjj2eo56mRsC7Y5vWMXKsULGUt gvETz5IQRCSitXKhyHRHD/0Y3cGZ5VqHc8KzPsWFYvzjtLz/q1vaD40+7XiEYw78enDe y2ew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=SA5bcVE32KgGG5TtTqzFEWB8zyElCwHL0lTeALGfaJE=; fh=3ReRYVWi0JBRZ0h60p1BI+CdQWvScvBfw9CiK/oBNpg=; b=wiqQNo0rYzPwBYmrbBnje85OHWyqjfeua18YutENM8XvB7aWukqlzMUbEJuoAT4NNN CEmfnF/78UpY3CvwQFdB7DiN2gHMFnw29uMvrfAeXNgP3pAnlDNawjY/AaWDPEae6AyV Ta9UQ7sqkteolqVSVz0IlBRHnqMHkGf0v4IzZV8qKK5nkjLgRN2uv0pXfcwaWAWzDZbh leJpUb0h5JTQqHh+gNH63UnBogwsHzR/QnOS9empNjY1GGMdiuPdRejPztnr6/+sJDxz Vhn+e1W1+8Ff++kJXJ/ges7AR35Ul5sCxGtP2DeGxuO2j6LGs1BnKqsOHCHsSvMQVjKT 33eg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=jpvfRixe; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-124153-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124153-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d20-20020a056a00199400b006eae6e1252fsi907614pfl.234.2024.03.28.22.16.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 22:16:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124153-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=jpvfRixe; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-124153-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124153-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 93F352886C8 for ; Fri, 29 Mar 2024 05:16:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 251A03BB2A; Fri, 29 Mar 2024 05:15:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="jpvfRixe" Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C801E381DA for ; Fri, 29 Mar 2024 05:15:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711689352; cv=none; b=T7cw4XmQiABFmDFaRkiQp0eiAuTF+uRTzzGJTCSPyae6ETB9jtm1TbvcsgStsGPHNjGsk2J6yVPLm4nbDchpOc2NDPYWqYHbtCKvDPPVhj89Am27anfu+lHRej9KvswEfchM7HMKIrpwmPn/rKKLgIkLGtZCH8bFsm0xc92/YXk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711689352; c=relaxed/simple; bh=SA5bcVE32KgGG5TtTqzFEWB8zyElCwHL0lTeALGfaJE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=VTeJisg+X+5b5E7NVGquYkND5MLNyOAEkAXo7xbxiq/zavcBrDXnHMzEdE4D7GD3dvGWDYFF+oa3EFHW7ripmU9+LmpI5Bq4D9tM3CWTQ0vxieF3tqZIearh/0VAxUEwCbMJyAcamJ1GT4z0uEtgiTw6JAO+ZFp9RCYloxeSM0Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=jpvfRixe; arc=none smtp.client-ip=209.85.128.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-609fb0450d8so18466607b3.0 for ; Thu, 28 Mar 2024 22:15:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1711689350; x=1712294150; 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=SA5bcVE32KgGG5TtTqzFEWB8zyElCwHL0lTeALGfaJE=; b=jpvfRixeJ1lib6rBDNJy3VtVIMgHg7aEwv2m+DZQBf+is6lPnAGqroYCRFzmYeAv8s fE7KKFwXFJnuedXoGUse6o2OxYHgP2U7iZc5cNFuO9AS8hsTaIO+wxv9nNouQYOzkZv1 4m7eF2IRCQprDUkTJMIki+D9bYD9yFsMPGZ2IOJKU0Odcn5BwTM7ecViqJnt5D1zN6vr LUXAXolN7Rkdo/9Ioldd8ai797kBcHGSLpsVhN+Yi6vvHaTBFhcLrTpWev0qy6DssQ3U Qw3jWLgprqRsAT3ZyQTgp3h7VVUFsA0XRLMKltM5ar2fv/3OEXtQ6dsk54QxMG4mwa5b OxnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711689350; x=1712294150; 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=SA5bcVE32KgGG5TtTqzFEWB8zyElCwHL0lTeALGfaJE=; b=jryiSqUn/e9CTUGT1t5LYBbyQRAWceYyxG2yYGfGTfZFWU8evqoVVAexl6NbKGKv99 wWj42qv4DLVNof0TNmyKZR2GW+Q7y3PrdXvSVoh4maYN9s2hIezzd/bB+UBNYC+YGjrd d9edIjcr6LzNZM0HPqUxs5PD29Heo4FvUS8lErnaAKerSOQshvJwldCrgesgVEwq8AXy 0+kGQORpCDE6wRLij7LuYP+xMRxpWXlUMuiGzcMmUSty4mxeRlnas1+jtuXbkllU7h8s MfJrxc5GK2ZC9itgY6cPTuRUNXHdF0Oo/1rNzFfQxypQuef00uLoBa3ae7+pVXJ9TpmF +8eA== X-Forwarded-Encrypted: i=1; AJvYcCWkblNtzod2x/77CLAuE2WLwJf253KvWWIj0NZn9QnEeJBVCWQgQGsCFh0JrMWlcVa4XlXLU/rkdjf/x8BdlOgVEUp8NHH5S1nvxAGY X-Gm-Message-State: AOJu0Yx1bIHgCgUX6DbJxGk2oyZynvh3FTz+g8AZTgsL6aWDDlwPPAC/ 9sWuUfqjFOMKn5YkBhxaTvoPiGxnpyxbpkHkk1VOyEMZ4YRE8qi2HlK9zkinrdmOA+c1/M+wzvt +eqBCJ3kfUwIWJ+mRIaAKZwo/n0oathJae39iMQ== X-Received: by 2002:a0d:f184:0:b0:608:5dfc:1336 with SMTP id a126-20020a0df184000000b006085dfc1336mr1323243ywf.39.1711689349755; Thu, 28 Mar 2024 22:15:49 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240329044459.3990638-1-debug@rivosinc.com> <20240329044459.3990638-12-debug@rivosinc.com> In-Reply-To: <20240329044459.3990638-12-debug@rivosinc.com> From: Deepak Gupta Date: Thu, 28 Mar 2024 22:15:40 -0700 Message-ID: Subject: Re: [PATCH v2 11/27] riscv mmu: teach pte_mkwrite to manufacture shadow stack PTEs To: paul.walmsley@sifive.com, rick.p.edgecombe@intel.com, broonie@kernel.org, Szabolcs.Nagy@arm.com, kito.cheng@sifive.com, keescook@chromium.org, ajones@ventanamicro.com, conor.dooley@microchip.com, cleger@rivosinc.com, atishp@atishpatra.org, alex@ghiti.fr, bjorn@rivosinc.com, alexghiti@rivosinc.com, samuel.holland@sifive.com, conor@kernel.org, linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: corbet@lwn.net, tech-j-ext@lists.risc-v.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, oleg@redhat.com, akpm@linux-foundation.org, arnd@arndb.de, ebiederm@xmission.com, Liam.Howlett@oracle.com, vbabka@suse.cz, lstoakes@gmail.com, shuah@kernel.org, brauner@kernel.org, andy.chiu@sifive.com, jerry.shih@sifive.com, hankuan.chen@sifive.com, greentime.hu@sifive.com, evan@rivosinc.com, xiao.w.wang@intel.com, charlie@rivosinc.com, apatel@ventanamicro.com, mchitale@ventanamicro.com, dbarboza@ventanamicro.com, sameo@rivosinc.com, shikemeng@huaweicloud.com, willy@infradead.org, vincent.chen@sifive.com, guoren@kernel.org, samitolvanen@google.com, songshuaishuai@tinylab.org, gerg@kernel.org, heiko@sntech.de, bhe@redhat.com, jeeheng.sia@starfivetech.com, cyy@cyyself.name, maskray@google.com, ancientmodern4@gmail.com, mathis.salmen@matsal.de, cuiyunhui@bytedance.com, bgray@linux.ibm.com, mpe@ellerman.id.au, baruch@tkos.co.il, alx@kernel.org, david@redhat.com, catalin.marinas@arm.com, revest@chromium.org, josh@joshtriplett.org, shr@devkernel.io, deller@gmx.de, omosnace@redhat.com, ojeda@kernel.org, jhubbard@nvidia.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 28, 2024 at 9:46=E2=80=AFPM Deepak Gupta w= rote: > > pte_mkwrite creates PTEs with WRITE encodings for underlying arch. Underl= ying > arch can have two types of writeable mappings. One that can be written us= ing > regular store instructions. Another one that can only be written using sp= ecialized > store instructions (like shadow stack stores). pte_mkwrite can select wri= te PTE > encoding based on VMA range. > > On riscv, presence of only VM_WRITE in vma->vm_flags means it's a shadow = stack. > > Signed-off-by: Deepak Gupta > > rebase with a30f0ca0fa31cdb2ac3d24b7b5be9e3ae75f4175 > hmm.. Note to self: Missed removing this lingering commit message. Will remove it in the next version.