Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp264045rwb; Tue, 25 Jul 2023 15:39:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlHiHr6vOmoVNd7IiA367cHFEuo1+ZWe7FjSjHSiIm1rQtrikUxDyNiP1hh+qUC6V/mfW5gE X-Received: by 2002:a05:6870:562a:b0:1bb:90d7:c449 with SMTP id m42-20020a056870562a00b001bb90d7c449mr595799oao.19.1690324770919; Tue, 25 Jul 2023 15:39:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690324770; cv=none; d=google.com; s=arc-20160816; b=umFLTOakiJplGDD5BXNz2McnQrD0mv7Jm5ovA9nVY4CFY8fC17ByBvbs++yd5EhtzK SduujqTzVUxsp+W+KwcBq2b6Z6iIDr1xDv6FCkxgPEOrQ9M4854YQLuraqdO9ybcpySj Cq8d/C31Ylg6OYBh8a1kGnbPPBFyGvpccZ/moic1tUT0x5IDpxDkD09gtKuOfIp9XDMP IkDjEYgl6+ywUsiRh1hYVKsQy4Uw46oGzW0wTESbyOGrTmagJG1GErl2oAK7OgbCT8je WgVIL5pqt9e2pJBIW7/H3RcbK+8qBNsPdYwAJq8IBBEhOD71DbqQDuLLpwIQy/TEIffo isMw== 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=eKI9VdSJzJOWvgj5TTmQn5BK3S8fsq5jyd3fUa1ZSGo=; fh=juxwNcA6iKwLISFgUCNwdoIYC0NKLUseq3xZdq25RR4=; b=nlh7018LcLAH+fQTJ7UktWmFFmJVH3V/HuO6TdH/aFmPGwkQdjEPEj3nk4w8l/zGCT lmLvmXzV/Xccn3YghX4kdxRNl1RMguiDE6WldFK8LwrbazSsKUylHZEnfVlBRV/N66qs NDJa0ufn2Bq/3dVDH9qxbZGTFJZUpfHXdJOGAjW5iryxQAdFxyvZQBM33QfmcmTBzi7V Bt+Hy+Q5JvUkwvxiXDB+iAfACM0RjOsZionN37hAvKbtm4XfyOdDDNNiVRrvXd79CyH7 Yrcexj7nn5ckaOgvj1XTP9U4Pdi0IXAHyxiU27dIzDqOHd2exQpbwydkoyKYZxBH0JcV yczA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Mgh28IKK; 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 k134-20020a636f8c000000b0055b618c77f1si11756711pgc.194.2023.07.25.15.39.18; Tue, 25 Jul 2023 15:39:30 -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=Mgh28IKK; 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 S232993AbjGYWZC (ORCPT + 99 others); Tue, 25 Jul 2023 18:25:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232893AbjGYWXI (ORCPT ); Tue, 25 Jul 2023 18:23:08 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19278525A; Tue, 25 Jul 2023 15:18:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690323500; x=1721859500; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6MnXbxUuZVLlZM6cT7ntdzX4oNXlyMD//p82EXhTiNI=; b=Mgh28IKKYFB5rKOsxhjkLpDTJPFcmeCO7e74u7u+m2D382KItvnKxLza FDfY37jmwlCQuOZg40C18r3k4qWI7kd4ConChIZkCkpx8oIs2htUN9Qt5 0zw54Qw2K9jyy4tai0PumvwfFc3RVEvGJeC1mLWsHOHnwFcU88dRJ19sN mFnEu3eWwPCB9RW7WWbaZNyfHeDE9LKQFGw/PhEQm7hg3pPLP23z6z5fv OjpbB9MGdK62jpFC0n4/Xd2i/6Fr+Cpuf87Qaswio7gTDCJ4oMlUwmBbZ 9DRhLt5XgfU3pVR8vQa0uUv2KgHnRZXCUskWpQhxR4oY57dwNPQCn9jDt Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="367882701" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="367882701" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:16:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="840001896" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="840001896" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:16:02 -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 , David Matlack , Kai Huang , Zhi Wang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com Subject: [PATCH v15 092/115] KVM: TDX: Handle TDX PV CPUID hypercall Date: Tue, 25 Jul 2023 15:14:43 -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=-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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 0e95e5c79337..9760d592bc68 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -989,12 +989,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