Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4119198rwb; Sun, 7 Aug 2022 15:35:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR6/mu6xdxxJLszTFYf3VbpSue+J74FODh/SM3HPq6A0m6M99M5v7H8AjhUblPqNe01KEQp/ X-Received: by 2002:a05:6a00:d74:b0:52f:575c:2d69 with SMTP id n52-20020a056a000d7400b0052f575c2d69mr1981015pfv.77.1659911748802; Sun, 07 Aug 2022 15:35:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659911748; cv=none; d=google.com; s=arc-20160816; b=j2VkJ2xMHHDrlB5/HGBiwvfObxnmk4jh8FgEB0C5Qj/+LejdJ34O+33pR7nwvJwZCE NCCSR65VNfBLjFJFeB3sVlmGdZrEhDzt2dFo7j2wN3bmk1Gs1qxnzixxwQmACfLsUByI 7QxFpZNzg8it4kNxTEn6rRSqsft0PGpb53MVvH/2EEUZ0IeRVFlA2boGwjC0MHvEK70l 7IHpgZxxY+c0lclhT0y2hdfUm7i59k+efhFKF819/eSwoqFhxZkplkvIx92UM6FpHHvR A3194fO/zBaSvT+Rp6+FOAxp7TOl7uiTCyzQ4xY6DlQVO4t7bdYDWv8zT82+xCLF3MT1 eZ+w== 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=1oUrp+LyD7XoYSKAaOtPse/8Nh5dhvhu5Og0CrOriaY=; b=ozqA0KtwfHhOEzxtL/gooy5Z9WG7v5yWinOoPbG2lBmB5d3hMxFEabjIXl3T0kIhfM ip5Tm2ho0aDbBmf+6h3pw2ReXG/Y4khx40i75fyzmlhFvEMd43loAw/0vK6udW4yHKJM XweCrkR+Y5yXy/eD+Gczr/qGzy5QSTE+HZdCd3usQh639aaTBv625Hm3t5oo/1QynpG1 Pd+foeK709ikCKQ4BKHDczXTpfpWyw6iGIZGEMlTiwf+7qW8qIUl0wwm9tkap4oYZSgH ncHtFyeIIUvE3IGKxQevaqcwCoiXI3lne8zTDr3cMcSb0PNXFkZQ0uO571zsnh3bAsIy BK4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BoLRWhlx; 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 v202-20020a6361d3000000b0041a5a80428esi8862823pgb.750.2022.08.07.15.35.35; Sun, 07 Aug 2022 15:35:48 -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=BoLRWhlx; 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 S242347AbiHGWLA (ORCPT + 99 others); Sun, 7 Aug 2022 18:11:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241873AbiHGWHQ (ORCPT ); Sun, 7 Aug 2022 18:07:16 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0B28BC1F; Sun, 7 Aug 2022 15:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659909798; x=1691445798; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dvY2QnLjVWunU4LZDJI5aPV8I0z/fE/3rogtYgCrynw=; b=BoLRWhlxEXmQZ4CG3u3X3dPfelVi5HJIDloNSBy9PshRUBxtArrtFLbo 3Mj9/F6ckc7gNZ3xkK7ICJ3aXA6pCSZf8x/pYWKFyHboW1D1C1ThFphWF UaF4l/mNHmPnH/JvKkjdbtZ7kNPysuLjxV8jcUsobtN9LzRq80GX7vsY3 XpoObOXOOYJO0Y6eWVNWPPzgzl/WB80xVzDM02cxz/jGc//PH4k1K+Wwy s7Sivr4dToOzeKq4aa0hKsNESW/vCU4VeJj//weiE37pG7PXlw6Hp15Bt FxdD7Q3bpKOekgi5xAjEPuzH0PDLAMFo3h476x4D5lZ12DuftryJgudIV w==; X-IronPort-AV: E=McAfee;i="6400,9594,10432"; a="270240402" X-IronPort-AV: E=Sophos;i="5.93,220,1654585200"; d="scan'208";a="270240402" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2022 15:02:43 -0700 X-IronPort-AV: E=Sophos;i="5.93,220,1654585200"; d="scan'208";a="663682740" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2022 15:02:43 -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 v8 090/103] KVM: TDX: Handle TDX PV CPUID hypercall Date: Sun, 7 Aug 2022 15:02:15 -0700 Message-Id: <6d9a5ec5e267162383160ff7f6889ea8ce906257.1659854791.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 X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,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 849bae37246a..93c4ef209a73 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -934,12 +934,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