From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 35BF6C2BA15 for ; Mon, 17 Jun 2024 14:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xQ90vuohxhLkRgnjK6+RXcwK/XjP2QtpXa7CcmpluT0=; b=HawYPkiT8O1aGo1xTfmZrHsnz7 MqX/igT+XFtmLFMniSBiRvcW58MfZEQ5o21aGzuM9qvK9ZEiCvJRLLTvddX6y8QPmd/+Dr4X+pGfi BmKvSpqK9HOZXADj0dNeMeXJIlxEew9sh6fAHU0pB60tpw/W12klDL2NG210Iwp6pUqmJj6f4GIII 1zPILn6SW8EJsdbhBCmFTOQaafzeWL6v5uib01tqRYGyiVcMgPF8NjQHO1VSPu4+mKHeBZGcOwiHC HAoT5xAxAc9BUZ3uT3ldE4rwe7sR/MG/aHrM3X6FhR3ZEZ3igwKc3izHqtecwRYIMy3UsQQBq7chk tg/TV9EA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJDle-0000000BIdU-1beN; Mon, 17 Jun 2024 14:55:34 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJDlb-0000000BIas-0s3u for linux-arm-kernel@lists.infradead.org; Mon, 17 Jun 2024 14:55:32 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 29177DA7; Mon, 17 Jun 2024 07:55:52 -0700 (PDT) Received: from [10.57.72.20] (unknown [10.57.72.20]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2528D3F6A8; Mon, 17 Jun 2024 07:55:24 -0700 (PDT) Message-ID: <1dd92421-8eba-48db-99da-4390d9e19abd@arm.com> Date: Mon, 17 Jun 2024 15:55:22 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 10/14] arm64: Force device mappings to be non-secure shared Content-Language: en-GB To: Michael Kelley , Steven Price , "kvm@vger.kernel.org" , "kvmarm@lists.linux.dev" Cc: Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Zenghui Yu , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , "linux-coco@lists.linux.dev" , Ganapatrao Kulkarni References: <20240605093006.145492-1-steven.price@arm.com> <20240605093006.145492-11-steven.price@arm.com> From: Suzuki K Poulose In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240617_075531_464511_447EDC34 X-CRM114-Status: GOOD ( 14.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 17/06/2024 04:33, Michael Kelley wrote: > From: Steven Price Sent: Wednesday, June 5, 2024 2:30 AM >> >> From: Suzuki K Poulose >> >> Device mappings (currently) need to be emulated by the VMM so must be >> mapped shared with the host. >> >> Signed-off-by: Suzuki K Poulose >> Signed-off-by: Steven Price >> --- >> arch/arm64/include/asm/pgtable.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h >> index 11d614d83317..c986fde262c0 100644 >> --- a/arch/arm64/include/asm/pgtable.h >> +++ b/arch/arm64/include/asm/pgtable.h >> @@ -644,7 +644,7 @@ static inline void set_pud_at(struct mm_struct *mm, unsigned long addr, >> #define pgprot_writecombine(prot) \ >> __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_NC) | PTE_PXN | PTE_UXN) >> #define pgprot_device(prot) \ >> - __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_DEVICE_nGnRE) | PTE_PXN | PTE_UXN) >> + __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_DEVICE_nGnRE) | PTE_PXN | PTE_UXN | PROT_NS_SHARED) >> #define pgprot_tagged(prot) \ >> __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_TAGGED)) >> #define pgprot_mhp pgprot_tagged > > In v2 of the patches, Catalin raised a question about the need for > pgprot_decrypted(). What was concluded? It still looks to me like > pgprot_decrypted() and prot_encrypted() are needed, by > dma_direct_mmap() and remap_oldmem_pfn_range(), respectively. > Also, assuming Hyper-V supports CCA at some point, the Linux guest > drivers for Hyper-V need pgprot_decrypted() in hv_ringbuffer_init(). Right, I think we could simply do : diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index c986fde262c0..1ed45893d1e6 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -648,6 +648,10 @@ static inline void set_pud_at(struct mm_struct *mm, unsigned long addr, #define pgprot_tagged(prot) \ __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_TAGGED)) #define pgprot_mhp pgprot_tagged + +#define pgprot_decrypted(prot) __pgprot_modify(prot, PROT_NS_SHARED, PROT_NS_SHARED) +#define pgprot_encrypted(prot) __pgprot_modify(prot, PROT_NS_SHARED, 0) + Suzuki