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 8F281CD37B4 for ; Wed, 4 Sep 2024 12:31:08 +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=924oFvXUS60bJLt9ijjCuzhCWMYnta5Eeyk7uboMeQY=; b=qG+CPhnxcTB62qXTYTZSe0h4kD 7a0JjaGm4Kvr6OyVmJ81fz1Ow29hIHF+XQm0JSZgsjPvNOvd2g8ObYlTUVpypeNRMHc9iKbPYPtB7 4nIeupXaERivaC2G8DYFF3/2NvPvWkCFJsojPEfvR+Xl4v5TH3oRsDnPm7LueU68ooCPBOnbXwGmo lt3gupyzbFVqvk1xXYRQZp7GFXJ5ZBxlV+sBfml49Nhsk8OoRZXAuqnfFBqSV0NWn5K0b4e3zRIyr vWFADlXFtl2dRvjM4q0UeNZyiD0WaJQB2x4D2S5bhQqmSRe4tY3zb+bryhAHMkj1Y/9loYdj2OPL0 skbVd0xA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slp9z-00000004Mzk-3fzL; Wed, 04 Sep 2024 12:30:55 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1slp91-00000004MlE-1lfQ for linux-arm-kernel@lists.infradead.org; Wed, 04 Sep 2024 12:29:56 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 2B6745C5780; Wed, 4 Sep 2024 12:29:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C4A8C4CEC8; Wed, 4 Sep 2024 12:29:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725452994; bh=ywrrvWGMOTGS+YcrhqzeKRqIPvwsjsNTnVgiKZAIX6M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DPWQiTaO5s8P0ZjSqzA0bUwrXTUqj5r5mUo16ge5GurjvEDTLHbnHDTYIl6fg11Nb tqRChBxU2jmgwnYRYUOEHFyCQvo8tUE+qVSnpgadnab/s4OXoAFceI8KJuUk/Rt9uN sG232kEDccAQajm+dE68HNuGj8di3S+sUoEsbcOJ8rigdUZvXJSLrbulbXzI3MDfdH xepfarbUV1XbWfsArJPRlbbcsgw1OxyEg6ftumb+YduO3W+1d7ix4L+YqFNnFunsfu X3qjRKolTGyz6ngclxLuHaOBDcva451jiRY4M4jbbuZF00mk6fPPM+2dSfQyoUZTqd Eg0NIFrr2BD+Q== Date: Wed, 4 Sep 2024 13:29:48 +0100 From: Will Deacon To: Catalin Marinas Cc: linux-arm-kernel@lists.infradead.org, Sudeep Holla , Lorenzo Pieralisi , Suzuki Poulose , Steven Price , Oliver Upton , Marc Zyngier , linux-coco@lists.linux.dev Subject: Re: [PATCH v2 5/7] arm64: mm: Add confidential computing hook to ioremap_prot() Message-ID: <20240904122948.GF13550@willie-the-truck> References: <20240830130150.8568-1-will@kernel.org> <20240830130150.8568-6-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240904_052955_546588_18DC8D99 X-CRM114-Status: GOOD ( 18.90 ) 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, Sep 02, 2024 at 08:08:45PM +0100, Catalin Marinas wrote: > On Fri, Aug 30, 2024 at 02:01:48PM +0100, Will Deacon wrote: > > @@ -16,7 +28,16 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, > > if (WARN_ON(pfn_is_map_memory(__phys_to_pfn(phys_addr)))) > > return NULL; > > > > - return generic_ioremap_prot(phys_addr, size, __pgprot(prot)); > > + /* > > + * If a hook is registered (e.g. for confidential computing > > + * purposes), call that now and barf if it fails. > > + */ > > + if (unlikely(ioremap_prot_hook) && > > + WARN_ON(ioremap_prot_hook(phys_addr, size, &pgprot))) { > > + return NULL; > > + } > > + > > + return generic_ioremap_prot(phys_addr, size, pgprot); > > } > > EXPORT_SYMBOL(ioremap_prot); > > I mentioned on the CCA series, the patch is all good but we may need > something similar for io_remap_pfn_range() which uses > pgprot_decrypted() (I think it mostly matters for the pKVM case). Thanks for pointing this out. We've not needed this on Android yet, but I think that it would be pretty straightforward to add with an arm64 definition of io_remap_pfn_range(). I'd just prefer to leave that until we know that we need it -- in all likelihood a driver would MMIO_GUARD the resources as part of its own ioremap() before remapping into userspace. Will