From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CB872185B1; Fri, 11 Oct 2024 13:19:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728652781; cv=none; b=tAbaT79jPmdxuIlJcZfhqRh3uWSyhWXyZbZllhQc1Kf+D64nonGa8NUirH/SEQMItcAMasasWjYeQgXxRpOOnzCb1Vn4xNZqmB27oaRZ4L1TTBpp7ht/yI0jctIfaHgzsTNVW0ObAf65+7fnA8NXuKTfC99KsbniTiui/bpkGJ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728652781; c=relaxed/simple; bh=KPk/oGQCSzHeJeEm1U6bQDYtA3wrtPagucVe1rAmc3o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nS2eXTBl8l1OlAvFhVqeo24qnWzAAt7hF4XXPU0WCzBydAnlaKi3uYIe6iCy/mnTeXhP+Oy9AV7hKnHOI4U7NParDcLN/v5Mnubz/H+d1IELcvyq2WYQ+eAGewCXA25Gm20gEElkkacCPxlyJDGH0RvZHgp3PjEgnXYZfUklMLg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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