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 75D29C27C79 for ; Mon, 17 Jun 2024 15:43:54 +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:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WIwMqvZVbsDwaNYl8P97YPharnYqry8TPWL7/6kCWMc=; b=ORguFebRiQw0YW2DHukkvuNWgG FwatyGsscS+CmXaiA4cP+Blk+a7XIkrJEn/GXhcVy5PohwZ/2Rfrm9jGhFnqA0pv9US2q5AGHLOzZ EwovkZzpVWvT125KAsRnibkB4wGcZGHHDSj5Uq3Ob/wI1NKNAI73XM2wYVsLw4Ahr97sDtoio6/eX dSPtBZYCsOO66vknLU2sq1i46UQI+yepZjUZNLchZANNI1PhmIud+OkqLCcKIrLGY3GfFtua3EypM wEL0u2Xugo+/Pq+nbiOQGcvgrUfjmnXodNKvpLSdlaSlrGJmuNV8zJhDFA+zi8LTdPY1OdyGhz9j/ vNyKWcew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJEWF-0000000BXbt-1eFK; Mon, 17 Jun 2024 15:43:43 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJEWB-0000000BXZY-0pzP for linux-arm-kernel@lists.infradead.org; Mon, 17 Jun 2024 15:43:41 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 9B513CE127D; Mon, 17 Jun 2024 15:43:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90818C2BD10; Mon, 17 Jun 2024 15:43:32 +0000 (UTC) Date: Mon, 17 Jun 2024 16:43:30 +0100 From: Catalin Marinas To: Suzuki K Poulose Cc: Michael Kelley , Steven Price , "kvm@vger.kernel.org" , "kvmarm@lists.linux.dev" , 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 Subject: Re: [PATCH v3 10/14] arm64: Force device mappings to be non-secure shared Message-ID: References: <20240605093006.145492-1-steven.price@arm.com> <20240605093006.145492-11-steven.price@arm.com> <1dd92421-8eba-48db-99da-4390d9e19abd@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1dd92421-8eba-48db-99da-4390d9e19abd@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240617_084339_731423_C920DBD2 X-CRM114-Status: GOOD ( 21.27 ) 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 Mon, Jun 17, 2024 at 03:55:22PM +0100, Suzuki K Poulose wrote: > 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) And maybe rewrite pgprot_device() as: #define __pgprot_device(prot) \ __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_DEVICE_nGnRE) | PTE_PXN | PTE_UXN) #define pgprot_device(prot) __pgprot_device(pgprot_decrypted(prot)) -- Catalin