Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp188394lqg; Fri, 1 Mar 2024 02:03:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVpH+0gEyMGH40kLC7loRhtAgRPWjLrN9wupW0V5akooBxZCfdruA1+XwpCkXxrfddR5q9PMlY57qiTwlv0WnqNT7+d29Gim/4cG2+y/w== X-Google-Smtp-Source: AGHT+IHh9z2GP+HGRz7k1pUhlDxKzVccG/e+TWhHA1f/dsHSUThDdFt0NusPM8TBbKD9X/kGqQc4 X-Received: by 2002:a05:6a00:13a1:b0:6e4:59b3:928c with SMTP id t33-20020a056a0013a100b006e459b3928cmr1317359pfg.10.1709287395134; Fri, 01 Mar 2024 02:03:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709287395; cv=pass; d=google.com; s=arc-20160816; b=UhI1DUd7nNqbvnpdgQ2eB3qlYWoeMQZMtOn1OJTHo8bg6cZ1hk0gTBC5PtEc2ITdi8 K30b12rUFW31a3cQv5U8l2ATxZEpX2nLWv85VhjvKODjtggc+hO/gBPW/aZLc5FEDIsD IGSk58eIJucfpz45rAxc/cF/sImGAYi48zKW/6FibKD3+3BxKSTWMx+P4XFlcVY2u/DJ B8qcKBbogCjNe6QbPToj2yutzMoWi9MmKmMZy61nHo4+sQ92JqbudPxwxNCA1aE9FVaa T7bBiG0S1PtAH9dE/vjNc/S8NFSudQfsOZuA1xt+938AvHg5tqZeeOzeZPkzEtmy1/9y 3/Xg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=dV4BW7Smt3KcskaTcKXTc5G/G0vUyBKb5Uai7JKbt3s=; fh=dP/4fPSm3AoiQh8mSmPVvq2kUHOHlQIUiLgjPXb/9jU=; b=iuEeGz7rRa+qr/yYzXuEuymAvO4S3pEjZzYJ6/AFBId4zKEQoE52OdIqdCceoHn5cR MkIYv6e1ZZMAAY+yjA1qCHSP1mjPUdGe5HAWEtq4W7KbI53pjgsXNWg/ghBMXdLacojx VGOguBUXNv5Gt/26ZJxhGa/5xAHG0xlPVV90hHwIK8uHWrlkqQJZpF9XrDI4BHW61tN7 rjdrj/n8q42UxKN6+pkh6SwM9T+lhaA4enSK+MJUGCyl9omy6wHmWeDvQyt7LxJTUrer UcoEKyQGyWqpiA7tCjhMT+r59J2zYqf/vYSu/1fewcN/GIVjUBpV20oi1I0i1m0rfeC/ M0Ug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NFKxcvA2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-88214-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88214-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c26-20020a634e1a000000b005d8c5595ddbsi3192704pgb.271.2024.03.01.02.03.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:03:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88214-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NFKxcvA2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-88214-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88214-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E43082884E3 for ; Fri, 1 Mar 2024 10:01:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 772F16A8CE; Fri, 1 Mar 2024 10:01:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NFKxcvA2" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A17F01E4BD for ; Fri, 1 Mar 2024 10:01:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709287307; cv=none; b=s+R1bGwIr/MeSl4icWnfaEFG4FfnryNhQtrOW03PcnxVPoBCUwbovkJ/n1g5Fkha0sfNTUNFlYYBjP6PH8ZzMdH8jhikguaQzEHlIaCzSghc42/EzmY55NpQDq1vz3YjHMwCd01GOxjavhAcU/5YqZastc4StFAKKIyX+LMdIPE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709287307; c=relaxed/simple; bh=4fXJidtJ1viRWoLejQDAlo2yu6HUvAkBioeflUHtadY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Zb26HLQ1+3DrmIMDAw1VW7pwCPVWHerMQhpOmxPUQwP5cL5e+oL1cslLrBAdNlolnsfORTx0pC0/h4BtdPMK+bZvehMotauFMxiiOMq8UZu6RPX27NedlmnOmSnAobbcj38wjfXxsGkl9EG+6lPajdzOCn4w/gNnsob3vW7x7bc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NFKxcvA2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23575C433F1 for ; Fri, 1 Mar 2024 10:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709287307; bh=4fXJidtJ1viRWoLejQDAlo2yu6HUvAkBioeflUHtadY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=NFKxcvA2kUGAKEa9DifNiPR6f+oqD2LxH+75c+UHCD23crQ2KwA/kXLyP7qukrxDO uxap0Wbxrbf/CHqc1E9g35WmxflGc0ofE/3OBtYMVIQyJarqovYvYFSz1HiP/HAlFJ sxQPVAt6B+PoPWQr+U9PhkKn1blUrDXJHry9BnIo48J53/d10LHXZKGtAE2EpX0JxQ PCz/4pgelp0IPgedMe5XHqLOsQAtwXvQ/iXEQLqFHQK/RnSuZiUDk2brIvMFCYEggb uTv7Yc2Fl9FlaJ9uULXSQPBJbj0zeItmpvdoWaWFJZJue9v5qot6k3QTAyBRqHoFCp YEqTmeomoHUcg== Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2d208be133bso22014191fa.2 for ; Fri, 01 Mar 2024 02:01:47 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXQJIq8UrNABXgKostvrnDXvoDS0Drt8rwdqCMVkRhGErbWVGwtqMKgaQ1+JABq4irJXWmJzTOEc96y68mj4vLHfmLGgxYGAet/sxhh X-Gm-Message-State: AOJu0YxD0vmPxUkd4eIgzm6QxzLX71u4GaQXWqayHH9Ppj5ZUtSsVYdo 3CKBDU51EN5KSEWowkVVce/hMZpgWtrj/oCxJeLQL9DU7mXni83/BBDn5hbwGCpwrQJ1M/w790p BusvDqpzOrU4LnClbSfYTe3Pnzhc= X-Received: by 2002:a2e:a365:0:b0:2d2:39b2:90e2 with SMTP id i5-20020a2ea365000000b002d239b290e2mr800907ljn.14.1709287305357; Fri, 01 Mar 2024 02:01:45 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240227151907.387873-11-ardb+git@google.com> <20240227151907.387873-13-ardb+git@google.com> <20240228205540.GIZd-dzFYIBbtfIAo3@fat_crate.local> In-Reply-To: <20240228205540.GIZd-dzFYIBbtfIAo3@fat_crate.local> From: Ard Biesheuvel Date: Fri, 1 Mar 2024 11:01:33 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 2/9] x86/startup_64: Defer assignment of 5-level paging global variables To: Borislav Petkov Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Kevin Loughlin , Tom Lendacky , Dionna Glaze , Thomas Gleixner , Ingo Molnar , Dave Hansen , Andy Lutomirski , Brian Gerst Content-Type: text/plain; charset="UTF-8" On Wed, 28 Feb 2024 at 21:56, Borislav Petkov wrote: > > On Tue, Feb 27, 2024 at 04:19:10PM +0100, Ard Biesheuvel wrote: > > From: Ard Biesheuvel > > > > Assigning the 5-level paging related global variables from the earliest > > C code using explicit references that use the 1:1 translation of memory > > is unnecessary, as the startup code itself does not rely on them to > > create the initial page tables, and this is all it should be doing. So > > defer these assignments to the primary C entry code that executes via > > the ordinary kernel virtual mapping. > > > > Signed-off-by: Ard Biesheuvel > > --- > > arch/x86/include/asm/pgtable_64_types.h | 2 +- > > arch/x86/kernel/head64.c | 44 +++++++------------- > > 2 files changed, 15 insertions(+), 31 deletions(-) > > Reviewed-by: Borislav Petkov (AMD) > > Those should probably be tested on a 5level machine, just in case. > I have tested this myself on QEMU with -cpu qemu64,+la57 and -cpu host+kvm using - EFI boot (OVMF) - legacy BIOS boot (SeaBIOS) - with and without no5lvl on the command line - with and without CONFIG_X86_5LEVEL The scenario that I have not managed to test is entering from EFI with 5 levels of paging enabled, and switching back to 4 levels (which should work regardless of CONFIG_X86_5LEVEL). However, no firmware in existence actually supports that today, and I am pretty sure that this code has never been tested under those conditions to begin with. (OVMF patches are under review atm to allow 5-level paging to be enabled in the firmware) I currently don't have access to real hardware with LA57 support so any additional coverage there is highly appreciated (same for the last patch in this series)