Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2623574rdg; Mon, 16 Oct 2023 09:41:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+60RcU8dS/oMmgzRl5RZxfEbNfG/DBEBTVCvAkmnH0eDOrHKKF+4YoAnu8Z8ilvFHWyW4 X-Received: by 2002:a17:903:234d:b0:1c9:ca45:f86 with SMTP id c13-20020a170903234d00b001c9ca450f86mr20428472plh.18.1697474466841; Mon, 16 Oct 2023 09:41:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697474466; cv=none; d=google.com; s=arc-20160816; b=rNg9Hbi2rSAq7O4npb1YVjbao9fZuvaJlwssDAzTvGYojwLp6uHofwLN94+WVN5SLR TucucX8vmjRlEKerJTvTtapuib6foR9qcbO4AvGVmdCk4FUY/EGgLK76NLdcJED4oXYQ 32dAa9yz1hRrGkEV9m6WYXBLiC31Z15VxDYXEUlks4+lMwiylB3Uqa1wQleNCHpTGyQT 7CqPVzJih8XKFqBrZp4xQWEKKTFqkZyA0C6/DV+xVvzOh3g/CLXfbL/02ghZwa4tVQwD JK5/3Pu+TZwiLm7fmbhFGJhBiAxo1gayI0enbWFWNfDcV1tFBPFq4wDZ2ElHU3O6dhrj rSdw== 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=M2O6CJovB0hmdjQan8AFLRttv1wwJlaTwj5YFz3Medg=; fh=lRdU2Q/1zx5DcPdZuWBjshA5VT5Oc9cEhB1tCFiV0Nw=; b=fzsc2U3arFP535cGTHsAm1iXTliHR2NF+D0XqZl+DcngRJFe2mo+hAuxjHiEGfAiAA IMAAhZZaGMOQUCC0/5wDnVgGhefsyiBHeFErbM/XGqjste86svcCXHogbGNKPx083HKw 74B9thhMxt1Y2YscJcaGaSgmr9XJPJckO1H5Fh7OVdP1owKmS5FRLl5vKy/mC5ORZoHh qrdxhdsDJBHfYrzvcD0qaIWWypyPU63dEutVTgYktjkKT1J/QRLn2SebiUQR7Ej+tMx5 HMwpBqQWqsdSrluptzBA1YTla87IWjHHS5K0Es157XSAyWmnC3qIunKzAeCt7q9UBiq2 2AvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MIomptm4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id jn20-20020a170903051400b001bbcddd6e82si10622533plb.91.2023.10.16.09.41.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 09:41:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MIomptm4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 3574C807C858; Mon, 16 Oct 2023 09:40:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234518AbjJPQjs (ORCPT + 99 others); Mon, 16 Oct 2023 12:39:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233737AbjJPQh7 (ORCPT ); Mon, 16 Oct 2023 12:37:59 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D00236FB8; Mon, 16 Oct 2023 09:22:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697473355; x=1729009355; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2snvj39E4RUSDydFJqJQfs08KpJHZVOl5jak2xY1TOs=; b=MIomptm4+4k2hdvAlDGhKzZs9p43nani7WtY/a/ba+kxEoLhgsb0bpwN asmVrawaH2FAMBc/fReU6UjBiACVXA+FAxBUQo8jWjmm3JtfE9nTJt/dT 6nL44CG1W5H1zKDtDUH6AG95Ar4xy5EbXDDbS+zxvSbMld5/+5kzwjeR/ Jd2vd33UFGjp9AfJQ4Reif50j46/CjQEjLVPrDh3YioVWcg/xnDYQRVB5 zNbLcYvSU8elIIPrMNuW5SUp+3NqiaQDnn+znljOY9U38U6SZJ4vG/ZxY nKxmLRIU/0zBJz12Q+biX4tG6WyVULE0YGpd+sGxKglbCowtDzAGFvUC+ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="364922127" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="364922127" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:16:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="1003006469" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1003006469" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:16:10 -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 Subject: [PATCH v16 105/116] KVM: TDX: Add methods to ignore VMX preemption timer Date: Mon, 16 Oct 2023 09:14:57 -0700 Message-Id: <6cbbe56a22774bd24bf25673e350f1f036b1f757.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=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Mon, 16 Oct 2023 09:40:38 -0700 (PDT) From: Isaku Yamahata TDX doesn't support VMX preemption timer. Implement access methods for VMM to ignore VMX preemption timer. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/vmx/main.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index 06eb0896a87a..eb02a73f3bb0 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -851,6 +851,27 @@ static void vt_update_cpu_dirty_logging(struct kvm_vcpu *vcpu) vmx_update_cpu_dirty_logging(vcpu); } +#ifdef CONFIG_X86_64 +static int vt_set_hv_timer(struct kvm_vcpu *vcpu, u64 guest_deadline_tsc, + bool *expired) +{ + /* VMX-preemption timer isn't available for TDX. */ + if (is_td_vcpu(vcpu)) + return -EINVAL; + + return vmx_set_hv_timer(vcpu, guest_deadline_tsc, expired); +} + +static void vt_cancel_hv_timer(struct kvm_vcpu *vcpu) +{ + /* VMX-preemption timer can't be set. See vt_set_hv_timer(). */ + if (KVM_BUG_ON(is_td_vcpu(vcpu), vcpu->kvm)) + return; + + vmx_cancel_hv_timer(vcpu); +} +#endif + static int vt_mem_enc_ioctl(struct kvm *kvm, void __user *argp) { if (!is_td(kvm)) @@ -1002,8 +1023,8 @@ struct kvm_x86_ops vt_x86_ops __initdata = { .pi_start_assignment = vmx_pi_start_assignment, #ifdef CONFIG_X86_64 - .set_hv_timer = vmx_set_hv_timer, - .cancel_hv_timer = vmx_cancel_hv_timer, + .set_hv_timer = vt_set_hv_timer, + .cancel_hv_timer = vt_cancel_hv_timer, #endif .setup_mce = vmx_setup_mce, -- 2.25.1