Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp45509rdb; Wed, 21 Feb 2024 16:40:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWMVcA/zn4VjNeXtmF+xKHTnl4ClCFpCRtnbjvnUTWqGdqCIkeMTtp1kxkVZw6srDItdNp/uyM5rgjYnbJDhBFpJZVfrPV5BsvmI7PicA== X-Google-Smtp-Source: AGHT+IHMA5QrGekWhgYyncdVPBNoCRwE+rFlZx91bcP8FPCW6elmog/loVnCA+cO8vIEtqZdrgCT X-Received: by 2002:a50:ee14:0:b0:564:a4e9:3688 with SMTP id g20-20020a50ee14000000b00564a4e93688mr5306625eds.10.1708562413226; Wed, 21 Feb 2024 16:40:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708562413; cv=pass; d=google.com; s=arc-20160816; b=U6HVx1U8raBYhGteryzInQho6vpJgiZKMw8kpRwSRi9wDV6Ber5o10vSRTy9WGBng7 y6Z5rXK9pMdlteL9TsoDa8+7F5C5O4giepkSe65FDw2P4N1aJP+yF2CaYz+5MlUy5QK4 NpA2hH/hMn6kXTNW8iSqkFRzs87Y8a9fOullrzn0Lqt7SGCED4G9BUIX6EFAtZ+Sre9L JMyMo+5YWR5XaQZdjOpF4vnB7Ob0s4TZhcqGoEJF07+Ldofl2RRk98lkjGe3z6KBnaRU NGe3QEgIJvjOAh4TaBifUWSPpHOuADNjMprUwBH/eMllJF0qmUjw/Mc+mll2Pr8YdLmD Tjgw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3cPh5EYVwGWaYgvsr8YLKJcb0/yJUuFAluKjFfz/1Eo=; fh=iM7iXAcm4qPTb25dNCe/rLwHBZXBNVHGfGdDWun678U=; b=bjv3ahG4/gbASZ14oN3Fbsc+m+V0STB2SpWPwaPfjbS5nfIrpNobTzuo6hhbAtAUU4 zAzfWwnuLzxkUktyB0SeOZ/Mm5ANGo5N+DpFppVN2+z5Y618uOAyMy8IGeJy7e9aVHYd jbmGZTuBayrRBqROuCRT2ilC7pYMZyLPyKoopqyLtCS9UBUlFuGxiC2dZSNmzPO5Fsm8 pXVyMMybdrlJKQypc1BwSnkCHMg/vb/jjg1GvFz5iKoA3uaL8ZYjjIf0bFfGIF68fGyM Vjf0Bmwp9Wv/ktfj4O3WW6E3K46qsK/H/d0K2I9dlrYiY4v4sK1yWW9YsQKerTrI6oRj 1zfw==; 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=MrLKmCi4; 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-75735-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75735-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m25-20020a50d7d9000000b00564accf2b6esi2462313edj.406.2024.02.21.16.40.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 16:40:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75735-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=MrLKmCi4; 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-75735-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75735-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 am.mirrors.kernel.org (Postfix) with ESMTPS id C13731F249FD for ; Thu, 22 Feb 2024 00:40:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3853810A1A; Thu, 22 Feb 2024 00:40:06 +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="MrLKmCi4" Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (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 CCCF010795 for ; Thu, 22 Feb 2024 00:40:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708562405; cv=none; b=TaSK5L85CAdk4QkHV8DrIdBkCCXOU0gT0zX4wl/Y5/qIz7BEu6Fg+UK2Pesod6BK2yTeFnnDNw28QDG7bk0jv8HZf6n9bXlQ4hxmoYdA9BCrCLc3p3rZmdkbW/G7MDhE1jNPgasPiTPXNWhuYneQPMS2AG6OKRvcvOopZwe9XLs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708562405; c=relaxed/simple; bh=3cPh5EYVwGWaYgvsr8YLKJcb0/yJUuFAluKjFfz/1Eo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ka9CvAl+QLrCEbjNoOdEu3YVRi3/q9pQT5HzCWNAEPe8y9sfCUV14ePnjis+UxiY9JOM2ZAxj7UhQLrn4WrKsWhSTotiQ5MB7/XdEHiQ9jME9ECFfhDRDY4BxUvtd2gmOmBoVu/kl3d4SgtN6D46vN1vKBfuxcWGbrWGRE3VTR0= 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=MrLKmCi4; arc=none smtp.client-ip=209.85.216.50 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-pj1-f50.google.com with SMTP id 98e67ed59e1d1-299e0271294so1735195a91.3 for ; Wed, 21 Feb 2024 16:40:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1708562402; x=1709167202; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=3cPh5EYVwGWaYgvsr8YLKJcb0/yJUuFAluKjFfz/1Eo=; b=MrLKmCi4BmAp5eYeFcOMeqQGDgSbpL/pOSxuO1z6vKvVfM50hQsEDkjCohesjLgRI6 3kl3r3Ttn9qadyDk/JdASepgleKakrM3Y95GBF2XS65GgoOgUKl9bozx+++np/XIb+6x K0pdbQYqoAMXv3n/kiUyBE0PEp6uDDgFTBfBsC+JjQYwVwXr8siNlaaRPkEcR65iK7SX wRQeTrhLhUu/VWeqr3+69+C8bGmTY8pYE8sGcn5WRPYaesKwGR76tD92974RkPUORtuE 5hx+A7kojYNgklKk9wO8i5IB2o/FwIJpCb3rDPCsXntXuGGoF1qCCczDdvmZQFQ8m9VO FU/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708562402; x=1709167202; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3cPh5EYVwGWaYgvsr8YLKJcb0/yJUuFAluKjFfz/1Eo=; b=EdBLPA1vTszXpMaJIni+SaO/iStsHE6hnvOTgYmiz0PGpwKS7VLlo34Rwru9ukd5th VBj5rDSMkmaO5CrVsXralNaKglWQ6HOkUmZ2iowz9RLMR7k5c/ukc048r0j34kgg3AHD I++sP1QMaaH8vnt6XymvyIPOPRJhFCkoN64uVIy2pJD+fQcE+ze+cihOcTorg/KjN8xk Ba9z37uwNOpCwJneEurJoh4TTFvZdQOjEySobtN++3gXUg8zk9era4VVxMGOukapGXXN 8Zz5HbppUv2rZ6GWHgdYY2AVyL2EGwn5Dg45/s3pm6R0iAxg35TdtyA6cXEsSuYneThU huOw== X-Forwarded-Encrypted: i=1; AJvYcCV4E02hjXrNziHKcKnNOzzs3HngjFJ2TdaTYhca7tIshUW1mw8Od9MVxGCaem/fnTh/VMPkKm+4hWRYT4QME4Fw4/Z+T2zKBsj2sO5G X-Gm-Message-State: AOJu0YwIZ6aEqmYZYlHxjefbu0wl/jROsI0Ybj7E0pVGwXDGR+lvmbHx Skxe2eBnGCPgBO5+3lsvyrML8S/ogADUv6NZ1kQNDBsjNhI2ciXzcfdSSyLz+18= X-Received: by 2002:a17:90a:72c6:b0:299:4fa7:71e5 with SMTP id l6-20020a17090a72c600b002994fa771e5mr11324761pjk.8.1708562402076; Wed, 21 Feb 2024 16:40:02 -0800 (PST) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id qc17-20020a17090b289100b002993743e4a7sm2480570pjb.20.2024.02.21.16.39.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 16:40:01 -0800 (PST) Date: Wed, 21 Feb 2024 16:39:57 -0800 From: Deepak Gupta To: "Edgecombe, Rick P" Cc: "ajones@ventanamicro.com" , "bjorn@rivosinc.com" , "conor.dooley@microchip.com" , "broonie@kernel.org" , "keescook@chromium.org" , "kito.cheng@sifive.com" , "paul.walmsley@sifive.com" , "palmer@dabbelt.com" , "alex@ghiti.fr" , "Szabolcs.Nagy@arm.com" , "alexghiti@rivosinc.com" , "atishp@atishpatra.org" , "cleger@rivosinc.com" , "josh@joshtriplett.org" , "linux-arch@vger.kernel.org" , "gerg@kernel.org" , "linux-kselftest@vger.kernel.org" , "bhe@redhat.com" , "charlie@rivosinc.com" , "david@redhat.com" , "samitolvanen@google.com" , "heiko@sntech.de" , "panqinglin2020@iscas.ac.cn" , "mchitale@ventanamicro.com" , "corbet@lwn.net" , "revest@chromium.org" , "mason.huo@starfivetech.com" , "ojeda@kernel.org" , "baruch@tkos.co.il" , "waylingii@gmail.com" , "linux-riscv@lists.infradead.org" , "joey.gouly@arm.com" , "ancientmodern4@gmail.com" , "mathis.salmen@matsal.de" , "aou@eecs.berkeley.edu" , "shr@devkernel.io" , "andy.chiu@sifive.com" , "shuah@kernel.org" , "arnd@arndb.de" , "linux-kernel@vger.kernel.org" , "vincent.chen@sifive.com" , "greentime.hu@sifive.com" , "oleg@redhat.com" , "willy@infradead.org" , "zhangqing@loongson.cn" , "jhubbard@nvidia.com" , "ebiederm@xmission.com" , "Wang, Xiao W" , "cuiyunhui@bytedance.com" , "brauner@kernel.org" , "catalin.marinas@arm.com" , "ruscur@russell.cc" , "shikemeng@huaweicloud.com" , "jszhang@kernel.org" , "jeeheng.sia@starfivetech.com" , "alx@kernel.org" , "guoren@kernel.org" , "omosnace@redhat.com" , "linux-mm@kvack.org" , "evan@rivosinc.com" , "bgray@linux.ibm.com" , "apatel@ventanamicro.com" , "akpm@linux-foundation.org" , "linux-doc@vger.kernel.org" Subject: Re: [RFC PATCH v1 11/28] riscv: Implementing "PROT_SHADOWSTACK" on riscv Message-ID: References: <20240125062739.1339782-1-debug@rivosinc.com> <20240125062739.1339782-12-debug@rivosinc.com> <2914cf78e47010e195d963857b37807e8446e3be.camel@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2914cf78e47010e195d963857b37807e8446e3be.camel@intel.com> On Fri, Feb 09, 2024 at 08:44:35PM +0000, Edgecombe, Rick P wrote: >On Wed, 2024-01-24 at 22:21 -0800, debug@rivosinc.com wrote: >> +???????/* >> +??????? * PROT_SHADOWSTACK is a kernel only protection flag on risc- >> v. >> +??????? * mmap doesn't expect PROT_SHADOWSTACK to be set by user >> space. >> +??????? * User space can rely on `map_shadow_stack` syscall to >> create >> +??????? * shadow stack pages. >> +??????? */ >> +???????if (unlikely(prot & PROT_SHADOWSTACK)) >> +???????????????return -EINVAL; > >Are you sure you need PROT_SHADOWSTACK? Since you are passing >VM_SHADOW_STACK into do_mmap() directly. Sorry for (very) late response. In this patch series since VM_SHADOW_STACK was an alias to VM_WRITE. And that's why I needed PROT_SHADOWSTACK to disambiguate. I am updating my patches and going with ARCH_5 bit (and thus only 64bit support). So x86, aarch64 and risc-v will be using same bit position.