Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp117314lqj; Wed, 10 Apr 2024 06:01:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW1yOpO/h0aCHgVUc4/zc7qGceQjDfom/5r/L3t+wW0ppLTqIBvlcOlyNEKus3cx0KOJnsLWGy3YtKopml/75KpBxKRrW8+fvG6qCqDwA== X-Google-Smtp-Source: AGHT+IElqU8Uzvh8V0fn8FMzkg4iZaGJbWnLbn+/7B4qUbbJ3UrZ3lX8GTTGOts/7AQyFhLKMhT0 X-Received: by 2002:a05:6102:3910:b0:47a:22cd:f306 with SMTP id e16-20020a056102391000b0047a22cdf306mr2349121vsu.4.1712754089900; Wed, 10 Apr 2024 06:01:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712754089; cv=pass; d=google.com; s=arc-20160816; b=a2qa7P5aOjCAp1dAwtpTQlQYEDL7BSnNsVQZuRgSYtf/1ShgW2hs28bUuKM3moLa1M M74DoCn7pF/zCxU4aNLt9L97AiRY98MPvolx1UdeyCtTaYQZLrmSTn+CdBeby5ySDyUQ fIige9aYHdKkOTp3fLoUFSU35Zzwpfrb6WCUy/zyCfdEC6J9J9Uql+F4iWsMn6p2Hxqg pxwsEIFUSCWkJcnyNpDheyl3Ded5Aov+EQsqUzQOKXW0HTrGOb9r6Lmg5DR+3oYT0t1I pYulzE0Jg2tk/a2jGep5NHEqc5DllCvzuUB1W0P731Hm+g8NK00/SmDPDumwM6gQWQ1d F96Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:sender:dkim-signature; bh=ERc0Mc3295DMpduY6C379p9vkt2xRGs6pLrBozDiTnc=; fh=lHX6LPKwl+jXrOl7yiD3KEPdl+G0D8AFufsyV6x7hQk=; b=KEcCnGnKRFz+msf94Y27J0+OPuTLsdUJRhAVOHQ0RFU6kcLtsVjuhWBNsnrbUJCxNd vz6+KeRYlI1pN7cpOQXpUY1q28wF/3qF8ZcWndgeHCkcftuN6jbwbgAh0M1gFUlC/ycd TntyaT0vHxBFkUBMnb0RhIFPV+xeCuB3LPRPu4D9hvjCQRcgUjAjIQtRGjOu8BOC7RVw XCjTFZ1GbsTXJNeKVQ0BPPbzhvLtf5Ji9y/HvyCZzkYMWVDJRNyGuHD2tGPPeow+jjBi HBq0NECbDem067DDikz85utzZtAgIvBCkrLqPXcNhid8os5yTSa+psCX8Pi4q7KNLK/l uxcA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MiKRZFQA; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-138546-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138546-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e32-20020a0561020fa000b0047a0d3704dfsi810111vsv.284.2024.04.10.06.01.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 06:01:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138546-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MiKRZFQA; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-138546-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138546-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6A4671C26C30 for ; Wed, 10 Apr 2024 12:59:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6453615B150; Wed, 10 Apr 2024 12:58:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MiKRZFQA" Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C27EB156F23 for ; Wed, 10 Apr 2024 12:58:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712753886; cv=none; b=e8POVtQAJ3aYEv0UgeGGCp5aC6yo1FqrQhac41kFTTbyXq5A3VtmrLRBUanP2iUXH+GoQoI/LV/vhcQIWP2UqmvRRqQEKy4B2pwIYtY+Ns1MlO/z5N+XjQ5Tn0lkAb9kAjR5Xxpy5tQQu9HATwvCwaHJFHAdF2/kaOPbQks8ylg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712753886; c=relaxed/simple; bh=nJUi9rPZej+h44WRD6Xh/z4m8frw/jvIQlcyirl031g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fIEbf+ca0UIV7N4vK5QMYlMCVU5xD+C4D/84m08Y3K9npnyFwXvCHSiO20KfT8I2onK7pFr62tlwuLF0l69UioChkVcd1uNXyrz68Db7Em+AmibYJx66fJdTl4EtlQItDh3CFnPtyp6Z3gZgZQ382/od0bh8V4V5vsxOBInMlZg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MiKRZFQA; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a51c6e91793so613803566b.0 for ; Wed, 10 Apr 2024 05:58:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712753883; x=1713358683; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=ERc0Mc3295DMpduY6C379p9vkt2xRGs6pLrBozDiTnc=; b=MiKRZFQAfLCl2D9mmdJoMaWxpfVG1dfILPb3AaIfhZxHwVdbONiJN1wiuNnxtJJKH9 0y38ozzdxCkQpNR/Cp3/nBKUzLCMicTxJfZIptit+L3placcTAee/hTFCFd82fh0JCbp Yz73HFlO5M9DouUmmNre89bk638qSkX92dUH/aGcw9qyZcqSa+XiAvKoxoYtcrOeKVYd 9exJLDyqOJfhAW3VzA5S9xdU8P5vPlDy9czClTzrhUtSlBzkgNLqmmmcep5e+5CuBAd/ SKNd2/dwYj0QUELXqYV7XUy8kkKB1NqTCQwlNe7t+W8Yzn/ANkFdKZdIQrX/jASltMrJ lFNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712753883; x=1713358683; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ERc0Mc3295DMpduY6C379p9vkt2xRGs6pLrBozDiTnc=; b=IRGbuJ/+GlHDoOc8bEeNItw4jRzvUra+9fEcFlirYGsC84xT5mdG9DnCzV/CM53FeE M5ESYnAkha5PcI+Js17A/f/CCXrFsZVhXaIOA0li59UlaKHihHpLzCOZxizRSZVNNEWJ OTbVAye0AAe65VyW0dZ/VNQap5I2MKyENKWgEyPi8O5m0+LXbBIcr9U7neXyPTnnGoXy oLA6GZj06mXUzPjHZZ/gb3TCKcEINClmmL5swKMIGQ1rtvIGwn2w4Owz8i4hUcC2+Kwo J8Lq/V6+rDC55vnfXZf9x4kzX+/dbTCppl73L//iowyI4Oy1KPN0ZrS5wddGw62Di18G JXlA== X-Gm-Message-State: AOJu0YzkdUsTKf60gZ+dl1NbZUcniPkd4uDyFFskHWEqJsOTPGkxNoa/ DwntrBmleRbPsUCOFMpuIX11+25beEuSszrKJZIEaqpFLDFGOd1ncKZwteqaUxtWGw== X-Received: by 2002:a17:907:86a7:b0:a52:176c:15f with SMTP id qa39-20020a17090786a700b00a52176c015fmr223791ejc.15.1712753882634; Wed, 10 Apr 2024 05:58:02 -0700 (PDT) Received: from gmail.com (1F2EF1A5.nat.pool.telekom.hu. [31.46.241.165]) by smtp.gmail.com with ESMTPSA id q18-20020aa7d452000000b0056e247de8e3sm6418852edr.1.2024.04.10.05.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 05:58:02 -0700 (PDT) Sender: Ingo Molnar Date: Wed, 10 Apr 2024 14:58:00 +0200 From: Ingo Molnar To: Ard Biesheuvel Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Ard Biesheuvel , Conrad Grobler , Kevin Loughlin Subject: Re: [PATCH] x86/boot/64: Clear CR4.PGE to disable global 1:1 mappings Message-ID: References: <20240410102520.348017-2-ardb+git@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240410102520.348017-2-ardb+git@google.com> * Ard Biesheuvel wrote: > From: Ard Biesheuvel > > The early 64-bit boot code must be entered with a 1:1 mapping of the > bootable image, but it cannot operate without a 1:1 mapping of all the > assets in memory that it accesses, and therefore, it creates such > mappings for all known assets upfront, and additional ones on demand > when a page fault happens on a memory address. > > These mappings are created with the global bit G set, as the flags used > to create page table descriptors are based on __PAGE_KERNEL_LARGE_EXEC > defined by the core kernel, even though the context where these mappings > are used is very different. > > This means that the TLB maintenance carried out by the decompressor is > not sufficient if it is entered with CR4.PGE enabled, which has been > observed to happen with the stage0 bootloader of project Oak. While this > is a dubious practice if no global mappings are being used to begin > with, the decompressor is clearly at fault here for creating global > mappings and not performing the appropriate TLB maintenance. > > Since commit > > f97b67a773cd84b ("x86/decompressor: Only call the trampoline when changing paging levels") > > CR4 is no longer modified by the decompressor if no change in the number > of paging levels is needed. Before that, CR4 would always be set to a > known value with PGE cleared. So if we do this for robustness & historical pre-f97b67a773cd84b quirk-reliance's sake, I'd prefer if we loaded a known CR4 value again, instead of just turning off the PGE bit. It's probably also a tiny bit faster, as no CR4 read has to be performed. Thanks, Ingo