Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2682870rwd; Sun, 28 May 2023 22:07:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6u1vBhT7T/+pQ+pE6EqWuqXrrp30lyet8T6rP2Py5fZSeXXg0eIqra9+fYLZyZSmDQFGhq X-Received: by 2002:a05:6a00:139b:b0:64d:413b:1e1b with SMTP id t27-20020a056a00139b00b0064d413b1e1bmr13162421pfg.23.1685336858961; Sun, 28 May 2023 22:07:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685336858; cv=none; d=google.com; s=arc-20160816; b=Zfwrxjpnetd8tYlIdktK6uhIQzAGz0eXqOBeWA+SP3B86BpjgYxTksk2BRmpT71J5g yCq8FK5Q0b9WPk15bPtJCTu6ylNkWjG9bPF46M7mS1lBXKycTLJx2eojFXPX9Jpst80h jEG25E+YJa5Mtnzt54HqakubTKxggcFjDrfiqEZOy5+LVT7z9vd7Se8a5MJR01yRAPU0 p/rLOuhNNpYM5cLMilKKc7S2ho5a6fWayPa8UeigVJ+cOXATs+d69UAQ4k0oAi3F7NcL HSNvYHallrrxPMd8o9lw4ZMxBXnAX0YIMP7/EoofoFwFyQmPLrdR68ItMzUmMQzSKv+8 dtbw== 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=uMhB+SEuMKMHgnCcw7rSsaNHZUI1MjEoyxgYqSW0RJ0=; b=YUMkbfCWYpUuHYC2+wys73dBurneWkgDqi1A2X8992GpU7vKPBi3QVRfED+xKvCBvN x4ExyA53NqazTiB9bRBYNJw8pzXKsjtg7om4WCbmHBaTyd5X219+WUBoNr7nqKZhSMHQ lIUVe+L7v3Vtn6yFwHPlsGHXr82ZDluPjX7gdk8lLYX6saQq+9eMWyCFh2MOeAiIzqGH UHlhXJ9E5gLfa97NhRqSi0B78Qaih4P3wuL1fBdahxbqxHs6/WHtkdtfJVXP9iBCk5cO 5gWVxblrSTgW0g5YdheVyxxrAUp9Sme/81r+hSPoEFQ/qiTvGokg77GzoyIj5OdQ/6Jx OtFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=k4hxoCo+; 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 c17-20020aa79531000000b0064f4865a125si8948277pfp.8.2023.05.28.22.07.27; Sun, 28 May 2023 22:07:38 -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=k4hxoCo+; 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 S231587AbjE2EVn (ORCPT + 99 others); Mon, 29 May 2023 00:21:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231448AbjE2EUx (ORCPT ); Mon, 29 May 2023 00:20:53 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8528BB; Sun, 28 May 2023 21:20:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685334050; x=1716870050; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SxhIGMvdCJYbDwXmzuj31mHmlnJSEmn2U/OQQ3+C0VM=; b=k4hxoCo+AbbidZrLgoylDmZGPGvRWtyXYMNmWIrz6M9rQHEoMSUo0WDg Tgd5qo0FHCsPKg8TfJy1A9qusumB9MeufvgGLUUBKzgkQh7jd4ztGJlUP C5vS+Q4ER6vrOZbLaHzW0gTC+iE2Lefr/0MDM+ateQdW6w5Lfvsj/RCWe MB9lEhI0Ifjd/qKE+PddUeiVR+M8vJnVIrqwmqUYcCdlLz1HR3ifE2ZfN VrA41nmYe/tAYhSO71nI5n02BJoSoyyoqVJGY9o8KS1jdDbka8TljtBJj dUsv1M+iI7hDQ/qtliEKTGusPztR8RpeW1utx8Dhai/2BnEZz1+VQYn3I Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="418094283" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="418094283" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2023 21:20:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="683419314" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="683419314" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2023 21:20:47 -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, Sean Christopherson Subject: [PATCH v14 010/113] KVM: TDX: Add TDX "architectural" error codes Date: Sun, 28 May 2023 21:18:52 -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=-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, 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: 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 --- arch/x86/kvm/vmx/tdx_errno.h | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 arch/x86/kvm/vmx/tdx_errno.h diff --git a/arch/x86/kvm/vmx/tdx_errno.h b/arch/x86/kvm/vmx/tdx_errno.h new file mode 100644 index 000000000000..7b9161a97160 --- /dev/null +++ b/arch/x86/kvm/vmx/tdx_errno.h @@ -0,0 +1,39 @@ +/* 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_SUCCESS 0x0000000000000000ULL +#define TDX_NON_RECOVERABLE_VCPU 0x4000000100000000ULL +#define TDX_INTERRUPTED_RESUMABLE 0x8000000300000000ULL +#define TDX_OPERAND_BUSY 0x8000020000000000ULL +#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_EPT_WALK_FAILED 0xC0000B0000000000ULL + +/* + * TDG.VP.VMCALL Status Codes (returned in R10) + */ +#define TDG_VP_VMCALL_SUCCESS 0x0000000000000000ULL +#define TDG_VP_VMCALL_RETRY 0x0000000000000001ULL +#define TDG_VP_VMCALL_INVALID_OPERAND 0x8000000000000000ULL +#define TDG_VP_VMCALL_TDREPORT_FAILED 0x8000000000000001ULL + +/* + * 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_SEPT 0x92 +#define TDX_OPERAND_ID_TD_EPOCH 0xa9 + +#endif /* __KVM_X86_TDX_ERRNO_H */ -- 2.25.1