Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4690337pxu; Tue, 13 Oct 2020 05:02:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOVaUXnuPEJGo7x6mpUaNSuPNt0kfL+S+2yiUiAGwHyBba1gIgzpt8qd5rP240xUmGR5RJ X-Received: by 2002:a17:907:4301:: with SMTP id nh1mr31063429ejb.397.1602590576339; Tue, 13 Oct 2020 05:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602590576; cv=none; d=google.com; s=arc-20160816; b=jc7fh+rhcYQWuvFsNeE0UJL2+TEFTpBLPHk6BoS9w2QnQ6nj4iw44RfNPhmV7q3bAd USjqitzLmPLUjtog+UGK8NbZp4dZhEfbLjOCz5GZoMhxA1ujM5hjDqfP5HYxEhR1nU4U VZFpf2OQM47fQbtdvqxSSrRQtpApZ/2aneu38FpPfvJHEI7FBI+DghE9lO1eONwzm+zh 36/x7fGTj+V7sHc7ehGDs88IK4qXsJcNvXOtVweTO5DDN1Gof/wbKWhqInEK2EjVephB LOO2XYGl2gBtPedbcVWyyt1/iYxtlC2KJ0Hv9ZeF7ydFmddp1PytuDEOEUi1CiexCdiJ H3xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=TWDS3GE3YCCVom7DvUkkvy4rhV8jJzxhoXw51Z+7zJM=; b=oDk8NLzgEgty9cJMaKWt9151+q42bE6e9zNxTlueJs6IyfhDiUduwwyCXLZLrU/IRM Z9vLyaJd2Y39fLr7IOsN5t+4r2Hi6AvVidDNqTOAZntMMo4ll6aDBW6iyZAspP0l5mEj mT0QVl76KcQGeG2BNvxmIXVf9cu2itTrq3kUjip68szxkJi5eRtuid2XBtOoUgalbPwG tvhM8xs4oTZwkw3DyldnAfBFiJ8tTrK/z3xsVxY1YvZ2i/waMT7yO8XMpzEZtwEk0B5M wPyt+YWmf8n0YVJAiEl2iV0xOizK7Rt+vnogrY2S4aQ0lKN2G7kK4lr2EmVVIXpfFEFb QSog== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r2si14985746ejr.265.2020.10.13.05.02.32; Tue, 13 Oct 2020 05:02:56 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390942AbgJMI7I (ORCPT + 99 others); Tue, 13 Oct 2020 04:59:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:35112 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388779AbgJMI7I (ORCPT ); Tue, 13 Oct 2020 04:59:08 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 0A7EDAF87; Tue, 13 Oct 2020 08:59:07 +0000 (UTC) Date: Tue, 13 Oct 2020 10:59:05 +0200 From: Joerg Roedel To: Arvind Sankar Cc: x86@kernel.org, Borislav Petkov , linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/boot/64: Initialize 5-level paging variables earlier Message-ID: <20201013085905.GA9328@suse.de> References: <20201008191623.2881677-1-nivedita@alum.mit.edu> <20201010191110.4060905-1-nivedita@alum.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201010191110.4060905-1-nivedita@alum.mit.edu> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arvind, On Sat, Oct 10, 2020 at 03:11:10PM -0400, Arvind Sankar wrote: > Commit > ca0e22d4f011 ("x86/boot/compressed/64: Always switch to own page table") > started using a new set of pagetables even without KASLR. > > After that commit, initialize_identity_maps() is called before the > 5-level paging variables are setup in choose_random_location(), which > will not work if 5-level paging is actually enabled. > > Fix this by moving the initialization of __pgtable_l5_enabled, > pgdir_shift and ptrs_per_p4d into cleanup_trampoline(), which is called > immediately after the finalization of whether the kernel is executing > with 4- or 5-level paging. This will be earlier than anything that might > require those variables, and keeps the 4- vs 5-level paging code all in > one place. > > Signed-off-by: Arvind Sankar > --- > arch/x86/boot/compressed/ident_map_64.c | 6 ------ > arch/x86/boot/compressed/kaslr.c | 8 -------- > arch/x86/boot/compressed/pgtable_64.c | 16 ++++++++++++++++ > 3 files changed, 16 insertions(+), 14 deletions(-) Thanks for fixing this! It is not only a fix but also a nice cleanup of the 5level-paging initialization code. Reviewed-by: Joerg Roedel Tested-by: Joerg Roedel