Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp283872rwb; Tue, 25 Jul 2023 16:04:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlFeGAM2pHM5h5FT++OllcNxlX1k1vo/KDWzxLmUZWKwt7ibb7djrUvamiLv0sBLl5lh0R1w X-Received: by 2002:a17:907:2c74:b0:99b:499c:ddb6 with SMTP id ib20-20020a1709072c7400b0099b499cddb6mr162299ejc.68.1690326245297; Tue, 25 Jul 2023 16:04:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690326245; cv=none; d=google.com; s=arc-20160816; b=gzzlz/DRTwhLRuGrc+lJV4fx8K2k2BMNdR6V191s5nWzcQMao83ZdrZn2zbFbojIcE 5Fn8STkiksWxrimr7TYcA2cc8/uU6jU7OcMMgGdlc07rSuBP3EB9lCHYeZSiAFp38JWE +9Dq6DrrZGX9FBjWbxvQieMohLIGcYKpZtLCOE9Ofb1PFKAaPsfDn8NDhE/mIfaDPrM9 s21YyDDso2puQ6qAnIIioIKPMNgYSaD0WX4HXipcGLCcYaDbaQve+w5vNGSucpBnM2lG PQ3Z+CQi7oKlnAolWwi7OulaK3ZujBCfvDUYN4VI18auEYdbprkjlUcOP/WE1/mvImjJ m6hg== 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=3hj9NhirhA4zXepljAMrZfIvJbYedIR1ljfa8yRjhPE=; fh=juxwNcA6iKwLISFgUCNwdoIYC0NKLUseq3xZdq25RR4=; b=tr40NMQvX0TyQd4yVGpBJd73HdZMBwQKbhsI57smtrm14Q6UwyyfNWMAFB79XyCJ8M AfSVoQP5Y1y/gJlSwHNup/DMjloKhBWUBIOu7cP2zjE22hJwn5dcaDtDcvC/dyyTqiol JKzb0XCv6yUbeJ0CAVvyu7+0BM+AHZh5RQiKR4znWveVwLwE2GEAs8V197FtLNWevTv8 XQ3/NWY4eXRJVMO2kGMGdZaNUQcnEzp6M7Bk8ZkMFmcF+40ESZVVbt3PkaStwXo3KaAN yTwWlTqH0bnyYwwlEPUjDENEr5x75ma3RVLz4KbAb5HUguSnBy2+QPb6/B9rp+TpTbjx vI+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="UoU/UNBF"; 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 c14-20020a170906340e00b00992bf74c314si7906680ejb.983.2023.07.25.16.03.29; Tue, 25 Jul 2023 16:04:05 -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="UoU/UNBF"; 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 S232803AbjGYW0A (ORCPT + 99 others); Tue, 25 Jul 2023 18:26:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233234AbjGYWXk (ORCPT ); Tue, 25 Jul 2023 18:23:40 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C00E51FE2; Tue, 25 Jul 2023 15:19:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690323544; x=1721859544; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nmGQUIRYutZ8GYkQpZch+sNrtHiOxg6NOGiFVVLF1qk=; b=UoU/UNBF4o4K9ahP7sLMz6SA3wk4IM/yKXArdpCPLhfYx6vkwXSPZvBF /OKl2GWiIb7QCaq4UuJwQcc1r8RBIfht3YD8VWxlF045lncOkVb0vfIWl k6bWQnjvr5Ed994LqvILinoeyBqyiAULpXXGs8bUFOwCJ2gnHoq7IjhnU 41JVJUM2EMzGXFq/TX+7Jy9/NqpeoCWMKKbvRRrsgmdki7LMR7uNVSwf6 M1NNF4qr6fRPGSFC+VKGpmuGGtWsWA3v1Z3tKH3XrZnsqY/ZW87wY04j9 DMTQCshr6Ey8+xZkaWlixIyEWSiILGr87H/zz+EGFkB5wpZMPv8dxy+Bm A==; X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="367882764" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="367882764" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:16:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="840001952" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="840001952" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:16:08 -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 v15 106/115] KVM: TDX: Add methods to ignore VMX preemption timer Date: Tue, 25 Jul 2023 15:14:57 -0700 Message-Id: <08069b5e67f5ad24a3c4dd3c5cbf7cca6850b469.1690322424.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=-4.4 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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 38a782c28b72..c2ad9c734376 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)) @@ -985,8 +1006,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