Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3404098iog; Mon, 27 Jun 2022 15:36:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v3GkXXnTPxefvya6PO6qibOsifJ8gYXPvPzjhCAvEUgdWKTIBCARmV3XhK7RGWJQmaVuMk X-Received: by 2002:a05:6402:5387:b0:435:7060:a759 with SMTP id ew7-20020a056402538700b004357060a759mr19125104edb.150.1656369392609; Mon, 27 Jun 2022 15:36:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656369392; cv=none; d=google.com; s=arc-20160816; b=KBe08xREQcIZKofecWMtlYOIfqLM3+WpDgp1Q19WnjaU+bsMR1Y4e4+fEtuVaQqVTV 03EVLqU8cWpxikpRRCL+HoROjdrEEUlDYW5cGb+cFghCFOHgDgoQKYErSmPBet1vKYtc Yl7pi2Vc+M+r8Nfs2V+OturnSkfb1Xp5CWY/zSyIKfkwWJVE1RxDYu9S8nnLb5ZISdVQ AkeWPp7ob8OJ+vRMe985NolqRlp54prCVST4PEjbWvDPNR9xDnyqDefGvpzSKKikUF8V uZjKQG/A5PKS+rsiq5WLdVx4fSGAd6+FyE30xUawd89qcPPvjiQKUS2OEEEl4A2c0k8h Xmqw== 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=c8+t5CG3Vxd1sLL+eQyZ1xITPvnkDsCs5TC4RrYwfvs=; b=IW6BT9NhBRdvsgCZoU/MnaF7AAUB2XNtGg7M0Mh/rW+ybgFNNGOmYBWT9A6OPgkXMH McY2AS/MRVIumX9rMbXLK4pX1je1LP471M/v5U+dpHIxAw3Mv42G+2ByPF1l0NA57dRF rqN2EylAKwhT/PKALS0e8GLXxhaEGmvdQEyMTwyv7hl6NPy5D4wfRu2obtB6i4gMhS1j 3LW2kvAc0grlpWWkJq2piU8eJhZijvIwU2miQI8cLs3quAXItXR40GXvN7P3jpayXdGw vuhlTEmCq7oUz5OncQwH6koXJJnJZASzxl7Zn878hwQKSkA80J43jJ4rrggC++oNZsbS O/SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gYj2w1EC; 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 fj2-20020a1709069c8200b00722d5b2fcafsi12909104ejc.40.2022.06.27.15.36.07; Mon, 27 Jun 2022 15:36:32 -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=gYj2w1EC; 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 S242359AbiF0WBZ (ORCPT + 99 others); Mon, 27 Jun 2022 18:01:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240208AbiF0Vzv (ORCPT ); Mon, 27 Jun 2022 17:55:51 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C203D14D27; Mon, 27 Jun 2022 14:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656366907; x=1687902907; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RURQ3udaqrRiQcyGTuHQxfa7/HRWoHgGXC9+BSTk/WE=; b=gYj2w1ECA0jrrqCfYriYZwDxO6DgRWOZMaPd1CInbmn6ZZXvriMU7gwS t8ixX/VQmG3BY9cqpXdxQkoUS8r0nf3AR9Fnf3uQvRIm1MjIUBVm8hzcz Mm+Zz6e/Y4DcwxENGBwduLPn66WhHR6fa1r4rd3tifkcG6KB66mLeZCsi aI9X2C9ez7RFcl4VOyMqVcnalfB7Ty+qRqpdLEEjLNg2ZcK2RmTp/LbQT i44mZlmMMyYoKnAFqPwS8G4dsxzt2neM3uR4VZ2NFuTeSXDhTV4buqhId zxvvGlAwUBRTnEk0ONwsyFQSTuNv/nFJek2S4zeEgDtwFvylKrOkkZcO1 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10391"; a="279116138" X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="279116138" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2022 14:55:01 -0700 X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="657863730" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2022 14:55:01 -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 Subject: [PATCH v7 089/102] KVM: TDX: Handle TDX PV CPUID hypercall Date: Mon, 27 Jun 2022 14:54:21 -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.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 a30be04229d7..96e41602125b 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -947,12 +947,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, true); + + 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