Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1174214rbb; Mon, 26 Feb 2024 00:37:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVdKlQvxTeRGb9TSgoQucRU2kEaym81Mciu/q9GkojNoH/bU3bILLu3gU82yEejAb7vk38FwBTmHq20/mO5+POwpPycmn1CF9sqPvNdXg== X-Google-Smtp-Source: AGHT+IFD58dq5fjzH3P07vB6jWqHCRtWejKZEn7JzlARbrgm3+I7ux58l1ygrzRGsd1cU4Qo9jsA X-Received: by 2002:a05:6808:2014:b0:3bf:db6a:7614 with SMTP id q20-20020a056808201400b003bfdb6a7614mr8861272oiw.42.1708936626917; Mon, 26 Feb 2024 00:37:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708936626; cv=pass; d=google.com; s=arc-20160816; b=GeBHAi0ezsUo2ZCTS2Re7RF1ccDLYBzYojyY7YMYTTxQ07K3RxckdEOZVGGNVVrLKc AwIA7h93p0GmpMYpDqUAtZ2h1UvWreZVgs3QPUthL0a5jqONRSMTuK6jxp38vr1KyaWt OFipDqtZI2zKzjT06gs6GnLqPYsaAyadywOU9BLl2AU5xHERDxiLgjEZeKPmf2W+qZ25 SDpdzSIESmuH/hISRI7FvOMo+n2EhXRpl+ED5yW396qqSoZicbKCpZ+fB82q1X+7ZOPQ GeTBgwsAJOfckyKv7dwbMcHoM3f85ejgQ77ZV6R9TGstvmxySaPn/HO7qLnmQBddFcSu mVHw== 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=Ovg94j4lRnaBQGNP0d/jPJwTx+foEsFv81HPxbogDBI=; fh=MhYZeJruOafeCklHQYl43SwBtxg04z9TFEPCHBXCB1c=; b=VZzyfqU5M5lpCjlkibO4xzT88rUIx+P2kHOBqUE1kvQWxzOaD0ewYlDmhIH0BMZbD5 s7cqrsuok+b2iUiOuJfW5MgfRlaj3N1i443YDA5KmmKEjuzzoJz3jHaQjWktwMO+VTAO 5ssVZcjiLyr1C4/eSVC40YacxAzXfJk1zv6SQ2NGjIH5hTtMgeKZMvI4szvLpr5ZK4xy YRu4ZRMHuLqAu5TyzqlkGretD9TqpbF0ZxQ0HULtiH/NoXl7qnZ/lmBcgIeOIxSCAl7T 7aM23K6DCf+Krcz2y1xq2Kdx8lN8aj6AaSDWMH36NMbI4T+QFmXPtbq5XDBDX4bCEQCu 7m6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JA1wXDvu; 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-80789-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80789-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s18-20020a056a0008d200b006e46189a572si3430237pfu.18.2024.02.26.00.37.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 00:37:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80789-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JA1wXDvu; 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-80789-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80789-linux.lists.archive=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 896B028129F for ; Mon, 26 Feb 2024 08:37:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A4AF5822A; Mon, 26 Feb 2024 08:28:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="JA1wXDvu" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 9FD265646E; Mon, 26 Feb 2024 08:27:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708936078; cv=none; b=ZDK+8rCkIf44HCxRSQosSTmb1aV8fYuMzv2d4BPcGAd7+QdJmAyK/zH0ISrdQpZY+KjRbWGsGSP6iCdilmUmWzA8AVeNQl4vRanyz58W6n/pPRUwrLNr/5e8RXcCFULiHDmdncw88QMeNesH4uCsSyaUmq0N8McLqrGbaZQiwCw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708936078; c=relaxed/simple; bh=yABnwpyEKSvL9YUubu3fELC/Z5Mahr2JAsazFYhrkAc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JhXLcLDRNjtZov6/acnpuG4cJGdELFX40z/aKDp7YDWvOtAfNLTD4hbzdmLfILkJg5hMrQkibM7tXsvff0yjrWWM2tdtFCarZa1OiZgQAHmDl0O0Q8tfDJvgw3UXOHqvCPX8bwffK+eHXNLwlMNxcKVd7IlprY+VY0QroYUdY0I= 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=JA1wXDvu; arc=none smtp.client-ip=192.198.163.13 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=1708936076; x=1740472076; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yABnwpyEKSvL9YUubu3fELC/Z5Mahr2JAsazFYhrkAc=; b=JA1wXDvuqhSljIsuFmR6eRgRyMPxYCafCYb4FHyq4EbyBXejITDSS/8R QkB2OM6u+TTmvw+AuvgjdQcm41Reey4rYFiFgv9hpAY+VG9BIE9FIwDb7 WQutphSdYKWlhFL2VQ2zXAJLueJbXDH0hTjWcwuDlMLxLYAKlVKOKM2rV ODbfL53HlUgISovkQvC+1HEQJyWPEoVnf4u6V8/UlRAW0j2Y2XXjSG4OA w5rwAyxjgS273vGp5RWMdqs4FF71xp2TT2vCkhATcnvljeOjnTXUAVAvO RKzfQ63nMGOjAvLqswPPWSDEanUrpqxExz30V5/iZIsTzqtAZKERL9huR w==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="6155259" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="6155259" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 00:27:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="6615496" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 00:27:54 -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, Sean Christopherson , Yuan Yao , Xiaoyao Li Subject: [PATCH v19 028/130] KVM: TDX: Add TDX "architectural" error codes Date: Mon, 26 Feb 2024 00:25:30 -0800 Message-Id: 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 Content-Transfer-Encoding: 8bit From: Sean Christopherson Add error codes for the TDX SEAMCALLs both for TDX VMM side for TDH SEAMCALL and TDX guest side for TDG.VP.VMCALL. KVM issues the TDX SEAMCALLs and checks its error code. KVM handles hypercall from the TDX guest and may return an error. So error code for the TDX guest is also needed. TDX SEAMCALL uses bits 31:0 to return more information, so these error codes will only exactly match RAX[63:32]. Error codes for TDG.VP.VMCALL is defined by TDX Guest-Host-Communication interface spec. Signed-off-by: Sean Christopherson Signed-off-by: Isaku Yamahata Reviewed-by: Paolo Bonzini Reviewed-by: Yuan Yao Reviewed-by: Xiaoyao Li --- v19: - Drop TDX_EPT_WALK_FAILED, TDX_EPT_ENTRY_NOT_FREE - Rename TDG_VP_VMCALL_ => TDVMCALL_ to match the existing code - Move TDVMCALL error codes to shared/tdx.h - Added TDX_OPERAND_ID_TDR --- arch/x86/include/asm/shared/tdx.h | 8 +++++++- arch/x86/kvm/vmx/tdx_errno.h | 34 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 arch/x86/kvm/vmx/tdx_errno.h diff --git a/arch/x86/include/asm/shared/tdx.h b/arch/x86/include/asm/shared/tdx.h index fdfd41511b02..28c4a62b7dba 100644 --- a/arch/x86/include/asm/shared/tdx.h +++ b/arch/x86/include/asm/shared/tdx.h @@ -26,7 +26,13 @@ #define TDVMCALL_GET_QUOTE 0x10002 #define TDVMCALL_REPORT_FATAL_ERROR 0x10003 -#define TDVMCALL_STATUS_RETRY 1 +/* + * TDG.VP.VMCALL Status Codes (returned in R10) + */ +#define TDVMCALL_SUCCESS 0x0000000000000000ULL +#define TDVMCALL_RETRY 0x0000000000000001ULL +#define TDVMCALL_INVALID_OPERAND 0x8000000000000000ULL +#define TDVMCALL_TDREPORT_FAILED 0x8000000000000001ULL /* * Bitmasks of exposed registers (with VMM). diff --git a/arch/x86/kvm/vmx/tdx_errno.h b/arch/x86/kvm/vmx/tdx_errno.h new file mode 100644 index 000000000000..5366bf476d2c --- /dev/null +++ b/arch/x86/kvm/vmx/tdx_errno.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* architectural status code for SEAMCALL */ + +#ifndef __KVM_X86_TDX_ERRNO_H +#define __KVM_X86_TDX_ERRNO_H + +#define TDX_SEAMCALL_STATUS_MASK 0xFFFFFFFF00000000ULL + +/* + * TDX SEAMCALL Status Codes (returned in RAX) + */ +#define TDX_NON_RECOVERABLE_VCPU 0x4000000100000000ULL +#define TDX_INTERRUPTED_RESUMABLE 0x8000000300000000ULL +#define TDX_OPERAND_INVALID 0xC000010000000000ULL +#define TDX_OPERAND_BUSY 0x8000020000000000ULL +#define TDX_PREVIOUS_TLB_EPOCH_BUSY 0x8000020100000000ULL +#define TDX_VCPU_NOT_ASSOCIATED 0x8000070200000000ULL +#define TDX_KEY_GENERATION_FAILED 0x8000080000000000ULL +#define TDX_KEY_STATE_INCORRECT 0xC000081100000000ULL +#define TDX_KEY_CONFIGURED 0x0000081500000000ULL +#define TDX_NO_HKID_READY_TO_WBCACHE 0x0000082100000000ULL +#define TDX_FLUSHVP_NOT_DONE 0x8000082400000000ULL +#define TDX_EPT_ENTRY_STATE_INCORRECT 0xC0000B0D00000000ULL + +/* + * TDX module operand ID, appears in 31:0 part of error code as + * detail information + */ +#define TDX_OPERAND_ID_RCX 0x01 +#define TDX_OPERAND_ID_TDR 0x80 +#define TDX_OPERAND_ID_SEPT 0x92 +#define TDX_OPERAND_ID_TD_EPOCH 0xa9 + +#endif /* __KVM_X86_TDX_ERRNO_H */ -- 2.25.1