From nobody Mon Feb 9 13:59:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71D06C001DF for ; Tue, 25 Jul 2023 22:21:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232584AbjGYWVg (ORCPT ); Tue, 25 Jul 2023 18:21:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232503AbjGYWUD (ORCPT ); Tue, 25 Jul 2023 18:20:03 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9B1649D7; Tue, 25 Jul 2023 15:17:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690323427; x=1721859427; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=S7tfUygsfsO9iaqRrMz1ajmnxRELIU1u0wIlIO3T+fQ=; b=Gnpq/jCnkUhdX/V4Dw7YygLlIpA/Kz4S7PN/loEV9lDoyUkmxahKGzTz zfpFc/Q+JfUGjb+kdA4KbGzmh6lB6BdiVZ+4PQD5DEQ5zJI0W8gq2caGO y0HPPVrPgJRu87+n2KjyJFSRS1ZV46E3fGnakz07AA12mQB5Uo59OLme/ Y1WKZXF7VoC1yF9IAfksQ/QbzIlzOzygHk/j8ordaX0CYALono5qPfFPs ZZnfFbOfIHxvpAuPWbWBVvs6HEsS+o+DyGQfzCrLpgbup2gYBhYaW6OJH 7JYbFw8RD9cdjGNWTI1WzsFhQCldLFMIRlYfopGo2rtYy9oxCypJaylAy g==; X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="357863297" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="357863297" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:15:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="1056938950" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="1056938950" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:15:40 -0700 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , David Matlack , Kai Huang , Zhi Wang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, Sean Christopherson Subject: [PATCH v15 050/115] KVM: VMX: Move setting of EPT MMU masks to common VT-x code Date: Tue, 25 Jul 2023 15:14:01 -0700 Message-Id: <1e5d9f4a8566a5de16422b826ca6c647d43015bd.1690322424.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sean Christopherson EPT MMU masks are used commonly for VMX and TDX. The value needs to be initialized in common code before both VMX/TDX-specific initialization code. Signed-off-by: Sean Christopherson Signed-off-by: Isaku Yamahata --- arch/x86/kvm/vmx/main.c | 9 +++++++++ arch/x86/kvm/vmx/vmx.c | 4 ---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index 8bb38db4323d..59a53a8cc475 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -4,6 +4,7 @@ #include "x86_ops.h" #include "vmx.h" #include "nested.h" +#include "mmu.h" #include "pmu.h" #include "tdx.h" #include "tdx_arch.h" @@ -50,6 +51,14 @@ static __init int vt_hardware_setup(void) if (ret) return ret; =20 + /* + * As kvm_mmu_set_ept_masks() updates enable_mmio_caching, call it + * before checking enable_mmio_caching. + */ + if (enable_ept) + kvm_mmu_set_ept_masks(enable_ept_ad_bits, + cpu_has_vmx_ept_execute_only()); + enable_tdx =3D enable_tdx && !tdx_hardware_setup(&vt_x86_ops); =20 return 0; diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 408c155f8566..26a762df2c23 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -8373,10 +8373,6 @@ __init int vmx_hardware_setup(void) =20 set_bit(0, vmx_vpid_bitmap); /* 0 is reserved for host */ =20 - if (enable_ept) - kvm_mmu_set_ept_masks(enable_ept_ad_bits, - cpu_has_vmx_ept_execute_only()); - /* * Setup shadow_me_value/shadow_me_mask to include MKTME KeyID * bits to shadow_zero_check. --=20 2.25.1