Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3405026iog; Mon, 27 Jun 2022 15:38:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sTmVQiNkCPa2ZG+N1iQmFKg+XykK9Ddcr6Yklf9wZ47JZWJPR96e/jJ5xZWzbWdxxSDSAb X-Received: by 2002:a17:907:da0:b0:726:9402:384c with SMTP id go32-20020a1709070da000b007269402384cmr11836124ejc.337.1656369481376; Mon, 27 Jun 2022 15:38:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656369481; cv=none; d=google.com; s=arc-20160816; b=guRDRNJ8BtIEPxWIV/kjOJQ+kg5qgfSR6rg+Mvk507UTWvePVaBllLdoM7UYKuOEO6 wsw1PivQpqCXnxpJioC+gYJ2h6w4wDt13qWrsLValWtITwMleUkHVWC/cokfz1+4kJqo YdWlW5mJhLFytl30D9ox314zVrx2KT+MRSRbHJtcQT72DPviBrEDwGl4YJgKxXvnGNCZ JbrpQg17ZsZc50R7KtGXf/Bkh6EWjyL2lv04oO+XCWTABbpxputZPcBLBUCtp6IiAG1B xjwvJT1cxbFgWE6hAlnRLy1geWrtDoJ6VQNxZwRLTRxAtan7r3I+QWRIbU06EfZP9zxy zEHg== 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=p7AsZn64V1iOqbOKMHZv9o1QgsSrF3zVBLjikY/SNPk=; b=q6636G1Q3EEQZLZn4jrHjkLs3mpNY1cmQIDggkllyUPVLjQEuODsga33hfHFjoLgeC tdgUAQ/VtCn5bQbwqPmIugZqjbCVxwVSdCF7OXULnkh2gocSpBhStjQnEVFcx8kdelDL 32qp2M6rHwU/npkmx8vpsKhCqXq4HNX5GbDXyxmvHUwYyqmJoIHo2q30lNEL/ASzRdTk QSNeetSwiJA/ycMOYDj5XBKkQ4IIrTlAkbL9rGnjHYa7HOGcm37OtjbjRZtMf0oJOJhq wmDrGGwxZSucGwXtAyaAvYrbZT53foJc3Pzd35JEMADQ5s597XKJQ2Vl5ocrh9hU/LSp 16lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Xr/NpRFK"; 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 h22-20020a056402281600b0043577827670si16574489ede.354.2022.06.27.15.37.36; Mon, 27 Jun 2022 15:38:01 -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="Xr/NpRFK"; 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 S242306AbiF0WCZ (ORCPT + 99 others); Mon, 27 Jun 2022 18:02:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241649AbiF0V4L (ORCPT ); Mon, 27 Jun 2022 17:56:11 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78D2318B02; Mon, 27 Jun 2022 14:55:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656366910; x=1687902910; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Z2v9awnUY4jkBBjDyMt8sC+0XqJ7pmCWw7adCSxhLw0=; b=Xr/NpRFKqhc/q7fRUs78MrPQqR1A8NqTAR/ZJDDMdFj4nGeFQ47yyJNm 0QUxEzswxmNqD0T3gIhUsUN8ODoKk/AOB+2slLyJ0fasBQJPufiO3PW3h Q8rmtunfyiZ7CSEofK+PQQvAdMvyXiFHh3HdJ/iqHj4Q2qHEbWijEGa/h ac8ASPNLWz0COpjNtNfSWWuOUuSBW7vAeet/51loeNkiTHbq8DWcyd9Mg p+3v2Z2Wmu5UoWnF2WvtqgdTZjfo1/WX/WH/rcgrq+aYGF6Oqybupk/9N bwZaBgzIe4cAHW0LZutFoPIWC6b3bX/rO3gwLYIYtC8DDd/SWG+nN9Z9K g==; X-IronPort-AV: E=McAfee;i="6400,9594,10391"; a="279116150" X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="279116150" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2022 14:55:02 -0700 X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="657863764" 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; 27 Jun 2022 14:55: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 Subject: [PATCH v7 097/102] KVM: TDX: Handle TDG.VP.VMCALL hypercall Date: Mon, 27 Jun 2022 14:54:29 -0700 Message-Id: <76d4e3cef05d6560a8c7606d66acefd2b1298db3.1656366338.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=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 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 d4ac573d9db3..b1a1a7d96f39 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -1203,6 +1203,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_report_fatal_error(struct kvm_vcpu *vcpu) { /* @@ -1297,6 +1311,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: return tdx_report_fatal_error(vcpu); case TDG_VP_VMCALL_MAP_GPA: -- 2.25.1