Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2626047pxb; Sun, 17 Oct 2021 20:53:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0CnxRPd87/8qk1aGegchblBZc445WnsnD1KhtU31CP9Z/YNfTJ3BIyZDxN2jlenGOGNDI X-Received: by 2002:a17:902:7c94:b0:13b:8d10:cc4f with SMTP id y20-20020a1709027c9400b0013b8d10cc4fmr25224488pll.54.1634529209642; Sun, 17 Oct 2021 20:53:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634529209; cv=none; d=google.com; s=arc-20160816; b=Nf+bXlSXsmxmP4MbEiAzVMa9rcOvDtYXLf0BtVfgeULyLEyVFDyp3clFPEaV+bKmi1 EDntdAlJ9xkOeRAIIFe14Ju3L8v6BB15szrsiBTagO3x6kLiqMVKrFm/52DzGk/55AJ8 jWvyo5Ee5uTY0X6mN9nTyG32+549WspZYU+hXCsZnWBC7CWAsqgxPWQ/9BUMod4VdCra L7nS2QYsBpfDRkg0iDDFACWNPpjO07O0LhE15P6U4T4qxwj09PtLatRDUfUEWzUDYrES 5zcJKtymneaMh7NpKhslP7B66cCnL/U2wmQfzgx0g/+mOzooUxZ80p1F+/3jctZJhgzb jYfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=F+K7eGwz/FgU4MIN2rCEypfuB7lzQ86p5DSnrtQ1Iww=; b=bXFUrzB6lPoxsI0/cn8pAaRg33LPx7qU1Rv0U+qdcaKgfmK0fMjRkztnvsQr1nnSgc aIWLyK4WIogP8/4bryHP3NRIjXeW2T0iheZJ7wPwBaQ1OSZA51E19BFWYvJTo+WA54KR wSyG3xGfAbkuYwLJKi0lEvSR58sX1NBTXFZNZ2TwKGwXT/LbWZnlM0VX+s+JkXlBNWhZ KcL8xBgdTMg8wYC1FD9wQmYc4/wMmG4JjZoNYoIbI1L8a+3s9JHExcRRo8lfEdjTAjRL x3n+dYN6aYjDRcLCQn32N6EolD1lKx6A907wlxYlF0LsVaPrZuCiA0I2hsQe/EKMJ2eP 3GfQ== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x69si16775355pgd.176.2021.10.17.20.53.17; Sun, 17 Oct 2021 20:53:29 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238541AbhJOVCp (ORCPT + 99 others); Fri, 15 Oct 2021 17:02:45 -0400 Received: from mga05.intel.com ([192.55.52.43]:4105 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231621AbhJOVCo (ORCPT ); Fri, 15 Oct 2021 17:02:44 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10138"; a="314183217" X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="314183217" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 13:59:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="571866704" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 15 Oct 2021 13:58:58 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 1CA83155; Fri, 15 Oct 2021 23:43:38 +0300 (EEST) Date: Fri, 15 Oct 2021 23:43:38 +0300 From: "Kirill A. Shutemov" To: Tom Lendacky Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Dave Hansen , Andy Lutomirski , Peter Zijlstra , stable@vger.kernel.org Subject: Re: [PATCH] x86/sme: Use #define USE_EARLY_PGTABLE_L5 in mem_encrypt_identity.c Message-ID: <20211015204338.64p3a7vwylqacbfm@black.fi.intel.com> References: <2cb8329655f5c753905812d951e212022a480475.1634318656.git.thomas.lendacky@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2cb8329655f5c753905812d951e212022a480475.1634318656.git.thomas.lendacky@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 15, 2021 at 12:24:16PM -0500, Tom Lendacky wrote: > When runtime support for converting between 4-level and 5-level pagetables > was added to the kernel, the SME code that built pagetables was updated > to use the pagetable functions, e.g. p4d_offset(), etc., in order to > simplify the code. However, the use of the pagetable functions in early > boot code requires the use of the USE_EARLY_PGTABLE_L5 #define in order to > ensure that proper definition of pgtable_l5_enabled() is used. > > Without the #define, pgtable_l5_enabled() is #defined as > cpu_feature_enabled(X86_FEATURE_LA57). In early boot, the CPU features > have not yet been discovered and populated, so pgtable_l5_enabled() will > return false even when 5-level paging is enabled. This causes the SME code > to always build 4-level pagetables to perform the in-place encryption. > If 5-level paging is enabled, switching to the SME pagetables results in > a page-fault that kills the boot. > > Adding the #define results in pgtable_l5_enabled() using the > __pgtable_l5_enabled variable set in early boot and the SME code building > pagetables for the proper paging level. > > Cc: # 4.18.x > Fixes: aad983913d77 ("x86/mm/encrypt: Simplify sme_populate_pgd() and sme_populate_pgd_large()") > Signed-off-by: Tom Lendacky Acked-by: Kirill A. Shutemov -- Kirill A. Shutemov