Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp323402rwb; Tue, 25 Jul 2023 16:43:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlFpHLWDpdHNGmveIoj3VECskjF/t+TbDtOZiB08ENMs9hh6g5r8E1zSXcryQJmi+bMBTJoY X-Received: by 2002:a17:902:db05:b0:1b5:4679:568f with SMTP id m5-20020a170902db0500b001b54679568fmr633458plx.45.1690328633405; Tue, 25 Jul 2023 16:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690328633; cv=none; d=google.com; s=arc-20160816; b=xT9TNUAm10V/m+QRI+2+Cq6PhQ6AeKMpQF3XxD2L3BaXRIGuYDCLDvYsBngx2E2Atv x2lbhRSi6sO5DQaqK5f9oTgkzzCEZUf8g41sDtFwu0IXwKNJtpw0YDxW964N5HEWx9XO 8PGmlyQ5ixIvrGQpXJj6+dvf0shJ8vkyr88IMHIiswo9HvvCgalFkqVjDVA65Wub1d9N obgWCgBpdeqLpaJ1bbsRSrpZz4dW629eukxDdBKOkj+UTgZle3L4nG+iyjzBdgC9CeTk 7j8joDzcnqIW1v8ISkwbmTcNlVggqOmViBP49Abb9LvkyEy6nqnk8JgDn0ZhV0+vrzGs o2Jw== 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=84PwfVTFtNLPD1V9UYVJmJ8psim/SY5APGvHcZl3ho0=; fh=juxwNcA6iKwLISFgUCNwdoIYC0NKLUseq3xZdq25RR4=; b=dahLxEQlHgojadOUjMtPY0gORQp/5KxcVMy++kEVw0zDv0KqOmvXwGHMVUjtixyDdo uQlo9kgkMCuGUoqUc+Y0uKaW8C2NlLoHL13aJomzqSqCjStmnVLFG38lsMp8Hh0bkgy+ X+3KNhxIh1xKBNSaWR3O/CBTJzJsHoVOmefL0f9oDb9Xx4iskLdAoRWUJ9ThjaV3CFtC /FD5PpZc3gF6DWqt7ELluHRWs++JpvGLcrQQpfQyazr0GcCUKdvbJytkTgnTFIGCp4NT zvgtWgF9WRGJ569zI+fl9XIO4Luo89tGYn8xNV6h4nnEZowzHUbO0S0MUxRoemW+t6TT Xp3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hVfo5+3K; 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 d8-20020a170903230800b001b885fbe17dsi13314691plh.532.2023.07.25.16.43.40; Tue, 25 Jul 2023 16:43:53 -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=hVfo5+3K; 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 S232177AbjGYWZe (ORCPT + 99 others); Tue, 25 Jul 2023 18:25:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233072AbjGYWXY (ORCPT ); Tue, 25 Jul 2023 18:23:24 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F2F93C01; Tue, 25 Jul 2023 15:18:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690323525; x=1721859525; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=18s/5jF2F7qugI8wqlhLGvFV9SRmY3sKou5s8wvtIz8=; b=hVfo5+3KnyiRDALOsfshWuh/tGRYWwxCOPEpTVCM6rmuTsIgI8Vj/ud0 xe9SVWb5IjX254YjhQEUN+yOrE+4+/bnfjfU+lO9ooZbud6YinHUkDDfa EV2uUqT667V+IHFuw/FDf8zXo1nwfkPJQUlfzIdVlzq5jqoJAKbI/akv+ cezn4EDu9TGbprWMOFlolnnosQUkDNWB9AwsbUC+IYvaoR/z3klQLQOQ7 yCddefdR4s6+G3mgbWtouuLWOrg3mRj98uG6XpYtVT0MMlU2cwjlHKP7R 5es4TM7cQgBGFytLnHnGY10QG7KRn84c1r54fSlpE8lpOCLuXPsnRymTY Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="367882736" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="367882736" 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:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="840001932" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="840001932" 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:06 -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 100/115] KVM: TDX: Handle TDG.VP.VMCALL hypercall Date: Tue, 25 Jul 2023 15:14:51 -0700 Message-Id: <590ced75e0bf1b003b755adfeac8622653d7e321.1690322424.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.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 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 77052f49481a..639fab4fc2cb 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -1236,6 +1236,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)) @@ -1254,6 +1268,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