Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp172308rdb; Mon, 22 Jan 2024 16:19:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvDSkexGd/czyUvX9DViFTBcmirzTmaNN6keb8Vlhz5v4iNvvdZo+kDWnW2rvALeq+VKuW X-Received: by 2002:a17:907:d403:b0:a2f:be20:aca6 with SMTP id vi3-20020a170907d40300b00a2fbe20aca6mr3332292ejc.10.1705969159238; Mon, 22 Jan 2024 16:19:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705969159; cv=pass; d=google.com; s=arc-20160816; b=BHIxkj53v7xAv81cVCHwZ55tIAPmym9WbZkPaEPiFAd3+ZkJecZbn7ZnlUdav13Jo5 61fiX4VwzuZn5p67XFaFgzDQglCRAJR7TIiL8kBMJ6kF04wD7dNOK4mZzkOxLixjBpwo TCGrJbL45/IS4xGWvLl4BSBWmDRaaLRs8pCIDEgb0E64qXfJJbGKAa5apjZ0yFFaSb9x Xb0cfBAclT33yvUK+PttxO3ykUnNSvTuygrBT6EouC5yc8zaaYPmRxLc6uF184HUA8p4 tkEeBpC9ju8OmRve7TgOAyM5veFHYXZ0ZPN1MP879NYcJ9UxO5K7NY43LS9dlLM4MhAU kIZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NyxiJr/kbbHhw0QH9qUo1vbTi5i6UADJMJr0fT+dqqQ=; fh=Itbyk7CEvizIrzGEESCqq3I2tZgG1kc/GkVOa3S7Hsg=; b=s8FbMbrQaxULoJyqrTEOqcH1uERKEDZDysWnHOVX0qxGpjs8CvpbUEHR/Y883Bdn2X Lnjzy/cgL3ECwtYkV0lrGw3m5tR8FPzE4/EP4xHr230e9KDCnMbuQLN1c4euWYz1PGVQ xVm73q8VJ79TxljHupG4KHg3cwrWpL0hl5UlpitbLPNQjDKKF7Sl/MTM352dahjOqwEc wAEOZ+UM+6NtOwRMABplv7SnraJ+Hv3cXr2MveOd0360ZxQcOznCQhuPFBvc9yC78I+r 0xEjXCu8Jd+rFXkdeXWLxV8u1mQ/SpCqbZdIJMPvK/yagg7uZKLqEnc+2HdvSl2HyX43 11tQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hIrY2jD2; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-34418-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34418-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id cw17-20020a170906c79100b00a30b487166csi175706ejb.393.2024.01.22.16.19.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 16:19:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34418-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hIrY2jD2; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-34418-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34418-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 041051F20EDA for ; Tue, 23 Jan 2024 00:19:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5467C7FBC4; Mon, 22 Jan 2024 23:56:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hIrY2jD2" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C46477E781; Mon, 22 Jan 2024 23:56:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.55.52.120 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705967772; cv=none; b=UNzt0CbXJKLzKkH5dXU5r2jX8xhHVExbZLajwFkxjYRYB8gB2cw8I8Aq4MzoLzD0xsGl0cyuiQNGf9ySnxz2ltxuHoCdAEGHth0nF1yVhy+vWaNuc6GiF/1aJwX6KZj4ltsfiSIrUp73UQ9eHJgrCahVsnI90ARYhsS8S1MG1dQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705967772; c=relaxed/simple; bh=14Wbeybu5eSjKa2ZVC82lKAgAKBXTRsyMhsmAKr3Hcs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hsDoF3QH8YKPC8JkFwDUEklkEKdfuCvVUiueBVM+LXmfM1jVTdPj5Q8lYnCO0kuwY71uPcKyAe9Bvax3zoYoRO+7mRIfOWtOYxDWFGUBs0I9Yc9fJsEWykEtlTFixFfacQkcBW26cDigKP9WezTu2MXGIEsWhovGugbQ2LketvE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hIrY2jD2; arc=none smtp.client-ip=192.55.52.120 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705967770; x=1737503770; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=14Wbeybu5eSjKa2ZVC82lKAgAKBXTRsyMhsmAKr3Hcs=; b=hIrY2jD2816/QrAlGIHIufK/gBcnGKkEgL4m9zgYh+h3etdZHZdM7qtr Bm11pkaUKWsGHvFFU12ZOG73ltA6KXOBzRSL+vIWFXGDLSS9IdxU+SoMb mi2LLIx7Q2PaKIB0ib6mPyAStIYcaxzEDbrfhQJtzGfWJoOs2/sNHAqTD oeF/LsgsAQh0RNbq0/aTvkoi5OrpyzCx5x2eTtL1TsWPPQ+NLAmyd1Zib 1siFhH8OR87EqaP9jMaCXaM0l2gnhdQBJ7cKaAaUE3qkCt0d77xa2r04a 01vjG6RK8l6McDsG+/66/VXB8pJJfnJQ0Rko9NSfsO6XR/AnFjXNEd+bX w==; X-IronPort-AV: E=McAfee;i="6600,9927,10961"; a="400217925" X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="400217925" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 15:55:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="27818017" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 15:55:56 -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 , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com Subject: [PATCH v18 110/121] KVM: TDX: Add methods to ignore VMX preemption timer Date: Mon, 22 Jan 2024 15:54:26 -0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 c9f72c383eee..74e5197733ef 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -855,6 +855,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)) @@ -1006,8 +1027,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