From patchwork Fri Nov 18 17:52:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 22414 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp338535wrr; Fri, 18 Nov 2022 10:11:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf5GdetSgpK3fEorct/rRdmla46DEgBLQMDSgvSJZ4fqxvvBqiT42f2EuDXXTbxJ8iyd0vkl X-Received: by 2002:a62:2504:0:b0:563:1ef3:c920 with SMTP id l4-20020a622504000000b005631ef3c920mr8916699pfl.30.1668795095166; Fri, 18 Nov 2022 10:11:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668795095; cv=none; d=google.com; s=arc-20160816; b=IQyrO7rb4XDXLNxFPvmxaB4bKszVUsEeqfO9/RdaQgMkfjzsWGAyBMCrmq8BhcoPNH 1cBq37yhWPJJrgyoLR6/ayEf3to7HBGpe/8sgomqA0FhYOD8y0eTm7tk0punP1yx2wJ7 lBiOMDDYa3X6kjJ0zgfSQu1U5100bFm+QQEt7KW67Mg5Cmicu8uaczAXOMadM0Potw/R FUuhvErzm6HJYj+DNFZLq9P7q7RvIJTbkPsU+L0V4n1hiyzO/lpBcABRhxdXcyMsFfHb RMs+bCZqchf9BvIeRUIMWXaxIjhAaUtSaVOf74zos13FAQ0VbDiY9eyI2lfKsNfeQBH5 AtgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=C9icFdV4kUTLB8nW3Zigy8SnuVAjyYCTdXQgDFSosuE=; b=Uuu9xHJuOa3RphwDo7cWLm+8+Rba8qrEmSLga4YHGgAR5fJw/tfinYF/Nq5h3tphDN xpUeroU0RGGjGmQ3YV6zBOxOPF278h0SGCDYeOGcON+BCqCtN6NHwheDCuNUuSZL12wT s/LuKA2L9rBU5XWhnb61BeBZfpnPEutLJ2uvoLO7swLERYbEtymua4lyme4p5hwH8LqP xDzhxYlW17ARirhgfC6ObxkfZiP69VaA/WbKxthfsakHoxN2GmvAF8oBzZZN6G8YnMn2 N3QB7b7y5BQSBBzR7oExW+Rw++u2o/+RrU86Sgly5C/PeqCIuFy66j+tWikebdZxoy5Y j2Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=PnTT8HBz; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 6-20020a631546000000b0046fed3af6c9si4353121pgv.370.2022.11.18.10.11.07; Fri, 18 Nov 2022 10:11:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=PnTT8HBz; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241234AbiKRRwk (ORCPT + 99 others); Fri, 18 Nov 2022 12:52:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234447AbiKRRwj (ORCPT ); Fri, 18 Nov 2022 12:52:39 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D6ED3F07B; Fri, 18 Nov 2022 09:52:38 -0800 (PST) Date: Fri, 18 Nov 2022 17:52:33 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668793956; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C9icFdV4kUTLB8nW3Zigy8SnuVAjyYCTdXQgDFSosuE=; b=PnTT8HBztbtDO/HULmqo2sMXhWKudg+EAzgU6+rT8y4zeWMvndZ0ifCABAUyptlzrkF248 HxNF4Z+xfEnp2oy8IdKgbCC3XHG7siGFzGNoOGVY4MeLDPZgu076S2pKXL5ip5X+z+GoL+ UzWyCQWPYMqprkt88vYstx1mu71Venh35XW68eogPR06iRo87swN6rp2LdrlEkWpQs71qV nQYnjsZ1Iz4KhiNqHWOBGCsXQUpEaVNpWFmKM2hxDS2ggYbl2vQe4crDF6TVyh0XXiQBG4 ss5S8rh800CKWK9hwi+U0wJeugGipLwZxxyCjtuV03+sNxuggmOCQIyxEKem9w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668793956; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C9icFdV4kUTLB8nW3Zigy8SnuVAjyYCTdXQgDFSosuE=; b=FdYjwZwnAFRW1h/Ubj3nzbDUZEtdjsPGWErh++oqufh8pQuuwaxuI3REjqhyaZlSbLJwwZ z52rdd22A8W62QCQ== From: "tip-bot2 for Dave Hansen" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/mm] x86/mm: Ensure forced page table splitting Cc: Dave Hansen , Marco Elver , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <166879395396.4906.1394517398531168643.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749858485820639095?= X-GMAIL-MSGID: =?utf-8?q?1749858485820639095?= The following commit has been merged into the x86/mm branch of tip: Commit-ID: 71cfdf0c336fb20b0f2941ca9b8f6b23d8d6c86b Gitweb: https://git.kernel.org/tip/71cfdf0c336fb20b0f2941ca9b8f6b23d8d6c86b Author: Dave Hansen AuthorDate: Fri, 18 Nov 2022 07:16:16 -08:00 Committer: Dave Hansen CommitterDate: Fri, 18 Nov 2022 09:46:05 -08:00 x86/mm: Ensure forced page table splitting There are a few kernel users like kfence that require 4k pages to work correctly and do not support large mappings. They use set_memory_4k() to break down those large mappings. That, in turn relies on cpa_data->force_split option to indicate to set_memory code that it should split page tables regardless of whether the need to be. But, a recent change added an optimization which would return early if a set_memory request came in that did not change permissions. It did not consult ->force_split and would mistakenly optimize away the splitting that set_memory_4k() needs. This broke kfence. Skip the same-permission optimization when ->force_split is set. Fixes: 127960a05548 ("x86/mm: Inhibit _PAGE_NX changes from cpa_process_alias()") Signed-off-by: Dave Hansen Tested-by: Marco Elver Cc: Peter Zijlstra (Intel) Link: https://lore.kernel.org/all/CA+G9fYuFxZTxkeS35VTZMXwQvohu73W3xbZ5NtjebsVvH6hCuA@mail.gmail.com/ --- arch/x86/mm/pat/set_memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index 220361c..0db6951 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -1727,7 +1727,8 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int primary) /* * No changes, easy! */ - if (!(pgprot_val(cpa->mask_set) | pgprot_val(cpa->mask_clr))) + if (!(pgprot_val(cpa->mask_set) | pgprot_val(cpa->mask_clr)) && + !cpa->force_split) return ret; while (rempages) {