From patchwork Sun Apr 3 23:51:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 12799772 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 6C149C433EF for ; Sun, 3 Apr 2022 23:52:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A7AD36B0072; Sun, 3 Apr 2022 19:52:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A29906B0073; Sun, 3 Apr 2022 19:52:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CABC6B0074; Sun, 3 Apr 2022 19:52:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 777AC6B0072 for ; Sun, 3 Apr 2022 19:52:28 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 40580241AF for ; Sun, 3 Apr 2022 23:52:18 +0000 (UTC) X-FDA: 79317219156.13.881B0B8 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf30.hostedemail.com (Postfix) with ESMTP id B8D3A8001A for ; Sun, 3 Apr 2022 23:52:17 +0000 (UTC) Received: by mail-pf1-f179.google.com with SMTP id w7so7377019pfu.11 for ; Sun, 03 Apr 2022 16:52:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jnxVFLHekOunLtWoWlKj8zJBbrok1zNY71HOhIA5VLo=; b=h1wuTbzfBbOsaQ8zE5QA8LCpBtZ1Hce3UXsIXzo1B/3iG/5mu/rQF1Ik3zyIbg9MiG 6K01wodbxSsbULqeK0a+idZPqasVp5/mTTU8jzeghj7zCpFv8912e+2bkwQP4xjfJajO Fbxtujqq3nMtIbwPf5p7g9/h8zlMz11LmyKuUt1BGZJWQSf2DwxX+/NchFm2ZEp80LQU gtNt+4i5Dp2mDmB/LUGUwXxPeJqObJfXT5i77TbHjvUseu5XHRRV5C8d95nQVGYeO5M3 gVBNGEjvMqOMNl9Dqxp7UDCEQtJw44sOhwNJ0DBLt9jwj+Hz3qyB4havcHY5bMin7u27 KBaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jnxVFLHekOunLtWoWlKj8zJBbrok1zNY71HOhIA5VLo=; b=MZWoXDTP4+fXVoKRk9HkAjDagAzECXaEwt1ch+D8XB6LaDtBPY7VCFgMnKZ7aCHq7X LYIzT+qxSOzyuO+6viIZZBZJiPEkFfiACkaqju+v8Ob364aHdugGHoFvgpEhFS9izujQ YbiFP2gJZIPjXNOhqpU0hN0GICkNiHLXqJBDU74U90xSai3NY77Fc+1WM/5CLzJautLO /SGYoNHjZXpq0o1hA7tzZ2aDqKdVHKEnaqMY8h5A4vxLNC+Vlxa4Vz32dcM4obg1GQJf kb/qswNw6LsAFtzg4A6qeZRRlk0SW4gbUH/CUeeBBeDcsYjoM5qEo+xVE7pnEKZ6SnGj keMg== X-Gm-Message-State: AOAM5301if5Yk/7wFH6b+dvaEOD211UifE17VUR5b0jv1vGsiittNkw5 0m6rcsU0uV7CovsMew4dk/8= X-Google-Smtp-Source: ABdhPJx0X1oiRABWDciIM9Dn/oUkVnyHhiYKy0/X8Aw3CetecnyuaBA+wneyVoZkDN9jqQvT9ahY0A== X-Received: by 2002:a05:6a00:1581:b0:4fa:e6d4:c3e6 with SMTP id u1-20020a056a00158100b004fae6d4c3e6mr21063889pfk.84.1649029936590; Sun, 03 Apr 2022 16:52:16 -0700 (PDT) Received: from octofox.hsd1.ca.comcast.net ([2601:641:401:1d20:98f7:b9d3:817b:7621]) by smtp.gmail.com with ESMTPSA id u17-20020a056a00159100b004faef351ebcsm9789697pfk.45.2022.04.03.16.52.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 16:52:15 -0700 (PDT) From: Max Filippov To: Thomas Gleixner Cc: "Peter Zijlstra (Intel)" , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Max Filippov Subject: [PATCH] highmem: fix checks in __kmap_local_sched_{in,out} Date: Sun, 3 Apr 2022 16:51:59 -0700 Message-Id: <20220403235159.3498065-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B8D3A8001A X-Stat-Signature: 9z91d4in7f8bbhmretq4fwceddqhttrn Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=h1wuTbzf; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf30.hostedemail.com: domain of jcmvbkbc@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=jcmvbkbc@gmail.com X-Rspam-User: X-HE-Tag: 1649029937-158329 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: When CONFIG_DEBUG_KMAP_LOCAL is enabled __kmap_local_sched_{in,out} check that even slots in the tsk->kmap_ctrl.pteval are unmapped. The slots are initialized with 0 value, but the check is done with pte_none. 0 pte however does not necessarily mean that pte_none will return true. e.g. on xtensa it returns false, resulting in the following runtime warnings: WARNING: CPU: 0 PID: 101 at mm/highmem.c:627 __kmap_local_sched_out+0x51/0x108 CPU: 0 PID: 101 Comm: touch Not tainted 5.17.0-rc7-00010-gd3a1cdde80d2-dirty #13 Call Trace: dump_stack+0xc/0x40 __warn+0x8f/0x174 warn_slowpath_fmt+0x48/0xac __kmap_local_sched_out+0x51/0x108 __schedule+0x71a/0x9c4 preempt_schedule_irq+0xa0/0xe0 common_exception_return+0x5c/0x93 do_wp_page+0x30e/0x330 handle_mm_fault+0xa70/0xc3c do_page_fault+0x1d8/0x3c4 common_exception+0x7f/0x7f WARNING: CPU: 0 PID: 101 at mm/highmem.c:664 __kmap_local_sched_in+0x50/0xe0 CPU: 0 PID: 101 Comm: touch Tainted: G W 5.17.0-rc7-00010-gd3a1cdde80d2-dirty #13 Call Trace: dump_stack+0xc/0x40 __warn+0x8f/0x174 warn_slowpath_fmt+0x48/0xac __kmap_local_sched_in+0x50/0xe0 finish_task_switch$isra$0+0x1ce/0x2f8 __schedule+0x86e/0x9c4 preempt_schedule_irq+0xa0/0xe0 common_exception_return+0x5c/0x93 do_wp_page+0x30e/0x330 handle_mm_fault+0xa70/0xc3c do_page_fault+0x1d8/0x3c4 common_exception+0x7f/0x7f Fix it by replacing !pte_none(pteval) with pte_val(pteval) != 0. Fixes: 5fbda3ecd14a ("sched: highmem: Store local kmaps in task struct") Signed-off-by: Max Filippov Reviewed-by: Thomas Gleixner --- mm/highmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/highmem.c b/mm/highmem.c index 762679050c9a..916b66e0776c 100644 --- a/mm/highmem.c +++ b/mm/highmem.c @@ -624,7 +624,7 @@ void __kmap_local_sched_out(void) /* With debug all even slots are unmapped and act as guard */ if (IS_ENABLED(CONFIG_DEBUG_KMAP_LOCAL) && !(i & 0x01)) { - WARN_ON_ONCE(!pte_none(pteval)); + WARN_ON_ONCE(pte_val(pteval) != 0); continue; } if (WARN_ON_ONCE(pte_none(pteval))) @@ -661,7 +661,7 @@ void __kmap_local_sched_in(void) /* With debug all even slots are unmapped and act as guard */ if (IS_ENABLED(CONFIG_DEBUG_KMAP_LOCAL) && !(i & 0x01)) { - WARN_ON_ONCE(!pte_none(pteval)); + WARN_ON_ONCE(pte_val(pteval) != 0); continue; } if (WARN_ON_ONCE(pte_none(pteval)))