Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1292722pxb; Fri, 21 Jan 2022 14:34:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxtJrYEWI2+sSCz2FDIuM/p7qU7BnxfiNwS7eQirsqvMXBsQoyFnWsFUQXdGwEqz3Niu9Ez X-Received: by 2002:a17:903:11c9:b0:149:bef4:2d7d with SMTP id q9-20020a17090311c900b00149bef42d7dmr5719039plh.48.1642804443971; Fri, 21 Jan 2022 14:34:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642804443; cv=none; d=google.com; s=arc-20160816; b=Q5kOen6tF4apbpY1cpS9vDpmBIYR3QfuTaQUKh3xRPt5tzVr2zE7zjFVD3LhfyePnq 4Ly5VfCoV3CuSPswTn2Wpwdbqsapp6HEu48Q8pCrPZpmTUIBR7JBgpB1fVEa0pcICXrU vFDo+gLSJX/EHVS5Wp37T+eimi4Tar5PhANnquWoIjqFJ7vh06yaF2fWneJtYtsa51Wg 8N+pWWUREUGTClbgjhk1J0gZuOcGVVX9JJCAsu5pwkJj7UTF0NyMATP6bExSRIdE2SKp 16gR5mqYAK4oF0rUX13qhOWMVkMYow3j57kCsN4k95u8h24LwwtsUgk/7b5zYMnDpEnF ghCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ljRHzu8EIti/rwgbKsna6fOCiQbES3TZ5TTYfFv0egw=; b=Splqyh6QVM1Zv92Fgqebk2B+3dVMuyz6183mqpJkxQrjrLqm3MA7WLIiQQD1GcNiA1 +LmT1c/I5J+V8utfdewsYMRub98+A0CvZYTfG5ql3IxlqB3EtZCwG4PVdPUSHBY0shlB SDmqpmcFDpFReh8IwDHfJdF1xRtEymi3aFHNMpSm5VbrpQbnI3xOc9pm2dRN65L3jDI7 xR2i5ToD0L9oU5obXvm9Qb/x6irQ1miabmqoSdfVNvFnpJHYpKkGjIKlNaJZKvapCqtB jdz3+8vY3nCMDawSkQlEKVUziXIMNVEhMscyABCWyOsP9nhOr6xf9upeVypCEsNdv8qm LDAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b="FyNEAIm/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si6493722pls.313.2022.01.21.14.33.49; Fri, 21 Jan 2022 14:34:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b="FyNEAIm/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377411AbiATTM5 (ORCPT + 99 others); Thu, 20 Jan 2022 14:12:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236860AbiATTMz (ORCPT ); Thu, 20 Jan 2022 14:12:55 -0500 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 026AEC061574 for ; Thu, 20 Jan 2022 11:12:55 -0800 (PST) Received: by mail-qv1-xf31.google.com with SMTP id 15so7778734qvp.12 for ; Thu, 20 Jan 2022 11:12:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ljRHzu8EIti/rwgbKsna6fOCiQbES3TZ5TTYfFv0egw=; b=FyNEAIm/3bE5CybyyukETOQ/BQa7EhXGoW8WaHTc5aG9OMBkNDJ0v0IxBNUDBn7JcJ qY/Fi2S4h5MYwXg4pELzsxmpyzOLEYq5cf2kR4ObXgaUcpEEl2M/8hR0/838NFa4RUSh WMTlEm+f/O2OesyO8SbAkTVyfRj1k0LXXgkfmAv2CLxhI/SCnWhAEE+c+pi15uDOQIs3 ANyEOssIBASnEYRn3/chz8M8SCXLBshno7oN6a78RV+aHElzwXJ6zmpR+KJIcE4XkWl9 egN5vg3Y9WPN//dCaL2OGEjhy1+Jc4eFmdmfTmJlVB7og/sM0WoHgVXCEne2nAaG44EU S1+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ljRHzu8EIti/rwgbKsna6fOCiQbES3TZ5TTYfFv0egw=; b=drcYsaWogEGBzQBcHLIVfLjK0swGaLNYYy8We1laey86PSsVkZo1u6wxoN8RVfJoWv vuwc/PC5mgKcQP3HWthOdiXhTq1Mc4VbaCJH44EGJeADU1PL883jCpe68qVl+QjAOAA5 R2EosrQempJGIPN5qfTQaj0uU3xI/eFqXYE0VqUtNpdyRYm7vMvqGZ4yRKQ6nuSptWW9 y48zaGoE5I3TOFt2YsMPW9uSTgcRzvzSAY7HihBdM0g9ztdyvrHEl2zmQRUFGWzU3Ayd jVw00X8kj6Uab/l1OgWWoiiVRlz5E1zFQ9UB7rXid4J6yRFEM2JI1DJRXne6JQ5d2RnH /7xA== X-Gm-Message-State: AOAM53145LAWvEQwqEGke14tilw4ZUmOf88uJQFpKxxJ+1TRwopvnShQ opo/M8jeiRnEE3BC08SYMuuKAw== X-Received: by 2002:a05:6214:20a4:: with SMTP id 4mr384015qvd.7.1642705974062; Thu, 20 Jan 2022 11:12:54 -0800 (PST) Received: from soleen.c.googlers.com.com (189.216.85.34.bc.googleusercontent.com. [34.85.216.189]) by smtp.gmail.com with ESMTPSA id w1sm1822509qko.40.2022.01.20.11.12.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 11:12:53 -0800 (PST) From: Pasha Tatashin To: pasha.tatashin@soleen.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, rientjes@google.com, pjt@google.com, weixugc@google.com, gthelen@google.com, mingo@redhat.com, will@kernel.org, rppt@kernel.org, dave.hansen@linux.intel.com, hpa@zytor.com, aneesh.kumar@linux.ibm.com, jirislaby@kernel.org, songmuchun@bytedance.com, qydwhotmail@gmail.com, hughd@google.com, ziy@nvidia.com, anshuman.khandual@arm.com Subject: [PATCH v2 1/3] mm/debug_vm_pgtable: remove pte entry from the page table Date: Thu, 20 Jan 2022 19:12:48 +0000 Message-Id: <20220120191250.2671557-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog In-Reply-To: <20220120191250.2671557-1-pasha.tatashin@soleen.com> References: <20220120191250.2671557-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The pte entry that is used in pte_advanced_tests() is never removed from the page table at the end of the test. The issue is detected by page_table_check, to repro compile kernel with the following configs: CONFIG_DEBUG_VM_PGTABLE=y CONFIG_PAGE_TABLE_CHECK=y CONFIG_PAGE_TABLE_CHECK_ENFORCED=y During the boot the following BUG is printed: [ 7.483050][ T1] debug_vm_pgtable: [debug_vm_pgtable ]: Validating architecture page tabs [ 7.490930][ T1] ------------[ cut here ]------------ [ 7.494926][ T1] kernel BUG at mm/page_table_check.c:194! [ 7.499172][ T1] invalid opcode: 0000 [#1] PREEMPT SMP KASAN [ 7.503610][ T1] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.16.0+ [ 7.508600][ T1] Hardware name: QEMU Standard PC (i440FX + PIIX, ... The entry should be properly removed from the page table before the page is released to the free list. Fixes: a5c3b9ffb0f4 ("mm/debug_vm_pgtable: add tests validating advanced arch page table helpers") Signed-off-by: Pasha Tatashin Reviewed-by: Zi Yan Tested-by: Zi Yan --- mm/debug_vm_pgtable.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c index a7ac97c76762..db2abd9e415b 100644 --- a/mm/debug_vm_pgtable.c +++ b/mm/debug_vm_pgtable.c @@ -171,6 +171,8 @@ static void __init pte_advanced_tests(struct pgtable_debug_args *args) ptep_test_and_clear_young(args->vma, args->vaddr, args->ptep); pte = ptep_get(args->ptep); WARN_ON(pte_young(pte)); + + ptep_get_and_clear_full(args->mm, args->vaddr, args->ptep, 1); } static void __init pte_savedwrite_tests(struct pgtable_debug_args *args) -- 2.34.1.703.g22d0c6ccf7-goog