Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1174471rbb; Mon, 26 Feb 2024 00:37:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVvfU/cRq90ApoDQZZsu7IPf2Szs8/bLwKNYn8/ek53qQ94yrnkeWvodrgjFVR92zaQjTMGvZ1nAeN21oeyLqNmKIRLPZQcG95IpJ9Wtw== X-Google-Smtp-Source: AGHT+IHTyQy85/bU+y7YxQdORiq+PU0tme2m2qeJ34v5qr5MqbWjk0U4wwFAWKEjQZfQ4Ggu5Eqt X-Received: by 2002:a25:b499:0:b0:dc7:4806:4fb with SMTP id o25-20020a25b499000000b00dc7480604fbmr4296527ybj.8.1708936659086; Mon, 26 Feb 2024 00:37:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708936659; cv=pass; d=google.com; s=arc-20160816; b=CRa/gQWN00e9nA6BfZzvalJFZz6hFNp/RiWDYdAOgB8x75zjYHQfXGb3XZZbWfXaMb eCxuOvgfvhTwrHxp656DRE57t4oaz0hTY/iiTBqrdS7Z9+lVZLvr/knTVLXmf5kiefuF Tw3GVopiNi1txSxR3rcBvGIDmA+iQ2jm4Rc6rgy6hvBm9824kA6FzRxAaYK+//EDMmHU QnFAWKbqUQNHhlBHUTbRTUk7nhEwNGkfPkZL/otrxCkybBp3eg7+odjJ1CdTSAhWrFY2 OWD9pMB5363Uomkv5XlJ//Hm6S67UMSr0Cw38KXhIpiUg7M1eGgLHTuDmkP7VoKY5jml ugtw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=KhWCs2UAlSeykZlVbAmTd0om7VdhkF1IYbAJv56xhEc=; fh=bayAhP3OId4MccIntuiV/aN2wmKvFK8yyT3oG/Ip6+s=; b=EI9b7Vhb3NYvwtZeny7gHTeRymtjoOEu9kG7wrQ9vxSRV6CWp28j/0e4XxyAoJ91EJ L75V7HIhmIEgvn3Z2pTZYid4pV6b8IwKh0/2vqV/pXKngud7e4wYb2uQmQIUEpmlOnnZ NSMPYznBffZlnH1cZy/UcFQn3yyfJrurXpPyGD7mnePToL12oMveBFgc/HERU3P9hazx LpyaHyqdp/vsQjS65zRHdIknwWEK8a//Wfe59RgjGl5q0JGYdzKMwL0Bz+6Xf8WFZzti rOB1QEGHyoUsc8qG4Hz14qAbkAxRWCOJMkUhWWNZWGJwcK4qbTFUbI1rC9yOUogZHYGX ojow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=J2TPyPea; 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-80790-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80790-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e6-20020ac86706000000b0042e58bb098csi4518197qtp.732.2024.02.26.00.37.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 00:37:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80790-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=J2TPyPea; 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-80790-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80790-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D27A81C202EB for ; Mon, 26 Feb 2024 08:37:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66B5A5914E; Mon, 26 Feb 2024 08:28:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="J2TPyPea" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 0BB275732A; Mon, 26 Feb 2024 08:27:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708936080; cv=none; b=mxLno+P7wfEnjpza4zjjSqdcvDygnB+5dfApbBlO2/CnO4Fpe5j//fPn3huImDIz6N5cLmQoTgzecrDRWh+LoY+jTOD8x/mA2Wvch0e8lgWRfhOF9VzslzrZJjU4s8y0sNG9pnca5ekOM6xCBO0BpUhqFH27GVGKiGi1sIAQeNw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708936080; c=relaxed/simple; bh=YpJuz/yxCnxq5gnhwOF3JBdeNECXepwyhjKiI0Sg8g4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NY3nHis0qg1Kr1i+eqdGj9xKOHKszG8XLerotSAsYvE6pe+ojHABy8IFhvn41wXtS1GDAqIkD4dcST75Owwf+31KXydUzfdubvE1eyy2KwZO4Fl1Ee9WH1cXxfmFCGMPRfWrZlLbGmORatV2v+Qny1a6GV0L4Fj4Z4yDadAjMaA= 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=J2TPyPea; arc=none smtp.client-ip=192.198.163.13 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=1708936078; x=1740472078; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YpJuz/yxCnxq5gnhwOF3JBdeNECXepwyhjKiI0Sg8g4=; b=J2TPyPeaqwKZYXJ0Td5kCkKM1Xphy3gK2luA68a8EwupBvCPGh7UurG8 pBAJlAMiG5q1bjZlmoqxEUDwwRywtptGFC4FGlCkJaN4bUb/fh83xQMG3 baHsFbjoJ9kB3hDutqYPhg5X6kuzBfoGe1VTNanbio+2W3YotSRRJ8snC ULd4c594fG2vtupUBYCFQc2Cc6wijDHhes4nwATqzPHuxH+UMb9PVl9nN KIyj0yCqevSSg2u5/VqfVFgJJ4glvjJiRrGUNSPj7+WgaTqUvwz9cjOWY 7Cjaegdv64l1xflS/00DB1TUc7TOw05B0zonUrRncH+Lf1Hp9lDJ3/KX6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="6155270" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="6155270" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 00:27:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="6615522" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 00:27:55 -0800 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 , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, Binbin Wu , Yuan Yao Subject: [PATCH v19 030/130] KVM: TDX: Add helper functions to print TDX SEAMCALL error Date: Mon, 26 Feb 2024 00:25:32 -0800 Message-Id: <1259755bde3a07ec4dc2c78626fa348cf7323b33.1708933498.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Isaku Yamahata Add helper functions to print out errors from the TDX module in a uniform manner. Signed-off-by: Isaku Yamahata Reviewed-by: Binbin Wu Reviewed-by: Yuan Yao --- v19: - dropped unnecessary include v18: - Added Reviewed-by Binbin. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/Makefile | 2 +- arch/x86/kvm/vmx/tdx_error.c | 21 +++++++++++++++++++++ arch/x86/kvm/vmx/tdx_ops.h | 4 ++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 arch/x86/kvm/vmx/tdx_error.c diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile index 5b85ef84b2e9..44b0594da877 100644 --- a/arch/x86/kvm/Makefile +++ b/arch/x86/kvm/Makefile @@ -24,7 +24,7 @@ kvm-intel-y += vmx/vmx.o vmx/vmenter.o vmx/pmu_intel.o vmx/vmcs12.o \ kvm-intel-$(CONFIG_X86_SGX_KVM) += vmx/sgx.o kvm-intel-$(CONFIG_KVM_HYPERV) += vmx/hyperv.o vmx/hyperv_evmcs.o -kvm-intel-$(CONFIG_INTEL_TDX_HOST) += vmx/tdx.o +kvm-intel-$(CONFIG_INTEL_TDX_HOST) += vmx/tdx.o vmx/tdx_error.o kvm-amd-y += svm/svm.o svm/vmenter.o svm/pmu.o svm/nested.o svm/avic.o \ svm/sev.o diff --git a/arch/x86/kvm/vmx/tdx_error.c b/arch/x86/kvm/vmx/tdx_error.c new file mode 100644 index 000000000000..42fcabe1f6c7 --- /dev/null +++ b/arch/x86/kvm/vmx/tdx_error.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/* functions to record TDX SEAMCALL error */ + +#include +#include + +#include "tdx_ops.h" + +void pr_tdx_error(u64 op, u64 error_code, const struct tdx_module_args *out) +{ + if (!out) { + pr_err_ratelimited("SEAMCALL (0x%016llx) failed: 0x%016llx\n", + op, error_code); + return; + } + +#define MSG \ + "SEAMCALL (0x%016llx) failed: 0x%016llx RCX 0x%016llx RDX 0x%016llx R8 0x%016llx R9 0x%016llx R10 0x%016llx R11 0x%016llx\n" + pr_err_ratelimited(MSG, op, error_code, out->rcx, out->rdx, out->r8, + out->r9, out->r10, out->r11); +} diff --git a/arch/x86/kvm/vmx/tdx_ops.h b/arch/x86/kvm/vmx/tdx_ops.h index c5bb165b260e..d80212b1daf3 100644 --- a/arch/x86/kvm/vmx/tdx_ops.h +++ b/arch/x86/kvm/vmx/tdx_ops.h @@ -40,6 +40,10 @@ static inline u64 tdx_seamcall(u64 op, struct tdx_module_args *in, return ret; } +#ifdef CONFIG_INTEL_TDX_HOST +void pr_tdx_error(u64 op, u64 error_code, const struct tdx_module_args *out); +#endif + static inline u64 tdh_mng_addcx(hpa_t tdr, hpa_t addr) { struct tdx_module_args in = { -- 2.25.1