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 BD6E7C25B78 for ; Wed, 15 May 2024 11:01:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=A8tu8mhIY3xUkdw0mOhOUxCAg+YjPXs8RQe90ALcBnQ=; b=VX9aj6yxJxIuHN zYaKq+ByKNXjoSyYcUzvJbgqDKeZ9PA4WFW2l9qpaGTZ0KXa9gBrfMu+Nvaq00CuWqMELYyPzsVCn wZrRTcOGYjG1pBNWhLsE3WKIhBVMpLAIPqKzLtFjUQRDmTQuuOgNS4uVG6m78bEaDCeOviX0N6dxm VhltzVewSPfMUsbH0boyCyC6ZmFLmQGmvMBua9MHZ1f+5G+hFuS8aVImPTtKdRfRxju05mCRpkKic 0WkADLVI/eswywwr5j+K2O1ldtjCkf9RE+b5u6XWou6S6iJSBtJnuL8wJSBmkrLw/0h1j9Gba9z5f /aGzd7rXOQrS2Zhd0fiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7CNj-00000001Iky-1aIz; Wed, 15 May 2024 11:01:11 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7CNh-00000001Iiw-1o5R for linux-arm-kernel@lists.infradead.org; Wed, 15 May 2024 11:01:10 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B7AD0CE1582; Wed, 15 May 2024 11:01:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECA0BC116B1; Wed, 15 May 2024 11:01:03 +0000 (UTC) Date: Wed, 15 May 2024 12:01:01 +0100 From: Catalin Marinas To: Steven Price Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , 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 Subject: Re: [PATCH v2 12/14] arm64: realm: Support nonsecure ITS emulation shared Message-ID: References: <20240412084213.1733764-1-steven.price@arm.com> <20240412084213.1733764-13-steven.price@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240412084213.1733764-13-steven.price@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240515_040109_682121_1EFAB4EB X-CRM114-Status: GOOD ( 16.32 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Apr 12, 2024 at 09:42:11AM +0100, Steven Price wrote: > @@ -198,6 +201,33 @@ static DEFINE_IDA(its_vpeid_ida); > #define gic_data_rdist_rd_base() (gic_data_rdist()->rd_base) > #define gic_data_rdist_vlpi_base() (gic_data_rdist_rd_base() + SZ_128K) > > +static struct page *its_alloc_shared_pages_node(int node, gfp_t gfp, > + unsigned int order) > +{ > + struct page *page; > + > + if (node == NUMA_NO_NODE) > + page = alloc_pages(gfp, order); > + else > + page = alloc_pages_node(node, gfp, order); I think you can just call alloc_pages_node() in both cases. This function takes care of the NUMA_NO_NODE case itself. > + > + if (page) > + set_memory_decrypted((unsigned long)page_address(page), > + 1 << order); > + return page; > +} > + > +static struct page *its_alloc_shared_pages(gfp_t gfp, unsigned int order) > +{ > + return its_alloc_shared_pages_node(NUMA_NO_NODE, gfp, order); > +} > + > +static void its_free_shared_pages(void *addr, unsigned int order) > +{ > + set_memory_encrypted((unsigned long)addr, 1 << order); > + free_pages((unsigned long)addr, order); > +} More of a nitpick on the naming: Are these functions used by the host as well? The 'shared' part of the name does not make much sense, so maybe just call them its_alloc_page() etc. > @@ -3432,7 +3468,16 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, > nr_ites = max(2, nvecs); > sz = nr_ites * (FIELD_GET(GITS_TYPER_ITT_ENTRY_SIZE, its->typer) + 1); > sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1; > - itt = kzalloc_node(sz, GFP_KERNEL, its->numa_node); > + itt_order = get_order(sz); > + page = its_alloc_shared_pages_node(its->numa_node, > + GFP_KERNEL | __GFP_ZERO, > + itt_order); How much do we waste by going for a full page always if this is going to be used on the host? > + if (!page) > + return NULL; > + itt = (void *)page_address(page); page_address() has the void * type already. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel