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 7C4DBC25B74 for ; Mon, 13 May 2024 16:56:30 +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=cAoiuyaUa0DxPhF6zYbIpBESe5blu4Cm1SpM6Ro39sE=; b=NB1/GSLxkxe2Fy g2rHKv0oDfctF608HVWJvrWUmAfdge7DIQxYxTB3YIFToQEkPobKzoyH4qxtmn/9WOgismO/0oooX ffr8NLANgvqIMJ+AwBPkPboLFTuI5jGkHLmN1CtPn8SjA1WsOT8WhgTX/3zW3AETCuh5iDL2EMjU6 0zsFp9bezsm2MykIAE0Np/hrkD9z58V2xjncDdD2NPQcppJfGQK+WOAExgYtA/d62d3ZIQRJH3jhm sYswADxkRD+tGchc/+fZ3gs3+g2ddj9ZfYTNGiVvGEAHwbqj9Rc1eLTZkaea0SKIUjy/rUrA48s02 VR3mdptetRmG0kziLJCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s6YyM-0000000DdCT-0iZs; Mon, 13 May 2024 16:56:22 +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 1s6YyJ-0000000DdBf-3G7m for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2024 16:56:20 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4691360EC2; Mon, 13 May 2024 16:56:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E05AEC113CC; Mon, 13 May 2024 16:56:15 +0000 (UTC) Date: Mon, 13 May 2024 17:56:13 +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 08/14] arm64: Enforce bounce buffers for realm DMA Message-ID: References: <20240412084213.1733764-1-steven.price@arm.com> <20240412084213.1733764-9-steven.price@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240412084213.1733764-9-steven.price@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240513_095619_879235_E5C3A3CE X-CRM114-Status: GOOD ( 12.52 ) 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:07AM +0100, Steven Price wrote: > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > index 786fd6ce5f17..01a2e3ce6921 100644 > --- a/arch/arm64/mm/init.c > +++ b/arch/arm64/mm/init.c > @@ -370,7 +370,9 @@ void __init bootmem_init(void) > */ > void __init mem_init(void) > { > - bool swiotlb = max_pfn > PFN_DOWN(arm64_dma_phys_limit); > + bool swiotlb = (max_pfn > PFN_DOWN(arm64_dma_phys_limit)); This series tends to add unnecessary brackets. > + > + swiotlb |= is_realm_world(); I first thought we wouldn't need this, just passing 'true' further down but I guess you want to avoid reducing the bounce buffer size when it's only needed for kmalloc() bouncing. > > if (IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) && !swiotlb) { > /* > @@ -383,7 +385,12 @@ void __init mem_init(void) > swiotlb = true; > } > > - swiotlb_init(swiotlb, SWIOTLB_VERBOSE); > + if (is_realm_world()) { > + swiotlb_init(swiotlb, SWIOTLB_VERBOSE | SWIOTLB_FORCE); > + swiotlb_update_mem_attributes(); > + } else { > + swiotlb_init(swiotlb, SWIOTLB_VERBOSE); > + } Just do this higher up and avoid calling is_realm_world() twice: unsigned int flags = SWIOTLB_VERBOSE; ... if (is_realm_world()) { swiotlb = true; flags |= SWIOTLB_FORCE; } ... swiotlb_init(swiotlb, flags); -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel