Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4117267rwb; Sun, 7 Aug 2022 15:32:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR5uHUpouyarggwUCoLbFL3O7PV/YYMlDzbd4bkR/uUD3yzICYqLXJ43+ZRjzqGjav/ET78E X-Received: by 2002:aa7:9813:0:b0:52d:395d:c98d with SMTP id e19-20020aa79813000000b0052d395dc98dmr16264071pfl.55.1659911559238; Sun, 07 Aug 2022 15:32:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659911559; cv=none; d=google.com; s=arc-20160816; b=en8DWkSnrTYVCYoW/hywkGCusBlLW+UR1FFcduk7+bN3eEJLCPrJPz5Jx+vmzDFowX Bvj+PzVerqNJSLB1SMCo5zh4M23THicY+jt/JyMjDZG80OIFDuA/CN7V8ckoqftDFSWo 77Y258rzeRqzxh+f6JY23aYNiWtAZ6mg+hAXxStEDTHvxgw0z1BwGekVLKPKvx3o7lBF bzutBojRpJbYdbwKmJ2xRtuI2Zk60ufO/Vx7pIEIngwz+LLh5g5WlbKfEpP1DLASKJCg BbKNVtQ9meuvhuqqJXBQJ0MaVU6z/tcNZiMOWFoI7DY9GVQ/Ub/rYT2mTenwbiixqV9V L/BQ== 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=bFTnO0tQAiWx1H1oX8xZYrLqZq5+xqRmBsy7xQZkHftWXCW5mencySYtpB2gNBT7pj LsRjK3qNw9EofcGu/lPrzNTccsXCsYT1nw3VXqtyC/N8ZnNnYKNCWjJdp9/F7/vPeZp6 M3ZkQF8xe02x8FBTaTaPr6Ax7FLyAnetaeHLjlJKvOuLYnPyWhCDGQav0XEOZRW75GdQ elm9xDOPxB961Wf+GVb1TfYCxEQPDLV7MKqdicEPUlGvjoBREXtdeeP4kx1rfNbT/mdT HIR7DiEsoDvu9epL5pPxcE3mDcd1L4ioRbGO+19MIDEqNSSMoroiGi/5gX7GAwU33fIR eGjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ed6Zcd2k; 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 l6-20020a655606000000b0041b87f0f512si3777245pgs.469.2022.08.07.15.32.25; Sun, 07 Aug 2022 15:32:39 -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=Ed6Zcd2k; 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 S236057AbiHGWDw (ORCPT + 99 others); Sun, 7 Aug 2022 18:03:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232269AbiHGWCg (ORCPT ); Sun, 7 Aug 2022 18:02:36 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96C586540; 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=5Wv/IPFVTRe4jyjKqgjJvRX4XujCf32I2mYt7uAyjxc=; b=Ed6Zcd2kkZXWi3PARy9Yqs7o/VLRLqojaDzmK1dg9hM3O3YVGRE8sL8Z VrC6+heH1/Qm9vQp6xiZ9R4f0YvszzTMTuiq0GnOrzsOOmMjnXaRc/966 YCtqR69cP/A0zAxsr+UPctSeyYC/OoyczhdgsBkywmBQPomxfvTA8eTsj KgYCOMLvTRp09gn3uXpBDFKHl5ItKhRtuFVrQ7Go0OmVRc4GwMVEwlYLj e45mVrsERniCAIaMTEGAg6b7hr/llXOPOWNWzZysq7/vk5+sYhB9nzhNt mFA8BIYuVDfKePRuugsjdOKOd+SGcqS2WVJfbUfao1tpvnt1H/RuNUydJ w==; X-IronPort-AV: E=McAfee;i="6400,9594,10432"; a="289224073" X-IronPort-AV: E=Sophos;i="5.93,220,1654585200"; d="scan'208";a="289224073" 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:31 -0700 X-IronPort-AV: E=Sophos;i="5.93,220,1654585200"; d="scan'208";a="663682486" 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:31 -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 016/103] KVM: TDX: Add helper functions to print TDX SEAMCALL error Date: Sun, 7 Aug 2022 15:01:01 -0700 Message-Id: <3ae0de7da9fbfab79768a2ad70379991502c6691.1659854790.git.isaku.yamahata@intel.com> 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: 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