Received: by 2002:a05:6358:795:b0:dc:4c66:fc3e with SMTP id n21csp1445645rwj; Sun, 30 Oct 2022 00:29:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM60Sh7CVVxk0c5mbVVSxKJuVVySU6oOkhgmY4T9DCloNoWpn+jywUJzpxS51W11NBRNvT1U X-Received: by 2002:a17:90a:e20d:b0:212:ec76:6fc6 with SMTP id a13-20020a17090ae20d00b00212ec766fc6mr8588498pjz.0.1667114955876; Sun, 30 Oct 2022 00:29:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667114955; cv=none; d=google.com; s=arc-20160816; b=BDaEodVXjGEM+KdtyXr/LcGBYdDlDGrgr6mVZ2WfRH/Qg0v+q0/84gpRPHr5940fYT h7wZr+/pgiwkiZHOwqaJKPa+iPUfD7fCKC3ewkhZppAQiwo2FNwU0oQemHYqpkC1sHoC rdHQdtZX14+qQdZ87gmqOYoCuE07gl6H34Hc8iIF4QZXbtHmbzkCvJ7OfX4OjPABLfMH RAAEqtoLRteZDFKvUjt1J+vsUQn6J8xGKFDhDh8kMx0l/74aPtBSaO3olPzhzLE1T7I6 ZVHo74qB6Cx1NFu+NxxawKL206VwYx3MsSaDht5liXlj0N4B/Nl43WCxVIzwB6E8v9oR tz4A== 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=Tbt50/AC+RbPsz2NdLvw4UvTZ3u6J3BtdEo2Ll/Dy7I=; b=G3Y/3ohw/NTPPVCqMCRinee1SEZ6Wi4x4Py1YJ8zAGGnohDjeSHTlW45fBO/jfwYH7 iGb+miw4+7l0UfukxijiXGqXMESIyNaPx4+2vHq/7acoUJLkM4HZY6wFD9ZWDn/eq7yk a8sBFfXaWVsjk7wPEr/K2fSQgWX/83JrYW10ZW6qEumtl5pm8Xsr9KDlLkN7HQjqN1L+ 45PmyfrobNLma3ykTzbl4wnoHPXO2KCmAcmCZ51WrnDpZTtetIt0SSv3QRIo7eC6S7eM YaY3LzBlmsU2SMvG2gIQlX2IgZy1/pWlZKi9qLOsKHIgcqvnmBfRarw418xcpLvycrLK eqAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QwZdbkst; 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 h11-20020a170902f70b00b00186a5b86ea3si4949007plo.50.2022.10.30.00.29.05; Sun, 30 Oct 2022 00:29:15 -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=QwZdbkst; 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 S230054AbiJ3GY6 (ORCPT + 99 others); Sun, 30 Oct 2022 02:24:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229795AbiJ3GYE (ORCPT ); Sun, 30 Oct 2022 02:24:04 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50D5BA8; Sat, 29 Oct 2022 23:24:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667111043; x=1698647043; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rRN5kbq0TqI2b4uCt5j6yH0GqnOcoNEW+tyjQehDDAc=; b=QwZdbkst8sRpUhDBuLCuW1ZfCEpWTFGTOweuEll52rAETzhd/ZjyAi0a IkkL6cZvxhUjVNWgcSkRs3YbVFORk/ollKZ2bA4ffIuxiIScGn2qxQEps 4ISjfty+/KSZQOnWfQ/OGGchNrQagOom48GC0DuVCX6m4LXm2wwaqUWN2 y5+yKk3eK/uxMqFQ0kc2UARI3AhihiclvwJ+tLm4WuU14Wsw4RbdsnnHB i/nBCX9InNU7PinkPB/c0S+KCat9LdzOtDKVFJyeQ8Msm2XIlTnFZOPCo 6bP/PbYyAsUUWS50c0VqB/+SKNFCDcezDxglzWunO+BBJrNfXHonvBCl+ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="395037124" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="395037124" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:23:58 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="878392866" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="878392866" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:23:58 -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 Subject: [PATCH v10 012/108] KVM: TDX: Add helper functions to print TDX SEAMCALL error Date: Sat, 29 Oct 2022 23:22:13 -0700 Message-Id: <752b25882092134bd8d117b3e429227bd5a18567.1667110240.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=-4.9 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 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 | 21 +++++++++++++++++++++ arch/x86/kvm/vmx/tdx_ops.h | 3 +++ 3 files changed, 25 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..574b72d34e1e --- /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_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