From nobody Sat Jul 25 00:16:11 2026 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA19D46EF8C for ; Tue, 21 Jul 2026 18:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784656966; cv=none; b=oewJBqZIAJ3r0AS9pLLqZXFPfJcmKREH96A68FUaz35kCJW8B1xEq6wcYmw3DBCYt5XLvbzwy5/pINbd5Oc7KETboi9AmnQklIzddX6z7AdyLbycLPwDPEVyF6YF0RtROjv29YskvcgeeXQ8WXmmIy2K6G13oNzisAtLuDgP/K8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784656966; c=relaxed/simple; bh=S74G3Hzp1xn7IYb5PjdPKa4E9fNu1Y5D2hCIThsQ2Y8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=sGzPQJy7vkIJln20cbfECLrDZQR0MR+yYeScUCUc2dsuu6jm6zmvNxSk9f5NzZ1EoOjO3wy2tdZcRzBURaaZTXpJY9tjuaMXeogD70u+98mmGpjq9FFGDYcBc89EAsz0GzcB4hPIkjIBq0zxtcNKm6PR6aU5qBBqJQxH4hpH6IU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--pohaosu.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=pc427V0U; arc=none smtp.client-ip=209.85.214.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--pohaosu.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pc427V0U" Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2cc88e22f92so245558255ad.1 for ; Tue, 21 Jul 2026 11:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784656964; x=1785261764; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=fKXoDurqCu73K4KxpvuOiTH2pdM8ddAsMnsgR4GIeQE=; b=pc427V0USJetrDa2+G7iqOKeS3ZfTYI2EnReDCJ3Dqtv/VLym9TGhQCDrhNe7k93hv 9WWDJ831nuqQqQYH3FY28I31idwtkhwty3Q+N6wC+0dFT7kQiWbLMDY19FC78KNq7J70 vTpveEBs+pfoPZHFgCAVuZDAUYwkglszhWZf3pIELHGcPRNrXUvLavT6ZhdjGpvvGvi5 ZHC3G4cYhu1BKrmRNY7bIfK1Dezh7FdYjK2c8T6rblSjgRM21urqypGy6V8ddOXhj5Aj KNSfDZcUH5keTUfUfCQ8wQO0v4wg6lDu/ErCwVboPDu4egUh+umWlP60eQznTy0ZKZ2G Xolw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784656964; x=1785261764; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=fKXoDurqCu73K4KxpvuOiTH2pdM8ddAsMnsgR4GIeQE=; b=ZSslx12LjMT8up+eCG5yxdkV1YNkSR2xPBvUbm8Aq67hqesnSa+Jkct9yyBVCliMhy Fk/ji2aLmrh1m7EWo10NNLucFeLGleJUFNGe4u9TGwIc9Q4Oy96RBGICmSh8M6P+rSbs oqI1qJAU+2LXCOnGx3JrkXsMCi6FyqtAC05WyXecQNeUQGrG77oaUgCPd1fI26skpWSU FYJCBhewwO1EDMPb5rHxSi97ju3nhJSdW21pIRRZfiOvkK2D0RZjlRFSYyAEWimL0XQT 9fMgQS+8jOoSXjp2l8CJ5Tq7VVgW1YJ6u3TBFPt+EkQz2eeyEuuvy8GPJUoQnugDD2/R 9FgQ== X-Forwarded-Encrypted: i=1; AHgh+RqqD/zPed1B2jG+nU20HoNqUWc9XCWA8+8pgaw4CBjMc4CpZT2ZJ8XN+YRPkewneqaWpyBjRhXSGRQJwzw=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3n1xG9cdNnTdXY0WS63kEA3YYcufWLa05S3yOCu5JSxKVnIi7 rfn9fH3jaR91S0Ijw+us5Dd3ZSyLJfERfhw8Fs2a1AvC0ov4RujYDhpi0XKKJA6bKbGaStCudq8 cgvI8WtJImw== X-Received: from plsl15.prod.google.com ([2002:a17:903:244f:b0:2ca:f1f8:ea00]) (user=pohaosu job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:f686:b0:2c7:f338:5691 with SMTP id d9443c01a7336-2cf349c0b41mr209240885ad.36.1784656963749; Tue, 21 Jul 2026 11:02:43 -0700 (PDT) Date: Tue, 21 Jul 2026 18:02:18 +0000 In-Reply-To: <20260719182633.2196873-1-pohaosu@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260719182633.2196873-1-pohaosu@google.com> X-Mailer: git-send-email 2.55.0.229.g6434b31f56-goog Message-ID: <20260721180218.767744-1-pohaosu@google.com> Subject: [PATCH v2] x86/mm: Clear PUD/PMD entries when splitting huge pages From: Phineas Su To: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org Cc: "H . Peter Anvin" , linux-kernel@vger.kernel.org, Phineas Su Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When phys_pud_init() or phys_pmd_init() splits an existing huge page (pud_leaf(*pud) or pmd_leaf(*pmd)) into lower-level table entries, it extracts the page protection attributes but does not clear the existing PUD/PMD entry (*pud or *pmd). Subsequently, set_pud_safe() / set_pmd_safe() is invoked to link the new PMD/PTE table. Because *pud / *pmd is still populated with the huge page entry, set_pud_safe() / set_pmd_safe() detects a present entry that differs from the new table pointer, triggering a WARN_ON_ONCE call trace: WARNING: CPU: 0 PID: 0 at arch/x86/mm/init_64.c:89 phys_pud_init+0x2d6/0x= 390 Call pud_clear(pud) and pmd_clear(pmd) right after extracting protection attributes when splitting 1 GB / 2 MB huge pages so that set_pud_safe() and set_pmd_safe() can populate lower-level tables cleanly without issuing a warning. Signed-off-by: Phineas Su --- v2: - Also add pmd_clear(pmd) in phys_pmd_init() to handle 2 MB huge page spli= tting. - Update commit message to cover both PUD and PMD splitting. arch/x86/mm/init_64.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index d57f29ca23a5..55845c40c1ca 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -573,6 +573,7 @@ phys_pmd_init(pmd_t *pmd_page, unsigned long paddr, uns= igned long paddr_end, continue; } new_prot =3D pte_pgprot(pte_clrhuge(*(pte_t *)pmd)); + pmd_clear(pmd); } =20 if (page_size_mask & (1<