Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 092B9C6FD1C for ; Sun, 12 Mar 2023 18:06:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231910AbjCLSGQ (ORCPT ); Sun, 12 Mar 2023 14:06:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232103AbjCLSFI (ORCPT ); Sun, 12 Mar 2023 14:05:08 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA0FE3D937; Sun, 12 Mar 2023 11:01:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678644060; x=1710180060; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k0qDJKrmWE8WRF/8Dkfe7Efw9evpPdNSFlNfJIhNIPw=; b=LatpYKwBmk7K3lPIJ/Lohr7ybqkEFBL8Ow7lGnKcCy+4ax99T2Mep58y 2147zGUYTnjt4TUASwO7oGdgBnNHOHpDo6xmRoPuGLYKVKoLcqc0amOZG gZNuEiOA1fNSx1M2ikfd4BwnLiTiW/TnqSWQ6rpFt3l8RS92udYLfJ7BY PIpsyQq61s2E1HIslS2sARj1mLUAyrGqaENrGWi1gQIQIP87pqk4Th/Ac CWHzYgV5ElfM2DooxqeczXH1bRzFh8OKtxMwT/Xkv12C3borQSpH09uuU R0rJhDmEV3laFDu4H78CY+lFy6yL97pmyCApfNILPHeJbwoEEV3bgyIZd Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10647"; a="316660098" X-IronPort-AV: E=Sophos;i="5.98,254,1673942400"; d="scan'208";a="316660098" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2023 10:58:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10647"; a="742596831" X-IronPort-AV: E=Sophos;i="5.98,254,1673942400"; d="scan'208";a="742596831" 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; 12 Mar 2023 10:58:15 -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 Subject: [PATCH v13 099/113] KVM: TDX: Handle TDG.VP.VMCALL hypercall Date: Sun, 12 Mar 2023 10:57:03 -0700 Message-Id: <8a8a6d4b367deb615f5368fe86085eb2e2f322c6.1678643052.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Isaku Yamahata Implement TDG.VP.VMCALL hypercall. If the input value is zero, return success code and zero in output registers. TDG.VP.VMCALL hypercall is a subleaf of TDG.VP.VMCALL to enumerate which TDG.VP.VMCALL sub leaves are supported. This hypercall is for future enhancement of the Guest-Host-Communication Interface (GHCI) specification. The GHCI version of 344426-001US defines it to require input R12 to be zero and to return zero in output registers, R11, R12, R13, and R14 so that guest TD enumerates no enhancement. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/vmx/tdx.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index 853cfda99fed..10bbac208a9c 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -1216,6 +1216,20 @@ static int tdx_emulate_wrmsr(struct kvm_vcpu *vcpu) return 1; } +static int tdx_get_td_vm_call_info(struct kvm_vcpu *vcpu) +{ + if (tdvmcall_a0_read(vcpu)) + tdvmcall_set_return_code(vcpu, TDG_VP_VMCALL_INVALID_OPERAND); + else { + tdvmcall_set_return_code(vcpu, TDG_VP_VMCALL_SUCCESS); + kvm_r11_write(vcpu, 0); + tdvmcall_a0_write(vcpu, 0); + tdvmcall_a1_write(vcpu, 0); + tdvmcall_a2_write(vcpu, 0); + } + return 1; +} + static int tdx_map_gpa(struct kvm_vcpu *vcpu) { struct kvm *kvm = vcpu->kvm; @@ -1252,6 +1266,8 @@ static int handle_tdvmcall(struct kvm_vcpu *vcpu) return tdx_emulate_rdmsr(vcpu); case EXIT_REASON_MSR_WRITE: return tdx_emulate_wrmsr(vcpu); + case TDG_VP_VMCALL_GET_TD_VM_CALL_INFO: + return tdx_get_td_vm_call_info(vcpu); case TDG_VP_VMCALL_REPORT_FATAL_ERROR: /* * Exit to userspace device model for tear down. -- 2.25.1