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: 13778400 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 322AAC54731 for ; Mon, 26 Aug 2024 20:44:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3505A6B0096; Mon, 26 Aug 2024 16:44:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FFD96B009A; Mon, 26 Aug 2024 16:44:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 152296B0099; Mon, 26 Aug 2024 16:44:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E9C786B0098 for ; Mon, 26 Aug 2024 16:44:13 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9F4F01C455C for ; Mon, 26 Aug 2024 20:44:13 +0000 (UTC) X-FDA: 82495573986.05.D1C8CF1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 93B8580005 for ; Mon, 26 Aug 2024 20:44:11 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VvSY6pkv; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724705032; a=rsa-sha256; cv=none; b=Zee+s4ISGqj/z7ezJFdRHu6f1FPPJGcT1SFYg5hD37pvb5Z50GZUmWyjZ3q048jNFxb30+ MjMUy4OxWZWUt0aXYwDewoLTwo3VQwhRyh0EZy41UuKSv45KWfTZgcaM7rcIT0swP2279c Z7FYd8zjPmPT+f08RUYDkVfhdC0B5TY= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VvSY6pkv; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724705032; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UaLXo2idJup/Oy4OwRPy2aK364ayUQ63MrUET5wBpvQ=; b=2Tl2I70aV9wDf4RkJC4TcQkbLZV/hAOMLbpd2UCRBqgS31gOnXPOcCWhftrxsXyYurv+O0 xrDs7p4KwBJHe5tqw/LaIi9prtiEdNxoBz7BkKCTM46USA5e2LqAXctUT/HW5qkboSpe+I wctLwnZvsIx/FvJKhKtMmFfyhuvT6fo= 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-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-284-8WfFysqLMESwmLOiE5Bx8A-1; Mon, 26 Aug 2024 16:44:09 -0400 X-MC-Unique: 8WfFysqLMESwmLOiE5Bx8A-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-7a1d06f8e78so523627285a.3 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=oxW/5ruuFu0bpvTAPvaKqjJlmtj96wMvQVpxnXdXRcmAMgQ3gZdeOrpp3/lB0399VG +BXfmbQY+NH4Fx53qB83VfnXPO+HYFUK7SisRuvGIRtPf0F9CY01h7WLOWo0+jZWTNFY hVk8jv+Yq+3tBAwDdFFKn4KmVjI64CZjThiI2VLeRs/PQgrpduxI+LzhGhyCY6p2CbOc wYAb4fg9k3kHAW/AhE066HPeeGj6I7TP8IMNhfCsQSMvhyvyQrsc43sItbuUWX7/o+n9 OI5pWEjB6ppgXbsTtwbaMLIfNBkArhrQlgEW/PGnMREv/2V9ONx1MpZQW4qFseF1qPaa /EUw== X-Forwarded-Encrypted: i=1; AJvYcCXqmqIy6k53Ter5ulkfbrTIxVch/GubaVg9eBeZ+7SdtlyAvztdLtRW+W4d8XZen4vAdTtz94JhUg==@kvack.org X-Gm-Message-State: AOJu0Yyvai/iK8Jt4VdZBdRMUQmwJAW31RGR9CAuANUsBxgloq3Ku30S KpKmCx9PvMEbM+P5a+ae09lxuMWvVicQOC6WXcjoS8TwWA4Gfs26hhSPj7A1wEb7SEegLu/iGNk 8CNZSfrgx/pfugDVjuwrCSNGaunFBWxREDGsrTGEMkDZHcj0x X-Received: by 2002:a05:620a:4112:b0:7a3:49dc:e6e3 with SMTP id af79cd13be357-7a6897a6f65mr1244452985a.53.1724705048903; 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-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B8Yy/jl/3809eYdlEMxgPZzBhhLdtvsF6Xr9JcuLF28BH45dfs+i90hTWxPbDwZp7Z5veMRA5ypYYu9d5bXgT/vpAN8m bfohO5vG PZsfog753xMGDtyrZw6iRCgMyusSgMQ+ejV80KwullDPpKySHkqGLeJ1MMYgzZNGRYAvoFnvztHduEqEITSlCvWOdR89g399TLHqrlSBbV4+JtmI5pG8lpapHatsRK8EHOonolb8jhXem2lK2dTTE0M2LC3Ph4zK9jTgb+6Uptn2SL2uYvrXJiq9ZMFGTdE9JvVRngnaoNWdOkubqNHmhQmCXn76ky2BBHWUN4xpBsxtw+HXtZulArSk8OnvsuwehKEV8Hp3pmjV6YfCExX22BAeYjGH5U3bWB0lOuW+bWshDSAqWd/W3qtc6JzgG0hjCtwJQMS3+uJ0qHyOOzmzhtA6rjlqFf78jyKCRWp/Dq+8YyRgaKbiUpJYXnql1Bd5NjxPAAK0vrrFQ3Y1LCXe+9tuy4E7eeESc21o8zPBnZdzrRXaxhGfzu/P1GzNL36/K5JzdR9hZtcxIQOnIXTRkf8hOVOBQxkcMp1rnKeEm0b7hO0//44HZlP3iTCSzpNAhcjUq 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: 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)) {