Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3398201iog; Mon, 27 Jun 2022 15:27:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uQh9xEnDQvedVJMB43tfH8+0yvgqzm0kzDDwU//utKIi49AtIJR57B0TFliHDYfNDaWh2j X-Received: by 2002:a17:906:5344:b0:711:f8fa:f16a with SMTP id j4-20020a170906534400b00711f8faf16amr15233862ejo.638.1656368876169; Mon, 27 Jun 2022 15:27:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656368876; cv=none; d=google.com; s=arc-20160816; b=dyksjpv3SJ41hn9PHydrdjwUEaGHzi9O5MtonT8x8AmFVhXt9VwRF8eW708VCul4bX 2oxnoQs+oRd2qjzJRpwMKgWWuwqcBXnh5K2nlAMzWtKEpAYKXyLHSdrWo7ZvlAPea1cq /S0CyksHz4C2WF6/P82WHEE1YfnexA9RbVoUPD1hoAMTsTffcf6Ckl/iko++GB2OnEQK +VtKkGjGZXdsllf1dFx8Bs2VodQ3Kv4U9wLwlht6goORrEPtkaZLPu4Q5O57hL34vCEg nDlw04smq3z/mj0bwQFFlPgMcIEf3VQyzMZqxoH1ikGa8ZUCYlWe56HAdtqnkgCF2dup eisQ== 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=rjFq2CL3xGj9NG/dG4diA2J7NH7QD0vHJk/dARYk5ww=; b=sZ0g4wfMwqZT8yKCARR43dPWuWCiSNAQ8hlgqeCzeEK3idShKn2Po9WtAGg90bP/34 wTGmUckMRZnkQnAoH8ep9HKwqeUExKjOe5LrGZKluiOmaT5Ayaua7HnRczsn+76kNXOs snj/u5BkFkv5LhYiZ8nrmUXInw4wIm//JlrdtE8Yl42HtT1RvLJDb5BBxKyDnPXxEDHB rAHjkEQPwosE/ag37flEBiQObU/LYz6xlD+U2WaR3d8ptiuLRpOTif3I34E+OtUTW/i6 lWnr8c5Y0Mg6RPCU07MmuDV3FEd4AWlMZypgOymHWxKPjAv7zGv4CbTEXnIaETjnBBvB AJEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Qys/B4J6"; 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 r9-20020a1709062cc900b0071223d9f214si12329447ejr.177.2022.06.27.15.27.31; Mon, 27 Jun 2022 15:27:56 -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="Qys/B4J6"; 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 S241640AbiF0V4J (ORCPT + 99 others); Mon, 27 Jun 2022 17:56:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241301AbiF0Vy4 (ORCPT ); Mon, 27 Jun 2022 17:54:56 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E2CF630C; Mon, 27 Jun 2022 14:54:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656366893; x=1687902893; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5Wv/IPFVTRe4jyjKqgjJvRX4XujCf32I2mYt7uAyjxc=; b=Qys/B4J65u7Xl3DEJWo/NloDpnd1qvCos7ATNf1gTOIh5zd3vRDoPoH0 XBPt5KWTxnpNkBd75ipZUAGGdiJNCpkyOrO1RbLPi9HM86+nDgIeX5r3F rPYRHZ4bi8OYmF7kQjw5nAslfrgiCMAj3ouarmWwzzb7276z4ipVjvPar DD+BJWJw9GOkMugxLgSBA/Jqnlbv0IgABnKklcrKhz/U0ofxiKwEvCXEW X90c+BQXZv6MHWjh/FJJIg4CJk21gFPYAu4eD5Bw/v2/4W76vzfBghaM8 jwVX2ySoZsGelJaoKGtmHRsIKBs9/DXgod/L2EYCp/89xzBZXXgOJc9eu g==; X-IronPort-AV: E=McAfee;i="6400,9594,10391"; a="281609513" X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="281609513" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2022 14:54:50 -0700 X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="657863490" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2022 14:54:50 -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 Subject: [PATCH v7 018/102] KVM: TDX: Add helper functions to print TDX SEAMCALL error Date: Mon, 27 Jun 2022 14:53:10 -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=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: 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 | 22 ++++++++++++++++++++++ arch/x86/kvm/vmx/tdx_ops.h | 3 +++ 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 e2c05195cb95..f1ad445df505 100644 --- a/arch/x86/kvm/Makefile +++ b/arch/x86/kvm/Makefile @@ -24,7 +24,7 @@ kvm-$(CONFIG_KVM_XEN) += xen.o kvm-intel-y += vmx/vmx.o vmx/vmenter.o vmx/pmu_intel.o vmx/vmcs12.o \ vmx/evmcs.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 diff --git a/arch/x86/kvm/vmx/tdx_error.c b/arch/x86/kvm/vmx/tdx_error.c new file mode 100644 index 000000000000..61ed855d1188 --- /dev/null +++ b/arch/x86/kvm/vmx/tdx_error.c @@ -0,0 +1,22 @@ +// 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; + } + + pr_err_ratelimited( + "SEAMCALL[%lld] failed: 0x%llx " + "RCX 0x%llx, RDX 0x%llx, R8 0x%llx, R9 0x%llx, R10 0x%llx, R11 0x%llx\n", + 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 85adbf49c277..8cc2f01c509b 100644 --- a/arch/x86/kvm/vmx/tdx_ops.h +++ b/arch/x86/kvm/vmx/tdx_ops.h @@ -9,12 +9,15 @@ #include #include #include +#include #include "tdx_errno.h" #include "tdx_arch.h" #ifdef CONFIG_INTEL_TDX_HOST +void pr_tdx_error(u64 op, u64 error_code, const struct tdx_module_output *out); + static inline u64 tdh_mng_addcx(hpa_t tdr, hpa_t addr) { clflush_cache_range(__va(addr), PAGE_SIZE); -- 2.25.1