Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2687740rwd; Sun, 28 May 2023 22:14:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5lcyx9w3S34EjmUE+ApEYKwH3kxWpOtKGO1XG9w6HaJO5lcXuOplatb0pytl4pZ+PYtavn X-Received: by 2002:a17:90a:756:b0:253:3ce4:b421 with SMTP id s22-20020a17090a075600b002533ce4b421mr9934009pje.1.1685337256754; Sun, 28 May 2023 22:14:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685337256; cv=none; d=google.com; s=arc-20160816; b=tnAfr8CeZC6rj9ZtwovY0wuzYjc4kdr1J4jJ63GbrprBkqvXe/Ld0lA5ym7bSGLI2J 3C2V3TFMJDCPTK4i7YbBDEaYp8A8ntbRtEKdF5R6pb0Nd6Di40lL0iLNe60qnZ8rmFTL JCupvaKhlCWCVusMVhWnd+5IhtWDgylYzPnVPWm0I+BCxKYWoWPJEzhc0R3VxRm8DXJF aGN7ihNpgTodlPCiTwQ2tAz4m6udLU60PPaEYmQq8q823l4qmjOcArZfgkoJfjWxV4dR f1A+PZrhYFi8wCM73qUUM42NGnxn3FylybdFr5KCCXZwV3sgLEcXVT47v9T1ENtmhixL 3fNw== 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=NPjC8q0MJGDxg4F+RzYkUCsCzfGDcENK35v7gvA40pI=; b=hQ+JBvsBQUZ0G468N0L8d4F0dmDib8x7z0ArxhPfS2BJuh9fUYSzkWdDZUfB6KDBLR jg4fWfuhz6ogsNjsYhdpA3INzyo2xwYNNAIzlhuyZiyLIRLeZCMpr5qwDodX0IdR9h2t Dr694QsbHQhnbmyxmiE9UaUUIKmkZlE8PTxMC29Ue4Yugdwp5vjELYP9xHXASzJnxeUf 5lq+MpDdH2gDoD5Sl+U3gynkbmQAqUsuvbrMdc8uWdyOv1og9f3TTKULQRsocnK8CIa3 Gj+CzkBOUBLIQxatw5OQ1k9sq+kBTbgbJJiAB6EtOKD3XJdFn/LFiVnlBIxW2Vss1YTC DJYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FwbQTywd; 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 e21-20020a637455000000b0053063a32dacsi3149550pgn.826.2023.05.28.22.14.04; Sun, 28 May 2023 22:14: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=FwbQTywd; 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 S232570AbjE2EaV (ORCPT + 99 others); Mon, 29 May 2023 00:30:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231730AbjE2E2r (ORCPT ); Mon, 29 May 2023 00:28:47 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC55C1731; Sun, 28 May 2023 21:25:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685334309; x=1716870309; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IOwSGfEQBluxSXHBvJJM52mFK08fd7yM05S9VbYyFj8=; b=FwbQTywd7Tm6xdDCdvwbT3HoeuVceIJgCR9U0Y/8oqWt9/h6C0MbWNBL 7KTeXlWb2z8/JMBoBm0diCICNw2qkhPjWZLN8qvnw5MwVwRoAg31Mg+Nq tVxKcDNPhGg7FUB0qusbmhfzjDUvufwJaUiO1SBYfyKbdEr/azWRxDrdl b0PV4QisXNBq+crixokkg2QA1+c5wEXzq4vYrYzej+GCuhzcDmBbpxujE ZN2x/fJ70giO+Lc4ijxnK2L8qgFutwRyP2p3adm4NAv+vqGYeuXMUOxPc 4G722GRrlY/cDwnmgT495Cqspds1kfP146Utp550rN2e4P2EJf3kRQqBs Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="356993463" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="356993463" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2023 21:21:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="830223500" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="830223500" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2023 21:21: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 , David Matlack , Kai Huang , Zhi Wang , chen.bo@intel.com Subject: [PATCH v14 098/113] KVM: TDX: Handle TDG.VP.VMCALL hypercall Date: Sun, 28 May 2023 21:20:20 -0700 Message-Id: <02d1d3a1ae83f0cb1959a18dcdeb543529bfe437.1685333728.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=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 bfe53c9fa859..28ab274a83c8 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -1229,6 +1229,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 handle_tdvmcall(struct kvm_vcpu *vcpu) { if (tdvmcall_exit_type(vcpu)) @@ -1247,6 +1261,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); default: break; } -- 2.25.1