Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp305021rwb; Tue, 25 Jul 2023 16:23:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlHPeRe6dGNksaWjIV7VeNAXBYXbdG+BY3he7ASZJ3Yoe6/lQ2FpFSxvSfe6gKKC+gUbTuav X-Received: by 2002:a17:906:7a12:b0:993:ec93:a5ef with SMTP id d18-20020a1709067a1200b00993ec93a5efmr203871ejo.47.1690327403877; Tue, 25 Jul 2023 16:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690327403; cv=none; d=google.com; s=arc-20160816; b=MdppkreBWOvk8nXQ4wTuEQX+yfHjqrNs21eaox/Fji7193EUq3eJ5bLmIZ8dijh5Ym 9dDh/8Od8n7S6AWXEL+uZ0jiOjYsB096FmanxsstgnY7Mj67sZxcwVE5VpjIMBHUx7jf Nqs/TdktETVAXnqpwM6lComfx4/3p7mMKg6yvoIIoifIvqc5kUC3rltmiWCqZEW2X/XT jfIgpuBp4PcUThSaQXxJpTbQsSi6ahL55ZR8I+f1SbmpMBI3GjawGiowuskiXMDOKtBR OvEY2lCyDP74YCF9Znx+ZFCKpjy5UBwEh72S+znLzYfw6hiEvWlpeckx3czY0ksJOHba FUOA== 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=rBJ6Ki6LH7pc3fXJG8aVDGRlaau6kPbRMnmv3DnV/mw=; fh=aHvdLX1Pa61KvQFmeZODM982ht845x7CZ22gIB9kxIo=; b=ZUBYXvItax7uE7FauPYOWP668bgdkb8z0erwRvzvQu1x3dHuvNmzEAxiW7cYuaepX/ pG4M62xcEo57GzufydE/0aWu7Yho5dTy1S8SebgB9UK7ceorFLLnUoBUQR7naEulycSJ gg9gMpJx/27UPI67QFx6+CE9kPYPDtdDEB7eUocx2eh7S6GAcS1R8im83tpoPXrixuAa 5TKqhNvDMRsHKHh7FZ2Ltbp0bo8MWTC2tqVN2Abg0obktrUa7MUheJOqQ7xAYOoX8WVY WQObnhmOAhLoh2Tq+MnebqQ8YUwtx+xGdNZ/m/DNayDhDnVkDHd3Ryc760HE6DeU9MgL j3Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BIkVv5+y; 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 bw1-20020a170906c1c100b00994b9b22346si8344552ejb.887.2023.07.25.16.22.59; Tue, 25 Jul 2023 16:23:23 -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=BIkVv5+y; 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 S231649AbjGYWQW (ORCPT + 99 others); Tue, 25 Jul 2023 18:16:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231324AbjGYWPm (ORCPT ); Tue, 25 Jul 2023 18:15:42 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB30F10D4; Tue, 25 Jul 2023 15:15:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690323341; x=1721859341; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jsnC5w7xoBmZgcR+lzWktph1m0Tek+3YysP7GWy/DeA=; b=BIkVv5+yCqEu8I9XxI9NuM3GwSyLlv8hN6n+XGYVcxp/Ak0+D8lPh1GQ JOkFg1G1kU+E7B2Tpxn4fQWPlVKcm7fltPSMQ2cqr06Hpad+lx+TTA03J r7nKPVA3SnjDH3RJacbOawREOkbvw4P4zZnD6orb/aEol1RpFrgfemfjA GpsROJ/eK6tMbtAeyDWw9D+2XLIIETZaCh0spFANrG6lKcyrAXy/FRNz1 ColuXk+o027o6wpipM3ozzWXGVDAcisUwBCvehZ+H8DPggwchuChVc/NK 6c+z/lVXsocLKjWRuymjjs1rOTrsNtEhoBb9UhSBg3GZGsHG/bnW2e2FL Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="357863074" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="357863074" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:15:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="1056938794" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="1056938794" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:15:19 -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, Sean Christopherson Subject: [PATCH v15 010/115] KVM: TDX: Add TDX "architectural" error codes Date: Tue, 25 Jul 2023 15:13:21 -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.4 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,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: 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 | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 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..56cfd2f558fa --- /dev/null +++ b/arch/x86/kvm/vmx/tdx_errno.h @@ -0,0 +1,40 @@ +/* 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_INVALID 0xC000010000000000ULL +#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