From patchwork Mon Jan 31 20:32:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12731114 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 AE34BC433F5 for ; Mon, 31 Jan 2022 20:32:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B8116B00EF; Mon, 31 Jan 2022 15:32:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 219DB6B00F4; Mon, 31 Jan 2022 15:32:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F38B56B00F5; Mon, 31 Jan 2022 15:32:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0069.hostedemail.com [216.40.44.69]) by kanga.kvack.org (Postfix) with ESMTP id D76236B00EF for ; Mon, 31 Jan 2022 15:32:55 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8F975181C5C32 for ; Mon, 31 Jan 2022 20:32:55 +0000 (UTC) X-FDA: 79091731110.28.117B3D8 Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) by imf17.hostedemail.com (Postfix) with ESMTP id 1DEB140003 for ; Mon, 31 Jan 2022 20:32:54 +0000 (UTC) Received: by mail-qk1-f177.google.com with SMTP id m25so12281262qka.9 for ; Mon, 31 Jan 2022 12:32: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=+b2VDnizluGVh9+la/y+t/dAo3W53LzEqz2Kl5SWq3M=; b=YngBIjjb/nHQSRa+qiaFZjTH9m/x8VBAIf2kGQ32pwNNBHyLxbRoo3ZxdB+I+6Oroe 8As6fNzzko3D/+CepuYqaHnseC9dE4lJZHAKbOeGxwlM3VV2+NEqYRGq7EZKMx/KFChK FWgvvuxmkldI3pOZosmJ7ktVltjev2UMC+qOgyGSEj/dvYjxGHoenQrLZTuXY+MqxtQH G6VqMbiuCYFjJS9Xi9jOPxvLuRc1K4fTP7k8ursBzujYyJxREZFkqCIw5YzvxtROhWa+ AMQF60zVFOrek/a1GrwkxGd6/H7mpiu0H/vGg0l1ymArsRf8Oa0L8c5Ja5h7C2lnZ8RV I4Dw== 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=+b2VDnizluGVh9+la/y+t/dAo3W53LzEqz2Kl5SWq3M=; b=XQQ9vY3RtqEGBJT5P8AQcv5H7FY986li/6ObeEudjB6LwZMyAKdchwMHqOlSMA+zO4 tfhpWN9NZVkNJlKghrGkE0ageO0NbSpKeJorYZqLSVcTw/K4FLY6xMDjaJFuJ8842mng W8uIlpUsuQwulvY3vvqQXfDhsnh0sueHtxQL1WtJZlb4FLMhRhwZxJCc+KKUZpuu34pl DdS83t6TzV0X9NurUgjBoW9itAm34OTz484LKUJnqXCQVki+WNRMRzSvOABuLgllh5VT 1tm0NJPthjwTRXw8KSHacAhPrj3JF97p2D5T+Tw9BV1wm1xW/wbXotB+aWG0OAWNicEb EhOg== X-Gm-Message-State: AOAM531QdgcBg4nH5BXLcMHyqejz0IbCuhDDHdLi/2aG4I+m+Y3Xqj2r sR7Z0V2u7KD2felljGQWv/uOxw== X-Google-Smtp-Source: ABdhPJzfANMgqiVqJGB+ggntyJhpzn27PcIgePLyPDDStslF+pnhqRXRQJMP/Ar96PUQKuG6r8ktmQ== X-Received: by 2002:a37:aa08:: with SMTP id t8mr14647255qke.773.1643661174408; Mon, 31 Jan 2022 12:32: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 j14sm5349661qko.10.2022.01.31.12.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 12:32: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 v5 1/4] mm/debug_vm_pgtable: remove pte entry from the page table Date: Mon, 31 Jan 2022 20:32:46 +0000 Message-Id: <20220131203249.2832273-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.35.0.rc2.247.g8bbb082509-goog In-Reply-To: <20220131203249.2832273-1-pasha.tatashin@soleen.com> References: <20220131203249.2832273-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: nil X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 1DEB140003 X-Stat-Signature: qbyp7k8yy8s5hk7nj94ikcakcrpxjwhe Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=YngBIjjb; dmarc=none; spf=pass (imf17.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.177 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com X-HE-Tag: 1643661174-64604 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: 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: [ 2.262821] debug_vm_pgtable: [debug_vm_pgtable ]: Validating architecture page table helpers [ 2.276826] ------------[ cut here ]------------ [ 2.280426] kernel BUG at mm/page_table_check.c:162! [ 2.284118] invalid opcode: 0000 [#1] PREEMPT SMP PTI [ 2.287787] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.16.0-11413-g2c271fe77d52 #3 [ 2.293226] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014 ... 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") Cc: stable@vger.kernel.org # 5.9+ Signed-off-by: Pasha Tatashin Reviewed-by: Zi Yan Tested-by: Zi Yan Acked-by: David Rientjes Reviewed-by: Anshuman Khandual --- 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)