From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88A94C433F5 for ; Thu, 2 Dec 2021 15:33:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347852AbhLBPhQ (ORCPT ); Thu, 2 Dec 2021 10:37:16 -0500 Received: from 8bytes.org ([81.169.241.247]:37256 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242153AbhLBPhO (ORCPT ); Thu, 2 Dec 2021 10:37:14 -0500 Received: from cap.home.8bytes.org (p5b006edb.dip0.t-ipconnect.de [91.0.110.219]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by theia.8bytes.org (Postfix) with ESMTPSA id BC09CBBE; Thu, 2 Dec 2021 16:33:49 +0100 (CET) From: Joerg Roedel To: x86@kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , hpa@zytor.com, Dave Hansen , Andy Lutomirski , Peter Zijlstra , Mike Rapoport , Andrew Morton , Brijesh Singh , linux-kernel@vger.kernel.org, Joerg Roedel , Joerg Roedel Subject: [PATCH v4 0/4] x86/mm: Fix some issues with using trampoline_pgd Date: Thu, 2 Dec 2021 16:32:22 +0100 Message-Id: <20211202153226.22946-1-joro@8bytes.org> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Hi here are a couple of fixes and documentation improvements for the use of the trampoline_pgd in the kernel. Most importantly it fixes the issue that switching to the trampoline_pgd will unmap the kernel stack and real_mode_header, making crashes likely before the code can actually jump to real mode. The first patch adds a comment to document that the trampoline_pgd aliases kernel page-tables in the user address range, establishing global TLB entries for these addresses. The next two patches add global TLB flushes when switching to and from the trampoline_pgd. The last patch extends the trampoline_pgd to cover the whole kernel address range. This is needed to make sure the stack and the real_mode_header are still mapped after the switch and that the code flow can safely reach real-mode. Please review. Thanks, Joerg Changes v3->v4: - Rebased to latest tip/master - Addressed Boris' review comments Link to v3: https://lore.kernel.org/all/20211001154817.29225-1-joro@8bytes.org/ Joerg Roedel (4): x86/realmode: Add comment for Global bit usage in trampline_pgd x86/mm/64: Flush global TLB on boot and AP bringup x86/mm: Flush global TLB when switching to trampoline page-table x86/64/mm: Map all kernel memory into trampoline_pgd arch/x86/include/asm/realmode.h | 1 + arch/x86/include/asm/tlbflush.h | 5 +++++ arch/x86/kernel/head64.c | 2 ++ arch/x86/kernel/head_64.S | 19 ++++++++++++++++- arch/x86/kernel/reboot.c | 12 ++--------- arch/x86/mm/init.c | 5 +++++ arch/x86/mm/tlb.c | 8 ++----- arch/x86/realmode/init.c | 38 ++++++++++++++++++++++++++++++++- 8 files changed, 72 insertions(+), 18 deletions(-) base-commit: b6c28e3cc445bf451a516ac075ec27b4619e4f5f -- 2.34.0