Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3098234pxj; Mon, 10 May 2021 18:49:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxW1HPyCcmTFkCaaG6kvJBGNn5eYNzMbwaCbk8GVzrCSFtnMr9Ow7S5747JvTWpdb3i/l5X X-Received: by 2002:a50:9d4a:: with SMTP id j10mr30068554edk.378.1620697754467; Mon, 10 May 2021 18:49:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620697754; cv=none; d=google.com; s=arc-20160816; b=IWx7JCvdM3i6GODOLS739WISmSZIE3q6tjd6uV6PE60xkUlZIfOPKFXICN1xJ3qRT8 2yZrcKjyyrH4UgfEQ0OyrBLWGkKX6hmyvKpk4Z33DvvUckgnPrUf7p3GUTm6Zs1LvPR/ QWK+thIab33l4x77+IjbKlxfUEXKt/RcKnJ4WYcy8vFpqzqUKVEBcCxMF4PWA89oNZol OFFLRkFisCKz0CJdObSQpw5dPRg7fl6BcetVHoRnLkvmGq40N2FPSy/3g17SbRmZXBTr 05yX5wYW/Ph7yuLFbpBGmEhw+KOPV9heeC+Ck0v9y4txZbzlnkSxOhpVYZw23+R0h5Sd IUSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=rzLs41ODXdZmfMcuwnj7O/DheLn98Tg2NMLgQW8eIV0=; b=DYPzN52z7i0E1/AYE1Ibz4ikdT3NBuBCHU5MSRwPeHXBPBRT3TLcUCTMdvi4A3gEeh vM1JHB/AkRxxM5VAjsEh89AcaoXuBmb+MF7hV2xBwMkIaL4XOZG3R57nH6WQSewH+MmB ROJ853IUeBoI7N4qDzyjcP22ak1DSfeFCohzt3Z5nohAUWWXb0SnFPxq8RmmN6QdVVk5 w+MSaOZJpVjBuCAfEICyoPATzOYvH6H9JqQUBw/lLDQMy4dQNjuDu2VrCefeY5UWa3eK LAna0165whfmxYWP4E3zCVSWdiFnWTGKZr3gxATLvSziXlhM38Q52x+2QlaVJGHRsT/r hP4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SrbUmQ3X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si14353382ejj.594.2021.05.10.18.48.50; Mon, 10 May 2021 18:49:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SrbUmQ3X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230330AbhEKBrl (ORCPT + 99 others); Mon, 10 May 2021 21:47:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:42580 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230023AbhEKBrl (ORCPT ); Mon, 10 May 2021 21:47:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 416A161629; Tue, 11 May 2021 01:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620697595; bh=zRFH7hcgqBzuVJGwApqdrtTvpvj+GmXyjHWNsw6DGg8=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=SrbUmQ3XfUDBVScU7RGYGh+COsif34UcsKqoTgGV9vf8XRs8R1lfXDv2Rg8m5+EF9 CJPluc1/MQWvbLjpb0BVOfrQVGN/CpceyyrZMmsRnCPL3kqtV6OlO3OEzsslK/qv7R zfl2Tf8Vw+0CIzNstymmxgXrqQa0cXQFMxMCpH3x+EScqVCBhtS+W0OWy9oXkU1Diw G6RzBgQ9DfY0kzP1vEIMFq5Dn15X6EwBB3uZAB8JhvRKGL4JvgSEGm4RjP4loHchpQ dnVwpyniLe2sjqdRGm4CgKX7WruGCQeIvlzp1r0kmQMvORLOQOTUtZolCtGmlfMEQH t7e1j5rQsPpEw== Date: Mon, 10 May 2021 18:46:34 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-T480s To: Christoph Hellwig cc: Julien Grall , f.fainelli@gmail.com, Stefano Stabellini , "xen-devel@lists.xenproject.org" , linux-kernel@vger.kernel.org, osstest service owner , Konrad Rzeszutek Wilk , Boris Ostrovsky , iommu@lists.linux-foundation.org Subject: Re: Regression when booting 5.15 as dom0 on arm64 (WAS: Re: [linux-linus test] 161829: regressions - FAIL) In-Reply-To: <20210510084057.GA933@lst.de> Message-ID: References: <4ea1e89f-a7a0-7664-470c-b3cf773a1031@xen.org> <20210510084057.GA933@lst.de> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 10 May 2021, Christoph Hellwig wrote: > On Sat, May 08, 2021 at 12:32:37AM +0100, Julien Grall wrote: > > The pointer dereferenced seems to suggest that the swiotlb hasn't been > > allocated. From what I can tell, this may be because swiotlb_force is set > > to SWIOTLB_NO_FORCE, we will still enable the swiotlb when running on top > > of Xen. > > > > I am not entirely sure what would be the correct fix. Any opinions? > > Can you try something like the patch below (not even compile tested, but > the intent should be obvious? > > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > index 16a2b2b1c54d..7671bc153fb1 100644 > --- a/arch/arm64/mm/init.c > +++ b/arch/arm64/mm/init.c > @@ -44,6 +44,8 @@ > #include > #include > > +#include > + > /* > * We need to be able to catch inadvertent references to memstart_addr > * that occur (potentially in generic code) before arm64_memblock_init() > @@ -482,7 +484,7 @@ void __init mem_init(void) > if (swiotlb_force == SWIOTLB_FORCE || > max_pfn > PFN_DOWN(arm64_dma_phys_limit)) > swiotlb_init(1); > - else > + else if (!IS_ENABLED(CONFIG_XEN) || !xen_swiotlb_detect()) > swiotlb_force = SWIOTLB_NO_FORCE; > > set_max_mapnr(max_pfn - PHYS_PFN_OFFSET); The "IS_ENABLED(CONFIG_XEN)" is not needed as the check is already part of xen_swiotlb_detect(). But let me ask another question first. Do you think it makes sense to have: if (swiotlb_force == SWIOTLB_NO_FORCE) return 0; at the beginning of swiotlb_late_init_with_tbl? I am asking because swiotlb_late_init_with_tbl is meant for special late initializations, right? It shouldn't really matter the presence or absence of SWIOTLB_NO_FORCE in regards to swiotlb_late_init_with_tbl. Also the commit message for "swiotlb: Make SWIOTLB_NO_FORCE perform no allocation" says that "If a platform was somehow setting swiotlb_no_force and a later call to swiotlb_init() was to be made we would still be proceeding with allocating the default SWIOTLB size (64MB)." Our case here is very similar, right? So the allocation should proceed? Which brings me to a separate unrelated issue, still affecting the path xen_swiotlb_init -> swiotlb_late_init_with_tbl. If swiotlb_init(1) is called by mem_init then swiotlb_late_init_with_tbl will fail due to the check: /* protect against double initialization */ if (WARN_ON_ONCE(io_tlb_default_mem)) return -ENOMEM; xen_swiotlb_init is meant to ask Xen to make a bunch of pages physically contiguous. Then, it initializes the swiotlb buffer based on those pages. So it is a problem that swiotlb_late_init_with_tbl refuses to continue. However, in practice it is not a problem today because on ARM we don't actually make any special requests to Xen to make the pages physically contiguous (yet). See the empty implementation of arch/arm/xen/mm.c:xen_create_contiguous_region. I don't know about x86. So maybe we should instead do something like the appended? diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c index f8f07469d259..f5a3638d1dee 100644 --- a/arch/arm/xen/mm.c +++ b/arch/arm/xen/mm.c @@ -152,6 +152,7 @@ static int __init xen_mm_init(void) struct gnttab_cache_flush cflush; if (!xen_swiotlb_detect()) return 0; + swiotlb_exit(); xen_swiotlb_init(); cflush.op = 0; diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index 8ca7d505d61c..f17be37298a7 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -285,9 +285,6 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs) unsigned long bytes = nslabs << IO_TLB_SHIFT, i; struct io_tlb_mem *mem; - if (swiotlb_force == SWIOTLB_NO_FORCE) - return 0; - /* protect against double initialization */ if (WARN_ON_ONCE(io_tlb_default_mem)) return -ENOMEM;