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 5F00FC3DA4A for ; Mon, 19 Aug 2024 14:12: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: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=CqEa4ZaHVjApUamOxvwbp6MayIKB2NVNbSrBiQmDAnI=; b=NF+E54t6flRDiOw+r0K/r3dHSj VOAXXcNtYB8+umddnkclwt0z2FhsVuoqqKtpT3nsPb1D7Oxfr4fV6NdBehakpMbuLqpY84YPpu8G3 j63ZAoJSULS/3Fva8rUd4Fl99FLknw4V7/FaglgDRdhoePfivwXRyfqKzzhxtcwVpz2chfAQEIJbP H8LLsxCwfk6j1W3kUSABvJ4RDcorb39TasKxH/bNnugmyVmljbfHiXEeLkEb0xM4vBtGCdvxPvu55 +JT7Bk7j5TprDK1VGCnlHaWO1Ou5H3W8ZDNVSQEVJIHdmlvm6ryiCSmiuCumjSpv15ni2oDquMe8v ih83cSAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sg37I-00000001hnp-34ab; Mon, 19 Aug 2024 14:12:16 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sg36d-00000001hgK-3kMm for linux-arm-kernel@bombadil.infradead.org; Mon, 19 Aug 2024 14:11:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID: Sender:Reply-To:Content-ID:Content-Description; bh=CqEa4ZaHVjApUamOxvwbp6MayIKB2NVNbSrBiQmDAnI=; b=PuiRJL78XPN5dIorSeojM2raqq C3pXHAwavZIizG5RhBls5WTW0T9zO6XrHPMbgmyIGQgWblKJqt62x8wNofMsLMo18WSYeIfs/2KMK B9g6M7DetqZ3zGPp6YFXmsxmCN9d2eAoWJXCUS/JD25eHKJCyEYSig0RviL9sCgzXzaVnhDcd4xl4 4x4GNEOxu+lMGY4JS9yYk0Jj+ivN8jo+Kc0++zdXB9pLkQeipk+UizQZT/OGSJKLzqGcor3/HWAuF 67yqcqxMneQ2Af2J+pUQRub+0zQbdwO0E+iaQ6coRp6uWVNCe1wEhxro+OzjdwDmUvSLRtHUij66C k+kCAfAA==; Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sg36X-000000099KF-43ru for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 14:11:33 +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 8A42E339; Mon, 19 Aug 2024 07:11:51 -0700 (PDT) Received: from [10.1.36.36] (FVFF763DQ05P.cambridge.arm.com [10.1.36.36]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 397773F73B; Mon, 19 Aug 2024 07:11:23 -0700 (PDT) Message-ID: <15213e51-e028-445e-a22f-f06fefd15fc8@arm.com> Date: Mon, 19 Aug 2024 15:11:22 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 11/19] arm64: rsi: Map unprotected MMIO as decrypted Content-Language: en-GB To: 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 , Gavin Shan , Shanker Donthineni , Alper Gun References: <20240819131924.372366-1-steven.price@arm.com> <20240819131924.372366-12-steven.price@arm.com> From: Suzuki K Poulose In-Reply-To: <20240819131924.372366-12-steven.price@arm.com> 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-20240819_151130_285301_DCF120AC X-CRM114-Status: GOOD ( 18.98 ) 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 Hi Steven On 19/08/2024 14:19, Steven Price wrote: > From: Suzuki K Poulose > > Instead of marking every MMIO as shared, check if the given region is > "Protected" and apply the permissions accordingly. > > Signed-off-by: Suzuki K Poulose > Signed-off-by: Steven Price > --- > New patch for v5 > --- > arch/arm64/kernel/rsi.c | 15 +++++++++++++++ > arch/arm64/mm/mmu.c | 2 +- > 2 files changed, 16 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c > index 381a5b9a5333..672dd6862298 100644 > --- a/arch/arm64/kernel/rsi.c > +++ b/arch/arm64/kernel/rsi.c > @@ -6,6 +6,8 @@ > #include > #include > #include > + > +#include > #include > > struct realm_config config; > @@ -93,6 +95,16 @@ bool arm64_rsi_is_protected_mmio(phys_addr_t base, size_t size) > } > EXPORT_SYMBOL(arm64_rsi_is_protected_mmio); > > +static int realm_ioremap_hook(phys_addr_t phys, size_t size, pgprot_t *prot) > +{ > + if (arm64_rsi_is_protected_mmio(phys, size)) > + *prot = pgprot_encrypted(*prot); > + else > + *prot = pgprot_decrypted(*prot); > + > + return 0; > +} > + > void __init arm64_rsi_init(void) > { > /* > @@ -107,6 +119,9 @@ void __init arm64_rsi_init(void) > return; > prot_ns_shared = BIT(config.ipa_bits - 1); > > + if (arm64_ioremap_prot_hook_register(realm_ioremap_hook)) > + return; > + > static_branch_enable(&rsi_present); > } > > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index 06b66c23c124..0c2fa35beca0 100644 > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -1207,7 +1207,7 @@ void set_fixmap_io(enum fixed_addresses idx, phys_addr_t phys) > else > prot = pgprot_encrypted(prot); > > - __set_fixmap(idx, phys, prot); > + __set_fixmap(idx, phys & PAGE_MASK, prot); This looks like it should be part of the previous patch ? Otherwise looks good to me. Suzuki