Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp171131rdb; Mon, 22 Jan 2024 16:16:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IG3ZASTku1TdyKjM48R7W3cRXMYDQbp+7kbiLeU4ZpdEnzH2DHn5MUsTg0zU2n5s6yZ8oqh X-Received: by 2002:a05:6870:472b:b0:210:ae0c:70d9 with SMTP id b43-20020a056870472b00b00210ae0c70d9mr762352oaq.105.1705968989787; Mon, 22 Jan 2024 16:16:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705968989; cv=pass; d=google.com; s=arc-20160816; b=Ij/V/1Ztr0ha2hN+KZHK+sMqF10fCKu8sMCJwSA2DJcXmBXYXR6KYO5/HDSsszaYow f00ocaWpAe/k5f8HPyXIk0kdMotvy1yA05iYOSJoiX8U9Ucc0sB0x3GTH7l0Y/DiUsl8 3jBp/dN2+2CaHYDJDhinygaKeJr9qmro+q3lhKofu94Bki17Z0GiqSR9XD77UnO91/jO RLYIny6eckbmRlrGfW5DrQOyd2+ZdgNDsFwyxiuF/GaNuQflRgxK+pTTlT3hoSYvJ9PG nzXksDxRs0T1nvlShMHMb8FyUva8U3WvMnWQWzElM0jj5Gu7Gin3RBTCA57QzupfmUFn HQpQ== 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=LzqSD7J3FPEqu5amBrM/qoSre65Aw+xI1mDlmOYwtwk=; fh=Itbyk7CEvizIrzGEESCqq3I2tZgG1kc/GkVOa3S7Hsg=; b=tHz9WiSflIW2IFb3TkC9dWhfhKu/LVV8KsQj6LeTRJAvjY41xkVS9nndsn/XwwhjWs rg4e38OHADDb4u2rEueoKpXfuVpSOSAjB4n/k1LgWMXTipqeb+/1mQhQCtlwzXnxVcBT Id8+diJPYg5mXIUaMaWyfRuQ+L9o03AnaTnzJkeVchii3Jvbj1vHNBcxktThQAY/DxX5 3RmtzxsE7cLBNP5gL5zYGdgc+5lJEMIOE/edPXTZ/1Lx5lgVEer4D3om2DPABZPxSrgd 1yw6ACvFJFqvUbqwNOEr0h2V3UOW/MBTZ0d1RBSe4Glmh2X28fKfOTFHjLAAYKBHiHlp Mhbg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IAoDxlH2; 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-34401-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34401-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. [139.178.88.99]) by mx.google.com with ESMTPS id z34-20020a631922000000b005ce9986a043si8799626pgl.370.2024.01.22.16.16.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 16:16:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34401-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IAoDxlH2; 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-34401-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34401-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 C430728C2EB for ; Tue, 23 Jan 2024 00:13:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 581676EB7D; Mon, 22 Jan 2024 23:56:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IAoDxlH2" 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 C06BF6A346; Mon, 22 Jan 2024 23:55:59 +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=1705967761; cv=none; b=RMTnwZ4Baj/mPq1QKXyBUO7fUJ6dEuCQNRdW/QPotP7wb5kV7nmNkTEX9bosGhJuRnKUKeb0bicuMOHeGy7K4GMSbMabQcdXbgdKU1MUGdKBzgqkR6jaEc7t9vbcdaRoMaZeR5SPrL5tGHrVGLbUw6omEqkkrxV26rbqFpI14sg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705967761; c=relaxed/simple; bh=wGtXGF0lMiZWLOH+oSNj/3dY7kZ4QLS7boBDRkmZahg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SlN4b2s1h/fhZ3Z4nFm8nAAjqt09pSpOx0nlAZzUF/Zt1S4YB70epR+85YQVyIbO8JfB+MnajT8tw3UAjCSuDvgtFbiNtLOhVKiRSUhkgR5OzITBMFzH6h264zCPDHsgchZZJOM8wwoekE0w1UkNXLA2Em7G0zolE7rvRWggz1k= 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=IAoDxlH2; 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=1705967759; x=1737503759; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wGtXGF0lMiZWLOH+oSNj/3dY7kZ4QLS7boBDRkmZahg=; b=IAoDxlH2h0NzxRgYCsRBCmUjUccoRngMX6RpZdxoCe7/6TQcgwg/Da2t JENKsLQsahMrj9fi7kDP0IewyUZPI7zPPwxu9z+dKAt953SXZJENRyQzM u4IwrloNp7NKQ1ifsJnvPUafdlZO4kBzgM5zXD5IR6EoQWi0BWG+XX/hd YWPZxXO/m0q8XrAOhfTunBYYktNSw4pmc92zGjuj89DkMBpJOVW/jZAwl QYbyAcLZKU74fHW1uJD66jTkFrqMe2kvWhnSK5NplHXncjeJCOlc2VeGk BcwsC9vSaErW7/95Rege/tWe93gTw2phmp1SSfRWCruxiTEEvQAgKjPL+ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10961"; a="400217854" X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="400217854" 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:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="27817974" 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:50 -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 096/121] KVM: TDX: Handle TDX PV CPUID hypercall Date: Mon, 22 Jan 2024 15:54:12 -0800 Message-Id: <63097ba137cf2cf08425d8ac1655e19bfe2b52d0.1705965635.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 c504c5d9debf..f952a95e493d 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -1160,12 +1160,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, TDG_VP_VMCALL_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