Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp683219rdb; Fri, 2 Feb 2024 00:04:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8p3PEUltToUaRpVp4wLFaWuSeWutxla23APDkGou2z3UGhA7CFn2vOTDtMkSDjGwhv+CR X-Received: by 2002:a05:6402:b4d:b0:55e:ef54:1239 with SMTP id bx13-20020a0564020b4d00b0055eef541239mr5369163edb.10.1706861082183; Fri, 02 Feb 2024 00:04:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706861082; cv=pass; d=google.com; s=arc-20160816; b=uAKvFg+Z4cifpzuE6v/v6IsGf9rMIYYsDYO57O/BtyKkFauM9YeGaDtS+zJ+/qq/zs h67J8UExtV1l1mhLoWXLY9TQGeqpbwW6b+OTGmKtnsJwt5gSP95n7VHmj2ZG5Q9ARF2U DA5EaowylmVueLd8YE1m0Vrh/09F3y5qr/BsGxAMZ8/quHVnlyNmpG/sXya2re6ihzxC RlEe97XDKtRgB9NWhNMQ25tjhOs9nDbJ7dOQvWcpEqQl9EZHTKSeV3kaKuMEnu7y9QGW Dcz3bN54Tw2M7RTh3U7AIWQQG6RIWBwpRsRnsIk2YIEYPMzzJ5Vh4JuZ9eEYNgOc0zPV xhoQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=/06yx6vTJYJnW9oWL3G1GuzgVGE5ZWOtHelx4VT/PvU=; fh=4flPRGZ67B3S3O9MY9lpAY2rfup2rXbmbYbApvAzCjM=; b=DtBxy+O6Pow5c+fr55mG/8njEZKAeQtEIHr02svORaqli+UO2cFFM3RNvmre+5gInW GOrk3fI7h2/s55Umx7UnxY/NpsMM9EBQwzwZYmrdvSwtZUXp1N7UxiWZbxqrGZaI4e1y Cz2pkS6euvr0fsnGTULbY9PWDTgt9CzTHZz6aS5Z0Sl5xGOQNb6D8k9RkYxCqD+mFwsm qQiX3furg30OF00gS53/3OKb7kn8CLD5Zia6IF184J5qgmyDtkNg2wRjGcluuoUc8cZK 7sRTcVE4jS+ZXeh8Gnp5nulG0Kl0rck6YV2rwhytbkDEbbLIt9trSeYVYjOWkabs0YqW VCIA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UBttLn8v; 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-49408-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49408-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCX0L0gjbQacZ9tNU30V/vk5zixUXyi3UzGe52r8DoKvYVvUSLgtKaxz7kEZVVM/9/bELBDzJSoTQHUGDMWbmAs514T5qlIUnUdibUFoog== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u12-20020aa7d88c000000b0055ff08a5194si340160edq.147.2024.02.02.00.04.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:04:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49408-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UBttLn8v; 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-49408-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49408-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 am.mirrors.kernel.org (Postfix) with ESMTPS id EA3BF1F2ACC2 for ; Fri, 2 Feb 2024 08:04:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1111C17C91; Fri, 2 Feb 2024 08:04:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UBttLn8v" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 5AC9E17C64; Fri, 2 Feb 2024 08:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706861069; cv=none; b=YnJEciWZYtPlGXhe6B7MESYHMYb/NkKZuLS0jxOer/fAkNDt1dI3JXTqXeTKZsBKyAJ/AamT+Tt+W2epsMuJ6RlldHNM4gAngSR9SC778gs7IFFYnWK9OLmUrVpkA2pjwkmTVUxHzh7hHi2aEg0urx0ro2ni7eaeGjEWjweGZ1g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706861069; c=relaxed/simple; bh=vn1Uy7iLyuBoZC2jtSRfxjt5sl8GxyEeXddLMX+BM7s=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kZ5nriDFjG67VlWjUede0ETq/wCXe2dpiWR16Fk1DGrcn1Q5YoIzOoCmBbyeOQMJcRQp5wkzfD4VzPIVRZDMljCRNRod8XQsEzu0D5pTCkKXyV+dbHF29ykiut18KioHoLwZtkdJ4eo9Hrn/Frgge1jz5VxQeVIDKMV8ENyY3kU= 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=UBttLn8v; arc=none smtp.client-ip=198.175.65.15 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=1706861068; x=1738397068; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=vn1Uy7iLyuBoZC2jtSRfxjt5sl8GxyEeXddLMX+BM7s=; b=UBttLn8vRLNhj50s9wsLyFXzIlmT3nI0a4IuVsERvdkPluq4a9bED7T1 YQMqaCrK/B1Wf+nYcZjI+qIeJFsAClqxmDBtjIl+TGW5sjOoQ5I+50wPI i6yNYAD5c65QeWbr1YrFWK/oCqbzec8F/HLS3shXdY7dYGwY36+keriCV Dh8khYnM+XUvXW2dm+VLVXeVqteKKarzkuxLTBvXCam2nAw+5mu5i9vUx DDbMVsysWaddeOdKuCUTZI1b67BSYMpvbzMiD+ADOo8sHPGZ2tybVK0TO 2q+emsFgl7txjVOeGEVyX0xQyMlVSiJnU5VipTnztuoV+NWVKkIKwHx5e Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10971"; a="3959696" X-IronPort-AV: E=Sophos;i="6.05,237,1701158400"; d="scan'208";a="3959696" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2024 00:04:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10971"; a="962145227" X-IronPort-AV: E=Sophos;i="6.05,237,1701158400"; d="scan'208";a="962145227" Received: from xiaoyaol-hp-g830.ccr.corp.intel.com (HELO [10.93.33.17]) ([10.93.33.17]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2024 00:04:22 -0800 Message-ID: <2e174040-933d-4f54-b5fb-380411b53355@intel.com> Date: Fri, 2 Feb 2024 16:04:17 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v18 013/121] KVM: TDX: Add TDX "architectural" error codes Content-Language: en-US To: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: 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 References: <212f22ed28e43c016607e3c420d7d98910878007.1705965634.git.isaku.yamahata@intel.com> From: Xiaoyao Li In-Reply-To: <212f22ed28e43c016607e3c420d7d98910878007.1705965634.git.isaku.yamahata@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/23/2024 7:52 AM, isaku.yamahata@intel.com wrote: > 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 | 43 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 43 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..7f96696b8e7c > --- /dev/null > +++ b/arch/x86/kvm/vmx/tdx_errno.h > @@ -0,0 +1,43 @@ > +/* 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_WALK_FAILED 0xC0000B0000000000ULL > +#define TDX_EPT_ENTRY_NOT_FREE 0xC0000B0200000000ULL > +#define TDX_EPT_ENTRY_STATE_INCORRECT 0xC0000B0D00000000ULL > + > +/* > + * 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 Same to previous Patch: These should be put in some shared header file, because they are shared with guest TD code. Other than it, Reviewed-by: Xiaoyao Li > +/* > + * 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 */