From patchwork Fri Oct 20 11:38:04 2023 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: 156076 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp995239vqb; Fri, 20 Oct 2023 04:48:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHckwyiJlpDcEvNEyf7H4PllepQ4CyhcFbtpIpXavxltb3QAH640K6yaNdqr5My/QnynZui X-Received: by 2002:a9d:6398:0:b0:6c6:42ca:ed52 with SMTP id w24-20020a9d6398000000b006c642caed52mr1469038otk.30.1697802498945; Fri, 20 Oct 2023 04:48:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697802498; cv=none; d=google.com; s=arc-20160816; b=WkvQoCQDsrHUEomebg4LETc1fB+5A9O3jx8uNSGjvFSUcE7d42g4WAEzR+CiauVJUa m8wuAuVv1TiI6nD16SQ1vuTPtDk+UbEtjMn1Kp7MG4peqxOyxQDn8CaKWSgzOF4a3hor FYDw2fD86sWnLuha6VyuDFYGYOgyifOjVOu+YzuZR4pBvl87oW7JH2jkBvsULB2r7pBA 5yhneBPSfcXd/KxvnNh70PBfzChnVbxeMM5xIF5Z+kbuBUc3y42SDil7iCxKDXgoRAJP TrBMRuO61NejSoyj9yZKTO2xEhoEjIGUIDtixzQqiQghc02KT1u9pBmjJpy7M/gGpETk ySzQ== 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:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=ogWOc8nXy0B5JyaUqFU72tNs/meYtmlK87PTwtl39Bw=; fh=LWlv3U+xZ3+vQt4tlJRIlKl5VzN7iFjjE/bzRmlxKDA=; b=tBWwt3T9sPuqCQ2DlgIMKE2VLVKJQ/GRbiR1y+x5SscXn9fDz8sSAJcQBv8Fjhq6TV TxZqdOmvH2l0jpZQC4NqtNuJW8dX7t26vt5SUAXCfeSlcv6DfcNjQaH49++8JsMfsVfk goD4EVthwgCsJ6DB8DxHlAal+6vl6omSfLFAHD0QNQXy9dw1MJH7NaKQxTiqKiawOn5g w8E552T02VoLLFD65VgzAvOlZLfocGnW2ISchhqKP0BJxhLtSI/aidWK7YWY/8aqCud4 WxmAe34K5kalnrA1+cf3kivPYEbflfuVBsGfpffl9x61s5rlw7SzVnL0cUo/ChqHy0/H uBew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WYVR0ZBI; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id z1-20020a633301000000b005ac154f0ff4si1669442pgz.119.2023.10.20.04.48.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 04:48:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WYVR0ZBI; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id A7EFE826E5AE; Fri, 20 Oct 2023 04:48:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377322AbjJTLsH (ORCPT + 25 others); Fri, 20 Oct 2023 07:48:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377319AbjJTLr6 (ORCPT ); Fri, 20 Oct 2023 07:47:58 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DB111BDA; Fri, 20 Oct 2023 04:39:00 -0700 (PDT) Date: Fri, 20 Oct 2023 11:38:04 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697801885; 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: in-reply-to:in-reply-to:references:references; bh=ogWOc8nXy0B5JyaUqFU72tNs/meYtmlK87PTwtl39Bw=; b=WYVR0ZBIjb+MabpddnPRH4Jrir+4YOdH9ff72XMudWT22btvX2hqJbsw0yRcQ+Pi8gKQ03 2YwbJAhnTgR8FrVkshwPjF63xLJwH5z+DlXQSpNfnbEkw1bQEbvB0PzQuTIU2hdOw1q8BM wCZwnjqGbq5Jnt0V+wR+49VFG/yLf+zoVxv00YKjkt2agyUF6fmEY2ghR1PACrGbup+Xrq xrnAjawvakHs5kXwHqw9+DqAsddrT26TD4SXjdY6/Nm3NOu1XaNcx5K9W8KcUsKvMxRibU QDVint3rp0Xyp/c489rKFXeVtnaATJyC+2wELwx/t9wgW1Q4iqLnGL8OKU9Xtw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697801885; 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: in-reply-to:in-reply-to:references:references; bh=ogWOc8nXy0B5JyaUqFU72tNs/meYtmlK87PTwtl39Bw=; b=88Rn4HLujFztxKig4LLnELHRApk4DxI65kTKPaZVzyCCFo9o0dRRarbXNov2mfAPQi4VMO iEDmESpYHxa5EVDQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/microcode] x86/boot/32: Restructure mk_early_pgtbl_32() Cc: Thomas Gleixner , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231017211722.175910753@linutronix.de> References: <20231017211722.175910753@linutronix.de> MIME-Version: 1.0 Message-ID: <169780188436.3135.10743660899507135319.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 20 Oct 2023 04:48:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780039369824225409 X-GMAIL-MSGID: 1780274952917486361 The following commit has been merged into the x86/microcode branch of tip: Commit-ID: 69ba866db281c768d5ecca909361ea4c4e71d57e Gitweb: https://git.kernel.org/tip/69ba866db281c768d5ecca909361ea4c4e71d57e Author: Thomas Gleixner AuthorDate: Tue, 17 Oct 2023 23:23:28 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Wed, 18 Oct 2023 18:28:41 +02:00 x86/boot/32: Restructure mk_early_pgtbl_32() Prepare it for adding a temporary initrd mapping by splitting out the actual map loop. No functional change. Signed-off-by: Thomas Gleixner Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20231017211722.175910753@linutronix.de --- arch/x86/kernel/head32.c | 42 +++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c index 2b65998..bdce632 100644 --- a/arch/x86/kernel/head32.c +++ b/arch/x86/kernel/head32.c @@ -79,35 +79,40 @@ typedef pgd_t pl2_t; #define SET_PL2(val) { .pgd = (val), } #endif -void __init __no_stack_protector mk_early_pgtbl_32(void) +static __init __no_stack_protector pte_t init_map(pte_t pte, pte_t **ptep, pl2_t **pl2p, + const unsigned long limit) { - /* Enough space to fit pagetables for the low memory linear map */ - const unsigned long limit = __pa_nodebug(_end) + - (PAGE_TABLE_SIZE(LOWMEM_PAGES) << PAGE_SHIFT); - pte_t pte, *ptep = (pte_t *)__pa_nodebug(__brk_base); - pl2_t *pl2p = (pl2_t *)__pa_nodebug(pl2_base); - unsigned long *ptr; - int i; - - pte.pte = PTE_IDENT_ATTR; - while ((pte.pte & PTE_PFN_MASK) < limit) { - pl2_t pl2 = SET_PL2((unsigned long)ptep | PDE_IDENT_ATTR); - - *pl2p = pl2; + pl2_t pl2 = SET_PL2((unsigned long)*ptep | PDE_IDENT_ATTR); + int i; + **pl2p = pl2; if (!IS_ENABLED(CONFIG_X86_PAE)) { /* Kernel PDE entry */ - *(pl2p + ((PAGE_OFFSET >> PGDIR_SHIFT))) = pl2; + *(*pl2p + ((PAGE_OFFSET >> PGDIR_SHIFT))) = pl2; } for (i = 0; i < PTRS_PER_PTE; i++) { - *ptep = pte; + **ptep = pte; pte.pte += PAGE_SIZE; - ptep++; + (*ptep)++; } - pl2p++; + (*pl2p)++; } + return pte; +} + +void __init __no_stack_protector mk_early_pgtbl_32(void) +{ + /* Enough space to fit pagetables for the low memory linear map */ + const unsigned long limit = __pa_nodebug(_end) + + (PAGE_TABLE_SIZE(LOWMEM_PAGES) << PAGE_SHIFT); + pte_t pte, *ptep = (pte_t *)__pa_nodebug(__brk_base); + pl2_t *pl2p = (pl2_t *)__pa_nodebug(pl2_base); + unsigned long *ptr; + + pte.pte = PTE_IDENT_ATTR; + pte = init_map(pte, &ptep, &pl2p, limit); ptr = (unsigned long *)__pa_nodebug(&max_pfn_mapped); /* Can't use pte_pfn() since it's a call with CONFIG_PARAVIRT */ @@ -116,4 +121,3 @@ void __init __no_stack_protector mk_early_pgtbl_32(void) ptr = (unsigned long *)__pa_nodebug(&_brk_end); *ptr = (unsigned long)ptep + PAGE_OFFSET; } -