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 A2D91C43458 for ; Mon, 6 Jul 2026 13:35:45 +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-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID: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=uLviVLYgT3tLYFzYiI6Zru82tyxHPobIeBJDsXCYEGE=; b=eBZhGWak1stmX2Z6tgshpY4Xm7 fOFNCs56K5HLp8aaQWa+bBi9B/EK6s/PEn1zlPr/os23VESw2LbT9DGEcamkI7etZ5C04dD94dq5S f/ty0HsAuapit9J30jiITVDjGtOaEOfY4zj/3+dNf8KWWDi6qigNQLOAdLZdS6A/IUocRqTOyORCH WBqqLkhb1pu2OQn8XeuZUsAevJJii5MOcrITfnxmH+qVL7Gp3s1kzVz7tBN0YOY57NqkkVYK4oKAi lfaxEHexzmiRI3qJaDVznPqKqN1WXHl2JpltOk05xNPqEbBgxATfcMFwOPnYB2H/JnMM5r4pSxwN9 qdRulwXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wgjU3-0000000CcLT-1w9A; Mon, 06 Jul 2026 13:35:39 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wgjU2-0000000CcLE-3EIA for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2026 13:35:38 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id EF6C4600DA; Mon, 6 Jul 2026 13:35:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A14D01F000E9; Mon, 6 Jul 2026 13:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783344937; bh=uLviVLYgT3tLYFzYiI6Zru82tyxHPobIeBJDsXCYEGE=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=W8mktv82qSURqSaR4khAQUk7rv+HF7NlRSLA73tWAmclaNwHXS+dyT8h0BbeTLW0C IXGQIHoi2kXpNIfZ6FMDRgPPHMAED6HnuJsb54jXSgdLzf1f/N6BkJH2uxa7wyHhAF ae6RJ6bfyviz/WHMgMJvpzqwht6LnYKSSzPufbKA65RL1MgU/lt8wtduUw+vXyMiQf wUWTR1RWuUh4hLbeNPgaSaCumyKdkLkFnF/yFAf4jSipK2FJST7DJlYo8OtxANoWWn Q8DvCEmW1TfJecSDxSkbRbLpcwqNRIFqUCsXgqYOyl68zhSonQh4CakRGWKadO6rU2 WoBbUPcDWwiJQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wgjTz-00000001xgl-2Wl5; Mon, 06 Jul 2026 13:35:35 +0000 Date: Mon, 06 Jul 2026 14:35:35 +0100 Message-ID: <86ik6sp7fc.wl-maz@kernel.org> From: Marc Zyngier To: "Aneesh Kumar K.V (Arm)" Cc: linux-coco@lists.linux.dev, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, Catalin Marinas , Jason Gunthorpe , Marek Szyprowski , Robin Murphy , Steven Price , Suzuki K Poulose , Thomas Gleixner , Will Deacon Subject: Re: [PATCH v5 02/10] irqchip/gic-v3-its: Align shared ITS allocations to the CoCo shared granule size In-Reply-To: <20260706060432.1375570-3-aneesh.kumar@kernel.org> References: <20260706060432.1375570-1-aneesh.kumar@kernel.org> <20260706060432.1375570-3-aneesh.kumar@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: aneesh.kumar@kernel.org, linux-coco@lists.linux.dev, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, catalin.marinas@arm.com, jgg@ziepe.ca, m.szyprowski@samsung.com, robin.murphy@arm.com, steven.price@arm.com, suzuki.poulose@arm.com, tglx@kernel.org, will@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false 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, 06 Jul 2026 07:04:24 +0100, "Aneesh Kumar K.V (Arm)" wrote: > > ITS tables allocated by the coco guest are shared with the hypervisor. > These allocations must satisfy the host shared-buffer granule size so that > the full converted range is safe for host access. > > Allocate ITS pages using a size rounded up to the shared granule size and > use the same allocation order when encrypting, decrypting and freeing the > memory. Also grow the ITT cache in shared-granule sized chunks instead of > assuming PAGE_SIZE is sufficient. > > Signed-off-by: Aneesh Kumar K.V (Arm) > --- > drivers/irqchip/irq-gic-v3-its.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > index b57d81ad33a0..5d6d38aa0dae 100644 > --- a/drivers/irqchip/irq-gic-v3-its.c > +++ b/drivers/irqchip/irq-gic-v3-its.c > @@ -213,16 +213,17 @@ static gfp_t gfp_flags_quirk; > static struct page *its_alloc_pages_node(int node, gfp_t gfp, > unsigned int order) > { > + unsigned int alloc_order; > struct page *page; > int ret = 0; > > - page = alloc_pages_node(node, gfp | gfp_flags_quirk, order); > - > + alloc_order = get_order(mem_cc_align_to_shared_granule(PAGE_SIZE << order)); > + page = alloc_pages_node(node, gfp | gfp_flags_quirk, alloc_order); > if (!page) > return NULL; > > ret = set_memory_decrypted((unsigned long)page_address(page), > - 1 << order); > + 1 << alloc_order); > /* > * If set_memory_decrypted() fails then we don't know what state the > * page is in, so we can't free it. Instead we leak it. > @@ -241,13 +242,16 @@ static struct page *its_alloc_pages(gfp_t gfp, unsigned int order) > > static void its_free_pages(void *addr, unsigned int order) > { > + int alloc_order; > + > + alloc_order = get_order(mem_cc_align_to_shared_granule(PAGE_SIZE << order)); > /* > * If the memory cannot be encrypted again then we must leak the pages. > * set_memory_encrypted() will already have WARNed. > */ > - if (set_memory_encrypted((unsigned long)addr, 1 << order)) > + if (set_memory_encrypted((unsigned long)addr, 1 << alloc_order)) > return; > - free_pages((unsigned long)addr, order); > + free_pages((unsigned long)addr, alloc_order); The comments I had in [1] are still applicable. M. [1] https://lore.kernel.org/all/86zf2ozrb8.wl-maz@kernel.org/ -- Without deviation from the norm, progress is not possible.