Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2746276iob; Fri, 6 May 2022 09:30:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxte7XJhuTRhkvh/3Co2qcUM/UVqldJeG3iQ88AymsFcMEd7S+RbOIjHgvGOIQ2b+wIqFui X-Received: by 2002:a17:902:ec83:b0:15e:b5d2:a81b with SMTP id x3-20020a170902ec8300b0015eb5d2a81bmr4428801plg.64.1651854616339; Fri, 06 May 2022 09:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651854616; cv=none; d=google.com; s=arc-20160816; b=PEfQSfH6SoLmniKBIkTSaLH9g+5R9nBFkRnw8FeftMYVD4cOD+HV4vD2KO2nLsvp0o JZZcvtsxEdP+NDizF1BWyUAicG0S2eJiHPUWy4xritw6CBvQ5r28YeuRhLDowuR/wW87 h0QBRb/lal4fuGdaGbXcLJXIKYkZhVj+HY2is5iiwdd9Q1skHYqDiuuu4pxBmSqErTJp GCOdkTwsbYf2aHhsK70USjyQps9PCB3DM8fAeRs6aiChRFe1KDb/l8AgZvcNDP1wuf0p QUeIlw7tqjaSph2HcSTRFdWIeRdQdYdf94Uh1R2eopfNsy0FlJbFqqChHx4ZRwL3cxeZ c1MQ== 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=V0sR8TQLj/wHudKiLUEF5R2GCLszOz7jYJ1BlVupS4I=; b=gFwplNFpsKTrlRXB6Q6isjswmhf+sT19sinp+N7MTby0YmKtrvctWl1E0c/Acv/JYP c7ej3exnPaA9aho8RC2KzLotBpT46r/Q2xKIDFpQUym3bxxvEhJORirZDbclHvh06dTM AOdU1IehPC0kwnqqTN3+I5PQED5nfzEPNuhMxr/GQSIGhHto/y38nftuD1bfn49EovDa SRH7koUA4NokhebTAURLmjCOBNBUrnD4jBF2n3/IXNsux19laqjyCxgnU/CRuicNvrhU tkktmMOlb6gubEZfPpLVIVoD/+GBviWkwGYa8VatvtDPdlghNuNgDFejElvtMtWRJlOw ezGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Zr9db+rJ; 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 n1-20020a170902e54100b0015d9e670bfesi2953416plf.554.2022.05.06.09.29.57; Fri, 06 May 2022 09:30:16 -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=Zr9db+rJ; 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 S1383880AbiEESXC (ORCPT + 99 others); Thu, 5 May 2022 14:23:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383239AbiEESTm (ORCPT ); Thu, 5 May 2022 14:19:42 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA7EB5DA52; Thu, 5 May 2022 11:15:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651774555; x=1683310555; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J3jJT6bCwC1e/7tz6SuLrzZPSdZIzYDNXbQn9zrg0R0=; b=Zr9db+rJPG5TL7n/0XZ3eCwNHj9PT7/TqpT8XIwDK+Y9lul2x5+PBbn6 3YqHRv4CMVT7qUHDkgwjTMppWY4hw9khrGa+4ItcdOKTT/XlNqX0wAgUM IAgbB90GlKUQcpYLIMAvDSZvMTNtd2d1eKRPjJhZDWmvevQCEdKXMDVuL 7pqY/zUgXltuCEBsAPeZZbtQZtZDtUysb6YfQBv/0Rlaa93svpQm0x4W7 k63UyPAAx9G6RtMwucrvytg0dPA50Dsjl555glFD36AT9e7HUvjIeVYYL +K5u9V/z5QpaJNJnQDj13fsyQPAahDCDWhqbRad0pMcU8BJnbK03P0hK8 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10338"; a="268097115" X-IronPort-AV: E=Sophos;i="5.91,202,1647327600"; d="scan'208";a="268097115" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2022 11:15:54 -0700 X-IronPort-AV: E=Sophos;i="5.91,202,1647327600"; d="scan'208";a="665083466" 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; 05 May 2022 11:15:54 -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: [RFC PATCH v6 090/104] KVM: TDX: Handle TDX PV CPUID hypercall Date: Thu, 5 May 2022 11:15:24 -0700 Message-Id: <98939c0ec83a109c8f49045e82096d6cdd5dafa3.1651774251.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_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 9c712f661a7c..c7cdfee397ec 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -946,12 +946,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