Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1184094rbb; Mon, 26 Feb 2024 01:04:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU+GCZ1bajwoVjOodjSRw/JFKyPGsd1MfOfV0jg98NKdioRHb5XUJWtJVDANEgFKpg1/H872EfJbd2zf32ZHDlWFFIgg9ALRBFGUWvXxw== X-Google-Smtp-Source: AGHT+IFaThR5ycG9Jl/srNIn+Eq9P56z918M9CP3Yah69NyxENKmEN/4HstFafgJOAKzUWmPcF5j X-Received: by 2002:a17:903:120c:b0:1db:e74b:5bb4 with SMTP id l12-20020a170903120c00b001dbe74b5bb4mr8236604plh.14.1708938244442; Mon, 26 Feb 2024 01:04:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708938244; cv=pass; d=google.com; s=arc-20160816; b=XQjAv8WTOjFZSEAEDlyRJ5BFpGIRVCBpFxrEP1lWpxcQAbBcXUCCCmHZtK59uJ3rCF uREDSwmOEO+8U63Jkqth69ueuD6jUBBbwvahhTpeiEXB0+LUavkqSpgPtBlKdALzqusn QSGwcCmYds446M7MnykILkwexVeXOKCzynLLti442c26DQ0UapdRSJnunoRC+uwCVot7 Hx5Le1oNQTw47Lt99Z30p6lURk6Y/06kZfqFfCBN5DBPhaVYvZE8VI+mv/dIaMnERLDj 6YaMOHOHz9JELfvteFCQbtOPWM7PCupORXWGHHdRWi+kWG3b0rKPqW32IKaB65kKHsLl 18+w== 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=b9m+r6VDIS6zgQIo0HeDmP6k2fcIEjYpewRBZjamb9M=; fh=Itbyk7CEvizIrzGEESCqq3I2tZgG1kc/GkVOa3S7Hsg=; b=QuJn0d+XpcqKOsgVcmUhGMLBJJJFcwb7IdTOiv8sZTjVLSbP5kArDW9CQEKAxLop8M yP3jd719Xwu70rn+7RNQbviVCmv1Drom2wDMwKf+DWpoAhumZdLQAQc/zEYdVeDC/82Q TG/2Xv0JOnvVWm8PxmC6mOx9NfdW1EpQQPr7uqUir6uN9vUTPq7NCJ0tzXd3djD+5sGE wN7qXlDEN96urPHy5XVhXhrzp96YrnddsbhjaB5D6xztuMJAGQMpflZ7XI6KbS8iYFY5 oaKTCk0Vl8paCk2wy9hmhHG9XaPrf/dQSP4fF9tCIR82MNp2Ukrr6DeWb0Ki+FFJJXBX ohVw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AI8GxbSH; 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-80871-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80871-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l1-20020a170903244100b001d9ece29addsi3422347pls.178.2024.02.26.01.04.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:04:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80871-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AI8GxbSH; 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-80871-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80871-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2C7EB28532F for ; Mon, 26 Feb 2024 09:04:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1484612A14F; Mon, 26 Feb 2024 08:29:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AI8GxbSH" Received: from mgamail.intel.com (unknown [192.198.163.8]) (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 8BBAF12881C; Mon, 26 Feb 2024 08:29:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708936147; cv=none; b=YVq+1NArk+W2NPXvUXRrZUZqJnJQiX0Ye4JH+jGIUELXTAFEIrTR12B4DuYlsNohJF4gKIwguTSK5txOYoN/KpyzzEBTjo1khYgb3pX3leD4dRsLN/szPz1x+uRzlFRY/Oa4PCZnpAk8pHjklSombgelG1p8Ms+TpufSdE3vilk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708936147; c=relaxed/simple; bh=nUfUpWtI/c8UEGyRqPpk6qguNHB+5fFp6Y3yMKH1okk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=F6EoAFXmH5fy4jbTagrc0bxzFzDAcQqwaQA7QOeg9RNl3q2iPYmvD1sBEurXzxRkwKfSUNQDo0JYtGhl4zC48J/531e9taQn6XewDH2YvO5QrjEiEbJBC7iACsAVxSw7310Lz2Evd/0ES6C3nIj02i3RxcqCaH8Xbuc+iwwtYNQ= 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=AI8GxbSH; arc=none smtp.client-ip=192.198.163.8 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=1708936145; x=1740472145; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nUfUpWtI/c8UEGyRqPpk6qguNHB+5fFp6Y3yMKH1okk=; b=AI8GxbSHU0Ob6+AyGr6nlBldBTB6/PVF6J7fwga9K48YMyZ0vjbHk+Po gufAUH6aYQoF2q4yeqg0mvnBzOAyRHIDmdJ9gwWnLdYwMgsTXh4VMMx8t 9AjlTijLTtk1qeRfPr2VF7Lg1wLegyBMNgwpV10y3Dbk3+tG49v/FuCf7 iU50/uTUSYLo3TsNrFTRpFZxpt96vlgN4YtYucdX4ol/eQc3B8xcGU9Mc lsc68Zi5Z1oANkfB/FG+kTuAkHAxSWEjHee9PQuZmbLmGuDOJKcUvpYZ/ WlyV9flYytD6/hQ44aEKwq6IqhogVfodnv5B1ZHp74aJlCZHch0CcD7OZ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="20751324" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="20751324" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 00:29:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="6735062" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 00:29:03 -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 v19 107/130] KVM: TDX: Handle TDX PV CPUID hypercall Date: Mon, 26 Feb 2024 00:26:49 -0800 Message-Id: <1999b2b095612e59746710e0a37f4caa466ee37f.1708933498.git.isaku.yamahata@intel.com> 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 Wire up TDX PV CPUID hypercall to the KVM backend function. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/vmx/tdx.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index 72dbe2ff9062..eb68d6c148b6 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -1110,12 +1110,34 @@ static int tdx_vp_vmcall_to_user(struct kvm_vcpu *vcpu) return 0; } +static int tdx_emulate_cpuid(struct kvm_vcpu *vcpu) +{ + u32 eax, ebx, ecx, edx; + + /* EAX and ECX for cpuid is stored in R12 and R13. */ + eax = tdvmcall_a0_read(vcpu); + ecx = tdvmcall_a1_read(vcpu); + + kvm_cpuid(vcpu, &eax, &ebx, &ecx, &edx, false); + + tdvmcall_a0_write(vcpu, eax); + tdvmcall_a1_write(vcpu, ebx); + tdvmcall_a2_write(vcpu, ecx); + tdvmcall_a3_write(vcpu, edx); + + tdvmcall_set_return_code(vcpu, TDVMCALL_SUCCESS); + + return 1; +} + static int handle_tdvmcall(struct kvm_vcpu *vcpu) { if (tdvmcall_exit_type(vcpu)) return tdx_emulate_vmcall(vcpu); switch (tdvmcall_leaf(vcpu)) { + case EXIT_REASON_CPUID: + return tdx_emulate_cpuid(vcpu); default: break; } -- 2.25.1