From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 52B073E44F3; Thu, 24 Sep 2026 10:06:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790244425; cv=none; b=fVL0JJZGtElu8LyKD7aGYrGvIMUOTxDV3pahZQJnJrpqezqQSv3OFt+23+TwjXcmpqvs11ZRwIaA4fFcHnrQ1opNzkfbfXbZ2CRSBx2NcFFqznj+d7oFJ+dhYGmiZBqqhe4jAEQeYljOrhXmQ+6JnrmGkcHs2M3K9MUibRcZAcM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790244425; c=relaxed/simple; bh=Z0tay+mZQxzzjyDmj//51K3kjDG5Z6SEp4+DBkaYiS8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YvImHReubClSm/68cZ1W04ZBm7DDVdxK13zZrOWrtc/kBmhTKjB+tfziiTjOJhcQ4kOs0U6S8943weBD423bNjVMKXV6eZdtQtM3TcF4FQ2Yixk0atrHDrXyyefoecxFk+YLviOQNi64Qy3OgkaKmYgo6QbB2lgOqH7YRIcKcP4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MBbTPQiM; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MBbTPQiM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FDE41F000FF; Thu, 24 Sep 2026 10:06:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790244417; bh=waix5vjh+pKFV3Wslxy857438fq/HyMRB7bQ/yb+Wag=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MBbTPQiMrIlhFnAQgodW4mh3L6x9pAnVoy9CpXDiD5kwwKVpSU3cW85m6YO3TllUe +8u1KpU1qq8ya8T0dvH9jh9swr5NkeWtJ0Jd25sXVXkLI4kJPPUC12YjRJqZRefRui Dr8TzQTF2X7fdYDA28ugxZlsWVSwiyDXVbEOHF18q78gXVUmWvnjBgJTLq7m5529Ex 8vXjEnYwjiugyhtg4AKJmlx9fPxgE3qm1L6Pf7xfudwJrSN6SlBAc1JbgB/SJzlNwz dtHD71eWILpn/kglR9wjXyVr+pY2jUtdefsLu9FHGEk86hCjUr/+mEpozltE+1KBYE +LiKQH7VzRRKA== From: "Aneesh Kumar K.V (Arm)" To: linux-coco@lists.linux.dev, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev Cc: "Aneesh Kumar K.V (Arm)" , Andrew Morton , Baoquan He , Mike Rapoport , Pasha Tatashin , Pratyush Yadav , Catalin Marinas , =?UTF-8?q?Christian=20K=C3=B6nig?= , Jason Gunthorpe , Joerg Roedel , Marc Zyngier , Marek Szyprowski , Robin Murphy , Steven Price , Sumit Semwal , Suzuki K Poulose , Thomas Gleixner , Will Deacon , Russell King , Benjamin Gaignard , Brian Starkey , John Stultz , Mark Rutland , Radu Rendec , "T.J. Mercier" , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Ritesh Harjani , Shrikanth Hegde , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , Kiryl Shutsemau , Rick Edgecombe , "K . Y . Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Paolo Bonzini , Vitaly Kuznetsov , Andy Lutomirski , Peter Zijlstra , dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v8 04/14] irqchip/gic-v3-its: Allocate shared tables using CoCo shared memory allocator Date: Thu, 24 Sep 2026 15:35:19 +0530 Message-ID: <20260924100529.1398790-5-aneesh.kumar@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260924100529.1398790-1-aneesh.kumar@kernel.org> References: <20260924100529.1398790-1-aneesh.kumar@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ITS command queues and tables are shared with the host in a confidential-computing guest. The ITS allocator currently assumes that the guest PAGE_SIZE is sufficient for both allocation alignment and private/shared state changes. Route ITS page allocations through alloc_cc_shared_pages_node(). Keep the tracked table size based on the ITS-requested order. On release, reconstruct the common allocation metadata from the original ITS order and the architecture granule size so the same transitioned range and buddy order are used. Cc: Marc Zyngier Cc: Thomas Gleixner Cc: Radu Rendec Signed-off-by: Aneesh Kumar K.V (Arm) --- drivers/irqchip/irq-gic-v3-its.c | 40 ++++++++++++-------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index ac5507acb1a0..4814161df02e 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -19,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -214,25 +213,13 @@ static gfp_t gfp_flags_quirk; static struct page *its_alloc_pages_node(int node, gfp_t gfp, unsigned int order) { - struct page *page; - int ret = 0; - - page = alloc_pages_node(node, gfp | gfp_flags_quirk, order); - - if (!page) - return NULL; + struct cc_shared_pages mem; - ret = set_memory_decrypted((unsigned long)page_address(page), - 1 << 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. - * set_memory_decrypted() will already have WARNed. - */ - if (ret) + if (alloc_cc_shared_pages_node(node, gfp | gfp_flags_quirk, + PAGE_SIZE << order, &mem)) return NULL; - return page; + return mem.page; } static struct page *its_alloc_pages(gfp_t gfp, unsigned int order) @@ -242,13 +229,15 @@ static struct page *its_alloc_pages(gfp_t gfp, unsigned int order) static void its_free_pages(void *addr, unsigned int 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)) + struct cc_shared_layout layout; + struct cc_shared_pages mem; + + if (WARN_ON(cc_shared_calc_layout(PAGE_SIZE << order, &layout))) return; - free_pages((unsigned long)addr, order); + + mem.page = virt_to_page(addr); + mem.shared_size = layout.shared_size; + free_cc_shared_pages(&mem); } static struct gen_pool *itt_pool; @@ -273,7 +262,8 @@ static void *itt_alloc_pool(int node, int size) if (!page) break; - gen_pool_add(itt_pool, (unsigned long)page_address(page), PAGE_SIZE, node); + gen_pool_add(itt_pool, (unsigned long)page_address(page), + cc_shared_granule_size(), node); } while (!addr); return (void *)addr; -- 2.43.0