From patchwork Sun Oct 30 06:22:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 12874 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1666250wru; Sat, 29 Oct 2022 23:29:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5UW9YuNdqX+HTiS/gWY3u+Fl4ENPuJWP41uwBixyVz15cA46uUmU0k6jFocLwpkbMangn2 X-Received: by 2002:a17:903:1c6:b0:185:47ce:f4f0 with SMTP id e6-20020a17090301c600b0018547cef4f0mr8108410plh.132.1667111370789; Sat, 29 Oct 2022 23:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667111370; cv=none; d=google.com; s=arc-20160816; b=kxIA1G1FIk36iDPRjwtA/pPmxafWhbZqup39BeuuLCiLCoIRO1tFqMjvY6xkbuLclO gFncDsMSDIXCe20fspsYPLH5/R4+BCigOA36sYDwqGnvAu8Pch/1G1GSGVCKtzuG+K5k pXmPozoDNzvWKlmVT0Iqrq4nrc8fKhlYlFOwTm8cFrq3taxQT59BIwYN7iCDd3kcMQCT cikFbpLtnru7YzNTs68GJp4GbJ/1kwAFhfqxNx1/MKYMk0/QYKgt/c+FLwaIq73EpxJS NMjub6xqIhg7Z+/FZcVGilAnYm5WSxHw8hbo4vK/hT/7tlLGfs9LKJTyyf4YZJ3CNcsS JU3Q== 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=d0eXdJ2MT3Bhle847Wag/7kSa5IJrv44Glhi78w0M68=; b=QsspR8CpBUKAZR/Kp1UblSXZPGlyFhmxNpZSUeWXTHHyWVaAHn9ic0hRr2KACiJ1JH 1ETJQQI0ic6obGN5xfUGdI6yem4+LgmfJRaRi5Yt3ou/FZAqiY3VawOxcvdJr3EnWeYY aDoNGwpls0f7xcUsONH5oDTauyIrmmBbv8cL5e1yL7r0dDNIB8F3NfLyy0Y1bi41ss7w 8yVzzrSCVs7x5d4IaHZw0XrZlf5qHu6ZRsM1uu70kn8HBnP042clN38M7U06hAltbnXw QyKoEmt/k/Nyzw52iIIY3wv9Qe25mdWMPXbgV3aPOb3lybb8GZ+riuQzfgIIRaVNyKEa t+XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UaqGt3ya; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q16-20020a632a10000000b0046f56372127si4199153pgq.468.2022.10.29.23.29.18; Sat, 29 Oct 2022 23:29:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UaqGt3ya; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230505AbiJ3G2b (ORCPT + 99 others); Sun, 30 Oct 2022 02:28:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbiJ3GY7 (ORCPT ); Sun, 30 Oct 2022 02:24:59 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F6F11D4; Sat, 29 Oct 2022 23:24:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667111053; x=1698647053; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uDvd5aLwQcJPBBxAxWbJDQm02RoATEZ6Bg3FqxNLsrI=; b=UaqGt3yasWfCMwcxtunmOtau4fwckFAoJF4N1ZzztxFPA8WcWhL9VRiu O7OBmXiolbYxZVH4rBq63JMYS9tTcxks89eRaO/q13Eo7RfZvT9oXrx8A XFVQPk8+KrFh+gYPtZ1NQxJIJ+RM6AS3v9jcR+u//yXrL58Tw2eLPdwia gsVdAMFZwOa8Iv6oEYVWSrMWEGWGVIjtokteNXVeh2Njl4sllGTCS6QRe wZRGYBoGPNP25bjE3SfBPdXM49TLffUwvJgrpyTEFpD0JD5fxF18KQCNt eaSwL68/IJN9ZbmZRWZ5ja/a8JHv5h8QTv98ATAe/YgP81bkvGE3SLQEb w==; X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="395037167" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="395037167" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:24:06 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="878393021" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="878393021" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:24:06 -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 , Sean Christopherson Subject: [PATCH v10 054/108] KVM: VMX: Move setting of EPT MMU masks to common VT-x code Date: Sat, 29 Oct 2022 23:22:55 -0700 Message-Id: <251f22af488caa17dcdbb0227e7fd0b7f61f3f54.1667110240.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748092973043681880?= X-GMAIL-MSGID: =?utf-8?q?1748092973043681880?= 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 | 5 +++++ arch/x86/kvm/vmx/vmx.c | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index 0d5ca65e9997..9fb6eb626a9a 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" @@ -26,6 +27,10 @@ static __init int vt_hardware_setup(void) enable_tdx = enable_tdx && !tdx_hardware_setup(&vt_x86_ops); + if (enable_ept) + kvm_mmu_set_ept_masks(enable_ept_ad_bits, + cpu_has_vmx_ept_execute_only()); + return 0; } diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 2ff7af959e30..b5c3652c3cc4 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -8256,10 +8256,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.