Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2619491rdg; Mon, 16 Oct 2023 09:34:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHmYXOkrOEvnQSGpOBR4ndGV+aE0i9CQrWK7VfMPFzktOCqcTOs5L9m1yfZM3H+TIVoiuJk X-Received: by 2002:a05:6e02:1d9b:b0:34c:b981:52d4 with SMTP id h27-20020a056e021d9b00b0034cb98152d4mr44577163ila.31.1697474041784; Mon, 16 Oct 2023 09:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697474041; cv=none; d=google.com; s=arc-20160816; b=jjjKG39BgrNcD+UyJmXNtvAg45F4fFVWwDkavAorKqRmA2JIUqV9hpMYWUngq/STh/ XDhjsK7ImtR52jaf8C0JiP8gyDl/E5zvA/Tj9eVWcQaYNLHZtoI1Z+Ya27leO7h/KlUa M4g/8WRWOUXY7Q+Fa/dNE3MgqCRyVqOSCvyEyqYw+YxPE4VJku8ML7QVmAR957vr2n9+ ijQzo6dQSm/3rKKqsYORo6nRfPmqVUB4C/UMRlRt5lyT0LRkNA2zguZ/wA63t9o/AGJq eRdIaAk0+VbWcUV2t0IAQzQepqvrf+KLZelOF1vUiLgUTLLd03dsi2RCf5eoo1YmAbP/ nnSg== 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=PmYSUwG0d5hQinPWdSQoix9wjc8e3b+96ppyeSDGdQ8=; fh=lRdU2Q/1zx5DcPdZuWBjshA5VT5Oc9cEhB1tCFiV0Nw=; b=db1bLuZY15pPMiGenEiPz+r0gl7pl/NxxvZAtwI941sOBgNd5vcZbQjxnpwD72zgo8 TRIIUsj9PJdOUgepFIWpvi84yDCr7YRp8AYUuP1+FRi88bXBmaGx6eV5HvX38gDSiPaq HkO/50v/Y11gMQQVInXK06/ogwwFNE2MnK5xU1LqFpQwsMt7OgZXYkVX52kyzHj+S6ui o+No81ra6LPJQkOhRUMf8FlbcocKH5CsMxKi5G4bt83CZ0+xQdiYb64AHSvpmvMjOJnU TRNfKz+x54lIhltMcvDifjN3wnV/487KWNbCGJ4ytLAZnFgLOavC0Wybwthd2IXon/RC GQ9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ElT4HCxL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id y70-20020a638a49000000b005af126df279si6372324pgd.503.2023.10.16.09.34.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 09:34:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ElT4HCxL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 5B5508095F65; Mon, 16 Oct 2023 09:33:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234027AbjJPQdQ (ORCPT + 99 others); Mon, 16 Oct 2023 12:33:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234194AbjJPQcp (ORCPT ); Mon, 16 Oct 2023 12:32:45 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AC30AB; Mon, 16 Oct 2023 09:20:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697473249; x=1729009249; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Xf9JEbEMSZzihI7UxRNf62gli24ANbkgRb0nh8DgInY=; b=ElT4HCxLKMG93KJN1Ba/wlEonSg80QzLelVmMg+dfHzOeCFZlCdPR0aC DwukZemTVO1QB35FTOLaBensB1JwMTzp6G0dLTJIjWILU1pnZx+k9/4ej GITlJJYUY3zyJkBmHZ4oHY6Mzm/HR3S7Nv6qLxJLXGoHaGwzpA6SnbJaO O6oIz9wZAZyqy/h/IS52sv1KUlVTdpdwpWiibUKudaXsSV3B0J9/8R9gH gmQU133Sraz5XgmrHZk2FyzY1aE71QbDBmexJp7yimHmqesY2BoklfPcX E6vb8yIQgUAXKHdG/morCKza+HLfVpeOOQrxgxf6TmDg/VciLZHOiDwHk Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="365825924" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="365825924" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:15:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="1087126003" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087126003" 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; 16 Oct 2023 09:15:26 -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 v16 013/116] KVM: TDX: Add helper functions to print TDX SEAMCALL error Date: Mon, 16 Oct 2023 09:13:25 -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=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 16 Oct 2023 09:33:52 -0700 (PDT) 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..d083c79a2331 --- /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_args *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 a55977626ae3..c9f74b2400a7 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" @@ -57,6 +58,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_args *out); +#endif + static inline u64 tdh_mng_addcx(hpa_t tdr, hpa_t addr) { clflush_cache_range(__va(addr), PAGE_SIZE); -- 2.25.1