From patchwork Thu Jan 20 19:12:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12718989 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 21D20C4332F for ; Thu, 20 Jan 2022 19:12:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0CAB6B0083; Thu, 20 Jan 2022 14:12:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BCAB96B0095; Thu, 20 Jan 2022 14:12:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 932DD6B0085; Thu, 20 Jan 2022 14:12:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay029.a.hostedemail.com [64.99.140.29]) by kanga.kvack.org (Postfix) with ESMTP id 7BE436B0083 for ; Thu, 20 Jan 2022 14:12:55 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2BB29229CC for ; Thu, 20 Jan 2022 19:12:55 +0000 (UTC) X-FDA: 79051612710.03.773DAFC Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) by imf15.hostedemail.com (Postfix) with ESMTP id B5A9CA0059 for ; Thu, 20 Jan 2022 19:12:54 +0000 (UTC) Received: by mail-qv1-f52.google.com with SMTP id a7so7833742qvl.1 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=nHR3Jv4ADBaJZ6r9fvhrupdAN0As0xbcqtJdEiJngj5z03mTiD4ZV2v0A5dC4H99q0 DHALGZ6Da/qoGu1PE47SpBTCsEz9SA/659hcJ26zUgfbof0Fhz3/qPZg23ATccneL90m FZJdYxflHq1knPPFoihOyzbnHcXD0WBjPasLJ9bidLbHd9rly+RFaWJ+8WWAaHtVfGED ojBJIdTQSYtvFYye7m37xNOOxtjg55thGh1Fkdz3trqb3X7uYTtIBIabJWj4pCXjIgsB 8TxWhv8A2bLj9Eh/xjXK8Wmh9fLLVQKg9iLzTatr0p7eonFQMQ8ZxVQpYohMiWagATpR SKHg== X-Gm-Message-State: AOAM530lhMqKIUln7EkAmxGG6AvQCMsxADaRRT7L38Wn0lSx3/mlyXhE DNl+9mmmYlzbFxLoio31hMh9Uw== X-Google-Smtp-Source: ABdhPJy2i251uJu/EMC4DLi9WRnxHlaT88/Fup2DjBtaR+0+svTyX1C9lcQd1dHZttx5/jijgXaJNg== 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 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B5A9CA0059 X-Stat-Signature: ca6knws4gfp3585ai66mju8kq7f7gbfb Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="FyNEAIm/"; spf=pass (imf15.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.52 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none X-HE-Tag: 1642705974-456068 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: [ 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)