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 3F711D0D78F for ; Fri, 11 Oct 2024 13:31:07 +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=AkAIVkCCLm+LBE1NyTtGoycFFnVAf/yRc8ebxXPNu1o=; b=TxpgROEevl9Uo70kAHePQ7vKIv Zmd+CVmw5Kjlt6yRx8njn6ZH9NJ7P/feOw8OnSj+gpXud1Mz9Bnja2OVzZgfq3eMxtD9RZnAEqG69 X6mjAt9wGywzz7ZsVXFMrZE6Zb4FaDyVoMS8KIu52mWwMSbQVFj7pb8YEdq7lxfcTAb6GpMg3FBfn QlxPPyfbu6QSCq2LZvILN+HOgam/r6sqjtQnWKzodLJHPc9zS65aOAVpijS5QhmKA/YkcmkQlL89g XUiIZJT2cwRJxC3qH8z3emplmxHtCYWw24esGx3TpSAy+yPc1lzAtqvS3UMPzNVAungd9yynfO+HO w5ON75HA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1szFjM-0000000GSPi-20uY; Fri, 11 Oct 2024 13:30:56 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1szFYT-0000000GQQV-35Ek for linux-arm-kernel@lists.infradead.org; Fri, 11 Oct 2024 13:19:42 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BA1535C5B9F; Fri, 11 Oct 2024 13:19:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58A97C4CEC7; Fri, 11 Oct 2024 13:19:37 +0000 (UTC) Date: Fri, 11 Oct 2024 14:19:35 +0100 From: Catalin Marinas To: Gavin Shan Cc: Steven Price , kvm@vger.kernel.org, kvmarm@lists.linux.dev, Suzuki K Poulose , 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 , Shanker Donthineni , Alper Gun , "Aneesh Kumar K . V" Subject: Re: [PATCH v6 05/11] arm64: rsi: Map unprotected MMIO as decrypted Message-ID: References: <20241004144307.66199-1-steven.price@arm.com> <20241004144307.66199-6-steven.price@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241011_061941_847936_677F0A52 X-CRM114-Status: GOOD ( 13.82 ) 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 Tue, Oct 08, 2024 at 10:31:06AM +1000, Gavin Shan wrote: > On 10/5/24 12:43 AM, Steven Price wrote: > > diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c > > index d7bba4cee627..f1add76f89ce 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; > > @@ -92,6 +94,16 @@ bool arm64_is_protected_mmio(phys_addr_t base, size_t size) > > } > > EXPORT_SYMBOL(arm64_is_protected_mmio); > > +static int realm_ioremap_hook(phys_addr_t phys, size_t size, pgprot_t *prot) > > +{ > > + if (arm64_is_protected_mmio(phys, size)) > > + *prot = pgprot_encrypted(*prot); > > + else > > + *prot = pgprot_decrypted(*prot); > > + > > + return 0; > > +} > > + > > We probably need arm64_is_mmio_private() here, meaning arm64_is_protected_mmio() isn't > sufficient to avoid invoking SMCCC call SMC_RSI_IPA_STATE_GET in a regular guest where > realm capability isn't present. I think we get away with this since the hook won't be registered in a normal guest (done from arm64_rsi_init()). So the additional check in arm64_is_mmio_private() is unnecessary. -- Catalin