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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45D10C369AB for ; Tue, 15 Apr 2025 19:08:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 544866B018B; Tue, 15 Apr 2025 15:08:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4CC576B018C; Tue, 15 Apr 2025 15:08:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 347376B018D; Tue, 15 Apr 2025 15:08:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1037C6B018B for ; Tue, 15 Apr 2025 15:08:18 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 02586AE2E3 for ; Tue, 15 Apr 2025 19:08:18 +0000 (UTC) X-FDA: 83337213918.07.D87C18A Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) by imf17.hostedemail.com (Postfix) with ESMTP id 1D90140013 for ; Tue, 15 Apr 2025 19:08:16 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=debian.org header.s=smtpauto.stravinsky header.b=jB0Rttd4; spf=none (imf17.hostedemail.com: domain of carnil@debian.org has no SPF policy when checking 82.195.75.108) smtp.mailfrom=carnil@debian.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744744097; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FCCLR5AQbfuKec16T4Z93Z+tygMuvFkccFhZdHp8QIQ=; b=pedjdLfBIia210G2A7B6hNJ3sYoaNRaZKRat3grWGBQ0zumelahWhNXryRI8lWmaEfQoev EiFV+3xIGUSgnklRYN1k9YLbdTn4pthU9P8adNIcphXbZ5iqLw9W6AxjC2UZbYcYGuIE7m KwFebxJ4yICNwkPoafsiD5nmMWNT2b8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744744097; a=rsa-sha256; cv=none; b=bfKm+W3T29sVO3gKaOPq9d1tsYsMMQVb6z02nVSDuNTjy7Pd8/MuMZUOkEztwpOLu1Fw+Z UgPnYKAdAYdPMy6e9yjTBIN5WgWbWtUS05RbZWwHX+ey8xPFWDZToFw7R0GPp3f104Y7TQ Jd2q+HzlYi1NyXw7LRdxzDvXR3fMGX0= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=debian.org header.s=smtpauto.stravinsky header.b=jB0Rttd4; spf=none (imf17.hostedemail.com: domain of carnil@debian.org has no SPF policy when checking 82.195.75.108) smtp.mailfrom=carnil@debian.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=FCCLR5AQbfuKec16T4Z93Z+tygMuvFkccFhZdHp8QIQ=; b=jB0Rttd4vsFJvqMQ4UO+lemXYR w+edNdq8Xza6S/skam4hFAl4CXl1COOhZOqPqv0JgNlQQp68xLjgILf3FVz9EU28luEVwGjO6Lwfv lS5qlCNHqn9WMTjTlhRpmUqLCg9izRXOTMSBJIH6jeDStUwYDY1hzdpEpsc+8gYCLMW/mzcQ56CwL TcNf20XGOxylrY+pvzPG9Bc3BlSfxrchxsWvX1zmdVywn6D6awLMcNRs/a3d1mrjj8FXJ+Zx84xzq Nr08JdmdMw3ZcXZ3lMWfqDbtQG22MMGq14roEIL8zhj9Ov4Wn2MhHprTBE37/VsbV9YHPPPlIhtt2 OcC4p97g==; Received: from authenticated user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2) (envelope-from ) id 1u4ldN-0046eE-U3; Tue, 15 Apr 2025 19:07:50 +0000 Received: by eldamar.lan (Postfix, from userid 1000) id ABFF8BE2DE0; Tue, 15 Apr 2025 21:07:48 +0200 (CEST) Date: Tue, 15 Apr 2025 21:07:48 +0200 From: Salvatore Bonaccorso To: David Howells , Christoph Hellwig , David Hildenbrand , Lorenzo Stoakes , Andrew Morton , Jens Axboe , Al Viro , Matthew Wilcox , Jan Kara , Jeff Layton , Jason Gunthorpe , Logan Gunthorpe , Hillf Danton , Christian Brauner , Linus Torvalds , Sasha Levin , Greg Kroah-Hartman Cc: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, regressions@lists.linux.dev, stable@vger.kernel.org, Bernd Rinn , Karri =?iso-8859-1?Q?H=E4m=E4l=E4inen?= , Milan Broz , Cameron Davidson , Markus Subject: Re: [regression 6.1.y] Regression from 476c1dfefab8 ("mm: Don't pin ZERO_PAGE in pin_user_pages()") with pci-passthrough for both KVM VMs and booting in xen DomU Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Debian-User: carnil X-Stat-Signature: aaqx9y6o7d5wew934oofb8n74hryh83k X-Rspam-User: X-Rspamd-Queue-Id: 1D90140013 X-Rspamd-Server: rspam08 X-HE-Tag: 1744744096-467273 X-HE-Meta: U2FsdGVkX186Q/wnM3DAjbx9noK7zEjAFlxqKkZLhG3MEfZC+lFu6RGRrNDUMUqHwgv40Jep7iLvWdf9l1S3gDDePNsTo7TgxKaUMeEahbxYckUFBScAlSF8m5+TxhnbbIhD7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wgztvpwFAD4xoFCLz3ryIoMKgkwWN8Z10pZKxRUBOUla1XOKomYHpnaAjyx5M3Jz+QldwSw05NwFv2AO/gZ3IReWsGVByZGuCxSLw8K5w8ze/INVRpoPi/BS1aoEZWN9ewW6i3UV/kiny0gqPVaPR+4saIUv52H3F3x1lmEGWmiu2PrkzdgkXdiWzNjPGf/lP5X7goWt1vEsdCAo8Zq2J9rD8nbPknviZeIO1umc5+1ar2w8DPHfli2fSldueZDoMe72xxdSUd+7mK7N0TVhAZrxV1rR1OQcQerM/ABu34asE8RZB9BURTD6IKppDxV9fop5TsLY2QfaajwG6uuDJVnGCtSlVlQRmf22IcmBjR5/6HLobdMoR5rEY4g5L9jVe9slD6luMdDDQiTQEgPScH4DV9bXbO5qi1OEgQOIFoB00fm X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: [resent with correct stable@vger.kernel.org list] On Tue, Apr 15, 2025 at 08:59:19PM +0200, Salvatore Bonaccorso wrote: > Hi > > [Apologies if this has been reported already but I have not found an > already filled corresponding report] > > After updating from the 6.1.129 based version to 6.1.133, various > users have reported that their VMs do not boot anymore up (both KVM > and under Xen) if pci-passthrough is involved. The reports are at: > > https://bugs.debian.org/1102889 > https://bugs.debian.org/1102914 > https://bugs.debian.org/1103153 > > Milan Broz bisected the issues and found that the commit introducing > the problems can be tracked down to backport of c8070b787519 ("mm: > Don't pin ZERO_PAGE in pin_user_pages()") from 6.5-rc1 which got > backported as 476c1dfefab8 ("mm: Don't pin ZERO_PAGE in > pin_user_pages()") in 6.1.130. See https://bugs.debian.org/1102914#60 > > #regzbot introduced: 476c1dfefab8b98ae9c3e3ad283c2ac10d30c774 > > 476c1dfefab8b98ae9c3e3ad283c2ac10d30c774 is the first bad commit > commit 476c1dfefab8b98ae9c3e3ad283c2ac10d30c774 > Author: David Howells > Date: Fri May 26 22:41:40 2023 +0100 > > mm: Don't pin ZERO_PAGE in pin_user_pages() > > [ Upstream commit c8070b78751955e59b42457b974bea4a4fe00187 ] > > Make pin_user_pages*() leave a ZERO_PAGE unpinned if it extracts a pointer > to it from the page tables and make unpin_user_page*() correspondingly > ignore a ZERO_PAGE when unpinning. We don't want to risk overrunning a > zero page's refcount as we're only allowed ~2 million pins on it - > something that userspace can conceivably trigger. > > Add a pair of functions to test whether a page or a folio is a ZERO_PAGE. > > Signed-off-by: David Howells > cc: Christoph Hellwig > cc: David Hildenbrand > cc: Lorenzo Stoakes > cc: Andrew Morton > cc: Jens Axboe > cc: Al Viro > cc: Matthew Wilcox > cc: Jan Kara > cc: Jeff Layton > cc: Jason Gunthorpe > cc: Logan Gunthorpe > cc: Hillf Danton > cc: Christian Brauner > cc: Linus Torvalds > cc: linux-fsdevel@vger.kernel.org > cc: linux-block@vger.kernel.org > cc: linux-kernel@vger.kernel.org > cc: linux-mm@kvack.org > Reviewed-by: Lorenzo Stoakes > Reviewed-by: Christoph Hellwig > Acked-by: David Hildenbrand > Link: https://lore.kernel.org/r/20230526214142.958751-2-dhowells@redhat.com > Signed-off-by: Jens Axboe > Stable-dep-of: bddf10d26e6e ("uprobes: Reject the shared zeropage in uprobe_write_opcode()") > Signed-off-by: Sasha Levin > > Documentation/core-api/pin_user_pages.rst | 6 ++++++ > include/linux/mm.h | 26 ++++++++++++++++++++++++-- > mm/gup.c | 31 ++++++++++++++++++++++++++++++- > 3 files changed, 60 insertions(+), 3 deletions(-) > > Milan verified that the issue persists in 6.1.134 so far and the patch > itself cannot be just reverted. > > The failures all have a similar pattern, when pci-passthrough is used > for a pci devide, for instance under qemu the bootup will fail with: > > qemu-system-x86_64: -device {"driver":"vfio-pci","host":"0000:03:00.0","id":"hostdev0","bus":"pci.3","addr":"0x0"}: VFIO_MAP_DMA failed: Cannot allocate memory > qemu-system-x86_64: -device {"driver":"vfio-pci","host":"0000:03:00.0","id":"hostdev0","bus":"pci.3","addr":"0x0"}: vfio 0000:03:00.0: failed to setup container > > (in the case as reported by Milan). > > Any ideas here? > > Regards, > Salvatore