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 3B5E2C5321D for ; Mon, 26 Aug 2024 11:43:29 +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=x1THXpanKj8WvQa+wr2aeG8fnnwrJZwxZrJeiEVVFYk=; b=t0XJFcjdVC573MWYgiYwDE45v/ kiDCjQC3jk5aS3axbkUKbCW2bRAMUoqTWCF5V3+rsO0miM2dI5/iQpzzRuG5iV8sCq0l/ASjn887R mUl9y0G3eb1qwfRhTTBfMCcysy/9M9FIqU7IxwOp8lQjW/KwtiXjnOQ5XKY4ZYqR6IA4GGfNr5s9M pbkR22g+u/Q34lDiOtq10N+FCx3nD3is9DbTDjXlPjWo3dYSgKl5A3D1LIN5p38UU0cf8Uj/hvn38 zn4NN1PTxuCbrtrhk+azlyYBeAessAX6dNzcEMRCnB7nKBo83a3vvML2iCifIGgtVd9Pewyg195Wl bi2E+Ovw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siY7z-00000007BN2-3VhL; Mon, 26 Aug 2024 11:43:19 +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 1siY7C-00000007BFb-3gyT for linux-arm-kernel@lists.infradead.org; Mon, 26 Aug 2024 11:42:32 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 10E2FCE0E01; Mon, 26 Aug 2024 11:42:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83A11C51409; Mon, 26 Aug 2024 10:12:58 +0000 (UTC) Date: Mon, 26 Aug 2024 13:13:06 +0300 From: Catalin Marinas To: Steven Price Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , 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 , Gavin Shan , Shanker Donthineni , Alper Gun Subject: Re: [PATCH v5 12/19] efi: arm64: Map Device with Prot Shared Message-ID: References: <20240819131924.372366-1-steven.price@arm.com> <20240819131924.372366-13-steven.price@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240819131924.372366-13-steven.price@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240826_044231_112089_083B4D59 X-CRM114-Status: GOOD ( 22.18 ) 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, Aug 19, 2024 at 02:19:17PM +0100, Steven Price wrote: > From: Suzuki K Poulose > > Device mappings need to be emualted by the VMM so must be mapped shared > with the host. > > Signed-off-by: Suzuki K Poulose > Signed-off-by: Steven Price > --- > Changes since v4: > * Reworked to use arm64_is_iomem_private() to decide whether the memory > needs to be decrypted or not. > --- > arch/arm64/kernel/efi.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c > index 712718aed5dd..95f8e8bf07f8 100644 > --- a/arch/arm64/kernel/efi.c > +++ b/arch/arm64/kernel/efi.c > @@ -34,8 +34,16 @@ static __init pteval_t create_mapping_protection(efi_memory_desc_t *md) > u64 attr = md->attribute; > u32 type = md->type; > > - if (type == EFI_MEMORY_MAPPED_IO) > - return PROT_DEVICE_nGnRE; > + if (type == EFI_MEMORY_MAPPED_IO) { > + pgprot_t prot = __pgprot(PROT_DEVICE_nGnRE); > + > + if (arm64_is_iomem_private(md->phys_addr, > + md->num_pages << EFI_PAGE_SHIFT)) > + prot = pgprot_encrypted(prot); > + else > + prot = pgprot_decrypted(prot); > + return pgprot_val(prot); Nit: This pattern appears in the previous patch as well. Maybe add a pgprot_maybe_decrypted(). The patch looks fine other than the need for an early initialisation if we find any workaround. In the pKVM case, IIUC this would need to call into the hypervisor as well but that can be handled by the bootloader. For CCA, our problem is setting the top bit of the IPA. What's the x86 approach here? The EFI is a bigger problem than the earlycon. -- Catalin