Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2687367rwd; Sun, 28 May 2023 22:13:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5TofMOYRhD/jf0zrlj8KK9Ze8RcGd1Nu2hhsnizAVSYEBhzetM1ACIzQ+T/Nw2uInERX8u X-Received: by 2002:a17:902:b70a:b0:1af:ea40:34e6 with SMTP id d10-20020a170902b70a00b001afea4034e6mr8434241pls.60.1685337226969; Sun, 28 May 2023 22:13:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685337226; cv=none; d=google.com; s=arc-20160816; b=m+Fr3niREdCCXF5muRlRm4fDO3L1TiaaCiHwiyccAIhJqzIIX5N78SEoMbFJtWCzZs KzmjFTFMqt1DkRhZzG/bEItLXL6kSDdB0FbH5U0Jbh5OZxXOVMEq1GXyXJpDKZfG+oep zL7/5hP70LkTocl3R5o1otGGYVKiT158w2AQ1TgmI43SsuLt2MOG8HtAqBw5D73BCOTE kTPi/0sIcWYIq4jHZ9km3ij1qgvppZlCQki1mlTDEAxvGuvtQETCmNbu2b0DFlqLcXVM dD8ly1nhGtyioD5ahJVLSmrvRkasiVlGxBg+dJIznyGhXVmfUsMQ15is5pH5tQa+jdrK Z1TQ== 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=/t5NtHEHXtcOWjkK21hJXvM9UgVWVVBP5aFg7yJeqAY=; b=QPs1ysIYu6IM2pMZUYQdrUYzi62JppvmtEhOzV+JKNaUY5n+TxzFvzUXSodEsTFGM2 j0/ooKHTgjh5VbUkm9Qd9XefCIVYHdkGLzeXCfIvp9jfU2iLBCcl4a5Xjg7O8XcWWnAw E+2P61am+Xp8UFhg9CWpVv57K9LL9zcz03tWk9MFsHWS7SyahgDYPCvlWpE1W08IU+u+ llUSnG5mj8gWQft31iA/upYpD9/3Akq0FmdKlKWAtk/36nnTdVzxdArwjHUxpnb5+Xod 9oY1rg/ImnqrWTtLvu/5lrOuoHk4q7upD/D+EJ6pyTpHdBRBrdb1qSM0t+wDuqNasiwI 44Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fYQyEg30; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g9-20020a170902868900b001ab29e16b3asi8413659plo.286.2023.05.28.22.13.35; Sun, 28 May 2023 22:13:46 -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=fYQyEg30; 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 S232611AbjE2EfD (ORCPT + 99 others); Mon, 29 May 2023 00:35:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232176AbjE2E3B (ORCPT ); Mon, 29 May 2023 00:29:01 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76A1F2133; Sun, 28 May 2023 21:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685334323; x=1716870323; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j+LPqaERVdMUMizpn4E7/cIkUwlDsGeJLN3wkZGaIJk=; b=fYQyEg300FvXLlLj5EBU0OC9WVWC0Y9XIgf4J1A7O+AA6nJmIrxywfiy zWbCQCa2D7KcMpx/kcpLgHmcnohTyv3xXupEdMh1YH2bjxKoSP6CC6oJV dUWF5xe3W3YtUmK3DmiJEXHfG9zqofS2b2OQuPIiwQoYc+CMoPrL3XEFh i9xIQTlJ57vgpgNpR+idoL8cvVJBungnXMmmqpop2esbvPjX6w7XkFdcK zdtwuN34swj9hx0+tmYKs1DPc7zk05yFsU0OcuTuhzpIYPtjVZYyW6Vmv oLCqsNfnYsic9J4y4MuUrwxpaUXnocZZaVJJg/KVuN2qnzl21EZEo1lyG w==; X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="356993519" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="356993519" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2023 21:21:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="830223572" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="830223572" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2023 21:21:51 -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 Subject: [PATCH v14 104/113] KVM: TDX: Add methods to ignore VMX preemption timer Date: Sun, 28 May 2023 21:20:26 -0700 Message-Id: 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=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 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 12872225af18..da963f305170 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -835,6 +835,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)) @@ -987,8 +1008,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