Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2609378rdg; Mon, 16 Oct 2023 09:17:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGgvupLHEQdA38UKaxaSB7aUaGnswR96bew9LBu0aXa5oylG68pXnzHd1JbikKUqYmu5D2k X-Received: by 2002:a05:6358:591c:b0:143:7d73:6e66 with SMTP id g28-20020a056358591c00b001437d736e66mr39167056rwf.1.1697473048306; Mon, 16 Oct 2023 09:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697473048; cv=none; d=google.com; s=arc-20160816; b=xMR/8mPPaDYsDHXKzQsE3cQXLvwYQ1RAy4D7WkEQ0PONLymHEkvC+GMcK4pnc1tKIa OC7rQhUilsVhCyit+rP2iHifqMSszRo03I/Q/rbX92ZaGR9ptIYGMXBmwt9mGCIJbqZ6 scj8V3Szp57hrULg7P4JnKTMSajUocTp3MjzLBg3TzBlsM3AJtOqKtnRbyyYXPxFZRRt a8fxiR+7BrEIEP4ZIuSJ7QSig98+PLGDSd3I+fkI3L5kMAGAlZH9PCLjfsqmg/wRHAbc hSAl3YPeUJJX34kQ5ZmXQIw5L16d0kmPBBJaS5d1K/LcNv1RgP66EH6irExcYr68SaZ4 tdLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Rpjc9T2mZ9a9M8D8R9c/uScQMzUzyhTBG17SgQBrdnI=; fh=4OEEkzWp/q+dELKxtVy/jK+pEs8VYY1pIiC6FIGYmPg=; b=A+cj7/vudzArwDq3AwXJwyr36f2tafspy4+2A/mzYSm1jCGvKHtwMQh1Dg9wyhRm+/ h8NT0Br+6xxuuLOb9B+MLLGopEpsFuBPBmDxGmlo7MBGcVGdEdvbUnXdOBirE+j2Gbq/ pca9dAju2XvDkyPpdbpmY5cGoNVQTy07aNuBmC+7785rqXTGU5xuYyvRfeC6JOuHDFos kNwD8A6LdmNIFKgh1m68oPUM7DI23W7sA21ItRX8UNu+yLru7RJ9hGBqfkt9wbCRBR3l 2E27yFyLsxx3IND9CFlG9DestVhGy9v8r5q5vvXmMTIB/VICb2mYA3ta3E3bTlLNDg/V VVew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TbRPG6QK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id ca27-20020a056a00419b00b006b43657e872si112348pfb.184.2023.10.16.09.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 09:17:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TbRPG6QK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5DE88802DD00; Mon, 16 Oct 2023 09:17:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234021AbjJPQRQ (ORCPT + 99 others); Mon, 16 Oct 2023 12:17:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233943AbjJPQRD (ORCPT ); Mon, 16 Oct 2023 12:17:03 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00C8A129; Mon, 16 Oct 2023 09:16:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697473013; x=1729009013; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wizU7VK6cpbL7Y05303i9CKPSzmV72JDPlzje9G6+hg=; b=TbRPG6QKbnSF9poSpVrKPf8I9Hpna+TLyZEw8fHBmUDLYXUs5B/B8g2Z HS1GqEXEDzlRfuNxy7zjQFqVPEzdnn8XaxrySOrinox0FXwHBv/a6nYim j26qoWZlRk1VEf3dpGT2ydGF79dym/WXBIfdNkLKDkxoljklRopHW73CH tsWpphcWsJK7j4gcgRQeG6vbAoG2xaCy02+sWpSZJoCdC/5WawvjZGRBJ 0VP+PjaME7cyE1p1QuaAJ7YgkJWTzHpuDj8BWCY4imnn7Yci/O5w7Aahh LqTFgYY1qszYCebmJy91D86hBfJotIPICRC+rQ1ovKbmMX1pkns9zs1+x w==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="364921787" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="364921787" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:15:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="846448128" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="846448128" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:15:44 -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 v16 050/116] KVM: VMX: Move setting of EPT MMU masks to common VT-x code Date: Mon, 16 Oct 2023 09:14:02 -0700 Message-Id: <4f869767fa5c6f2ff83cb1215c2f40a5445c9b79.1697471314.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 16 Oct 2023 09:17:27 -0700 (PDT) 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 5d88d2196822..eab31d389916 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; + /* + * 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 4ea2f95a554c..82ca1ae3963a 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -8412,10 +8412,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