From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795984882; b=X3btL+OG4tID6fus+Kqj/oYsR5b5y0vT4OyNLyNddr8s7M7M2Cb/miGq8lLVG+cF8jQP LzTGaZf/vo96lg909Vxj4jasqjDopq+J6+HbU3iDcIu+5eW8gm2qIr49yz93hVWhdm7Yt gvQPJt373pyr4fFG+qU49MN5L7dmocJw3E8fdtmh2Ko6v3ftYLuNh7JiSM89tm1axpm0R y/v1p91pADNXv0dmzbGCG2VQUPS7TqqumAQrs3avSr1zW5j02C0YffNmk+m/8kHP+++I3 Jsf/uvV7E8EsO6t2nzjqsp8E6IlyZAnNq4YsbXYecQlOByDUe+bpV00HLGr14QQPgQw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795984882; 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=w8XdXS0ZQeqoY1FOiYsXmmoui0VIdIdhn7QsfPJFtnY=; b=rjDq3eTES8Pf8Jk+LvoTdWJeopMKqushvj12SXU6mGYoXOOndCEEqgyh+uO/9wfgPiwO Q0lnDNSeOC2eRRgeCNKsl8wnwYH5n97rgBkRXOThLJ9Jc9WZTN4R1BbJgXAOmRWCO7m7G KB1nyt4hwrk/v+3Gdey0RuNE/X2maAUxUgiAlltVr4pA73AzKSwjTnRL8ny5ufWqbiPnr I+eEcoWPJVKVPUPdThs9Qksrg2B8EteuYb01vf4/nIrm/O5JyAMz4XrSr/W7D5C5H5iss 3ZfFlUkbrVpv/3JjI0KOzMQVrMTsDXS7xEinDLqpZBuZoiHZPhxm4TWRY4kfwtw2AoQ== 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=Rw1rgOtW; arc=none smtp.remote-ip=209.85.221.51 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 2D72A606A329 for ; Sun, 29 Nov 2026 20:41:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2D72A606A329 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=Rw1rgOtW Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-48dfc0421d9so8867540f8f.1 for ; Sun, 29 Nov 2026 12:41:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795984879; x=1796589679; 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=w8XdXS0ZQeqoY1FOiYsXmmoui0VIdIdhn7QsfPJFtnY=; b=Rw1rgOtWh1cwe6znP6IhcsCpCAr8/trye19G3dEWK6vw/yueyteermuaVwWPPoweMC vcm7wUYJODlol9VacY32EPR8cyPq4ULAdoI212UwjB43wqMdCukWpmZgzJRP6iCxeuzl dMobgPuMEDYLwszzORz/2isB5RvrlP7NDLYBZ3zRugqXVJhnDYMnh1MDULcU/NQsml0g tn4fA59/s1NIXx43x7wHXmqUh9s8tv+VGGfpSH+AIEl8CdxEw8BDDpRCB5jYxxG9/GiT MyJfE02UrFmoKZxUzmtr/g8S4DSE9TF2PYMr/t6mGcpNWT1SbVt3t01+KR0xkLhCwX1B 0YNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795984879; x=1796589679; 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=w8XdXS0ZQeqoY1FOiYsXmmoui0VIdIdhn7QsfPJFtnY=; b=j2rt/O7TziC4bvZQLMcPx8aTWyQLriaVEeiPoSmbivv1Uq/mLzC9FMD3FJylB4PyLJ vsTYG8zsxlfjW3d4OsQvltxm/eNc6JK3c1v9yQDeYH4YrFjleJ+EHBZ8Hbp802YDZFb2 lQm6WHs3MRHXc1FHBMEffs8uD8RT/5zXUyzX3LVeiC4hCwvDXuDEm8h722lagUnSjFlM BqHo2jKb5zOt59xDNSC8mPATdboSFPs8RQZftRPdI57Z4QxQToJ+35qDSHjvpOUWhlJF UiHJDoHqYQrd4i2R38iVgpe3gqIsoXdVOrJFjzVAnJNlpiTt5sTVqc9peMUNZS4m3CPs d3oA== X-Forwarded-Encrypted: i=1; AL+hErGP7AwyHk8+odJgLmNwAL1ww2QnfWeLdTqFl/5H0utGhTq7cppnr7UgvfuzMUpwyPNJVm5Mh1UmCdDnEaqsDw==@lists.linux.dev X-Gm-Message-State: APuU4Z+EMgIfzYzuTtTB3R4mFvC9gEjZEOqpYztfVX+nPb+xR8s3W+2P /f2DyxC+sDI8tr3BIBFuz/LypxHF5CuCqHOjQ3F7NRBO4jwlXaC3yQ0p X-Gm-Gg: AZFdTZcrGOpoBLMKQHgfHWZ/4bsnwXw1aCYgaM8e4wjn0yyZqp97Ib+R9cZ5bbdeek6 km7HFWJFkdaAp3Hp6fCo2TfzetjPf/NXrala6l1cetzswB+0Wve/u+MhnAX8JJO+1+aelfK7dlR G+hz13blTst0Ueg352mV01I0x9JKDZFEDyg3WWfY/l9/U6Szup6D+nANkd1s7bQI21dRmMt7UWZ srV+2mfnLUxSYoc1u66ekp8K2JGbZUt0xq03mBauBEWdlpESofmaFPYz+Qq64oX72cmW0E+ZjtH ZleF4Q7wOnmuBMy8hjyljbhZlRr6KeyyJSaKMq3rX8N9k7JXk9yAOSc4LExpDVvYX0CC8e06bMl KwXSv9pWrlqHxYQUVrUpoj/GdcZkwD6sLxjKjpYGfepooHjmM7d1MK9KVUMCW+RecC9ZNqi+auY 5VH/irzgFPeXmJJX9R6njQ6LrFr0SQp0wk1ciPy95g4kor6wNiCnJg7/HiH719CaRqNSmPun0z5 sR0Y1R0BBekJ0tekn7iciRCD4lqTcn+tl4U9jYMhowwztCanv+g7sY5kaVukzC9+sWOjh3IIY+p judj/7FgRinaQjX67OOhk8gN X-Received: by 2002:a5d:5888:0:b0:48c:4a62:9af7 with SMTP id ffacd0b85a97d-4abb70d6148mr54471697f8f.28.1795984879213; Sun, 29 Nov 2026 12:41:19 -0800 (PST) Received: from [192.168.1.22] ([83.231.69.9]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6bc8ce06sm57584924f8f.47.2026.11.29.12.41.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Nov 2026 12:41:18 -0800 (PST) Message-ID: <4db79aac-b8bd-4dcc-ab19-9008eeb8fb74@gmail.com> Date: Sun, 29 Nov 2026 21:41:14 +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> Content-Language: en-US From: "Jose A. Perez de Azpillaga" In-Reply-To: <20261129-fixes_core_3-v1-15-f66094116801@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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? -- cheers, jose a. p-a