Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2620292rdg; Mon, 16 Oct 2023 09:35:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1No/xEubOHN/3wZa2CyEz8d8/OLPX5TwIBIvrKoiKyVLOKOf+ai5eBYYe1L7tzOqgyvxz X-Received: by 2002:a05:6358:e90:b0:166:d637:a2db with SMTP id 16-20020a0563580e9000b00166d637a2dbmr356114rwg.9.1697474118490; Mon, 16 Oct 2023 09:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697474118; cv=none; d=google.com; s=arc-20160816; b=mVwiiyiVZdLynrpCxc1uMuFCr+0Zrt2z99fM6qGs0vafmnaorCztgVFNLtos15czJz jgO/YYo+RcO6l2ZmVOuIv4xXc1CMwki7pMLZYFZ/F9NTpFq2yb9k1TnNYlVUXANX7dTw bdHxbeXRx8IIQX1eG12usOU/wNhRO9Rg6F/1Dz5DFfq5TDGc+QikUx2cb2Zz9zhSTXMM KW1P9OiBYDA0ln9x+tAu+wgqoGcjxC5Oqv9sLhQPynKMunj+aYA82jJp8F0jw9ExG9ya AtXHjB8W1MvRhjWh7tM1XuGmKKeu+TQKNk1ZBKhQpIOjVKqj0VUYNKdDL5+HvgCDIlgF OkOQ== 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=Vs2MjJIanxbBTInmynByEA9EquqqNqMYg5x34F9inKQ=; fh=lRdU2Q/1zx5DcPdZuWBjshA5VT5Oc9cEhB1tCFiV0Nw=; b=c4U4nowojJ2nmnvvAwpHmTPnlLvQ2oYwPXvOsDIiwTM01PvOoTLbYiqxxDFISkmyse z2w8I+CwZCIIduLtgKO84AMq4htuHo9UkopFbPuHxonYUedHi5rqi2RRU0MO6mpcO/s1 za3jnheVSyDgqDjfpdtUJTqY1pkZfUPvpDIu1MSEq8kLT/SEUpuaWXSkHqDmqsDrQgJt nlEV1x3MCi8tog79L91pySxCWWUNk+9SLboRE+iT4gcNK7PhzIS4ig0bdh4XoNgsONLn 4kLtBtJHfdElwG/b1IJn4289u5yWwcRMsXQl0vFzLiSEk15ezt4JckiUxS444zt0OSAE VJjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iMgc9JKx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id c8-20020a056a00248800b006bdaa24308fsi174836pfv.105.2023.10.16.09.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 09:35:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iMgc9JKx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 225248021EE0; Mon, 16 Oct 2023 09:35:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234392AbjJPQet (ORCPT + 99 others); Mon, 16 Oct 2023 12:34:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234320AbjJPQd5 (ORCPT ); Mon, 16 Oct 2023 12:33:57 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 515B849C1; Mon, 16 Oct 2023 09:20:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697473242; x=1729009242; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+2p1xzrhiX+9X0wDbY0wXRtdc0DNQPfrgiIzyA0c9Ts=; b=iMgc9JKxgAWlr7Zf5KO3pRqqtF0vjPxhflHKddBi+MTpP9Tkk7LfRIn5 LeEhL/BiDFe/9ITRLIjeCfwWYZ83iBwRpGeByO5YBsQAe8ZkpyP4CS1KM tRCqWJwGmqqVd962RwCRgpPqPGoog4lYKi0+mw6XojNPlO5U0ZKM43GQu 5P2CrqA1kw5SWL3mW3EtRhtESbHP08qgZqRKU9FsohBDUyQFK6oPD5ift coaXaDb4GdFcYW0vCZqFGHjHS47nH6+ShB3f6DbAvUw9d8pOc21FfUXrJ Wb/OQ4a6iHc0eLWIIZAZ4dYQMLlT6Z7NdaevkOS8LQPDsdUY9FlP4u6xL g==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="364922038" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="364922038" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:16:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="846448299" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="846448299" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:16:03 -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 v16 091/116] KVM: TDX: Handle TDX PV CPUID hypercall Date: Mon, 16 Oct 2023 09:14:43 -0700 Message-Id: <22f807a289c3cdfac3c2f44b2d3d3111a1eba3de.1697471314.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 16 Oct 2023 09:35:16 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 eb6ba2eee16c..9430091fec80 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -1084,12 +1084,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