Received: by 2002:a05:6358:795:b0:dc:4c66:fc3e with SMTP id n21csp1398094rwj; Sat, 29 Oct 2022 23:26:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ypo+neGQcn/B0GOxV1qIEkmkn9YLKLxEo01iaNbt/nECx2ENrJiPk6FSQ25CeZ89T6++V X-Received: by 2002:a17:907:3e87:b0:78d:bb06:9066 with SMTP id hs7-20020a1709073e8700b0078dbb069066mr6970097ejc.387.1667111209032; Sat, 29 Oct 2022 23:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667111209; cv=none; d=google.com; s=arc-20160816; b=MLvNE2BspcJIV22yoiZGAQwBqE76DThgVv2heeuPy6NDNAlvPGhwcwnEUu2D4AnMm+ 1EZEF0gA37PutxRD/Ll/T9jh2p/dAObGgPxZbEX80yD1pUVS3BsgleYq8csxSNH2Egt+ TPsCaeJXcJ3lMquhsHwJajizy8ocoiq6BKXxtQIeTV0gEbdfY5ns9pHG9saK1U48Lwt2 g0P6M8QgNEqMGxB7vSqqtfX2HuRKIqcLg6VaWmp0YyHqGYC93o/w7vPZQ0dCEnp0ZOMQ cKGqTmlNTxXi6FTnXDSViyZhisjGLHfcvw0BaMMLsxSryhrntzmUL0BlPyUmwuiLZ6GU 60uw== 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=38aFb9ID8rQQJAYk3md0CJgUvdADHHBJoraPiF7VRb0=; b=uhFXxli9JwC9UJRbwndKpzijuo8zGBj2oG93gugKniN5NpcK+rToUaPB0lYQHuCm+7 jWxAQ84KKVcExsvHlmgtwAE1/tQi1JRG5tsim6CGnwSU4HLA0z6o//LKXK3uuUSe5pjq gmUHc2A3/Q/50sCs4zRdg7mNQHYlieJkZ34il9KIlUmz/atW0l8sCOflcxmYKmn7FO1u HrDLujWa8aj8OP5Vpx3oBI8F7IJwtPKO5GIEUuWq2ftMgPbDx7YGziXxnd5L3435S4Z1 s0cEZ5HFEyvZu8Iys2jWXybtBeOnXbOu90F++oFF8uvuHBXdvFam184SLakNLJISJIp0 ZddQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ACJqljr6; 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 js2-20020a17090797c200b0078d9f02b452si4615045ejc.861.2022.10.29.23.26.23; Sat, 29 Oct 2022 23:26:49 -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=ACJqljr6; 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 S230007AbiJ3GYo (ORCPT + 99 others); Sun, 30 Oct 2022 02:24:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229782AbiJ3GYD (ORCPT ); Sun, 30 Oct 2022 02:24:03 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B16ABC; Sat, 29 Oct 2022 23:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667111043; x=1698647043; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QafbYPMxQOgi9WthXzffod7HReNCaa9JqivlLmXQmJw=; b=ACJqljr61hFNUbgY/tMRS49oDUKuRTFMlFU9zWyu+LniWF0PSwBxLvdS WcPcfVL7q/I4Yg5ODsmsCyCI8VWcEzPwjdSJPJc26Gcg8LWS6YMUsc0jl 2+jxrh6wQAckgKt5rv+m7hSClFRZ2jXQMzUmL/IXq33FjI5ij5XPQMozF A7kWbU+YlrxFJfxfc4BSMTJRju3VU2u05R3LYK/ZYKW7aKbEqeITTbMsK eAtozbJKy8nltrj8hzbpqPM7tt4gNgQZXmRpEyAR0GxWaFqUakDo9gWNI K6X1KM4AXrTg2pl/1dKKAjnzVV92+UyDPuJyDk2w2bAjo8lj/yONwdmb0 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="395037120" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="395037120" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:23:58 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="878392860" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="878392860" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:23:58 -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 , Sean Christopherson Subject: [PATCH v10 010/108] KVM: TDX: Add TDX "architectural" error codes Date: Sat, 29 Oct 2022 23:22:11 -0700 Message-Id: <679bb45187dc54b82ebc9df5381a7d5de0b782d5.1667110240.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.9 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 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 | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 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..ce246ba62454 --- /dev/null +++ b/arch/x86/kvm/vmx/tdx_errno.h @@ -0,0 +1,38 @@ +/* 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 + +#endif /* __KVM_X86_TDX_ERRNO_H */ -- 2.25.1