Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2179073lqo; Mon, 13 May 2024 09:56:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwFo031O81rmmoXPcyAD9vv7L+On8LtBBwMhRAaCKJG7z9/4UG9EwUGUjRljHwR0rzjyjJNJXDzCj1jzjmnnL9O8WoJE1Igx1pzIOQ7g== X-Google-Smtp-Source: AGHT+IGqirthVwIRl1VqCz3+19GMeVVarxrq/QFkkhVDF0u/+RUtzIq8Mgld42oG9ld2nHUhmrII X-Received: by 2002:a17:906:31ce:b0:a52:65bd:a19a with SMTP id a640c23a62f3a-a5a2d672e74mr631186566b.57.1715619390700; Mon, 13 May 2024 09:56:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715619390; cv=pass; d=google.com; s=arc-20160816; b=NpZehguMiQMwirWrB8n3RxdI5PKfsF2K8Pz1TyxrTCKNdmDF0D2jNlYOl/lV7klHWE kMjufOKTZRgRzqr1wKevzW7WFyh3+X6NH6TMKWabj4rvzs2o9Nb84zuH6ykZSa2dBujl TPnMBIedNGrdlXcG0kVmHMaRf9xFRA+aCzbHUwD7cwbmxbpMv+X2nNQB3ZTHnoMCeTaF /3GzvgB5qWMMJ3gy40NPSdq+8maJgUF4l83npfMFtqWZZB20PDfdT41DCUDtgwcGmQrk wtM9dlOhA85U0kojr7UQ+wcY4pYktNACF+7j//jn/K0E+kDO/Amkq8RkJjeUdc/DCrU9 EEvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=DH18rg6yIrdzT5HkgbyWTkmyJd5a7KKcl+O5OgqZ38A=; fh=0PvXTblvcOsrMPT3yEGqxR5sUU4n6OEeMAbaOpzry54=; b=hsXB+9uxJF2LDyoTPDpR1zKcXyM9wdhIfS8RdoeYpzJZ6HM83tJF4D5NpMmU/zvwHr BIMApgYnCdSApK58nQ1t28UdSgdLmKLkH0aIrc+lpmdl+IhER5IHKxBbB6pr8zPokV9R T+lmhCVveRID2CVV89Tv0H6nkzy2zLAYVAVCuCnlIrlKh/vZ5oWY0g2AZP2J84p+I4Pn G1KsDMLARxbGXiJLQsSAerI27r2Fl4EjE9VVIECvekbn/qYsMRlBMnbAHpZYpi1CXxQR aR3qxRwxypHBBzhQlQHo0RPAUuBIUT+YIffq7n6OqQo/JLhAS+CNSK3bsuVuDpmebcTG 83dg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-177859-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177859-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a1797bda6si532038866b.230.2024.05.13.09.56.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 09:56:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177859-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-177859-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177859-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6CD431F21935 for ; Mon, 13 May 2024 16:56:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D873A1C69D; Mon, 13 May 2024 16:56:19 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 514EE1CD15; Mon, 13 May 2024 16:56:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715619379; cv=none; b=hlysFIS6YOKZyEzZkBXUlCRhp5KkNbL4PR0neMfbSnt3cJ8IEtwK4sMKxKBsB+4JmPOI5jSxCJSkucjqPQoZQMnhImpEp73/cwysvLPTc6SPVsxTg1g08WLE50J7qhVh/17Fk4pKpXdbLrtn7otT15Li55w4DYyKxMYg4/a5tE8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715619379; c=relaxed/simple; bh=R1yt8VY85saTQsFLGCPH5N9UB7wO5F3GKqnZyj/mioc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dG6ebOgTG0ObmAZdOgcZyiYED6cWwK9pozKa7Tc02eAypEo2772QxdOuZfYY99bMfkXLTJjK4kAG8Xb6ITG697RCPtwVzr3vonA79fq0EWHeyxqpuV85CeX+R+ZzA+irCxdVorGGMjPguUEXO/jn4pymAKuFOZjkmDNYGFn6g0E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240412084213.1733764-9-steven.price@arm.com> 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