Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp434193rdb; Mon, 15 Jan 2024 01:58:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IFk6Mpb9jL4hnDGZUyiUfYRjQiQ+eMgMhDccC2m/RgIZ/+RRh4YiS6y1HobJ/9NRoDivLVJ X-Received: by 2002:a17:907:50e:b0:a28:c2a9:44b4 with SMTP id wj14-20020a170907050e00b00a28c2a944b4mr1918448ejb.17.1705312701755; Mon, 15 Jan 2024 01:58:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705312701; cv=none; d=google.com; s=arc-20160816; b=GOIEB1m9ZqMVazNGI9pHWYatlU38DYQyxo7i8lU5++riBLxI63Hpa5rXczsguFPAdK luDRhBv5eocoM5lhWkZCT86gjlyYHpz2E7M9oB5uoc3IPT+3z2/pxtWBa2reNNrBJN06 7tQEYRksP9CXPQ3CTcljokLVAF/TwzhU2Zq8+TogizK5DnQq3v6hxVSo00RSDTqrF0lS T7pcpnsISZEc8RzXo1ru+TzwhGnjc3tVAWbvbf3Ojm8LpNjliUQWagIJnc5Ph71vavPG JZQrDhIztnI6MpESiSm/OArQQS25++HsfQel/m47YEcH3RkqMqfCo9sZj8T9CNxeZAf4 reyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=fe8mNUSnuT2Rk4u22bF8bcm+1qdNPa73ljEKhbbQ4mk=; fh=BYPWXTFuQ/AuMDLxT+UvIhRKtFIWBIs5AA2HOAW5yNc=; b=Xk2sxYq+hGmNh3e8P8paFMwhZfE2lIcW78hoqUnuYovJz0qMCPty9zYvJKBHqbuj7K t5GdT0fiAaHqRBS6Kd68cLDMF0grCaUKXHZpxIO+ABToVcdNIFs1oxtIsiC6UMhrOZo/ 8tFU8b4pTf5u/Mt5JzrVLU1ZqXwUhefW22dH2OnPLayHsobyJP5I1BkZ3f2IqNW9+HMh n/AxdD70AEDVSuLFphSDGGxu052AYMtAXIpwHd0lHb+rAHWTkeLJHiK27gA0+1ujDTnk 5jv9ExVXLAJfuq4Ot82xCbRRKhi+KFjXioBTBAUsHq6PC71Ijndup1HKHDbWIQK8+iKO o63A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-25834-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25834-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 v13-20020a170906380d00b00a28eed5b645si3606912ejc.791.2024.01.15.01.58.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 01:58:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25834-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; spf=pass (google.com: domain of linux-kernel+bounces-25834-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25834-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 7FA1D1F234B7 for ; Mon, 15 Jan 2024 09:58:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A459F9D3; Mon, 15 Jan 2024 09:58:15 +0000 (UTC) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 0E22FF9C1 for ; Mon, 15 Jan 2024 09:58:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ghiti.fr Received: by mail.gandi.net (Postfix) with ESMTPSA id A684620010; Mon, 15 Jan 2024 09:58:10 +0000 (UTC) Message-ID: <73f39533-9384-4067-bd81-1ddd56a16236@ghiti.fr> Date: Mon, 15 Jan 2024 10:58:10 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] riscv: mm: implement pgprot_nx Content-Language: en-US To: Jisheng Zhang , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org References: <20231121160637.3856-1-jszhang@kernel.org> From: Alexandre Ghiti In-Reply-To: <20231121160637.3856-1-jszhang@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: alex@ghiti.fr On 21/11/2023 17:06, Jisheng Zhang wrote: > 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 > --- > 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 294044429e8e..4fc6ee5226fb 100644 > --- a/arch/riscv/include/asm/pgtable.h > +++ b/arch/riscv/include/asm/pgtable.h > @@ -608,6 +608,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) > { This one looks good too: Reviewed-by: Alexandre Ghiti Thanks, Alex