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 0FC833AFAE0 for ; Thu, 4 Jun 2026 09:03:28 +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=1780563810; cv=none; b=L/0OFJ4J1CmsLVhWvFTS9TZyPEMFcH7odQIV/jj4LUi4vsnr4s46NJ9vv6aUXYq8QcQu9MDecfElrmOm03XwFHQEjRqXDbUDg5tcYkaoRT9BdeZEyz6MtO4yo+ea2cS5nNSOrcXgdkhalNQXhdWixkaR2XUKXvTGvsTuTkCOMiU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780563810; c=relaxed/simple; bh=+14LXOMfySu5esrffTmAZnYa7qCPPLMpP0/fLUUxfGo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=RDF3qI/5JobxDBoU2F/r3aAfBhWP9an+mIrkq0r97b/one81tOBPJbFZXip+ZnLfsQKC78AJ12ezaco30ZWRoyEwivKp4HES2SkPVYJsBZ9Owp9WJaX0HDCfaYz0xngMmZafYOmtyeOLvTXfnKKjF6nmbwv56wCMM+NZ1Mym1Wk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=auhIrtK9; 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="auhIrtK9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 067CD1F00893; Thu, 4 Jun 2026 09:03:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780563808; bh=9LUDHGMpxY5/D93pfLKYpEzHyH09fS49yr/B51sO0vo=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=auhIrtK9ikXMdXDAcVSTuvzh6VYtK99/HrDClrE5/wSkJtxxX5DNXBPaM9o2Adw4p 4YBDaRR66KpOtPX87uSnZaTlivRWZ6jLVqfltutjDQLx23WALPYYy6LS26XgBiH9hX iXnvJxDA/IIu0nk5B8jm4N8MYL/2M+5zer/AzXoKsiHY4gjEM8hco6uit6JO0VNAPi uw7Cc/kUjzfVlQy7iZSTTMpuEZnZl5+jqK6VZQOq3/0Rqlinh9TZ8ygb+Hi+PT+82p c2R0H9cOx0cG/bBkyro3pNven9jghAs4YfTS4bo467AvvBOltFnJuzMnSYJGt7H4e/ enhbqCB4nnGJQ== X-Mailer: emacs 30.2 (via feedmail 11-beta-1 I) From: Aneesh Kumar K.V To: Mostafa Saleh , Mike Rapoport Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, catalin.marinas@arm.com, will@kernel.org, maz@kernel.org Subject: Re: [PATCH 1/3] arm64/mm: Simplify SWIOTLB setup in arch_mm_preinit() In-Reply-To: References: <20260603110522.3331819-1-smostafa@google.com> <20260603110522.3331819-2-smostafa@google.com> Date: Thu, 04 Jun 2026 14:33:23 +0530 Message-ID: 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=utf-8 Content-Transfer-Encoding: quoted-printable Mostafa Saleh writes: > Hi Mike, > > On Wed, Jun 03, 2026 at 03:27:52PM +0300, Mike Rapoport wrote: >> Hi, >>=20 >> On Wed, Jun 03, 2026 at 11:05:20AM +0000, Mostafa Saleh wrote: >> > At the moment, arch_mm_preinit() checks if the system has limited >> > addressing or is running under CCA to enable SWIOTLB, only after to >> > be forced to true anyway if it was false due to >> > CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC being unconditionally true for >> > arm64. >> >=20 >> > Simplify this logic, by making it clear that SWIOTLB is always used >> > but its size depends on the address layout of the system. >> >=20 >> > Signed-off-by: Mostafa Saleh >> > --- >> > arch/arm64/mm/init.c | 11 ++++------- >> > 1 file changed, 4 insertions(+), 7 deletions(-) >> >=20 >> > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c >> > index 97987f850a33..fcc9c05a8fe6 100644 >> > --- a/arch/arm64/mm/init.c >> > +++ b/arch/arm64/mm/init.c >> > @@ -336,25 +336,22 @@ void __init arch_setup_zero_pages(void) >> > void __init arch_mm_preinit(void) >> > { >> > unsigned int flags =3D SWIOTLB_VERBOSE; >> > - bool swiotlb =3D max_pfn > PFN_DOWN(arm64_dma_phys_limit); >> > + bool limited_addressing =3D max_pfn > PFN_DOWN(arm64_dma_phys_limit); >> >=20=20 >> > if (is_realm_world()) { >> > - swiotlb =3D true; >> > flags |=3D SWIOTLB_FORCE; >> > - } >> > - >> > - if (IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) && !swiotlb) { >> > + } else if (!limited_addressing) { >>=20 >> Can realm_world() coexist with limited_addressing? Then the size adjustm= ent >> is still required. > > My guess would be no, my understanding is that CCA guests have niche > hardware. > > However, the check for limited_addressing is negated, we adjust the > SWIOTLB to be smaller if no bouncing is needed. > So, if this is a realm world, address space layout is irrelevant as we > keep the original size which is larger. > That=E2=80=99s correct. Realm guests need swiotlb to always be enabled, and= we should not reduce the size of the pool. > > Otherwise, this alters the current behaviour. > >>=20 >> I'd also make this more explicit: >>=20 >> if (max_pfn > PFN_DOWN(arm64_dma_phys_limit)) > > Sure, I can drop the bool. > -aneesh