Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4102767rwb; Sun, 7 Aug 2022 15:06:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR5XALslIan2R+zBfnVWJJ97+loQ5ZS53hYieoyZ4kAhKhk6IXuHeRqacq8EaS+eu2Q0waao X-Received: by 2002:a63:8048:0:b0:41c:6ab8:8d9f with SMTP id j69-20020a638048000000b0041c6ab88d9fmr13716783pgd.93.1659909962048; Sun, 07 Aug 2022 15:06:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659909962; cv=none; d=google.com; s=arc-20160816; b=SQQ3tTrqyZS16aqCkwKMYVUDM83RHfqsdkDO+EN1rihM9oQca+/M7ufrXMxi6p3Y+j qkjzK9hdP5Ls0oaBTXFLYP1SAD+QSeKZWgWim8RQpbphkU3SEV6wJ2zstq6Cc3gigJM/ FiP9h2izQwtictUgY180rpvx39pmkrq93URnVvtGQ1KUZ7UXZt9hJBDXsW7BgZEQK8rD fa5GWv+0G84xsFJVnuVXTMj0EhRtq9KvU9iR66jXoo3jXRd56Dv568oiQeggtWesJY11 8TkFvXYCmQennr1npqF15Av/lJD24noZdgY1EWoSBq10H2L5eNCZ/TocKgni1oAEalqo OW/w== 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=0EoAKbwCS/SpW+gA4bZNPj75x/vLjCc8KohQn2dSmbI=; b=rTWSiePk0xpoRoNwLAWDrlxhyKGMXU9VDosthuPzBAXAW1ALYY9I+Zty+rBB6yCnPe 7pzG0KxC5PWA5pBx4YHj3mtQGw80Vb3Hzf/MkD7s4XYZUg5noQoV/MN4Or82I+x1VmA0 oncu17nEBgLTMmdIGPgOsNeXA3mmLTKsPbfZgWURPREMdlk/0qWBHdm8ewTJeI3aK8Qp Bb5XE2Th92+B3Y6ZwtS4iHkzgeHK0KFYjIs96OkicuUT+vgqz6qeWeXUgGjN2EaZ1YgE VnSQ7jsAb211qDrOWr674s8GVynjwbGsmRtQq6xdHpgjos+8wyRHl+2LFm6eZYFJj6qX C2jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=W+Y79Ve9; 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 s15-20020a056a00178f00b0051899760d88si3834508pfg.9.2022.08.07.15.05.43; Sun, 07 Aug 2022 15:06:02 -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=W+Y79Ve9; 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 S236177AbiHGWEH (ORCPT + 99 others); Sun, 7 Aug 2022 18:04:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231853AbiHGWCf (ORCPT ); Sun, 7 Aug 2022 18:02:35 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A840647F; Sun, 7 Aug 2022 15:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659909755; x=1691445755; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KEIAjHg+U4wWqFG4QgHIE8RVytQUcfrlVjc5d4iCVrU=; b=W+Y79Ve9eZXKlPxXKWhFv28a59nnSavUkI7qsNIIy5QAaYmeEsg38BiB ct3SjAOLQpdV/esB03CFppNqwE/NCgJaoOMKUwKfkZA7ePqgsbBkAxi7Z 74niIEii+nmFDqW70ngmjJFM1h0oVZGAaLLyoABtdxiGQ/qATACxNzQcf TPSf2YzfXPFxUVYlyoQ76AULnjjTo0KntH4nQwjl3iBp8Yr+w1Y3nH4qO JgA3xwY8QFr5kRqUBeYi3ZZvB1Q2iGwlvTMuzvZESFFh9lg3t35nKu1Z5 vLkoHjj8fDZpc+VfLwp0TiRnj2iHR7bC4QAPFvH9YhVrf9a959nRrqBcY Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10432"; a="289224068" X-IronPort-AV: E=Sophos;i="5.93,220,1654585200"; d="scan'208";a="289224068" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2022 15:02:30 -0700 X-IronPort-AV: E=Sophos;i="5.93,220,1654585200"; d="scan'208";a="663682479" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2022 15:02:30 -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 Subject: [PATCH v8 014/103] KVM: TDX: Add TDX "architectural" error codes Date: Sun, 7 Aug 2022 15:00:59 -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=-5.0 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 | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 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..f2b1c4cc516f --- /dev/null +++ b/arch/x86/kvm/vmx/tdx_errno.h @@ -0,0 +1,37 @@ +/* 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_SEPT 0x92 + +#endif /* __KVM_X86_TDX_ERRNO_H */ -- 2.25.1