Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1367394pxb; Fri, 1 Oct 2021 09:10:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGY12KUhuYayx5uewBg0IxMdulnIcnflWfYnkkBYgeV2g2ZBcaiIiAvRpF9C6G/JGaY8Oc X-Received: by 2002:a19:f20c:: with SMTP id q12mr6495362lfh.166.1633104603975; Fri, 01 Oct 2021 09:10:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633104603; cv=none; d=google.com; s=arc-20160816; b=c/F7VD5+cOOLGELARkiI0NQLdOOT3haR37LtJgwo/lKiHlm9eFqz911NPVI9QnU6DV tjGNNmbxS3i4zVn0Dyc18+x1HnObWy+hJ/pRK+lnXsI5278I9Bl+ptoq3v2sAvbvWLzc pjY5I8EpB8RKmtJauTFoXyJGLp/QoBO/N+E3Yb3d0stlV+l2J05kqRwWzVrspB9sVq8R qASV5vuEJ6n6OWnuCyqgwhY09/ZtjYg3kfvcuGQ6W4fINaNBYxxY4Ec8iav7ml6kZ2P1 2qFzoUthsI+iEh5Tc3tYqu3ybWsNKw/WPkLtjz+bOpaoWlOQMM0aT2vmr/2xBnTHtl2n XoRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=tZ9ME3sxYkrC923JcZz1Q2yxTEq9xs+zq/9V1ydvUwM=; b=INmwlR8NIEalBp+b/jyFKPMEeXcOpVOWqM9fEUvQhH9T4nybJnWFwMn2/HgSU+Kukq yAbVEuHCfjaiV2J3yJBXpYlMY+OOJ4VoIANcbb7rjcPgDzQSfdX9TSvBzmKTdoMVLcqG 7cTXmHkpdww2D50KUYeoVStshsTzp6ezwQCx06lzgIEJKWMLdFSyLBkvBa5tJ8hAz/18 jVWQ9MFO28YKo8wguvSF59oJ5ceMIUyxORMzAUfrwMrA3DF06NiLMlNYvYroOBADYDQU JinWZFPMsMtXVdOqJERALXrd/nr5876ZQ1URrKYqeSeRVr6I3W5rrwCXCl7x6Dp6d5V6 YrlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 9si6965134ejy.65.2021.10.01.09.09.37; Fri, 01 Oct 2021 09:10:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355075AbhJAPuY (ORCPT + 99 others); Fri, 1 Oct 2021 11:50:24 -0400 Received: from 8bytes.org ([81.169.241.247]:42912 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230162AbhJAPuM (ORCPT ); Fri, 1 Oct 2021 11:50:12 -0400 Received: from cap.home.8bytes.org (p4ff2b5b0.dip0.t-ipconnect.de [79.242.181.176]) (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 291291A4; Fri, 1 Oct 2021 17:48:26 +0200 (CEST) From: Joerg Roedel To: x86@kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , hpa@zytor.com, Dave Hansen , Andy Lutomirski , Peter Zijlstra , Joerg Roedel , Mike Rapoport , Andrew Morton , Brijesh Singh , linux-kernel@vger.kernel.org Subject: [PATCH v3 0/4] x86/mm: Fix some issues with using trampoline_pgd Date: Fri, 1 Oct 2021 17:48:13 +0200 Message-Id: <20211001154817.29225-1-joro@8bytes.org> X-Mailer: git-send-email 2.33.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 v2->v3: - Addressed review comments from Dave Hansen Link to v2: https://lore.kernel.org/lkml/20210929145501.4612-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/kernel/head64.c | 15 ++++++++++++++ arch/x86/kernel/head_64.S | 19 +++++++++++++++++- arch/x86/kernel/reboot.c | 12 ++--------- arch/x86/mm/init.c | 5 +++++ arch/x86/realmode/init.c | 35 ++++++++++++++++++++++++++++++++- 6 files changed, 75 insertions(+), 12 deletions(-) base-commit: 5816b3e6577eaa676ceb00a848f0fd65fe2adc29 -- 2.33.0