Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3296731pxb; Fri, 12 Feb 2021 14:47:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJw46KkseUPMqkjez4exj2IcdsBMdaKTmMxYEOtomH7BjufTjayUmqyrqz2tFjML7SBr3XAf X-Received: by 2002:a50:e186:: with SMTP id k6mr5423647edl.353.1613170039831; Fri, 12 Feb 2021 14:47:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613170039; cv=none; d=google.com; s=arc-20160816; b=XYu0CcExUvnp7irUCdB7f1jatCl8MTmjQB0+eHZDxLsCNwQX3slDviNt7bTzrb6NjA xsmZ2W1LwDZJiCQtCB+8+CWhf6w71siXYyXu8pfq5AM8v9gt3SJLFtyKd7B16/oNaohg sKHr1Q0zXQz1GpGdmmbt/h/7fgmwZdEZx3J2+Uh42eLdUU/6FKd1aOqvYd3Ydub7aemp TotLg/Baf4pPqC+CIkzmeVElL4DGWPJFNyZe3duR/z8UhzbvBeABJMUx13IVcb9Lu067 0uIll27Ns0mWp2aszr9j51w5Hs5igfjgBHzsEhhnfJziLXWSHbXouhr1u5B8jCtRiVz3 ClWg== 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 :ironport-sdr:ironport-sdr; bh=o/2pE5Uo8yUmGxhG26HjsSRoLhmQS7YASJ8IUivUKIc=; b=xY+AnR727nqYRzetiQVeLTegmyvCtf9wpWcsbYubtQwoCGTYcI/qLram36oxtD9hBs Dhi7Qd8xm76D9WIOGCUEPQlLaET16VZLdWQ5u5P5K/Jgqsitqdc+mvzgucD1kxGXhEXG 8CXCItfdWEAjPjg/N3dKCZcypD37CgCcTpcBsrYjPSe777mIB3J7uiz3zx93kxIRTRh1 DgQisUUd3iEc3TV1uLbEJQVYSBA9I1AfAsnBU6pYu18lvIB0vrdrPANjQcH+7nT/l1e1 dcEZ+ov6TND+RASdQlj98KzYv22Zqg7DRjr3H84Zici1zKkvtPAinmxtJNJ8e1zYvPkB MMXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a17si7109596edn.146.2021.02.12.14.46.56; Fri, 12 Feb 2021 14:47:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232401AbhBLWop (ORCPT + 99 others); Fri, 12 Feb 2021 17:44:45 -0500 Received: from mga03.intel.com ([134.134.136.65]:60252 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232297AbhBLWbs (ORCPT ); Fri, 12 Feb 2021 17:31:48 -0500 IronPort-SDR: O1IcydUjBTRwTsjYuKdMfk+thdguKAS6ws8K5VhP7pufzA2IBwGXfmyE5qLrDdxktOgo4zyBQB /a8O9PealkjA== X-IronPort-AV: E=McAfee;i="6000,8403,9893"; a="182555605" X-IronPort-AV: E=Sophos;i="5.81,174,1610438400"; d="scan'208";a="182555605" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 14:25:58 -0800 IronPort-SDR: r6YZYqlYIvTty3eB86Tikw6LVEBlc0F4Xyl9ql4Ojc9awVKYH45lxFwkZ9J4lMXXmvybRrHcyb VJiJekJ3ko7A== X-IronPort-AV: E=Sophos;i="5.81,174,1610438400"; d="scan'208";a="587605404" Received: from smandal1-mobl2.amr.corp.intel.com (HELO bwidawsk-mobl5.local) ([10.252.133.121]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 14:25:57 -0800 From: Ben Widawsky To: linux-cxl@vger.kernel.org Cc: Ben Widawsky , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, Bjorn Helgaas , Chris Browy , Christoph Hellwig , Dan Williams , David Hildenbrand , David Rientjes , Ira Weiny , Jon Masters , Jonathan Cameron , Rafael Wysocki , Randy Dunlap , Vishal Verma , "John Groves (jgroves)" , "Kelley, Sean V" Subject: [RFC PATCH 9/9] cxl/mem: Add payload dumping for debug Date: Fri, 12 Feb 2021 14:25:41 -0800 Message-Id: <20210212222541.2123505-10-ben.widawsky@intel.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210212222541.2123505-1-ben.widawsky@intel.com> References: <20210212222541.2123505-1-ben.widawsky@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's often useful in debug scenarios to see what the hardware has dumped out. As it stands today, any device error will result in the payload not being copied out, so there is no way to triage commands which weren't expected to fail (and sometimes the payload may have that information). The functionality is protected by normal kernel security mechanisms as well as a CONFIG option in the CXL driver. This was extracted from the original version of the CXL enabling patch series. Signed-off-by: Ben Widawsky --- drivers/cxl/Kconfig | 13 +++++++++++++ drivers/cxl/mem.c | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/cxl/Kconfig b/drivers/cxl/Kconfig index 97dc4d751651..3eec9276e586 100644 --- a/drivers/cxl/Kconfig +++ b/drivers/cxl/Kconfig @@ -50,4 +50,17 @@ config CXL_MEM_RAW_COMMANDS potential impact to memory currently in use by the kernel. If developing CXL hardware or the driver say Y, otherwise say N. + +config CXL_MEM_INSECURE_DEBUG + bool "CXL.mem debugging" + depends on CXL_MEM + help + Enable debug of all CXL command payloads. + + Some CXL devices and controllers support encryption and other + security features. The payloads for the commands that enable + those features may contain sensitive clear-text security + material. Disable debug of those command payloads by default. + If you are a kernel developer actively working on CXL + security enabling say Y, otherwise say N. endif diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index 3bca8451348a..09c11935b824 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -341,6 +341,14 @@ static int __cxl_mem_mbox_send_cmd(struct cxl_mem *cxlm, /* #5 */ rc = cxl_mem_wait_for_doorbell(cxlm); + + if (!cxl_is_security_command(mbox_cmd->opcode) || + IS_ENABLED(CONFIG_CXL_MEM_INSECURE_DEBUG)) { + print_hex_dump_debug("Payload ", DUMP_PREFIX_OFFSET, 16, 1, + mbox_cmd->payload_in, mbox_cmd->size_in, + true); + } + if (rc == -ETIMEDOUT) { cxl_mem_mbox_timeout(cxlm, mbox_cmd); return rc; -- 2.30.0