Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp549746rwb; Thu, 12 Jan 2023 09:12:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXuxODVAQ/+p+LyZhtbJlg5NaPVz/YxhsRhsPQ9sUuvodWunQnMaNlyM/9tIk28Mbeqkj+Pe X-Received: by 2002:a05:6402:5293:b0:494:eb9:54c4 with SMTP id en19-20020a056402529300b004940eb954c4mr24343532edb.19.1673543536265; Thu, 12 Jan 2023 09:12:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673543536; cv=none; d=google.com; s=arc-20160816; b=lo8OsO3rEnMkLyaG/JpWSgnsztueLwwIaCDzFL8ALhjEIdQhk5MZoKuXmrUX/Ol1OB 2moW5gVWQACDZfgAx9OrqTmlJfKVgbtfU/SFriYujL8StQF32aM5Xit6b4s5QEWkZrY2 24dg7dNiDzOFbNOnSLYSzhTItd4j08kCXO/cYNpvP4WmcWBsGg1Hss3FOaBNVjORMGuS uM2Jvv/k4kRYlozN4vWsF2vmcqWwd2OW+Yaa2qwzb2BTiY9UOKgHLQoac3D7OcHSSkqs OJGD/eJqyZ7oVGAUgBsUMBoNBi0CwmZq9lPrcgyrOaySDVWherOAmJKoF79FhQgCbxSG BYeQ== 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=F4uFro+lnRIbmKBvnpReP3KHdtyYGYV7cBxcIqOIFnQ=; b=EZ1yCsHMlpl1tN+/3oJ+0jOzfS9YEpwlrpK82WoyBWBOXxznpw2tD9ItfvxxNmQc8q efPv8hjXI1esRTp8ppCq6qzCbSRW2cCZAOUOAczEzy88rhR5QTUKnZB5OM/PFX0taosP UVOVhIQgosuQMP5Gvi5xv3sjBi1xjEPupgRd6WmoqwrEYpqZUIGPFw1Kc0Ft+YheWGeH gnVGxgVUQU06VSgFIVj6k7sFzhlgcymZVQwGvgUq39xJq8MhkBLazIi+zbh1eKH/CZhS Dcyr5LewuBGlRJIhB9ki3mH1Kpx6YGs0sm108tXCV69G+DHrCreKx3JhYX+mKBSrgaHp nNBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cFSFcO5l; 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 f12-20020a056402194c00b00499b50657d6si11499380edz.531.2023.01.12.09.12.03; Thu, 12 Jan 2023 09:12:16 -0800 (PST) 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=cFSFcO5l; 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 S240663AbjALQlk (ORCPT + 50 others); Thu, 12 Jan 2023 11:41:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232772AbjALQh2 (ORCPT ); Thu, 12 Jan 2023 11:37:28 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 307BFDF4B; Thu, 12 Jan 2023 08:33:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673541229; x=1705077229; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qO8e6bM3otymu5WCnXl9Um+rd7DoA2ZJ2n+Qv92VWas=; b=cFSFcO5lDhQvI8+R37Q+WqtyyOYdqNAYvxCu071sg+wAx0gH+zmBJtvW 5adw9+oawugf8q1pLFiO8yOD7TuJG+XDDuHHiOUqMqAS0M7LhSunmkkHl qUOMBWInI3lx/Zab9LS0DvZSFMdVowC+yQSSn8JKZRyt4BiBLBs3rulUO 8F+brBnCpviq+SR4q1onU8f/mIhVy6XuKbNDX9iNFYAKmRxSkAc16LST+ z41DxryfyKRvN4rXp5hfFt4hOTz/SqMsBQ/PkQP8sJH1cevnHNZIl4djb at5bGHdNBeQAu0+xzv4n8Clug8WmAjBVyxUwXqCwZRFLdLO1CxM/p0561 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="386089803" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="386089803" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 08:33:39 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="726372614" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="726372614" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 08:33:38 -0800 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 Subject: [PATCH v11 106/113] KVM: TDX: Add methods to ignore VMX preemption timer Date: Thu, 12 Jan 2023 08:32:54 -0800 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.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 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 cbac63170cea..2d2738e8c0b1 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -738,6 +738,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 void vt_get_exit_info(struct kvm_vcpu *vcpu, u32 *reason, u64 *info1, u64 *info2, u32 *intr_info, u32 *error_code) { @@ -889,8 +910,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