Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3472178rwb; Fri, 30 Sep 2022 04:13:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5/05qTcl6yhXDwQ10deBdoNcrdlfNmvo8YmT9kZQubxduC4N75Jigxw0ldRgeSkF8nR8Uu X-Received: by 2002:a05:6402:1cc1:b0:453:1517:94e4 with SMTP id ds1-20020a0564021cc100b00453151794e4mr7267521edb.399.1664536422014; Fri, 30 Sep 2022 04:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664536422; cv=none; d=google.com; s=arc-20160816; b=VuyZ75014FFxGXd/3w6RSaqpzDq9q7QGe9g9YwqDAznU2RdfzYEhNtZkTRHlpo6Jji CMSWXTfdiAuAXmn2qhchbviu+IWso+87RK36PaBCDwGTlzngBmVT+8U+GwSMy8IHIZaB ZprOaVU8fW5k5piHQVFxf8BbfDjx5dvz/KTey+bEOUWUvb4QipNgyZYZSXX6G8N5zzfj 1c22HOt/T0TAk0bko5+1Lc8TUL3Eb2SPfpSXWn0SEqEqU8qx6NR+rEfaD5CaN6h6+Fyn 1D4/4HQE6ABzqcYl42q61hikVUR6BWwiSua8TWqSj25J90Fzu7TbhEGVrU7vekw3gw0W gVCw== 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=wGNiDVrFf8C8sg5eO6kkwWcXP6v5KBCIAaTi1az1R1Q=; b=sTb8FoXp6dkCZnH28PRqPfdrTHbTj4uliBwTftthAXroPi8Hhs/AyLAXLQQGNYslQ1 h6tx4NBw8IgK9CHH0e0ql78SUNLBgsE/ekG30iPn/q21lct2Rkv634vJlL7epgL9J9o6 RSFoP7sRYcE6dFXPEUnUYnxQGBFUFD/wlZcygzrXdfdZPzPWxeMl05SQyyUIHvbM4nSy H8iWdFzPWoKzDUd18N0hbHtW/wi7591b55MEPafk03rTQSz+Sjkgvepi30Vd3X7kTqJT IzVhMJ0CGqSsXuZhrdH0uFMIWZI/nbLkWxwRBCKPXPA8PyNmyh1IVpc7NyEnt+1dUa2U kuiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=n2OrMcVM; 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 a1-20020a17090682c100b0078306c5c48asi1460931ejy.250.2022.09.30.04.13.16; Fri, 30 Sep 2022 04:13:42 -0700 (PDT) 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=n2OrMcVM; 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 S232646AbiI3K1E (ORCPT + 99 others); Fri, 30 Sep 2022 06:27:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232297AbiI3KXF (ORCPT ); Fri, 30 Sep 2022 06:23:05 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D134F163B60; Fri, 30 Sep 2022 03:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664533171; x=1696069171; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AhKoPnSHGVSzISgtP2jtzWItLYKNfc5a26JG8TZ/m4A=; b=n2OrMcVMwjUQP+CTRTdY3N4e2nHEG05nvalwdWGxFB8L/xSYWUk/D5xE b55bT9w62byjYM/hJ2JDZBRWTiZlAewWU9V5SAMeTHkAos0z+Od8jHg5T 1dx5Y4m2NubLsfrYrZL7cYEajIJeTWcRZWyD2GAJqAa6gvY7BFaMN4HPN iZA187GJiV4xb3mdXwR4t/dvko0vU+UW8JfRYq9XzpjozwLZ1L9dOO1Jf C9bLEmPcZgHkuLcSjP535oMcDcp4oNGO6JZIJGcJShpv8AO4yBQVWfhw7 L1SB8jaGmT9qHAzJxeXlNQed65bz42i6ZZpqwUZNavpVP4jzaTczSy401 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="328540168" X-IronPort-AV: E=Sophos;i="5.93,358,1654585200"; d="scan'208";a="328540168" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2022 03:19:07 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="726807801" X-IronPort-AV: E=Sophos;i="5.93,358,1654585200"; d="scan'208";a="726807801" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2022 03:19:06 -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 Subject: [PATCH v9 091/105] KVM: TDX: Handle TDX PV CPUID hypercall Date: Fri, 30 Sep 2022 03:18:25 -0700 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=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 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 4e3c45e3b24d..16bee3b38bf4 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -802,12 +802,34 @@ static int tdx_emulate_vmcall(struct kvm_vcpu *vcpu) return 1; } +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