From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 914A73ACA53 for ; Tue, 24 Feb 2026 19:23:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771961016; cv=none; b=Rjwdny6c/u+tLZ4iP8yNpW6Drx2ZnEhOOGFOPRKTNQ0SsEy7XtqisWJzD6OT0f4AtgVizwjnoa9N9+wLmhSxU5QzCvKfq1hPZB1NrUeaC4FC0aLhXHOhDmYTYIOxCrBIBQMNuvsi/Xcs3cVVQMzv+f6VwJAnm5Tjej29wlve7F0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771961016; c=relaxed/simple; bh=8W1FHTmSZLvxiYvmbXSxc9vFio4oR+3HdpOr56UCHAw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uEmi6sbUyPJ2nX7d1jKSw6g0VGuH06ug6ZQkvCY7hneVU4Jbun4lX4uanV3DnkapghGfbQFWtB6heDw/ufhHKawiRKqLT+17ESfNzFPNJnwO0INZM5EWCQRhD4QgRpJT70e9LHB9IQ/czUV3EK1zlqXbCXgpDFBf/WTy/9WYgw4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=oY2qrhPm; arc=none smtp.client-ip=209.85.222.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="oY2qrhPm" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-8cb3dfb3461so600364485a.3 for ; Tue, 24 Feb 2026 11:23:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1771961014; x=1772565814; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=kH3+s8+YV7Jxhg+0pWecX+ujJZRfi9cUlSTEhsPv7+E=; b=oY2qrhPmR6i0JI/iavhvApy1d1ZPsYxFwgOxKMJmBabj4EASO30ct7Z/Xtj93WoiJw ZdJAj9xRb8s9AGGA2X5S7NQp+l1/CDF5wvL5DH5VKZkYvn1Ri/mXOa9sVSZW0eNiVnoq Tfa8dGu8QV6aPSRCqX5+Lbh2MmBdYzET3O6qo/Ky6GYFh4c0fMbnksJ/CI1f9mww2goL fGk/78H6XRiTuxUAI5tszezjghlgEm7lHxia9TUq1lQD1bqcuxWdSGe+jSDBNQRYXTgB yi3slmDwcpa8PR00c1fF4CXJ9iwXbP9JdgoR/8RX4NFiZn4s0Ljf/uejZ219hqWjVOLI XYEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771961014; x=1772565814; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kH3+s8+YV7Jxhg+0pWecX+ujJZRfi9cUlSTEhsPv7+E=; b=mO5HyGc6Kb9Zkhw5oiLVpI+Tb8ZNLQYLL5lcPBQ3V5BF4IOlwz6pWpQmv7+71Zm9SH l26Vvho4wVaSiwmqfmDxkDo6yQ5xk5+aqU+C+bGN0Oy3ei0fprp33YiIB9Z7C7kJSEia fIByWSr2fezdBwXCMfv2+eSxGxN/Af1FzIH5EYbBLn45pYTBUl09MTMM6rg9LfO/Qd2d ORSFNz3d3Q6aellHkAJqK+Q8dSs4tgeAJQnd0N9v2EV4RTr4OaxGScCLrY6PxRFdknvK mo7UAQkIGc8ryZcT4htFQ/vG018MB7UdzLpNo575/pi092SlwY1/B2/mealg8Qjk4Ypq x3cA== X-Forwarded-Encrypted: i=1; AJvYcCWB6CuxxBONMwAaSlawteckdNBhBZ+KTmDcoDTFVdlNaSzUk7XN3lqbw7oPUHvS6mK6pO/I9VjvILJr7tk=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+HjLZgBNal8I8mEDFH1Qjcsk0orB0qIvy+Y6pxcTSaEwMibCn pg53GwFm5QBHA53ZaGYJP46CndLu6+h6HgRCHwS/zMWNk1oQu675Ooz3nJFHjk2MYqI= X-Gm-Gg: AZuq6aLTB0cIccTnv3+eCeGaSyQJreJMG2fqC6eVa/2Kwgm9g9grrVXeDqy3DhXtX6L wQxIvcjO+Ld/fkzdbpwYj8dQJiz7C6k064F5diMYDAli64rC53CHKd1FDES1ETKjGSLm+lhY/lW UYAUj8R+39uG0f3Pi56gJYa2PR9A/WhMixvd1bY5ItDY+lxQUimSJ3wwvcRzE5Zut14zB3mczrx wTh4XbXuAz2Ox+fFPMoJyOlV/YUTmtQCeMeUoi7Gh1ImZOFHFvzy4I1KCmC6FaPHxEQtHbT9gl1 Iqqb89sJiMCmBkSC1qN4UP+oB58R7+thA8jVsvErbMfIzxDWgRYrrTZaO226Kbg95viIqW59one cbz3XQjy3xmy9nrSMZ2gKjaI37qjWTKNfbf9n5SBTMjrrrQzS2iIAfWe6RqAY6keCxgkbC8J7lZ c= X-Received: by 2002:a05:620a:46a6:b0:8c7:115a:d0e3 with SMTP id af79cd13be357-8cb8ca640f0mr1663473085a.37.1771961014357; Tue, 24 Feb 2026 11:23:34 -0800 (PST) Received: from ziepe.ca ([173.231.112.170]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8cb8d0eb32dsm1204908085a.31.2026.02.24.11.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Feb 2026 11:23:33 -0800 (PST) Received: from jgg by jggl with local (Exim 4.95) (envelope-from ) id 1vuy0L-0009No-Ej; Tue, 24 Feb 2026 15:23:33 -0400 Date: Tue, 24 Feb 2026 15:23:33 -0400 From: Jason Gunthorpe To: Antheas Kapenekakis Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Joerg Roedel , Will Deacon , Robin Murphy , Vasant Hegde , Alejandro Jimenez , dnaim@cachyos.org, Mario.Limonciello@amd.com Subject: Re: [PATCH v1] iommu: Skip mapping at address 0x0 if it already exists Message-ID: References: <20260221235050.2558321-1-lkml@antheas.dev> 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: <20260221235050.2558321-1-lkml@antheas.dev> On Sun, Feb 22, 2026 at 12:50:50AM +0100, Antheas Kapenekakis wrote: > Commit 789a5913b29c ("iommu/amd: Use the generic iommu page table") > introduces the shared iommu page table for AMD IOMMU. Some bioses > contain an identity mapping for address 0x0, which is not parsed > properly (e.g., certain Strix Halo devices). This causes the DMA > components of the device to fail to initialize (e.g., the NVMe SSD > controller), leading to a failed post. I'm trying to understand the issue here, is it that the old AMD code incorrectly succeeded iommu_map() on top of an existing mapping while the new code returns -EADDRINUSE? Then the existing guard for double mapping doesn't work since 0 is an ambiguous return? > @@ -1224,6 +1224,11 @@ static int iommu_create_device_direct_mappings(struct iommu_domain *domain, > ret = iommu_map(domain, addr - map_size, > addr - map_size, map_size, > entry->prot, GFP_KERNEL); > + if (ret == -EADDRINUSE && addr - map_size == 0) { > + dev_warn_once(dev, > + "iommu: identity mapping at addr 0x0 already exists, skipping\n"); > + ret = 0; > + } Nothing else prints here, so I wouldn't print either.. Apparently we just silently ignore if the BIOS creates conflicting mappings for some reason.. I think it is OK to just ignore EADDRINUSE always, it unambigously means a mapping is present and the intention of this logic is to ignore double mappings to the same IOVA. The cleaner fix is to correct the return code of iommu_iova_to_phys() or to make EADDRINUSE reliable and remove the iommu_iova_to_phys(), those are both a lot of trouble so I think this proposed single if is reasonabe. Just please clean up the commit message to be a bit clearer on what caused this regression and add a short comment above the new if: 0 return from iommu_iova_to_phys() is ambiguous, it could mean a present mapping. EADDRINUSE is reliable when supported, it means the IOVA is already mapped, so ignore it to resolve the ambiguity. Thanks, Jason