Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4117470rwb; Sun, 7 Aug 2022 15:32:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR7ICC17GZ7/M8pv68W/Q2hvvLxfjYVqAoIl8vStN/puOVcrXzA1jslyV1bQ3ILwr9pyK7DC X-Received: by 2002:a63:87:0:b0:419:f2d0:1e3b with SMTP id 129-20020a630087000000b00419f2d01e3bmr13862673pga.234.1659911578867; Sun, 07 Aug 2022 15:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659911578; cv=none; d=google.com; s=arc-20160816; b=vsqrYxosSoaiY/5bLwvEU3QcbZdKNMaIDLiArh35T2jyP6OZrnhrgcRIns/av1nQ/+ xdJEElcFbXmenS/hRt26ncNlTxQLATTup7dH4wqfTfDIlfq9zHpTDR8l5iK4iY+rxxva HTz27h6yOEL0pzTDnNHdH2EPHCYLkVCSigxnKqf53xHxcf5WopbK4no8Z/iviu+rNRH6 Q3q95LadI/PgypcDwtF1gaTqTrxnHjlO6u67dtdvtgh2t2Pywy9KN6z1uRP0PVGhsHuM e6QEthbSQYbX9SLsGCggTPbw1LGdcoN6CwJtLNHXCAwV/ehv577kEuKDMj4woCwhZCR6 Pdzw== 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=xuKSfswNjYam2CjK7/fA8ForXUB0sRCiXUsGQn4DRF8=; b=d2wvc0nfJBZ/CR4P2PFvJWZ0ful7Gp6dhu/eImpfzdsXmAWw1DQjncWoGlzA0Dnvmk a+8/GsWvHnmzI9OM2V25zX1AOLZ0ZV1RMCLRctJYUnSdSkqlfo+1l6AHGxjMvLyQR3pW AhGPyW0+qKvxyrAsijd0SsVMH2XCwjFH4tgBN/3UWfFcbOvLE0T/NrE78m52OF7u9w6r d2dLGxfxIr8gBAo678x4rcQfCo6sOkSa0K548PaclZqMbaBKsOsOaImhF3jJB8RhkYOV /DoiR2hnP6Cbw4qA18F+S1dTraYU7Wj8aHNGhWhfA/C5jyEGaD6RyRXv0OobjU5/xS+5 Oszw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lGGY5FYa; 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 m6-20020a170902db0600b0016eeaf9e994si12009164plx.36.2022.08.07.15.32.45; Sun, 07 Aug 2022 15:32:58 -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=lGGY5FYa; 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 S241876AbiHGWNq (ORCPT + 99 others); Sun, 7 Aug 2022 18:13:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241877AbiHGWJI (ORCPT ); Sun, 7 Aug 2022 18:09:08 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9310DBF4D; Sun, 7 Aug 2022 15:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659909810; x=1691445810; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dejhnk7oTG5/T18uRTUPKdx6UC6UMwm5GuNqcfgUBFI=; b=lGGY5FYa8eBKTIPf8JVp4yIzrgE1sYBPHiZWrM2pOsobRr1YJqd+m5it NorewebdltgwX/BD9VLGqQRTd533UKf1yyAO/Ph/h/2/qZcyuDQWagymw wcrqWxdRLHe7qlOqdGrwAxNt7FxffL0UFi8ZoAOUZD8qoCCrNGRqXgGUa LFnl756gSBadh2n3UmuRiqwelTmG9eN3j9wiOhpnlM/BOAjAO2ACeK4F7 6LjaCNHTaktLZfiXlslB2ElNLgAwiQHxVPOwrL3fsrsCsQZfgRqeWIEy6 jtURjMZW9lrIIiF9ywgY37M6Sdc7g53UBNnS/DI0+hlLeQw/TMEstnYUa Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10432"; a="270240418" X-IronPort-AV: E=Sophos;i="5.93,220,1654585200"; d="scan'208";a="270240418" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2022 15:02:45 -0700 X-IronPort-AV: E=Sophos;i="5.93,220,1654585200"; d="scan'208";a="663682767" 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; 07 Aug 2022 15:02:44 -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: [PATCH v8 098/103] KVM: TDX: Handle TDG.VP.VMCALL hypercall Date: Sun, 7 Aug 2022 15:02:23 -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=-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_PASS,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 47b3e5e591f4..a58973d982c0 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -1192,6 +1192,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) { /* @@ -1259,6 +1273,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