From patchwork Sat Dec 17 18:55:31 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: 34232 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1636095wrn; Sat, 17 Dec 2022 10:57:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf6RcPCZOxtDmmLYawScfakrv0muq8PRdY4op5MOC4a0lKeznT7Hbh22HG0O4Tw2Ss7jexJZ X-Received: by 2002:a17:906:d8c9:b0:7ae:8144:690 with SMTP id re9-20020a170906d8c900b007ae81440690mr19072469ejb.32.1671303450652; Sat, 17 Dec 2022 10:57:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671303450; cv=none; d=google.com; s=arc-20160816; b=CGSYOXP8N5YAhLgifaiDk/w3RCOKaSHjCZh2D0riW1VhKD6jx6SV7/haiq/ipMgBhq HQ2tV/9BOKDGUhua+yfGuMcdzaoJfXiG0EVUWdlA9E7CiXa7UNtiJx2XDti92dBFJ+f6 RCeLcPhrKWaFZUGRmyro2tvDVRilat1MIVhY0ce44easUAo03c/4plMxRnOJBL1EXOqE sQIilM8D0nAKkFMiCmKQmlKvHwYpWyr4hgJH917HOzpLez4T8z6bIPilPHA3e8m8QxAa +MZr5VseXXJ1DsE6KykIJCq64mym2qo3vlH28R9ocwfQcf8rPepHyf4Ix0XiZ5tnik6s voQA== 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=E53RHJcelb4AnLKZMjCK+9UEbOGOVcHWJYrXV9uNWa0=; b=PjaeW3213x8JGMzV8kkZduTxTl6p3dwqvPW/cnYaM5yOwx3JlmuH+wSdGJ6SNSW4eW pM0O8Ok1px398ObBtJRHmwylicwJHJNClaJhWad4kFWCGJVErfHuV+i+u8bFRZO/dz0f qBdg8phIIWNe6blrZkoiqCg7BcjoOEKA7lzfcI/OQTzarWVm6jLbcRM4kLDT5UDhrdWJ A69Cfq8cP2U2hvMnNRdU7cXmKuG31jn17b/HC9i5ztRXmH2GQPp/HwQ2xWfvsYZqnqzX XwoXmBUcYXNOHHLEHlUlUUhoXI/xaH7QnIMunbhXD2HkhwW8Ij9oI7/G8Pg+B+vauRHz KaSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yH+mnT4R; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=8RbTgiRH; 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 x11-20020a05640226cb00b00458a650f3fasi5736333edd.409.2022.12.17.10.57.06; Sat, 17 Dec 2022 10:57:30 -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=yH+mnT4R; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=8RbTgiRH; 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 S230251AbiLQS4Z (ORCPT + 99 others); Sat, 17 Dec 2022 13:56:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230006AbiLQSzg (ORCPT ); Sat, 17 Dec 2022 13:55:36 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9118210FC2; Sat, 17 Dec 2022 10:55:35 -0800 (PST) Date: Sat, 17 Dec 2022 18:55:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1671303331; 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=E53RHJcelb4AnLKZMjCK+9UEbOGOVcHWJYrXV9uNWa0=; b=yH+mnT4RYIgcvr902on/EAwQspQAB5i6UAX0p0QRQ+Eifa6FjFz3XtjZRt+U8rxfzkwhOF 5x9bdvSpSWK4NYnMDmZ0kDOw773hTjApeeL4R5MATNDFbaH2iH2YzqJREZIUdv/zsfo8Vj Jvw0A3n+lqRdnuHds7gH9eelXd92/91WppoG+cZHR5+cMXPNN4h8ZBqOh6D7saLopi/CRk lUMfwdQLlwONMI8riylxzoc5+tT2fkhz7DBg8OHukXa5IOOprSZEIeSl2TjbLVqoCOacPc ez1HgJnDdBgww88h7eOxOnARoEOm4PvemSWhfucoyg1wc8/1gM/Yb3b/xR2D+w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1671303331; 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=E53RHJcelb4AnLKZMjCK+9UEbOGOVcHWJYrXV9uNWa0=; b=8RbTgiRHZ2lW+CfrexmWMarLVi2YezGcVHdpFuu1UYXX1nMmBEoD3W0NB1/8C75H2mF5fR hVviw8XRIdH8f3AQ== From: "tip-bot2 for Peter Zijlstra" 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: Add a few comments Cc: "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <167130333104.4906.15196955293503615286.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?1752488687058430330?= X-GMAIL-MSGID: =?utf-8?q?1752488687058430330?= The following commit has been merged into the x86/mm branch of tip: Commit-ID: 5ceeee7571b7628f439ae0444ec41d132558f47e Gitweb: https://git.kernel.org/tip/5ceeee7571b7628f439ae0444ec41d132558f47e Author: Peter Zijlstra AuthorDate: Thu, 10 Nov 2022 13:33:50 +01:00 Committer: Dave Hansen CommitterDate: Thu, 15 Dec 2022 10:37:28 -08:00 x86/mm: Add a few comments It's a shame to hide useful comments in Changelogs, add some to the code. Shamelessly stolen from commit: c40a56a7818c ("x86/mm/init: Remove freed kernel image areas from alias mapping") Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20221110125544.460677011%40infradead.org --- arch/x86/mm/pat/set_memory.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index 06eb891..50f81ea 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -219,6 +219,23 @@ within_inclusive(unsigned long addr, unsigned long start, unsigned long end) #ifdef CONFIG_X86_64 +/* + * The kernel image is mapped into two places in the virtual address space + * (addresses without KASLR, of course): + * + * 1. The kernel direct map (0xffff880000000000) + * 2. The "high kernel map" (0xffffffff81000000) + * + * We actually execute out of #2. If we get the address of a kernel symbol, it + * points to #2, but almost all physical-to-virtual translations point to #1. + * + * This is so that we can have both a directmap of all physical memory *and* + * take full advantage of the the limited (s32) immediate addressing range (2G) + * of x86_64. + * + * See Documentation/x86/x86_64/mm.rst for more detail. + */ + static inline unsigned long highmap_start_pfn(void) { return __pa_symbol(_text) >> PAGE_SHIFT; @@ -1626,6 +1643,9 @@ repeat: static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias); +/* + * Check the directmap and "high kernel map" 'aliases'. + */ static int cpa_process_alias(struct cpa_data *cpa) { struct cpa_data alias_cpa;