From patchwork Mon Feb 26 08:26:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 206449 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1951059dyb; Mon, 26 Feb 2024 01:07:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVuf2lGqBoUk0hCbXip1anKLwbxgXHgMDdLrhZ/e1MPHHtCXwvQJ2Lt7Bb6j7ApN3x38ZDGER2i+V0/DRd/auW6p249Xw== X-Google-Smtp-Source: AGHT+IGUQ7Xp1PNFW2CGEDD6jVMWdLXdEOUS5dR4ryCukKkMn36JMVOaR06UoWPVO6MbB84f7yVN X-Received: by 2002:a17:902:ebcd:b0:1db:bfea:3657 with SMTP id p13-20020a170902ebcd00b001dbbfea3657mr8043891plg.22.1708938443879; Mon, 26 Feb 2024 01:07:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708938443; cv=pass; d=google.com; s=arc-20160816; b=jIfte6d54xwPt9i1bEV40A5+GwMsMKE6EBk+R6j2xyQWAD6yixKFBxD+AonCX2FG0r vqlr4e7C/8o7y26mcbL45rLVr5n6S+2ucGAwZ3FF6h8klzidtzH2pvTSIRG8kEPvum/J wiH8Tikm4NzTHX4X5e5+bbZxE1nrnrPRrYaKQPSZ/SARjRBaBJ8OKRr0Yrx6KXF5M3ag AIRV1UxSVenqX6mHNTE7LRYJjPsASGAxgJbOEsVi9xkI31uX+Cez2uKykD+xeqO2jDgF F0gNZB8JxiCDX0dIcGgWMOH3RQIDTvvN14lqKFZdO9xwrtg+FANMFKTOolyUsLk74pg3 HVyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=whkPdUYh0Nuhak76U1m6TYV4OssivSSTqUL9eXjTSiY=; fh=Itbyk7CEvizIrzGEESCqq3I2tZgG1kc/GkVOa3S7Hsg=; b=PPoWGPX5JlkbDw6vIU2UArGyplQ9n0CYQGh5o2tPINonYslgIJv5GDsfsfFxZKf+f8 PRMyivuteDYjTx3k886KzFlVA6nYgiJM/TIMmogvG+MjpEsB9O9t7nITEdWn1PDP9PMg KNLUoeMU5pKDjKBWUMXeYC1lg6DtRY1SubimGCtrKqjFsy4eAm/udKK8AbnI0c72Jj+D 3GLENXidgfvQ3EMvpYwpXBJrakU5OT/t/huK/oKSOOAMTsGFOEblisEJhXhTVjnQcJtn ctoE08GeMtdbAUP0qNnfLK8IBUu7eUI+XJ6w3zi11RxWLY1CaSMPXLUkFzhM4tvtyCTl 38WA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PsTnVErr; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-80879-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80879-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k10-20020a170902d58a00b001dbcc32fcc4si3313571plh.466.2024.02.26.01.07.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:07:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80879-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PsTnVErr; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-80879-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80879-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B3478284726 for ; Mon, 26 Feb 2024 09:07:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74EBF12E1E5; Mon, 26 Feb 2024 08:29:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="PsTnVErr" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABE6612BF02; Mon, 26 Feb 2024 08:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708936152; cv=none; b=XZ25khyz7FJPH8cWpZ7sdI7s/H1u8yY5rBMcmS0TfUGH8rh1WiQmvr2fnLYavHuMfa3QgwM7+CybCIks4a6AFTegBedqaa6RZYithfrc4Dhs4RgnNn/u67+x7aOLOuEZjRX/epJj6vCu+kRbFKwF0suarvACrPLKXnQtKNyVsYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708936152; c=relaxed/simple; bh=d5xutcnpm9SfZzS14NRBtPoOgUgb4pPOvm9954l6hF0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ErQM5G/+99og1iRH0WAzfIlCMg06VXcSLppdrPnlXWuf9R4qQwiK/4QoqR09MnARZNKHaeg4lYzJGBhHTon4LilS/Gzm6eLlRxWHqrt3ck9OKQYpiEukUvZFzrV8TMdtBzKBvSRLnIKlhyAvgOGMIQvPipJ0Tz1qBMRJKA/EjLc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=PsTnVErr; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708936150; x=1740472150; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=d5xutcnpm9SfZzS14NRBtPoOgUgb4pPOvm9954l6hF0=; b=PsTnVErrMLLtLWHvBolg8GgH3D0CxgetBkbaVR4cdwCTQCas6FdrkEyF xVE8Xz0xRBiNKUeyYLvUp9I//NiYPcy6BDr3XQktS+GwlU0PQMOCiBXKx JApG/kimsgvTIxtYBODo9pQgWXa5lPlD2tsi9uNthehvmYuTjUkoj9teR JT5tK4VZWr5Ey8lKS70MEOi2WaTEhtWKYSQ2aCUUzPACjRlyNnmlNkDLN lyVOwlPWmT3VeBx+ZCqnRLKkkY7k62I/MgW0tSmMhQcQBKtWY05LnPc83 YYgi5LKB0v/J5mGrgagmhG43IyNPf+gikytKml30UHgaYHPHV7eLnZDHf g==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="20751366" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="20751366" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 00:29:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="6735091" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 00:29:07 -0800 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 , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com Subject: [PATCH v19 115/130] KVM: TDX: Handle TDG.VP.VMCALL hypercall Date: Mon, 26 Feb 2024 00:26:57 -0800 Message-Id: <86f5018e3c7a1ab6649f93c8103611b195c1b5d5.1708933498.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791951838094408284 X-GMAIL-MSGID: 1791951838094408284 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 --- v19: - rename TDG_VP_VMCALL_GET_TD_VM_CALL_INFO => TDVMCALL_GET_TD_VM_CALL_INFO --- arch/x86/include/asm/shared/tdx.h | 1 + arch/x86/kvm/vmx/tdx.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/arch/x86/include/asm/shared/tdx.h b/arch/x86/include/asm/shared/tdx.h index 28c4a62b7dba..3e8ce567fde0 100644 --- a/arch/x86/include/asm/shared/tdx.h +++ b/arch/x86/include/asm/shared/tdx.h @@ -22,6 +22,7 @@ #define TDCS_NOTIFY_ENABLES 0x9100000000000010 /* TDX hypercall Leaf IDs */ +#define TDVMCALL_GET_TD_VM_CALL_INFO 0x10000 #define TDVMCALL_MAP_GPA 0x10001 #define TDVMCALL_GET_QUOTE 0x10002 #define TDVMCALL_REPORT_FATAL_ERROR 0x10003 diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index 3481c0b6ef2c..725cb40d0814 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -1353,6 +1353,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, TDVMCALL_INVALID_OPERAND); + else { + tdvmcall_set_return_code(vcpu, TDVMCALL_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)) @@ -1371,6 +1385,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 TDVMCALL_GET_TD_VM_CALL_INFO: + return tdx_get_td_vm_call_info(vcpu); default: break; }