Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp433394rdb; Mon, 15 Jan 2024 01:55:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IGPEtFhxnr64NHY/jZ2uCY5Ph28Ou7SEz4dueNVOhifpNngMR4TFP0hFkhCLBVlqcHttPoB X-Received: by 2002:a17:90a:4cc2:b0:28d:deca:f42d with SMTP id k60-20020a17090a4cc200b0028ddecaf42dmr2293681pjh.90.1705312542032; Mon, 15 Jan 2024 01:55:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705312542; cv=none; d=google.com; s=arc-20160816; b=W3KzbEJuRZpqezXO0oczJjvMx5gLb/aWxsF3FYslbM7QtZehjAAkv5FiQHozs/GJf+ XSUELuZkG1D7Vbw79j3YhA338w5pZZQuQdf7FAvvBuA2WOe19K0VrswfEeNOpBkozTG8 5BjLSy78wPlfz21Zkrh5vQsHMYEgg1x32g8LqLA9UeKVrIm+78Li1Tlfg1cU/XraQPJn 64CXmKOe/cepnAhifDi58iXNpKEc3eVa1PNPCAwaHJ578IE8DiH1PvcQOapGuqpj6wVi K2Qd0htyh8c0D59zjH0fbrcWclStQXJozXt6lNwAg/oy+z/684hzP3N89P1YGu+NfpPe lXtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ayM3VXLBcrNRpTHYUNamZ0bANAYgOyvoZvdsHWRe71M=; fh=srb/EijQIrMEdOeqn3qQX6qrsAGyqHAqeSFkl/qDdLM=; b=YXED19H2hKLGkg2hj3mh5WnV1IoMYfju91M+VHtIHeeoU4wVRpkKdaR/839K693Tsl qOZBCsWgmI8z3dhQXNDLEN/pAazOEcNCHzCchKHayKZeWFh2a+CFgXuMnYnBS2yuicC7 RGkaAJihYSNyZAfJOF+JBe+dZhAsIKQjx4omhpaUTc4SdMRS8Z4rFoJgvuiwfAAUWZN9 mHMdG2hN5bL26b+/8ZhhqCxAtcLR0Ys3szqFugxSXbConj1b4PywuVnlRafFPhaBj7re cGaZow+fDPzSp9dpjzSN79tpTJYaYdhLf3VNe+/vYH2o/pl8Lcao56QP5l7V5j8wFYf6 FogA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uvOrwRci; spf=pass (google.com: domain of linux-kernel+bounces-25830-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25830-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 j12-20020a17090276cc00b001cfa70fd337si8543182plt.301.2024.01.15.01.55.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 01:55:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25830-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=@kernel.org header.s=k20201202 header.b=uvOrwRci; spf=pass (google.com: domain of linux-kernel+bounces-25830-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25830-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A29FF281B42 for ; Mon, 15 Jan 2024 09:55:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01982EAF8; Mon, 15 Jan 2024 09:55:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uvOrwRci" 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 34379DF4C for ; Mon, 15 Jan 2024 09:55:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6460AC433F1; Mon, 15 Jan 2024 09:55:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705312517; bh=Y0aXOS+b6gFxoHVGLnmvCujUW0jIxABtyiwWOpMnOy4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uvOrwRcibUEOPd2gfHpwl68cNRhLAGmvLkmx3PXLjDOsB5f4Y/snIEUNpq+T3ctVu /aHgT65BQiXO7wIGoXCaSSqAvd4/Hn1pWpnhnvsvWr6G80vkTcmUt8MeyAlKLQNMKa C/RroNXYaoP34iFrd88FdhbO9AOpt0QrxAJSkod1JZ5iZU5EaXhLuEsEcN+xHanK8h LzM58DvkhUylMOv6WWSjwlcmqMPaA1h48+LSHH6rY5J3fTHNuac+QSxkCJ0R3j4yIt pxWn4SSzhTtf0i7ToQ5y4v1vVRt3JbDYV+1s3juWg4vxyZW9AlrRpWdGBqPeyqG6V7 umTEvzDbXCjsg== Date: Mon, 15 Jan 2024 17:42:26 +0800 From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] riscv: mm: implement pgprot_nx Message-ID: References: <20231121160637.3856-1-jszhang@kernel.org> 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=utf-8 Content-Disposition: inline In-Reply-To: <20231121160637.3856-1-jszhang@kernel.org> On Wed, Nov 22, 2023 at 12:06:37AM +0800, 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. And this simple patch to enforce W^X protection is also missed ;) Thanks in advance > > 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) > { > -- > 2.42.0 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv