From patchwork Tue Nov 15 22:26:28 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: 20619 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2973408wru; Tue, 15 Nov 2022 14:33:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf47Ya3eeZYA4R0ASlhoxQc+z3xXdzcG/Udk53wlkb/BpM/xfWyzQKRV9LEj3R6GMYzruy12 X-Received: by 2002:a05:6402:457:b0:462:750b:bced with SMTP id p23-20020a056402045700b00462750bbcedmr16239595edw.313.1668551637172; Tue, 15 Nov 2022 14:33:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668551637; cv=none; d=google.com; s=arc-20160816; b=0n6+R/lW3n0kL0jNPiMjVKziqTxDe2KmZNFXvf8Ohro9Shwp2PNTuBtWrORx58Dsx4 dPnXrX62gYJihuGW35FhC9dVhP0jPQ+Gs5pMXNrlqXhpgFh7x/VOT1IwkUYEC6QSnEGn i3/s8JFd5aG1U39U1Co+u7gnXVxvvFuCTkY2HOm7xqTyxCzXy55/X2O3Hw1phaNVo13v g7oHZaIbQcHyDRRjM1Vb55uUXu7fgzXofVHtBtSY1V1ao6jhx8XTo40r34tWZldYW7hP JnWCVNzHIjn4FEkfm9IDVfFSL7JPf+kNREaaQEOE/eaz+eDA/9yhF7u32NpjRdcvQ7Z8 D7+w== 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=DcgxX3STYUwWxly17519IsLnQkOgRIvO2ojp6HNvEfw=; b=oHpIE0pX9fkxH0IPAuaRGxDMHo8FAPZwRtWW0b1qO5niRwhu4Rkb54woygvI6qfz3g 9YXCKs13G9rR8R0uv42tueB2LOkR/7bxWi8A8lG9iUDN3CPqV3O5gdHtN1empC5Lkmez Tx2oxsTmmOlBXoHBXqn2TcaU6QjYNlPbAlIizMmKitTg1bFsvmjlfjq9jqOPffnRxhFO KvPr24T+F8YMQ54i6DcycK0M5qz9a+wf9XhgO4sJx7dtohlHDpCBwZL/uS+QIahkqIel yV24/FAVtSdfKcMLSENLMkC2kIcTyLTZ1xOABh4pXSAkLDXCPNwY+5/PBtTUD+7Gip23 XFaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="too/gPjN"; dkim=neutral (no key) header.i=@linutronix.de header.b=Fqab7t02; 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 nc11-20020a1709071c0b00b0079330b37fb6si12824918ejc.880.2022.11.15.14.33.33; Tue, 15 Nov 2022 14:33:57 -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="too/gPjN"; dkim=neutral (no key) header.i=@linutronix.de header.b=Fqab7t02; 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 S238632AbiKOW10 (ORCPT + 99 others); Tue, 15 Nov 2022 17:27:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232243AbiKOW0n (ORCPT ); Tue, 15 Nov 2022 17:26:43 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 679CC317E9; Tue, 15 Nov 2022 14:26:31 -0800 (PST) Date: Tue, 15 Nov 2022 22:26:28 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668551190; 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=DcgxX3STYUwWxly17519IsLnQkOgRIvO2ojp6HNvEfw=; b=too/gPjNiWybU6NEC1yzFTl0gOJ43FP8ouUP9Mn7q0Q9GgcI/YvpIko6uU0ozY5/YD4hih qnWxFmQ+ts8iuyxFCDiBFdlOAeZNp+cVYeoHk+ibCny41azLOId0OifcTZuiD9j/WLUIjX nd1w5M3DKbY+SiO1PIbVcL3y5vi61N4omReIjGVwJAAr4Do1ysEAgGGWzy1SasZgWoP79I 31owgd7ZmylktaZ/1+mC3i5bHl6jQplJ+WyH7ZDh9x/pPBiWJh14LFjdj8DQQ533nwBLxy t0R4ZKZZCWXmvPoL5W8vM/v81YJay5UpWTOkSBEDXSfFRH+fGYwublkpWg8zfw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668551190; 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=DcgxX3STYUwWxly17519IsLnQkOgRIvO2ojp6HNvEfw=; b=Fqab7t02am5IQ3gq5oz0CA/BvyUfWdGUvBBTQZjs1LbPa+CcFs0JJPBLFgDHFNFrL8H94j ckqXeMhKFRBkFxCQ== 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: <166855118885.4906.15832099809755736940.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?1749603201842853135?= X-GMAIL-MSGID: =?utf-8?q?1749603201842853135?= The following commit has been merged into the x86/mm branch of tip: Commit-ID: 558e2dc0fb7145e7b244dcdd2e287bd9c86d66f3 Gitweb: https://git.kernel.org/tip/558e2dc0fb7145e7b244dcdd2e287bd9c86d66f3 Author: Peter Zijlstra AuthorDate: Thu, 10 Nov 2022 13:33:50 +01:00 Committer: Peter Zijlstra CommitterDate: Tue, 15 Nov 2022 22:29:57 +01: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;