Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp558783rwb; Thu, 12 Jan 2023 09:18:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXut53dcxAPmgIKGiLMuXkN5qgkBvtrFvSOK2H5kUJyxxV27hkiV+WKq+Wp9dYBab4Est3Bf X-Received: by 2002:a05:6402:26d5:b0:495:d3fb:a244 with SMTP id x21-20020a05640226d500b00495d3fba244mr27930445edd.3.1673543892284; Thu, 12 Jan 2023 09:18:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673543892; cv=none; d=google.com; s=arc-20160816; b=ORPg4KvdVDdmhEQpPvbN3kdduCB82kWKHFCs9JVPsiW1/Xkz1rOQqdJdnufX1rocHc vl0l5HUN5AemsRi4gQk7G3D6Brw5r/8m2aKlAjxBy+lvomqmNsiLeJrxb1FYPzeF9Cxr Yhz9t8YpsBngu2lhmvXLaqph76ZYpNDVwueysXyxy4RWev2uL5Uh6ONpFvW62C3sHt/n FAG6aFIWNkuCE/re2Vio1+jvJqXfurHfFMvrYcTr7JbgiMxgUDv7dNAMPvAbbxL7vyLK 4gbmMMZ0qnCuZn/o1jyPBjOdp/ZzlmZ6Q1Fcev5O/hGCoCqGWruaO5TFhf6ANF1zHD79 Ghcw== 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=d9/EMBXvKulNqc1tRuRMxlgI2fLMe2B7IhlaJeXlubM=; b=RAhA+z/fUWk23jcTLvqqsyY6lF6O21B6+8VTqtqZ+/G8wlVnlZVPnOmT7euMyc/m2b n9eNEFqaNnILxUL2UvOplW9eHX9zY/MtknELzO520v7DXCw/VtDnuVS+wZRJLetkUbhV BhTxwHcSiLZu9b5Obf3mcsWmSQstiHATPGiOSb5SSFiWe2oqytCCJK5rDhwl6OOskeVo pUDW126Pdf8BTQ6HbzRXVdrZ5A2V2kzun+j31qCOSglTkoQSqMsb5LoeMiPSet2aYwcU 0HofdXqawgpLedFAM+9PDHssbw4nXTThhAol0SecjGvUsorgzH4JoUcLe1dSW6rLC8U9 c+MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RjXgPgH0; 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 va28-20020a17090711dc00b007b99436026dsi10698040ejb.968.2023.01.12.09.18.00; Thu, 12 Jan 2023 09:18:12 -0800 (PST) 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=RjXgPgH0; 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 S235533AbjALQjv (ORCPT + 50 others); Thu, 12 Jan 2023 11:39:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232555AbjALQhY (ORCPT ); Thu, 12 Jan 2023 11:37:24 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 846A510041; Thu, 12 Jan 2023 08:33:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673541224; x=1705077224; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6Cs+vnL5xeV//APM1/4rRZmxU4rCJeFcpisPPdJiZQ8=; b=RjXgPgH0p7HKKxeXKdt4X0xzg0BcKxcbhhgfofeyGI/Thb603AiiosTt cG9fpbJ3oukUWC36yOsw2AQBYYJnpU87t/PYNCK3d5aYMmvbSXU5gNrOG WRisLf2AaomV1CdPN2Fyo2baoznjzzZt/F8hcHrmb7YrEnUbr9ZC7r91X +ZXgGvxm9Gh47mpeDf9f7R3+ZL04F8kR80VGCcK+AiCHSt8ayv54CKgbJ XXyP6yEwqOp7HnGg8dvNOpT8JdLgrRzDHypKI7iMBzGm3utz+mLpITh0Z JUi8g2GVVVeXclu5IROD4EVilWXiEuAzY4KVDzvkaJ8j/9aluWrwoc0ka g==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="386089721" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="386089721" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 08:33:36 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="726372557" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="726372557" 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; 12 Jan 2023 08:33:36 -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 , David Matlack Subject: [PATCH v11 092/113] KVM: TDX: Handle TDX PV CPUID hypercall Date: Thu, 12 Jan 2023 08:32:40 -0800 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=-4.4 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_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 89693405892d..6419cb741996 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -923,12 +923,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