From patchwork Mon Aug 26 20:43:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13778440 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF2E9C5321D for ; Mon, 26 Aug 2024 20:49:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=UaLXo2idJup/Oy4OwRPy2aK364ayUQ63MrUET5wBpvQ=; b=N2t8mnKY/hABGYJI90Cf7Z6Nku 1++BG4U5NEyMczAonkQHNpd3IhjHf7d6C5Q+DO2PpXAb+2Fdssm3G4/wtvMxWwgXcaoa+Tu4Jop/W /FmzghjGTYQL1Do+iRFNLk1NVbr/Zw9DBnKn7iSd/6LwOtb6cmqcWyvV5uoPdegYyryvF2+0C8IU4 5P7J6EGURD22d67NacIviifexMq4+sf8eo0cFzvPsIego9kTobvfZypA751CdQ41FakHXO2iRCyoX 50oZeo3aXx2I/Gi98CE94JOhn59XJB+jdJjzcdXwYv7G41qH/WQr9HWBb3RjHTphiMFY/omiTK7BH 7dHimKfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sigen-00000008gPD-41NT; Mon, 26 Aug 2024 20:49:45 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sigZQ-00000008ePr-0oIc for linux-arm-kernel@lists.infradead.org; Mon, 26 Aug 2024 20:44:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724705051; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UaLXo2idJup/Oy4OwRPy2aK364ayUQ63MrUET5wBpvQ=; b=VvSY6pkvdoBZR75VdSwrCXL41Ztxpb9sxBHfdhY1xyQ9FTIzLlFvJe2N827g+cLdbXveRS Lwc/9rtaxin1Lh9fU+Vxa4dz6k7DpopmW+Ff8gMRfm2neGduTqzujKJAoilpj+uK0YWRkd f3SCG/mG83+FK8OwdFk0J0XdZjisQFY= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-562-XgI7vkohOLqhEW4mRYFRZQ-1; Mon, 26 Aug 2024 16:44:09 -0400 X-MC-Unique: XgI7vkohOLqhEW4mRYFRZQ-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7a1df704ef8so599548585a.2 for ; Mon, 26 Aug 2024 13:44:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724705049; x=1725309849; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UaLXo2idJup/Oy4OwRPy2aK364ayUQ63MrUET5wBpvQ=; b=L+VKCoyU0i86mwAnvKHjVc9J6THUSPIFAJe6RSdVi+KoKuLnqgRWeThWs8U88XASLP 8Nfd4ygWLsBHfy2ZPxp5QumgsTBBOMXmoihTKdXGM04vtP09A2p8JfSX3eaNK09KtncH B5qv/wfnRF0wVp57XR6bYp+CoH1zQz0T4DTyxNgBhKlkxCC0ALCZJremaroGW1ByaqOx qIptyqnNtE6N+3Xat6uLb59fkwR/BWx/7EF+VAII8eSWZAtXM7SggXJz+WJBvQsPcZj5 p5hXUpJOaNpmYFD7v+9LkuO5BFG5ExP9sM8As1n4stBKSHr7oA/RIsauMQxGsLK/VMIL gM5w== X-Forwarded-Encrypted: i=1; AJvYcCXYtXGJop0pnJi240vxUJSVEtUDF9p+/H2SnipZX7D7L5ln+/1Y+UXKFddFsUZ6xf42SxfbF5v3fHLr2akKf/pZ@lists.infradead.org X-Gm-Message-State: AOJu0YxSf9iS1qn9GiKvU2HKOoyNZ/NtC5DVm8nCtbcL8NIoO0eCdnst nq19aWZofcdEpcobTAWXfumhSTZZRsDjGo5r/52gjxfFRIakSmZFaNp2jM4yWS/oZb5pb4ncD0u c6cv6V8WcRdidinnRBWZbPbvhBsU36Blhdce7+bNu0pLov1Y1ZvtsA5ZMH1KbfzILZ4F6dzdW X-Received: by 2002:a05:620a:4112:b0:7a3:49dc:e6e3 with SMTP id af79cd13be357-7a6897a6f65mr1244451985a.53.1724705048900; Mon, 26 Aug 2024 13:44:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAEqST5igJBEO0jhxDT4OAwN3xGv5rzMyL4N+pVFoujxFDEyZ/hbdQR2zB1kD+DQ4JLF652A== X-Received: by 2002:a05:620a:4112:b0:7a3:49dc:e6e3 with SMTP id af79cd13be357-7a6897a6f65mr1244449385a.53.1724705048557; Mon, 26 Aug 2024 13:44:08 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a67f3fd6c1sm491055185a.121.2024.08.26.13.44.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 13:44:07 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Gavin Shan , Catalin Marinas , x86@kernel.org, Ingo Molnar , Andrew Morton , Paolo Bonzini , Dave Hansen , Thomas Gleixner , Alistair Popple , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sean Christopherson , peterx@redhat.com, Oscar Salvador , Jason Gunthorpe , Borislav Petkov , Zi Yan , Axel Rasmussen , David Hildenbrand , Yan Zhao , Will Deacon , Kefeng Wang , Alex Williamson Subject: [PATCH v2 06/19] mm/pagewalk: Check pfnmap for folio_walk_start() Date: Mon, 26 Aug 2024 16:43:40 -0400 Message-ID: <20240826204353.2228736-7-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240826204353.2228736-1-peterx@redhat.com> References: <20240826204353.2228736-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240826_134412_457359_ED5AEC7C X-CRM114-Status: GOOD ( 13.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Teach folio_walk_start() to recognize special pmd/pud mappings, and fail them properly as it means there's no folio backing them. Cc: David Hildenbrand Signed-off-by: Peter Xu --- mm/pagewalk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/pagewalk.c b/mm/pagewalk.c index cd79fb3b89e5..12be5222d70e 100644 --- a/mm/pagewalk.c +++ b/mm/pagewalk.c @@ -753,7 +753,7 @@ struct folio *folio_walk_start(struct folio_walk *fw, fw->pudp = pudp; fw->pud = pud; - if (!pud_present(pud) || pud_devmap(pud)) { + if (!pud_present(pud) || pud_devmap(pud) || pud_special(pud)) { spin_unlock(ptl); goto not_found; } else if (!pud_leaf(pud)) { @@ -783,7 +783,7 @@ struct folio *folio_walk_start(struct folio_walk *fw, fw->pmdp = pmdp; fw->pmd = pmd; - if (pmd_none(pmd)) { + if (pmd_none(pmd) || pmd_special(pmd)) { spin_unlock(ptl); goto not_found; } else if (!pmd_leaf(pmd)) {