Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp170154rdb; Mon, 22 Jan 2024 16:13:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGR6KjiK7j9/2j94pC9I4Gn3SBVNnJfJhLpydkFXs8zpVYt4y0EObOa5DUYIAW/ERs3H2a X-Received: by 2002:a17:90a:4298:b0:290:767d:9c97 with SMTP id p24-20020a17090a429800b00290767d9c97mr1629075pjg.10.1705968838929; Mon, 22 Jan 2024 16:13:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705968838; cv=pass; d=google.com; s=arc-20160816; b=AewUFnPRmo1p0TmUtxCuLqAAy0Nttcy7JZOggzMmdjk/yHjnlZ9/fHEWDBgBjHg5MO IEu8zGL10sem4eGkUznY0EsBX2lg9yDpCBLLVes4jYkQxcMRxPOtDBFkrdlun1MbSIuH ii4EB3v4T7JS6u/ugKqISuz+9Q5rda6Szb69lJDf0FhofJn4Tw4Cq43VEyuGI15NXoAg pFSfUkLf8KGEdLB23/HKmQHDe7umTtFyUoTGSXYsvaYhUmC+JMz1xJ3HCbPxrZRzkqkr VW91+U8rAF/16nrZ/npB7KgEUE1L/0R2Tc7dV1LdXbNHWZux7AqIAjuiq77YE/qLcdK5 9h7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=XVPGYSAIz2Q0Ex7YwVzlGk3yIyq23H7XtCnB9ykMQWk=; fh=ka1BjeomumTXa1Vhgkzg2yK2f13tB8VguFI2e9zPJ3c=; b=mTNoTi+cZ3RGgHBeIyUKUy4L8O4+a8aIE1rxQDN/DxdRm6jwvwPbXGkw2Jfm++iIIT ElecbYSd49k6bIPqbOTwIAK5dA7xTnvTelSqphpQ6fT+MQ8oaEho41rSRvhejrOWmKy8 zeeK7OnpewUWSTAnRpCz5eNX3nnFPiJ7hP0M9+SbUC4SLYCoR5XSabRf1p6CNhBvG499 VZ2pLCmV1vnCeuzG137Zgde/lWllSZB5VITDIX6TqhyiNN5HJNA8Ko3WxLzonbE1l9uk 6Q664hM+FNgqEnd6XcFeFvupwxIUDbio5XGWTMlK6Jm1+1FxM9GfW+okWo3b+5mZt7jc KeQA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=leVZauRd; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-34372-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34372-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u9-20020a170903124900b001d4af7a3cd3si9062612plh.83.2024.01.22.16.13.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 16:13:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34372-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=leVZauRd; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-34372-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34372-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2634D28D478 for ; Tue, 23 Jan 2024 00:05:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C4D96341F; Mon, 22 Jan 2024 23:55:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="leVZauRd" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86DF8627E4; Mon, 22 Jan 2024 23:55:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705967748; cv=none; b=AaT0BB3Y+5VqFXEkG4iZFvs/NZj95v2yfQV6OBOXvg7nd51IYQ+c2XO68CHpeVVtS4PXX/LUvyk/R+LTRHmosdRPVnsf1NsMY2NmgECLEOwUrem9PjQPH+KMXrgSZqLE3gw5uTxbsv6c2ZTvHSsSiECivKN+0UJTicfpb7RZMRI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705967748; c=relaxed/simple; bh=l6Zco0SEeOUpI7QVkUZQZzcUgZZfpXd/uMYRqYQK7PQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=laV+fVmXNHBX+oBdy82ILKELSSZ0N80b+XfG3EEoOH2ED/KEi04TDTjwZ0GqMABQExBLELC37qODRbfZA5HVnozPmeS6ajOomuUKeV2AKEngoo7K1X2uZ+kInXfTwrGpQ/xSA0u6p8GzD0d9PyrtbCkBpoV966f3aneItH+Sqgw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=leVZauRd; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705967747; x=1737503747; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l6Zco0SEeOUpI7QVkUZQZzcUgZZfpXd/uMYRqYQK7PQ=; b=leVZauRdJxPa39RipDY4+M9SVESTN+HTSzZa6URMBIPBjD2P3xUie5MF +zAjClV860JV6p4/TGMNhfDoFO1T2lGm6LOEYNc7WGHQpJophffc/YS0H 8WY1YDStEkfH4rGhxPgj4i6pEoNBclODI6shF6EYhmFDc7aDJGlARnJGr UYd344goJADTc2BFPuoHofN66ZRe0za/VG2YFAZyDepTRR8nIhFmBM4Eh UgpHdYSS7ehLa3LF1p23EN/nBwjHEbMmNyUJpgYj4DDeEXIngUbTF2imb K2p7jjFJcYYT58QkxLuX6SzcH/kFcK1dZXaZ6bLuknUaJKXowMMJe7yZi w==; X-IronPort-AV: E=McAfee;i="6600,9927,10961"; a="8016416" X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="8016416" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 15:55:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="1468164" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 15:55:33 -0800 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 , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, Sean Christopherson Subject: [PATCH v18 055/121] KVM: VMX: Move setting of EPT MMU masks to common VT-x code Date: Mon, 22 Jan 2024 15:53:31 -0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 de4b6f924a36..8059b44ed159 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" @@ -54,6 +55,14 @@ static __init int vt_hardware_setup(void) if (ret) return ret; + /* + * 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 = enable_tdx && !tdx_hardware_setup(&vt_x86_ops); return 0; diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 185e22a2e101..c2da39ceb02b 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -8452,10 +8452,6 @@ __init int vmx_hardware_setup(void) set_bit(0, vmx_vpid_bitmap); /* 0 is reserved for host */ - 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. -- 2.25.1