Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp21104rdb; Thu, 25 Jan 2024 07:11:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHxx+rEupSSwpN6AU5eeEOT6FV0PoGoK6xCimqpmkRRPo3plPdjBhvwMiYocIeoC1Xy8gT X-Received: by 2002:a17:906:5ac5:b0:a2c:30ff:f76c with SMTP id x5-20020a1709065ac500b00a2c30fff76cmr643228ejs.17.1706195465523; Thu, 25 Jan 2024 07:11:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706195465; cv=pass; d=google.com; s=arc-20160816; b=BJbwtKtXKI96zzFIqUdXojaJh8fA3m69+I+uT59Gxr0i9qAHRnMEEWbu8bDKRw+5jZ wlMTTJhmd7oTNlj8b8t61Fx6UiLG9W5txiXdLoKTpHes76FqDR7tqtqpEbjneN7dQTfs zoP4dfea9DfmQPyeMazBIOq9ycruC1w2HSdAeMH/XVDebtwLJUFG+Tcjjkwgx5TgIhny nJBDlTyWB/iGJ9oPAcaZqnAHOncgcEgXgfuzAKdRAfKYs9WskHETnfMJGqmaK4H3RNru 0igYYEaC1XE+7gVpd76QT3LFPmU4hRiV+aj9JrXrwd9wvOa21vRHCluljVcTik/LgFlv /z5Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=muOJuvhRyB2KU2OmrhvdAVcdYv62QvF8+MusI68b6Lk=; fh=Owy+qTVqGN9gnI22GfT3FpCnMspYP1OOd7whkMle+3w=; b=B+Ue7gTFNwMyxO2TSGgiS+ZIuyNyCpHK9OfPD3q704pF3ifpEKEU6fcbjW6/1tQWDA 7V+gzy8uOHn3+Q7EashBlOK4AGNMjTy3pcTzyHvTCghjliRouZL6q5Hnq/b6pMmc81lu K88fDXc25ChHDEf0QPXHGmjAiNqrgrNZZfzFJK6nGq2b5QZqgunb2EGTkhgwwltz1cMJ 5kuAuybwfYr/ZPrzC5gFXUWPWG9RzAoiRD9UHlnzbFHSro/8YV4al1Y3IGEprOFdsc2i O9on/Ry9YkcEhKX4S06byKWdtmD6cmX9eKWJpCwudQkPgsDbzx1q0FyUN8wdHTfdYON+ 8FmA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ij1pUEAQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-38798-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38798-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 v22-20020a170906565600b00a318b349cd6si467744ejr.330.2024.01.25.07.11.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 07:11:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38798-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=@kernel.org header.s=k20201202 header.b=Ij1pUEAQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-38798-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38798-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 3DBDB1F23047 for ; Thu, 25 Jan 2024 15:11:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4EC256EB4C; Thu, 25 Jan 2024 15:10:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ij1pUEAQ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C3CF6E2C9 for ; Thu, 25 Jan 2024 15:10:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706195455; cv=none; b=YB4C3RzlHwka7FdbgObfuvkKLXH1KyO3uOyGxaRpm0qa9zKejovjRVlUOFq+39TeMnblrNvigTF7jtLp7CaT8IDJE6qQHrkdfPCfIZRaRvXYN+5tBDv/jK3SB5I2hQ77jYxNdOzlfVLTepyDRn6JDxZka0cx0W9zQ1sY2oste7M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706195455; c=relaxed/simple; bh=aiagvA75HtW5poT6xWiLeVnkWkTmbI5Tbf6wRBi0vHw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Os1aHSOYUIuhz1ooiWkK0vby/xkB80fuGorsktWd791fNgTYqYyznQYyO7B8vOXphIIWTHxdOdrB83I4NAk0ac2Pv5127/eQWMEdqVaJLvs+gQ2BD+mMa0MN82UTDFmG3vGyt2Amo+upoDyl1lTOxe1H+J0fZ9DxloO+nf2o5ro= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ij1pUEAQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3394CC433C7; Thu, 25 Jan 2024 15:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706195455; bh=aiagvA75HtW5poT6xWiLeVnkWkTmbI5Tbf6wRBi0vHw=; h=From:To:Cc:Subject:Date:From; b=Ij1pUEAQqNLvjJQFRqvQCVYs/CBS9MkCzvkpTxre4q0x05oixWvMoB4acBW5xjCxU rWNbwMb04w6sj36leFQHmm9IYNesSR8Hs8/3EvGy7ZWf61z0/i/7NcJZSGXlvUFlpZ EM52ul/U0h7BqugeRktj6OFfeflFxBN/4oqNrBAjFMQcibapWIdttHHPl9IVz+TPO/ bAOXsB2FescT/oFQWxOZ5Ee7U9ZUgTHFqOes+UrO+2XFBRocCW2RUxHt9P3SkTJkYy 1rr5HnEdhdU0OK/p8PbpvLFCSdnzuYMT25ou4uslnTTA7t8d7iQi1+Zfv1wRDeUQHp QDOJ+f4e+y4aA== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Samuel Holland , Alexandre Ghiti Subject: [PATCH v2] riscv: mm: implement pgprot_nx Date: Thu, 25 Jan 2024 22:58:06 +0800 Message-ID: <20240125145806.933-1-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit commit cca98e9f8b5e ("mm: enforce that vmap can't map pages executable") enforces the W^X protection by not allowing remapping existing pages as executable. Add riscv bits so that riscv can benefit the same protection. Signed-off-by: Jisheng Zhang Reviewed-by: Christoph Hellwig Reviewed-by: Samuel Holland Tested-by: Samuel Holland Reviewed-by: Alexandre Ghiti --- since v1: - rebase on v6.8-rc1 - collect Reviewed-by and Tested-by tag arch/riscv/include/asm/pgtable.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 0c94260b5d0c..c931863bbd1a 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -591,6 +591,12 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma, return ptep_test_and_clear_young(vma, address, ptep); } +#define pgprot_nx pgprot_nx +static inline pgprot_t pgprot_nx(pgprot_t _prot) +{ + return __pgprot(pgprot_val(_prot) & ~_PAGE_EXEC); +} + #define pgprot_noncached pgprot_noncached static inline pgprot_t pgprot_noncached(pgprot_t _prot) { -- 2.43.0