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 X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBDAAC433E7 for ; Tue, 13 Oct 2020 08:59:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8842D20E65 for ; Tue, 13 Oct 2020 08:59:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391036AbgJMI7I (ORCPT ); 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