Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp277653rwb; Tue, 25 Jul 2023 15:58:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlHgWnjFEIHhIdpumzG2/AvSFh9pCR1LolIoBqNKOuhhCPcZtxONJMwAhdW/lIG/5Uk5E9Yg X-Received: by 2002:a17:90a:5185:b0:268:36a2:bd0 with SMTP id u5-20020a17090a518500b0026836a20bd0mr459936pjh.8.1690325902400; Tue, 25 Jul 2023 15:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690325902; cv=none; d=google.com; s=arc-20160816; b=QVbuJQzjn8AZQv0hY8y8T6zjTGnTGuyMzR1YbA29a5LQrECJwxRoYZE/a3Vs7DggJj cc18rmPVhn/c9kAaXgIqS7U7eZvWsJcmaddX5UQi+Vck5kt2t5lvFDQ7SIrMWgUxQNJo 9YqVV19uRS4YsHCLTiu+BTOhTIdvnYucEjApSP5GBFTn1BnjiNKhhj8wP0zdAFSJlPbK yEK3/tYBzKkcgTuhfKdfEc21Vy97lO0aC96XrZhB5iaf9M7NEZ1N7aSRlzOEfXabQW+G l/1Rtkz+p2eb+/xRXEtbSz07gpUXXlXiSKl1kdTXP7haTPtZ7UPWH0wzLd/1/izz+Chw QoaA== 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=lG5lE0d/GsHNYQ5a+dMURrbrb90N/f5EOfJrxxWxDg8=; fh=juxwNcA6iKwLISFgUCNwdoIYC0NKLUseq3xZdq25RR4=; b=huogrKn+m3aDKR5zAe+x7904XL5Xop0NDrXZepyA9a6DZwHxDPRNVPuqG8vGGpORw2 BQAubJQrN0dp1x3wFxM+qnU3Re3rEDXrBpMCjVXUM0vYvWPlfPb8Fc/p+FbQGASYNd49 93xuqYV8S3npKKL1Iq3vCQOe/3rABb6XHHhIgfUETNf5l1iOKeKD60fwMISW7gY9HPek 4VeANQ4jC8bZQNKORqAccOGjtLHgWaMxw8jfWd6zovC/OThU8jlQber3F7KLDd9aTqvr 8VciWf5JDzOQR1+HEnt3PsAHmunAJ0ecC6c3J2JhrY23Aqa7V4kyJRU7ZeVFzYeGVpxl e8TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hORLSQlR; 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 q100-20020a17090a1b6d00b0026806ed3fd8si145238pjq.71.2023.07.25.15.58.09; Tue, 25 Jul 2023 15:58:22 -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=hORLSQlR; 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 S232272AbjGYWQu (ORCPT + 99 others); Tue, 25 Jul 2023 18:16:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231414AbjGYWPn (ORCPT ); Tue, 25 Jul 2023 18:15:43 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DDCBBC; Tue, 25 Jul 2023 15:15:41 -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=JMtVpqNAMjI4Ci0bJaSt8eNsqbuL48mvNaWm2+I8CxI=; b=hORLSQlRMTfETKEdi7pCzQ1BVE4mFrY8X0UkjPrN3y/Z7qQFFXqcQR58 fvOBMbBg4nuWZHJtrhQ7iaR+wk8eLJKEr+eiazN92CiPnVfKw5z9zhRD8 gMTZld0KzrworPRwCpvNjOJYCClYzYJZZ6ShBNMzdbc4Z4nsfG39LPt6M epQCEyh5TFXlJYocvVl7ZJMNrD+32Iaov5tA4iOiwW5uDo/PqZwDw6nC7 FtusNRvOe1mZWxK6RV/LztuqY+UIWwJVVZtuuCMnv20Lmm31UJJ2c/mZM bI90nwdqU5BG+pMKM+Nauw0zs9jL50YEDgf2nxAMWwtrBJz5vFT5eSZXQ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="357863093" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="357863093" 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:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="1056938806" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="1056938806" 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:20 -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 Subject: [PATCH v15 013/115] KVM: TDX: Add helper functions to print TDX SEAMCALL error Date: Tue, 25 Jul 2023 15:13:24 -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: Isaku Yamahata Add helper functions to print out errors from the TDX module in a uniform manner. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/Makefile | 2 +- arch/x86/kvm/vmx/tdx_error.c | 20 ++++++++++++++++++++ arch/x86/kvm/vmx/tdx_ops.h | 5 +++++ 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 4b01ab842ab7..e3354b784e10 100644 --- a/arch/x86/kvm/Makefile +++ b/arch/x86/kvm/Makefile @@ -25,7 +25,7 @@ kvm-$(CONFIG_KVM_SMM) += smm.o kvm-intel-y += vmx/vmx.o vmx/vmenter.o vmx/pmu_intel.o vmx/vmcs12.o \ vmx/hyperv.o vmx/nested.o vmx/posted_intr.o vmx/main.o kvm-intel-$(CONFIG_X86_SGX_KVM) += vmx/sgx.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 svm/hyperv.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..6459cbada713 --- /dev/null +++ b/arch/x86/kvm/vmx/tdx_error.c @@ -0,0 +1,20 @@ +// 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_output *out) +{ + if (!out) { + pr_err_ratelimited("SEAMCALL[%lld] failed: 0x%llx\n", + op, error_code); + return; + } + +#define MSG "SEAMCALL[%lld] failed: 0x%llx RCX 0x%llx RDX 0x%llx R8 0x%llx R9 0x%llx R10 0x%llx R11 0x%llx\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 d588a5507f5a..9db19c0711a9 100644 --- a/arch/x86/kvm/vmx/tdx_ops.h +++ b/arch/x86/kvm/vmx/tdx_ops.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "tdx_errno.h" #include "tdx_arch.h" @@ -41,6 +42,10 @@ static inline u64 tdx_seamcall(u64 op, u64 rcx, u64 rdx, u64 r8, u64 r9, return ret; } +#ifdef CONFIG_INTEL_TDX_HOST +void pr_tdx_error(u64 op, u64 error_code, const struct tdx_module_output *out); +#endif + static inline u64 tdh_mng_addcx(hpa_t tdr, hpa_t addr) { clflush_cache_range(__va(addr), PAGE_SIZE); -- 2.25.1