Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3799946pxu; Mon, 12 Oct 2020 01:08:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+7n7NF0vwoYIh/h67cdCqEqqdOBdkp/ccKOOVHhvmVNam9Fu9BprVpAwUF6Pu+3zIHTNR X-Received: by 2002:aa7:d4d8:: with SMTP id t24mr13247845edr.247.1602490097757; Mon, 12 Oct 2020 01:08:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602490097; cv=none; d=google.com; s=arc-20160816; b=ILzl2qBmFc7YhWz4fEgPVc9kxn6U+2h1c6JljFTdD/gPsxVfy7sHRUnk/10tu+eFku Fgr05NGq9NedubAtBwEUgiXY1QbyWMPQSN/+HPVmHP+1/IzyOhPVVJvlwwSKaISypXX0 Hs7DrtEg3G6rFI1WozE9zotr7OnnkSsyMNHojdANQI3PgIcDKls8CxgOdmiaqD6y8fjg GXzhhE5BvyOwo32mTw9llTAj3M8sAXnaj0o4T8Air20VSL9RHjZe1D9DBPZPiZ6+vdTV qm+DuYC64iuPVUvcOcxGjob92jST3b3a900AbzGaT4Cre68U1Qaba3/HVcFPGb1Bwn1p XXQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=R8ZqIVFSVt2X8+aDC1vTjvW/FIG+ksOh8dz2Iw6jY0I=; b=ONngBVcEmV/mVRk/Y5oLF+MjpzMsJXR0pJiJItXtHKjVArlskDIBuqapbO4CsWJs0v z29pH6ValrHI/9hIc3uCwCdCH9hWvxo0p3HcqQrUlIAQz3wTeBUMyGCSFC0ZPxbwUvVC w4IKkjl74qKXuxzex4YvYW5hhL0Hyah3I49eY5FM458gBuHU7PPs8C42hg/+csQjZ4sa x+0+Pirt8PZ0cP/j78CDpRrF0et5QCJoqFEv4WWgdI7cH9upVuxOOSJkB3PeGIA41XmU R0NnCdVlWcOD3OzQqlbSBfXJ2JSkJr9zVj62thjE+YvpHjHMHcCmgbVTxsTL8j0njGMG zXog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rz8Dixp3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f1si11280548eds.558.2020.10.12.01.07.54; Mon, 12 Oct 2020 01:08:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rz8Dixp3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727363AbgJLHZ3 (ORCPT + 99 others); Mon, 12 Oct 2020 03:25:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:52954 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726413AbgJLHZ3 (ORCPT ); Mon, 12 Oct 2020 03:25:29 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 87AE0207FF; Mon, 12 Oct 2020 07:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602487528; bh=J36sJhtxzl7UwDAHdCIhtRxDUhNjAfyMJ6sQVGj2UnE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=rz8Dixp3suYOT7a8hu+OOevIejnYpmmTdGf5ZZj8ZPLrdKko+VmwJJGyEgYwc2B7t Y7jWAO+7YDnhpdyCPoQEuBMrNVSJmAjAP3ReZ81/jaq307ryq9bw5qeMzP2MTxYTFw LvH+oUGgFHopPkeH6S7uG53orHm43gayluIGXKV4= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kRsD0-000Qzd-EX; Mon, 12 Oct 2020 08:25:26 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 12 Oct 2020 08:25:26 +0100 From: Marc Zyngier To: l00484210 Cc: catalin.marinas@arm.com, will@kernel.org, broonie@kernel.org, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, fanhenglong@huawei.com, wanghaibin.wang@huawei.com, tangnianyao@huawei.com, jiangyifei@huawei.com, dengkai1@huawei.com, zhang.zhanghailiang@huawei.com, victor.zhangxiaofeng@huawei.com Subject: Re: [PATCH] arm64: KVM: marking pages as XN in Stage-2 does not care about CTR_EL0.DIC In-Reply-To: <20201012010852.15932-1-limingwang@huawei.com> References: <20201012010852.15932-1-limingwang@huawei.com> User-Agent: Roundcube Webmail/1.4.9 Message-ID: <47f80f46b9bac66846871b2db32a3f92@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: limingwang@huawei.com, catalin.marinas@arm.com, will@kernel.org, broonie@kernel.org, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, fanhenglong@huawei.com, wanghaibin.wang@huawei.com, tangnianyao@huawei.com, jiangyifei@huawei.com, dengkai1@huawei.com, zhang.zhanghailiang@huawei.com, victor.zhangxiaofeng@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Li, On 2020-10-12 02:08, l00484210 wrote: > From: MingWang Li > > When testing the ARMv8.2-TTS2UXN feature, setting bits of XN is > unavailable. > Because the control bit CTR_EL0.DIC is set by default on system. > > But when CTR_EL0.DIC is set, software does not need to flush icache > actively, > instead of clearing XN bits.The patch, the commit id of which > is 6ae4b6e0578886eb36cedbf99f04031d93f9e315, has implemented the > function > of CTR_EL0.DIC. > > Signed-off-by: MingWang Li > Signed-off-by: Henglong Fan > --- > arch/arm64/include/asm/pgtable-prot.h | 12 +----------- > 1 file changed, 1 insertion(+), 11 deletions(-) > > diff --git a/arch/arm64/include/asm/pgtable-prot.h > b/arch/arm64/include/asm/pgtable-prot.h > index 4d867c6446c4..5feb94882bf7 100644 > --- a/arch/arm64/include/asm/pgtable-prot.h > +++ b/arch/arm64/include/asm/pgtable-prot.h > @@ -79,17 +79,7 @@ extern bool arm64_use_ng_mappings; > __val; \ > }) > > -#define PAGE_S2_XN \ > - ({ \ > - u64 __val; \ > - if (cpus_have_const_cap(ARM64_HAS_CACHE_DIC)) \ > - __val = 0; \ > - else \ > - __val = PTE_S2_XN; \ > - __val; \ > - }) > - > -#define PAGE_S2 __pgprot(_PROT_DEFAULT | PAGE_S2_MEMATTR(NORMAL) | > PTE_S2_RDONLY | PAGE_S2_XN) > +#define PAGE_S2 __pgprot(_PROT_DEFAULT | PAGE_S2_MEMATTR(NORMAL) | > PTE_S2_RDONLY | PTE_S2_XN) > #define PAGE_S2_DEVICE __pgprot(_PROT_DEFAULT | > PAGE_S2_MEMATTR(DEVICE_nGnRE) | PTE_S2_RDONLY | PTE_S2_XN) > > #define PAGE_NONE __pgprot(((_PAGE_DEFAULT) & ~PTE_VALID) | > PTE_PROT_NONE | PTE_RDONLY | PTE_NG | PTE_PXN | PTE_UXN) I don't understand what you are trying to achieve here. This whole point of not setting XN in the page tables when DIC is present is to avoid a pointless permission fault at run time. At you noticed above, no icache invalidation is necessary. So why would you ever want to take a fault on exec the first place? M. -- Jazz is not dead. It just smells funny...