From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796126570; b=2iV1SYIxdXY7xXXpUv+ZK0ZUbsncJJJ2/DWv0QEQNUJiyKVozuRpeJYBH7vry+tlbySS QejVdBq7X0NsgRytJ2xXi3aKfg/1DlIRxoaU+f0LRP9CPulgRjoCP8A3w3GDAesXhb4By HYIk+a6G60N7nqVbL12RFdTByhcpJYOl8UBvzdneP1xUoo7DqGzacBFEdxA175y3JNfdk Udp59qZDVlG5PEV+Mep0cOOP10JwkQOixNsebMKQQuKsIPlDggJJLh76Hh3xtb64XNzID 5K37EiwLBZiUrrIbNucmP3RpL47wAsYgasy09D+33B26GWDzkvwHoRphINXQdDCim+A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796126570; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=PFLXXNGAhlMn2SkemVFES+9JO6OwNT/1b+ah0hEaj4w=; b=rMeYgLGTteJTvb3LUGCLaIjkOrwN4Uwy1oectKb+0n2jraQ5oXpii7mf2nf6P05tqu6S uSRID7Ye+BWAQKOl5oF0oeizcGSzuxf5Yd5Zogs6aL1jGT0MsP1HF0Du5xciinpb2cCIB EImdgR0dn1lOm5J6jTeRmGyBAKJScz0Ti8J/JSlaqhvBRK2ADGJ5gv8SEpizbEtkcFgPb A6NFXkSpe9rKBYQg6rI2Br9Ro9/UYWCwDH8bQh4jsXQ82RWIZCGKWlJM4PUvyF8usgy+x 7qk1KK8E0dO+KWkQY4pLsjSdK0lON4411RInGsN8pOzGtzj3V0VJgod/hH1MPiD3pmA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qtB3Uy+y; arc=none smtp.remote-ip=209.85.221.43 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 929AF606A327 for ; Tue, 1 Dec 2026 12:02:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 929AF606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qtB3Uy+y Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-4ac08f4a0b2so8209343f8f.3 for ; Tue, 01 Dec 2026 04:02:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796126568; x=1796731368; darn=lists.linux.dev; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=PFLXXNGAhlMn2SkemVFES+9JO6OwNT/1b+ah0hEaj4w=; b=qtB3Uy+yNUR9cWBUCC+V3vXrVcC8Ginsuk8bWGH9Xpru6yoAacIROni2NJnd/1TVCH zEPRVBBfH+g6t4OEI5tR7ZeaNGhklIKIskbN8/rWl9sY3d2nl/qbv9NDo/sqF+dHSDaH 3wqODkXokSnOFUQqOv808LPndxipdGMbsw0byjS2KINRXDlFAw+SCyIThAXIyJc60Ast JLFj8OZmYjeAsGURU7oF+Jk1r+MgW9WnWk+/PC46oVlQgbDlSemf/EpAaC3EQL8cexjF mZ5nFq6jCkbJbB89SFjbx1+SuCHbj/s1S4RGT5mfvZx2MOAMmjzfQGAhYXo5Wk4uyLpd LF7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796126568; x=1796731368; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=PFLXXNGAhlMn2SkemVFES+9JO6OwNT/1b+ah0hEaj4w=; b=gfd8iyT69wbCRgYOhFolpY0KraLjgyrDRNx4gSy5v0QegqNnVoQBdFkg6TvmnmRRZB vEFbsYgtQL6BYaibr5fXQmIFm3+PGmojPoz1LcbtoK2Ykg7JzDRML/PsKtc1pAgpjYdg ImexkVO/3DhSB5FZxTc0NB+vkISZ6gQh5/jhG/Fxnosb1sAt9wK/ITnvkaeYhO0Iun26 xPnx2eXujKoYhIVEhUCB3rmpCdvt8eFi8uRZBZicMXanXOKYkjSNaT2khDtSKmveevw+ aJ1axLLAVjxu4DgIvcC62l+SvQOdTbspF9TcJb6wcl+q4FZLjBX6cM0vXprWi0sVIdOx j9iQ== X-Forwarded-Encrypted: i=1; AL+hErG9UYGa30DO8ikMcNi52vHl16jKqYB7VJBOq/V7bNutn3praIab3l9QkYBmYSC7mtxMLx9jzahZ99lrYU5YzA==@lists.linux.dev X-Gm-Message-State: APuU4Z+ipBVOYAueQvE9v778y1xGFk5K+4rTjNIQ2D+x0bYQVBDJolyf RS5h12ZlFMhaMkac5Z9uuhZUB3sp+yLGWM+cQbgE+VAiotiDYxsXk4JA X-Gm-Gg: AZFdTZfYC0uzBniVqgJIIy5BwyGPbo2to1cSQINMio0KBUPE/4ivPBEQOdLiwmaRXER 4YJQzXlaFCfGCVgjCd+JZZm+vy2FkXRZAUTunMiVClH4gSKDDE4Lwz4KiTf8CRXOQt/zzNnFp4a xiu5Ip91zOc6wxtqbc0wGsSvRHTXvDXGKv/MftZDdKUg0WV5WVu89UEhvdrVj6s7q+x2CFIlFpL affZs6lFQbyE+Y7yiuUY25PXtIh0U5r5bN4gCb6UqVsI7hFTEXrDYuBqsFhXTZrobljkCMalog4 EZZv06su2rm0/vqnM2dbSDKRmuXWauD8DOK74um8V7j4inbfqatsmSPRSjGUms5kmM1PTb3kUQb zJ6KufUdXpxP1JEtM8hqwGMNw6Rd97mrPMa6Oypw1VgH1C8Rd2XDsIascAQvU2+ZtFjQw5Hm5zJ WG39UQnHY1vdC8t0rlW6qxMwzOf8n8yJ/iuFCi2K8IVazoXHoD5Ihel6+xybRHlIG+W25UGew0k rS/9o9qI2Q54uDNlpjAfVuRT9L97ycQEr+FsmPZZJ29Jn1YWQ62LkNvwZTUbWoKMjUhQx7sEvuU QxjCLDXTQXy7XthoklqPVSlVtWREsHFNOuz5OPUzjnnX7Fa1ukLn92c= X-Received: by 2002:a05:6000:26ca:b0:4a7:8406:1e6f with SMTP id ffacd0b85a97d-4abb0c5d691mr65772785f8f.17.1796126567785; Tue, 01 Dec 2026 04:02:47 -0800 (PST) Received: from [192.168.1.22] ([83.231.69.9]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6a68048esm74100747f8f.29.2026.12.01.04.02.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2026 04:02:47 -0800 (PST) Message-ID: <499c2776-eb2f-4419-8a89-baae30224a7b@gmail.com> Date: Tue, 1 Dec 2026 13:02:42 +0100 X-Mailing-List: linux-rt-devel@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 15/32] mm/huge_memory: don't map huge PFN entries if the arch restricts PFNs To: "David Hildenbrand (Arm)" , Hugh Dickins , Baolin Wang , Andrew Morton , Mike Rapoport , Peter Xu , Michal Hocko , Kiryl Shutsemau , Manfred Spraul , Davidlohr Bueso , Cyrill Gorcunov , Zi Yan , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Lorenzo Stoakes , Rik van Riel , Vlastimil Babka , Harry Yoo , Jann Horn , Yang Shi , Zach O'Keefe , Song Liu , David Stevens , Kefeng Wang , Alex Williamson , Suren Baghdasaryan , Dave Jiang , Matthew Wilcox , Miaohe Lin , David Rientjes , Shakeel Butt , Jan Kara , Mel Gorman , Jason Gunthorpe , John Hubbard , Gerd Hoffmann , Vivek Kasireddy , Dave Airlie , Matthew Brost , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Hagen Paul Pfeifer , James Bottomley , Felix Kuehling , Alex Sierra , Balbir Singh , Kairui Song , Qi Zheng , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Oscar Salvador , Muchun Song , Dan Williams , Rakie Kim , Hao Li , Christoph Lameter , Roman Gushchin , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , Alexei Starovoitov , Xu Xin , Chengming Zhou , Shivank Garg Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cxl@vger.kernel.org, linux-rt-devel@lists.linux.dev, SJ Park , stable@vger.kernel.org, Chris Mason References: <20261129-fixes_core_3-v1-0-f66094116801@kernel.org> <20261129-fixes_core_3-v1-15-f66094116801@kernel.org> <4db79aac-b8bd-4dcc-ab19-9008eeb8fb74@gmail.com> Content-Language: en-US From: "Jose A. Perez de Azpillaga" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/1/26 10:54 AM, David Hildenbrand (Arm) wrote: > On 11/29/26 21:41, Jose A. Perez de Azpillaga wrote: >> On 11/29/26 11:06 AM, David Hildenbrand (Arm) wrote: >>> change_huge_pmd() and change_huge_pud() temporarily invalidate huge >>> entries, for example during mprotect(). The invalidated entry is not >>> present, but still contains the PFN. >>> >>> On x86 with L1TF, we invert the PFN of a not-present entry, which for a >>> PFN at or above l1tf_pfn_limit() points into the lower half of the >>> physical address space, where RAM might be. That's why >>> pfn_modify_allowed() forbids such entries for unprivileged users. But >>> we never check it when mapping huge PFN entries. >>> >>> This was not a problem as long as only DAX used huge PFN mappings, >>> where all PFNs have a memory map. But vfio-pci now maps BARs, which can >>> be at or above the limit, with huge entries. >>> >>> Consequently, an unprivileged user with access to such a BAR can make us >>> temporarily create not-present entries that point at RAM, which is what >>> the L1TF mitigation is supposed to prevent. >>> >>> Let's fix it by not mapping huge PFN entries at all in >>> vmf_insert_pfn_pmd() and vmf_insert_pfn_pud() if the architecture >>> restricts PFN modifications, and fall back to PTEs instead. We clear >>> PTEs instead of invalidating them when modifying them, and mprotect() >>> already checks for PROT_NONE PTEs. >>> >>> This only affects old CPUs that suffer from L1TF; not worth optimizing >>> for. >>> >>> This has low urgency, as it requires a CPU affected by L1TF and access >>> to a vfio-pci device. >>> >>> Fixes: f9e54c3a2f5b ("vfio/pci: implement huge_fault support") >>> Cc: stable@vger.kernel.org >>> Reported-by: Chris Mason >>> Signed-off-by: David Hildenbrand (Arm) >>> --- >>> mm/huge_memory.c | 14 ++++++++++++++ >>> 1 file changed, 14 insertions(+) >>> >>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c >>> index 0b4834f843c73..38b16333d3987 100644 >>> --- a/mm/huge_memory.c >>> +++ b/mm/huge_memory.c >>> @@ -1732,6 +1732,13 @@ vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, unsigned long pfn, >>> if (unlikely(is_huge_zero_pfn(pfn))) >>> return VM_FAULT_SIGBUS; >>> >>> + /* >>> + * Disallow huge mappings if we cannot reliably temporarily invalidate >>> + * them later. >>> + */ >>> + if (arch_has_pfn_modify_check()) >>> + return VM_FAULT_FALLBACK; >> >> if I'm not wrong, that only checks the CPU, not the PFN, so >> drm_gem_shmem RAM pages lose the PMD mappings too. is that okay? > > I'd say, people running on these old buggy CPUs should have other problems than > benefiting from huge PMD/PUD entries for somne odd things. > > Not interested in adding more hacks to core-mm to make that work. :) > > Long story short: I thing this is just fone. > okay, then: Reviewed-by: Jose A. Perez de Azpillaga -- cheers, jose a. p-a