Linux Hardening
 help / color / mirror / Atom feed
* [PATCH v5 00/27] DCD: Add support for Dynamic Capacity Devices (DCD)
@ 2024-10-29 20:34 Ira Weiny
  2024-10-29 20:34 ` [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device ira.weiny
  2024-10-30 14:48 ` [PATCH v5 00/27] DCD: Add support for Dynamic Capacity Devices (DCD) Jonathan Cameron
  0 siblings, 2 replies; 13+ messages in thread
From: Ira Weiny @ 2024-10-29 20:34 UTC (permalink / raw)
  To: Dave Jiang, Fan Ni, Jonathan Cameron, Navneet Singh,
	Jonathan Corbet, Andrew Morton
  Cc: Dan Williams, Davidlohr Bueso, Alison Schofield, Vishal Verma,
	Ira Weiny, linux-cxl, linux-doc, nvdimm, linux-kernel,
	Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
	Johannes Thumshirn, Robert Moore, Len Brown, Rafael J. Wysocki,
	linux-acpi, acpica-devel, Li Ming, Jonathan Cameron, Kees Cook,
	Gustavo A. R. Silva, linux-hardening

A git tree of this series can be found here:

	https://github.com/weiny2/linux-kernel/tree/dcd-v4-2024-10-29

Series info
===========

This series has 4 parts:

Patch 1: Add core range_overlaps() function
Patch 2-6: CXL clean up/prelim patches
Patch 7-25: Core DCD support
Patch 26-27: cxl_test support

Background
==========

A Dynamic Capacity Device (DCD) (CXL 3.1 sec 9.13.3) is a CXL memory
device that allows memory capacity within a region to change
dynamically without the need for resetting the device, reconfiguring
HDM decoders, or reconfiguring software DAX regions.

One of the biggest use cases for Dynamic Capacity is to allow hosts to
share memory dynamically within a data center without increasing the
per-host attached memory.

The general flow for the addition or removal of memory is to have an
orchestrator coordinate the use of the memory.  Generally there are 5
actors in such a system, the Orchestrator, Fabric Manager, the Logical
device, the Host Kernel, and a Host User.

Typical work flows are shown below.

Orchestrator      FM         Device       Host Kernel    Host User

    |             |           |            |              |
    |-------------- Create region ----------------------->|
    |             |           |            |              |
    |             |           |            |<-- Create ---|
    |             |           |            |    Region    |
    |<------------- Signal done --------------------------|
    |             |           |            |              |
    |-- Add ----->|-- Add --->|--- Add --->|              |
    |  Capacity   |  Extent   |   Extent   |              |
    |             |           |            |              |
    |             |<- Accept -|<- Accept  -|              |
    |             |   Extent  |   Extent   |              |
    |             |           |            |<- Create --->|
    |             |           |            |   DAX dev    |-- Use memory
    |             |           |            |              |   |
    |             |           |            |              |   |
    |             |           |            |<- Release ---| <-+
    |             |           |            |   DAX dev    |
    |             |           |            |              |
    |<------------- Signal done --------------------------|
    |             |           |            |              |
    |-- Remove -->|- Release->|- Release ->|              |
    |  Capacity   |  Extent   |   Extent   |              |
    |             |           |            |              |
    |             |<- Release-|<- Release -|              |
    |             |   Extent  |   Extent   |              |
    |             |           |            |              |
    |-- Add ----->|-- Add --->|--- Add --->|              |
    |  Capacity   |  Extent   |   Extent   |              |
    |             |           |            |              |
    |             |<- Accept -|<- Accept  -|              |
    |             |   Extent  |   Extent   |              |
    |             |           |            |<- Create ----|
    |             |           |            |   DAX dev    |-- Use memory
    |             |           |            |              |   |
    |             |           |            |<- Release ---| <-+
    |             |           |            |   DAX dev    |
    |<------------- Signal done --------------------------|
    |             |           |            |              |
    |-- Remove -->|- Release->|- Release ->|              |
    |  Capacity   |  Extent   |   Extent   |              |
    |             |           |            |              |
    |             |<- Release-|<- Release -|              |
    |             |   Extent  |   Extent   |              |
    |             |           |            |              |
    |-- Add ----->|-- Add --->|--- Add --->|              |
    |  Capacity   |  Extent   |   Extent   |              |
    |             |           |            |<- Create ----|
    |             |           |            |   DAX dev    |-- Use memory
    |             |           |            |              |   |
    |-- Remove -->|- Release->|- Release ->|              |   |
    |  Capacity   |  Extent   |   Extent   |              |   |
    |             |           |            |              |   |
    |             |           |     (Release Ignored)     |   |
    |             |           |            |              |   |
    |             |           |            |<- Release ---| <-+
    |             |           |            |   DAX dev    |
    |<------------- Signal done --------------------------|
    |             |           |            |              |
    |             |- Release->|- Release ->|              |
    |             |  Extent   |   Extent   |              |
    |             |           |            |              |
    |             |<- Release-|<- Release -|              |
    |             |   Extent  |   Extent   |              |
    |             |           |            |<- Destroy ---|
    |             |           |            |   Region     |
    |             |           |            |              |

Implementation
==============

The series still requires the creation of regions and DAX devices to be
closely synchronized with the Orchestrator and Fabric Manager.  The host
kernel will reject extents if a region is not yet created.  It also
ignores extent release if memory is in use (DAX device created).  These
synchronizations are not anticipated to be an issue with real
applications.

In order to allow for capacity to be added and removed a new concept of
a sparse DAX region is introduced.  A sparse DAX region may have 0 or
more bytes of available space.  The total space depends on the number
and size of the extents which have been added.

Initially it is anticipated that users of the memory will carefully
coordinate the surfacing of additional capacity with the creation of DAX
devices which use that capacity.  Therefore, the allocation of the
memory to DAX devices does not allow for specific associations between
DAX device and extent.  This keeps allocations very similar to existing
DAX region behavior.

To keep the DAX memory allocation aligned with the existing DAX devices
which do not have tags extents are not allowed to have tags.  Future
support for tags is planned.

Great care was taken to keep the extent tracking simple.  Some xarray's
needed to be added but extra software objects were kept to a minimum.

Region extents continue to be tracked as sub-devices of the DAX region.
This ensures that region destruction cleans up all extent allocations
properly.

Some review tags were kept if a patch did not change.

The major functionality of this series includes:

- Getting the dynamic capacity (DC) configuration information from cxl
  devices

- Configuring the DC partitions reported by hardware

- Enhancing the CXL and DAX regions for dynamic capacity support
	a. Maintain a logical separation between hardware extents and
	   software managed region extents.  This provides an
	   abstraction between the layers and should allow for
	   interleaving in the future

- Get hardware extent lists for endpoint decoders upon
  region creation.

- Adjust extent/region memory available on the following events.
        a. Add capacity Events
	b. Release capacity events

- Host response for add capacity
	a. do not accept the extent if:
		If the region does not exist
		or an error occurs realizing the extent
	b. If the region does exist
		realize a DAX region extent with 1:1 mapping (no
		interleave yet)
	c. Support the event more bit by processing a list of extents
	   marked with the more bit together before setting up a
	   response.

- Host response for remove capacity
	a. If no DAX device references the extent; release the extent
	b. If a reference does exist, ignore the request.
	   (Require FM to issue release again.)

- Modify DAX device creation/resize to account for extents within a
  sparse DAX region

- Trace Dynamic Capacity events for debugging

- Add cxl-test infrastructure to allow for faster unit testing
  (See new ndctl branch for cxl-dcd.sh test[1])

- Only support 0 value extent tags

Fan Ni's upstream of Qemu DCD was used for testing.

Remaining work:

	1) Allow mapping to specific extents (perhaps based on
	   label/tag)
	   1a) devise region size reporting based on tags
	2) Interleave support

Possible additional work depending on requirements:

	1) Accept a new extent which extends (but overlaps) an existing
	   extent(s)
	2) Release extents when DAX devices are released if a release
	   was previously seen from the device
	3) Rework DAX device interfaces, memfd has been explored a bit

[1] https://github.com/weiny2/ndctl/tree/dcd-region2-2024-10-01

---
Major Changes in v5:
- Clean up more bit processing with bug fixes
- Add cache flush on extent removal path
- Split out %pra print specifier
	Link: https://lore.kernel.org/all/20241025-cxl-pra-v2-0-123a825daba2@intel.com/
- Split out ACPI flags additions
- Address comments on code format/spelling etc.
- Link to v4: https://patch.msgid.link/20241007-dcd-type2-upstream-v4-0-c261ee6eeded@intel.com

---
Ira Weiny (13):
      range: Add range_overlaps()
      ACPI/CDAT: Add CDAT/DSMAS shared and read only flag values
      dax: Document struct dev_dax_range
      cxl/pci: Delay event buffer allocation
      cxl/hdm: Use guard() in cxl_dpa_set_mode()
      cxl/region: Refactor common create region code
      cxl/cdat: Gather DSMAS data for DCD regions
      cxl/events: Split event msgnum configuration from irq setup
      cxl/pci: Factor out interrupt policy check
      cxl/core: Return endpoint decoder information from region search
      dax/bus: Factor out dev dax resize logic
      tools/testing/cxl: Make event logs dynamic
      tools/testing/cxl: Add DC Regions to mock mem data

Navneet Singh (14):
      cxl/mbox: Flag support for Dynamic Capacity Devices (DCD)
      cxl/mem: Read dynamic capacity configuration from the device
      cxl/core: Separate region mode from decoder mode
      cxl/region: Add dynamic capacity decoder and region modes
      cxl/hdm: Add dynamic capacity size support to endpoint decoders
      cxl/mem: Expose DCD partition capabilities in sysfs
      cxl/port: Add endpoint decoder DC mode support to sysfs
      cxl/region: Add sparse DAX region support
      cxl/mem: Configure dynamic capacity interrupts
      cxl/extent: Process DCD events and realize region extents
      cxl/region/extent: Expose region extent information in sysfs
      dax/region: Create resources on sparse DAX regions
      cxl/region: Read existing extents on region creation
      cxl/mem: Trace Dynamic capacity Event Record

 Documentation/ABI/testing/sysfs-bus-cxl | 125 ++++-
 drivers/cxl/core/Makefile               |   2 +-
 drivers/cxl/core/cdat.c                 |  45 +-
 drivers/cxl/core/core.h                 |  34 +-
 drivers/cxl/core/extent.c               | 500 +++++++++++++++++
 drivers/cxl/core/hdm.c                  | 231 ++++++--
 drivers/cxl/core/mbox.c                 | 610 +++++++++++++++++++-
 drivers/cxl/core/memdev.c               | 128 ++++-
 drivers/cxl/core/port.c                 |  19 +-
 drivers/cxl/core/region.c               | 185 ++++--
 drivers/cxl/core/trace.h                |  65 +++
 drivers/cxl/cxl.h                       | 120 +++-
 drivers/cxl/cxlmem.h                    | 131 ++++-
 drivers/cxl/pci.c                       | 122 ++--
 drivers/dax/bus.c                       | 356 ++++++++++--
 drivers/dax/bus.h                       |   4 +-
 drivers/dax/cxl.c                       |  71 ++-
 drivers/dax/dax-private.h               |  66 ++-
 drivers/dax/hmem/hmem.c                 |   2 +-
 drivers/dax/pmem.c                      |   2 +-
 fs/btrfs/ordered-data.c                 |  10 +-
 include/acpi/actbl1.h                   |   2 +
 include/cxl/event.h                     |  32 ++
 include/linux/ioport.h                  |   3 +
 include/linux/range.h                   |   8 +
 tools/testing/cxl/Kbuild                |   3 +-
 tools/testing/cxl/test/mem.c            | 958 ++++++++++++++++++++++++++++----
 27 files changed, 3502 insertions(+), 332 deletions(-)
---
base-commit: c2ee9f594da826bea183ed14f2cc029c719bf4da
change-id: 20230604-dcd-type2-upstream-0cd15f6216fd

Best regards,
-- 
Ira Weiny <ira.weiny@intel.com>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device
  2024-10-29 20:34 [PATCH v5 00/27] DCD: Add support for Dynamic Capacity Devices (DCD) Ira Weiny
@ 2024-10-29 20:34 ` ira.weiny
  2024-10-30 14:05   ` Jonathan Cameron
                     ` (3 more replies)
  2024-10-30 14:48 ` [PATCH v5 00/27] DCD: Add support for Dynamic Capacity Devices (DCD) Jonathan Cameron
  1 sibling, 4 replies; 13+ messages in thread
From: ira.weiny @ 2024-10-29 20:34 UTC (permalink / raw)
  To: Dave Jiang, Fan Ni, Jonathan Cameron, Navneet Singh,
	Jonathan Corbet, Andrew Morton
  Cc: Dan Williams, Davidlohr Bueso, Alison Schofield, Vishal Verma,
	Ira Weiny, linux-cxl, linux-doc, nvdimm, linux-kernel, Kees Cook,
	Gustavo A. R. Silva, linux-hardening

From: Navneet Singh <navneet.singh@intel.com>

Devices which optionally support Dynamic Capacity (DC) are configured
via mailbox commands.  CXL 3.1 requires the host to issue the Get DC
Configuration command in order to properly configure DCDs.  Without the
Get DC Configuration command DCD can't be supported.

Implement the DC mailbox commands as specified in CXL 3.1 section
8.2.9.9.9 (opcodes 48XXh) to read and store the DCD configuration
information.  Disable DCD if DCD is not supported.  Leverage the Get DC
Configuration command supported bit to indicate if DCD is supported.

Linux has no use for the trailing fields of the Get Dynamic Capacity
Configuration Output Payload (Total number of supported extents, number
of available extents, total number of supported tags, and number of
available tags).  Avoid defining those fields to use the more useful
dynamic C array.

Cc: Li, Ming <ming4.li@intel.com>
Cc: Kees Cook <kees@kernel.org>
Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Navneet Singh <navneet.singh@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Co-developed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
Changes:
[Jonathan/Kees: use __counted_by()]
---
 drivers/cxl/core/mbox.c | 166 +++++++++++++++++++++++++++++++++++++++++++++++-
 drivers/cxl/cxlmem.h    |  64 ++++++++++++++++++-
 drivers/cxl/pci.c       |   4 ++
 3 files changed, 232 insertions(+), 2 deletions(-)

diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
index aac3bfc0d2c3f916dd870b9f8288b24d90fc9974..2c9a9af3dde3a294cde628880066b514b870029f 100644
--- a/drivers/cxl/core/mbox.c
+++ b/drivers/cxl/core/mbox.c
@@ -1168,7 +1168,7 @@ int cxl_dev_state_identify(struct cxl_memdev_state *mds)
 	if (rc < 0)
 		return rc;
 
-	mds->total_bytes =
+	mds->static_bytes =
 		le64_to_cpu(id.total_capacity) * CXL_CAPACITY_MULTIPLIER;
 	mds->volatile_only_bytes =
 		le64_to_cpu(id.volatile_capacity) * CXL_CAPACITY_MULTIPLIER;
@@ -1274,6 +1274,154 @@ int cxl_mem_sanitize(struct cxl_memdev *cxlmd, u16 cmd)
 	return rc;
 }
 
+static int cxl_dc_save_region_info(struct cxl_memdev_state *mds, u8 index,
+				   struct cxl_dc_region_config *region_config)
+{
+	struct cxl_dc_region_info *dcr = &mds->dc_region[index];
+	struct device *dev = mds->cxlds.dev;
+
+	dcr->base = le64_to_cpu(region_config->region_base);
+	dcr->decode_len = le64_to_cpu(region_config->region_decode_length);
+	dcr->decode_len *= CXL_CAPACITY_MULTIPLIER;
+	dcr->len = le64_to_cpu(region_config->region_length);
+	dcr->blk_size = le64_to_cpu(region_config->region_block_size);
+	dcr->dsmad_handle = le32_to_cpu(region_config->region_dsmad_handle);
+	dcr->flags = region_config->flags;
+	snprintf(dcr->name, CXL_DC_REGION_STRLEN, "dc%d", index);
+
+	/* Check regions are in increasing DPA order */
+	if (index > 0) {
+		struct cxl_dc_region_info *prev_dcr = &mds->dc_region[index - 1];
+
+		if ((prev_dcr->base + prev_dcr->decode_len) > dcr->base) {
+			dev_err(dev,
+				"DPA ordering violation for DC region %d and %d\n",
+				index - 1, index);
+			return -EINVAL;
+		}
+	}
+
+	if (!IS_ALIGNED(dcr->base, SZ_256M) ||
+	    !IS_ALIGNED(dcr->base, dcr->blk_size)) {
+		dev_err(dev, "DC region %d invalid base %#llx blk size %#llx\n",
+			index, dcr->base, dcr->blk_size);
+		return -EINVAL;
+	}
+
+	if (dcr->decode_len == 0 || dcr->len == 0 || dcr->decode_len < dcr->len ||
+	    !IS_ALIGNED(dcr->len, dcr->blk_size)) {
+		dev_err(dev, "DC region %d invalid length; decode %#llx len %#llx blk size %#llx\n",
+			index, dcr->decode_len, dcr->len, dcr->blk_size);
+		return -EINVAL;
+	}
+
+	if (dcr->blk_size == 0 || dcr->blk_size % CXL_DCD_BLOCK_LINE_SIZE ||
+	    !is_power_of_2(dcr->blk_size)) {
+		dev_err(dev, "DC region %d invalid block size; %#llx\n",
+			index, dcr->blk_size);
+		return -EINVAL;
+	}
+
+	dev_dbg(dev,
+		"DC region %s base %#llx length %#llx block size %#llx\n",
+		dcr->name, dcr->base, dcr->decode_len, dcr->blk_size);
+
+	return 0;
+}
+
+/* Returns the number of regions in dc_resp or -ERRNO */
+static int cxl_get_dc_config(struct cxl_memdev_state *mds, u8 start_region,
+			     struct cxl_mbox_get_dc_config_out *dc_resp,
+			     size_t dc_resp_size)
+{
+	struct cxl_mbox_get_dc_config_in get_dc = (struct cxl_mbox_get_dc_config_in) {
+		.region_count = CXL_MAX_DC_REGION,
+		.start_region_index = start_region,
+	};
+	struct cxl_mbox_cmd mbox_cmd = (struct cxl_mbox_cmd) {
+		.opcode = CXL_MBOX_OP_GET_DC_CONFIG,
+		.payload_in = &get_dc,
+		.size_in = sizeof(get_dc),
+		.size_out = dc_resp_size,
+		.payload_out = dc_resp,
+		.min_out = 1,
+	};
+	struct device *dev = mds->cxlds.dev;
+	int rc;
+
+	rc = cxl_internal_send_cmd(&mds->cxlds.cxl_mbox, &mbox_cmd);
+	if (rc < 0)
+		return rc;
+
+	dev_dbg(dev, "Read %d/%d DC regions\n",
+		dc_resp->regions_returned, dc_resp->avail_region_count);
+	return dc_resp->regions_returned;
+}
+
+/**
+ * cxl_dev_dynamic_capacity_identify() - Reads the dynamic capacity
+ *					 information from the device.
+ * @mds: The memory device state
+ *
+ * Read Dynamic Capacity information from the device and populate the state
+ * structures for later use.
+ *
+ * Return: 0 if identify was executed successfully, -ERRNO on error.
+ */
+int cxl_dev_dynamic_capacity_identify(struct cxl_memdev_state *mds)
+{
+	size_t dc_resp_size = mds->cxlds.cxl_mbox.payload_size;
+	struct device *dev = mds->cxlds.dev;
+	u8 start_region, i;
+
+	if (!cxl_dcd_supported(mds)) {
+		dev_dbg(dev, "DCD not supported\n");
+		return 0;
+	}
+
+	struct cxl_mbox_get_dc_config_out *dc_resp __free(kfree) =
+					kvmalloc(dc_resp_size, GFP_KERNEL);
+	if (!dc_resp)
+		return -ENOMEM;
+
+	start_region = 0;
+	do {
+		int rc, j;
+
+		rc = cxl_get_dc_config(mds, start_region, dc_resp, dc_resp_size);
+		if (rc < 0) {
+			dev_err(dev, "Failed to get DC config: %d\n", rc);
+			return rc;
+		}
+
+		mds->nr_dc_region += rc;
+
+		if (mds->nr_dc_region < 1 || mds->nr_dc_region > CXL_MAX_DC_REGION) {
+			dev_err(dev, "Invalid num of dynamic capacity regions %d\n",
+				mds->nr_dc_region);
+			return -EINVAL;
+		}
+
+		for (i = start_region, j = 0; i < mds->nr_dc_region; i++, j++) {
+			rc = cxl_dc_save_region_info(mds, i, &dc_resp->region[j]);
+			if (rc)
+				return rc;
+		}
+
+		start_region = mds->nr_dc_region;
+
+	} while (mds->nr_dc_region < dc_resp->avail_region_count);
+
+	mds->dynamic_bytes =
+		mds->dc_region[mds->nr_dc_region - 1].base +
+		mds->dc_region[mds->nr_dc_region - 1].decode_len -
+		mds->dc_region[0].base;
+	dev_dbg(dev, "Total dynamic range: %#llx\n", mds->dynamic_bytes);
+
+	return 0;
+}
+EXPORT_SYMBOL_NS_GPL(cxl_dev_dynamic_capacity_identify, CXL);
+
 static int add_dpa_res(struct device *dev, struct resource *parent,
 		       struct resource *res, resource_size_t start,
 		       resource_size_t size, const char *type)
@@ -1304,8 +1452,15 @@ int cxl_mem_create_range_info(struct cxl_memdev_state *mds)
 {
 	struct cxl_dev_state *cxlds = &mds->cxlds;
 	struct device *dev = cxlds->dev;
+	size_t untenanted_mem;
 	int rc;
 
+	mds->total_bytes = mds->static_bytes;
+	if (mds->nr_dc_region) {
+		untenanted_mem = mds->dc_region[0].base - mds->static_bytes;
+		mds->total_bytes += untenanted_mem + mds->dynamic_bytes;
+	}
+
 	if (!cxlds->media_ready) {
 		cxlds->dpa_res = DEFINE_RES_MEM(0, 0);
 		cxlds->ram_res = DEFINE_RES_MEM(0, 0);
@@ -1315,6 +1470,15 @@ int cxl_mem_create_range_info(struct cxl_memdev_state *mds)
 
 	cxlds->dpa_res = DEFINE_RES_MEM(0, mds->total_bytes);
 
+	for (int i = 0; i < mds->nr_dc_region; i++) {
+		struct cxl_dc_region_info *dcr = &mds->dc_region[i];
+
+		rc = add_dpa_res(dev, &cxlds->dpa_res, &cxlds->dc_res[i],
+				 dcr->base, dcr->decode_len, dcr->name);
+		if (rc)
+			return rc;
+	}
+
 	if (mds->partition_align_bytes == 0) {
 		rc = add_dpa_res(dev, &cxlds->dpa_res, &cxlds->ram_res, 0,
 				 mds->volatile_only_bytes, "ram");
diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h
index e8907c403edbd83c8a36b8d013c6bc3391207ee6..2fb93269ab4359dd12dfb912ded30654e2340be0 100644
--- a/drivers/cxl/cxlmem.h
+++ b/drivers/cxl/cxlmem.h
@@ -403,6 +403,7 @@ enum cxl_devtype {
 	CXL_DEVTYPE_CLASSMEM,
 };
 
+#define CXL_MAX_DC_REGION 8
 /**
  * struct cxl_dpa_perf - DPA performance property entry
  * @dpa_range: range for DPA address
@@ -434,6 +435,8 @@ struct cxl_dpa_perf {
  * @dpa_res: Overall DPA resource tree for the device
  * @pmem_res: Active Persistent memory capacity configuration
  * @ram_res: Active Volatile memory capacity configuration
+ * @dc_res: Active Dynamic Capacity memory configuration for each possible
+ *          region
  * @serial: PCIe Device Serial Number
  * @type: Generic Memory Class device or Vendor Specific Memory device
  * @cxl_mbox: CXL mailbox context
@@ -449,11 +452,23 @@ struct cxl_dev_state {
 	struct resource dpa_res;
 	struct resource pmem_res;
 	struct resource ram_res;
+	struct resource dc_res[CXL_MAX_DC_REGION];
 	u64 serial;
 	enum cxl_devtype type;
 	struct cxl_mailbox cxl_mbox;
 };
 
+#define CXL_DC_REGION_STRLEN 8
+struct cxl_dc_region_info {
+	u64 base;
+	u64 decode_len;
+	u64 len;
+	u64 blk_size;
+	u32 dsmad_handle;
+	u8 flags;
+	u8 name[CXL_DC_REGION_STRLEN];
+};
+
 static inline struct cxl_dev_state *mbox_to_cxlds(struct cxl_mailbox *cxl_mbox)
 {
 	return dev_get_drvdata(cxl_mbox->host);
@@ -473,7 +488,9 @@ static inline struct cxl_dev_state *mbox_to_cxlds(struct cxl_mailbox *cxl_mbox)
  * @dcd_cmds: List of DCD commands implemented by memory device
  * @enabled_cmds: Hardware commands found enabled in CEL.
  * @exclusive_cmds: Commands that are kernel-internal only
- * @total_bytes: sum of all possible capacities
+ * @total_bytes: length of all possible capacities
+ * @static_bytes: length of possible static RAM and PMEM partitions
+ * @dynamic_bytes: length of possible DC partitions (DC Regions)
  * @volatile_only_bytes: hard volatile capacity
  * @persistent_only_bytes: hard persistent capacity
  * @partition_align_bytes: alignment size for partition-able capacity
@@ -483,6 +500,8 @@ static inline struct cxl_dev_state *mbox_to_cxlds(struct cxl_mailbox *cxl_mbox)
  * @next_persistent_bytes: persistent capacity change pending device reset
  * @ram_perf: performance data entry matched to RAM partition
  * @pmem_perf: performance data entry matched to PMEM partition
+ * @nr_dc_region: number of DC regions implemented in the memory device
+ * @dc_region: array containing info about the DC regions
  * @event: event log driver state
  * @poison: poison driver state info
  * @security: security driver state info
@@ -499,6 +518,8 @@ struct cxl_memdev_state {
 	DECLARE_BITMAP(enabled_cmds, CXL_MEM_COMMAND_ID_MAX);
 	DECLARE_BITMAP(exclusive_cmds, CXL_MEM_COMMAND_ID_MAX);
 	u64 total_bytes;
+	u64 static_bytes;
+	u64 dynamic_bytes;
 	u64 volatile_only_bytes;
 	u64 persistent_only_bytes;
 	u64 partition_align_bytes;
@@ -510,6 +531,9 @@ struct cxl_memdev_state {
 	struct cxl_dpa_perf ram_perf;
 	struct cxl_dpa_perf pmem_perf;
 
+	u8 nr_dc_region;
+	struct cxl_dc_region_info dc_region[CXL_MAX_DC_REGION];
+
 	struct cxl_event_state event;
 	struct cxl_poison_state poison;
 	struct cxl_security_state security;
@@ -708,6 +732,32 @@ struct cxl_mbox_set_partition_info {
 
 #define  CXL_SET_PARTITION_IMMEDIATE_FLAG	BIT(0)
 
+/* See CXL 3.1 Table 8-163 get dynamic capacity config Input Payload */
+struct cxl_mbox_get_dc_config_in {
+	u8 region_count;
+	u8 start_region_index;
+} __packed;
+
+/* See CXL 3.1 Table 8-164 get dynamic capacity config Output Payload */
+struct cxl_mbox_get_dc_config_out {
+	u8 avail_region_count;
+	u8 regions_returned;
+	u8 rsvd[6];
+	/* See CXL 3.1 Table 8-165 */
+	struct cxl_dc_region_config {
+		__le64 region_base;
+		__le64 region_decode_length;
+		__le64 region_length;
+		__le64 region_block_size;
+		__le32 region_dsmad_handle;
+		u8 flags;
+		u8 rsvd[3];
+	} __packed region[] __counted_by(regions_retunred);
+	/* Trailing fields unused */
+} __packed;
+#define CXL_DYNAMIC_CAPACITY_SANITIZE_ON_RELEASE_FLAG BIT(0)
+#define CXL_DCD_BLOCK_LINE_SIZE 0x40
+
 /* Set Timestamp CXL 3.0 Spec 8.2.9.4.2 */
 struct cxl_mbox_set_timestamp_in {
 	__le64 timestamp;
@@ -831,6 +881,7 @@ enum {
 int cxl_internal_send_cmd(struct cxl_mailbox *cxl_mbox,
 			  struct cxl_mbox_cmd *cmd);
 int cxl_dev_state_identify(struct cxl_memdev_state *mds);
+int cxl_dev_dynamic_capacity_identify(struct cxl_memdev_state *mds);
 int cxl_await_media_ready(struct cxl_dev_state *cxlds);
 int cxl_enumerate_cmds(struct cxl_memdev_state *mds);
 int cxl_mem_create_range_info(struct cxl_memdev_state *mds);
@@ -844,6 +895,17 @@ void cxl_event_trace_record(const struct cxl_memdev *cxlmd,
 			    enum cxl_event_log_type type,
 			    enum cxl_event_type event_type,
 			    const uuid_t *uuid, union cxl_event *evt);
+
+static inline bool cxl_dcd_supported(struct cxl_memdev_state *mds)
+{
+	return test_bit(CXL_DCD_ENABLED_GET_CONFIG, mds->dcd_cmds);
+}
+
+static inline void cxl_disable_dcd(struct cxl_memdev_state *mds)
+{
+	clear_bit(CXL_DCD_ENABLED_GET_CONFIG, mds->dcd_cmds);
+}
+
 int cxl_set_timestamp(struct cxl_memdev_state *mds);
 int cxl_poison_state_init(struct cxl_memdev_state *mds);
 int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,
diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
index 295779c433b2a2e377995b53a70ff2a3158b0a8e..c8454b3ecea5c053bf9723c275652398c0b2a195 100644
--- a/drivers/cxl/pci.c
+++ b/drivers/cxl/pci.c
@@ -899,6 +899,10 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (rc)
 		return rc;
 
+	rc = cxl_dev_dynamic_capacity_identify(mds);
+	if (rc)
+		cxl_disable_dcd(mds);
+
 	rc = cxl_mem_create_range_info(mds);
 	if (rc)
 		return rc;

-- 
2.47.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device
  2024-10-29 20:34 ` [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device ira.weiny
@ 2024-10-30 14:05   ` Jonathan Cameron
  2024-10-30 16:28     ` Ira Weiny
  2024-10-31  0:24   ` Davidlohr Bueso
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Jonathan Cameron @ 2024-10-30 14:05 UTC (permalink / raw)
  To: ira.weiny
  Cc: Dave Jiang, Fan Ni, Navneet Singh, Jonathan Corbet, Andrew Morton,
	Dan Williams, Davidlohr Bueso, Alison Schofield, Vishal Verma,
	linux-cxl, linux-doc, nvdimm, linux-kernel, Kees Cook,
	Gustavo A. R. Silva, linux-hardening

On Tue, 29 Oct 2024 15:34:43 -0500
ira.weiny@intel.com wrote:

> From: Navneet Singh <navneet.singh@intel.com>
> 
> Devices which optionally support Dynamic Capacity (DC) are configured
> via mailbox commands.  CXL 3.1 requires the host to issue the Get DC
> Configuration command in order to properly configure DCDs.  Without the
> Get DC Configuration command DCD can't be supported.
> 
> Implement the DC mailbox commands as specified in CXL 3.1 section
> 8.2.9.9.9 (opcodes 48XXh) to read and store the DCD configuration
> information.  Disable DCD if DCD is not supported.  Leverage the Get DC
> Configuration command supported bit to indicate if DCD is supported.
> 
> Linux has no use for the trailing fields of the Get Dynamic Capacity
> Configuration Output Payload (Total number of supported extents, number
> of available extents, total number of supported tags, and number of
> available tags).  Avoid defining those fields to use the more useful
> dynamic C array.
> 
> Cc: Li, Ming <ming4.li@intel.com>
> Cc: Kees Cook <kees@kernel.org>
> Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
> Cc: linux-hardening@vger.kernel.org
> Signed-off-by: Navneet Singh <navneet.singh@intel.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Co-developed-by: Ira Weiny <ira.weiny@intel.com>
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
I'll assume you'll fix the typo the bot found.

> +
> +/* See CXL 3.1 Table 8-164 get dynamic capacity config Output Payload */
> +struct cxl_mbox_get_dc_config_out {
> +	u8 avail_region_count;
> +	u8 regions_returned;
> +	u8 rsvd[6];
> +	/* See CXL 3.1 Table 8-165 */
> +	struct cxl_dc_region_config {
> +		__le64 region_base;
> +		__le64 region_decode_length;
> +		__le64 region_length;
> +		__le64 region_block_size;
> +		__le32 region_dsmad_handle;
> +		u8 flags;
> +		u8 rsvd[3];
> +	} __packed region[] __counted_by(regions_retunred);
returned

> +	/* Trailing fields unused */
> +} __packed;

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 00/27] DCD: Add support for Dynamic Capacity Devices (DCD)
  2024-10-29 20:34 [PATCH v5 00/27] DCD: Add support for Dynamic Capacity Devices (DCD) Ira Weiny
  2024-10-29 20:34 ` [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device ira.weiny
@ 2024-10-30 14:48 ` Jonathan Cameron
  2024-10-31 15:55   ` Dave Jiang
  1 sibling, 1 reply; 13+ messages in thread
From: Jonathan Cameron @ 2024-10-30 14:48 UTC (permalink / raw)
  To: Ira Weiny
  Cc: Dave Jiang, Fan Ni, Navneet Singh, Jonathan Corbet, Andrew Morton,
	Dan Williams, Davidlohr Bueso, Alison Schofield, Vishal Verma,
	linux-cxl, linux-doc, nvdimm, linux-kernel, Chris Mason,
	Josef Bacik, David Sterba, linux-btrfs, Johannes Thumshirn,
	Robert Moore, Len Brown, Rafael J. Wysocki, linux-acpi,
	acpica-devel, Li Ming, Kees Cook, Gustavo A. R. Silva,
	linux-hardening

On Tue, 29 Oct 2024 15:34:35 -0500
Ira Weiny <ira.weiny@intel.com> wrote:

> A git tree of this series can be found here:
> 
> 	https://github.com/weiny2/linux-kernel/tree/dcd-v4-2024-10-29
> 
> Series info
> ===========
> 
> This series has 4 parts:
> 
> Patch 1: Add core range_overlaps() function
> Patch 2-6: CXL clean up/prelim patches
> Patch 7-25: Core DCD support
> Patch 26-27: cxl_test support

Other than a few trivial comments and that one build bot reported
issue all looks good to me. Nice work Ira, Navneet etc.

Maybe optimistic to hit 6.13, but I'd love it if it did.
If not, Dave, how about shaving a few off the front so at least
there is less to remember for v6 onwards :)

Jonathan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device
  2024-10-30 14:05   ` Jonathan Cameron
@ 2024-10-30 16:28     ` Ira Weiny
  0 siblings, 0 replies; 13+ messages in thread
From: Ira Weiny @ 2024-10-30 16:28 UTC (permalink / raw)
  To: Jonathan Cameron, ira.weiny
  Cc: Dave Jiang, Fan Ni, Navneet Singh, Jonathan Corbet, Andrew Morton,
	Dan Williams, Davidlohr Bueso, Alison Schofield, Vishal Verma,
	linux-cxl, linux-doc, nvdimm, linux-kernel, Kees Cook,
	Gustavo A. R. Silva, linux-hardening

Jonathan Cameron wrote:
> On Tue, 29 Oct 2024 15:34:43 -0500
> ira.weiny@intel.com wrote:
> 
> > From: Navneet Singh <navneet.singh@intel.com>
> > 
> > Devices which optionally support Dynamic Capacity (DC) are configured
> > via mailbox commands.  CXL 3.1 requires the host to issue the Get DC
> > Configuration command in order to properly configure DCDs.  Without the
> > Get DC Configuration command DCD can't be supported.
> > 
> > Implement the DC mailbox commands as specified in CXL 3.1 section
> > 8.2.9.9.9 (opcodes 48XXh) to read and store the DCD configuration
> > information.  Disable DCD if DCD is not supported.  Leverage the Get DC
> > Configuration command supported bit to indicate if DCD is supported.
> > 
> > Linux has no use for the trailing fields of the Get Dynamic Capacity
> > Configuration Output Payload (Total number of supported extents, number
> > of available extents, total number of supported tags, and number of
> > available tags).  Avoid defining those fields to use the more useful
> > dynamic C array.
> > 
> > Cc: Li, Ming <ming4.li@intel.com>
> > Cc: Kees Cook <kees@kernel.org>
> > Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
> > Cc: linux-hardening@vger.kernel.org
> > Signed-off-by: Navneet Singh <navneet.singh@intel.com>
> > Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Co-developed-by: Ira Weiny <ira.weiny@intel.com>
> > Signed-off-by: Ira Weiny <ira.weiny@intel.com>
> I'll assume you'll fix the typo the bot found.

Already done...  I did not realize my compiler was too old for this
feature.

FWIW:

/*
 * Optional: only supported since gcc >= 15
...

FC40 is still at 14.2.1...  :-/

Ira

> 
> > +
> > +/* See CXL 3.1 Table 8-164 get dynamic capacity config Output Payload */
> > +struct cxl_mbox_get_dc_config_out {
> > +	u8 avail_region_count;
> > +	u8 regions_returned;
> > +	u8 rsvd[6];
> > +	/* See CXL 3.1 Table 8-165 */
> > +	struct cxl_dc_region_config {
> > +		__le64 region_base;
> > +		__le64 region_decode_length;
> > +		__le64 region_length;
> > +		__le64 region_block_size;
> > +		__le32 region_dsmad_handle;
> > +		u8 flags;
> > +		u8 rsvd[3];
> > +	} __packed region[] __counted_by(regions_retunred);
> returned
> 
> > +	/* Trailing fields unused */
> > +} __packed;


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device
  2024-10-29 20:34 ` [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device ira.weiny
  2024-10-30 14:05   ` Jonathan Cameron
@ 2024-10-31  0:24   ` Davidlohr Bueso
  2024-10-31 14:48     ` Ira Weiny
  2024-10-31  1:34   ` Davidlohr Bueso
  2024-11-04 17:09   ` Davidlohr Bueso
  3 siblings, 1 reply; 13+ messages in thread
From: Davidlohr Bueso @ 2024-10-31  0:24 UTC (permalink / raw)
  To: ira.weiny
  Cc: Dave Jiang, Fan Ni, Jonathan Cameron, Navneet Singh,
	Jonathan Corbet, Andrew Morton, Dan Williams, Alison Schofield,
	Vishal Verma, linux-cxl, linux-doc, nvdimm, linux-kernel,
	Kees Cook, Gustavo A. R. Silva, linux-hardening

On Tue, 29 Oct 2024, ira.weiny@intel.com wrote:

>Linux has no use for the trailing fields of the Get Dynamic Capacity
>Configuration Output Payload (Total number of supported extents, number
>of available extents, total number of supported tags, and number of
>available tags).  Avoid defining those fields to use the more useful
>dynamic C array.

More of a general question, if anyone knows: why does the spec define
the fields in that order, and not put the region config structure(s)
at the end, as with all other cmds, afaik.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device
  2024-10-29 20:34 ` [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device ira.weiny
  2024-10-30 14:05   ` Jonathan Cameron
  2024-10-31  0:24   ` Davidlohr Bueso
@ 2024-10-31  1:34   ` Davidlohr Bueso
  2024-10-31 16:00     ` Fan Ni
  2024-11-04 17:09   ` Davidlohr Bueso
  3 siblings, 1 reply; 13+ messages in thread
From: Davidlohr Bueso @ 2024-10-31  1:34 UTC (permalink / raw)
  To: ira.weiny
  Cc: Dave Jiang, Fan Ni, Jonathan Cameron, Navneet Singh,
	Jonathan Corbet, Andrew Morton, Dan Williams, Alison Schofield,
	Vishal Verma, linux-cxl, linux-doc, nvdimm, linux-kernel,
	Kees Cook, Gustavo A. R. Silva, linux-hardening

On Tue, 29 Oct 2024, ira.weiny@intel.com wrote:

>+/* See CXL 3.1 Table 8-164 get dynamic capacity config Output Payload */
>+struct cxl_mbox_get_dc_config_out {
>+	u8 avail_region_count;
>+	u8 regions_returned;
>+	u8 rsvd[6];
>+	/* See CXL 3.1 Table 8-165 */
>+	struct cxl_dc_region_config {
>+		__le64 region_base;
>+		__le64 region_decode_length;
>+		__le64 region_length;
>+		__le64 region_block_size;
>+		__le32 region_dsmad_handle;
>+		u8 flags;
>+		u8 rsvd[3];
>+	} __packed region[] __counted_by(regions_retunred);
>+	/* Trailing fields unused */
>+} __packed;
>+#define CXL_DYNAMIC_CAPACITY_SANITIZE_ON_RELEASE_FLAG BIT(0)

Fan, is this something qemu wants to support?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device
  2024-10-31  0:24   ` Davidlohr Bueso
@ 2024-10-31 14:48     ` Ira Weiny
  0 siblings, 0 replies; 13+ messages in thread
From: Ira Weiny @ 2024-10-31 14:48 UTC (permalink / raw)
  To: Davidlohr Bueso, ira.weiny
  Cc: Dave Jiang, Fan Ni, Jonathan Cameron, Navneet Singh,
	Jonathan Corbet, Andrew Morton, Dan Williams, Alison Schofield,
	Vishal Verma, linux-cxl, linux-doc, nvdimm, linux-kernel,
	Kees Cook, Gustavo A. R. Silva, linux-hardening

Davidlohr Bueso wrote:
> On Tue, 29 Oct 2024, ira.weiny@intel.com wrote:
> 
> >Linux has no use for the trailing fields of the Get Dynamic Capacity
> >Configuration Output Payload (Total number of supported extents, number
> >of available extents, total number of supported tags, and number of
> >available tags).  Avoid defining those fields to use the more useful
> >dynamic C array.
> 
> More of a general question, if anyone knows: why does the spec define
> the fields in that order, and not put the region config structure(s)
> at the end, as with all other cmds, afaik.

Because the 3.0 spec only left 7 bytes of reserved space before the region
config structure array.  One might argue that no one would ever implement
the 3.0 spec for DCD but at the time it was seen as an unbreakable
structure.

While it is not impossible to utilize those fields they are not required
right now.  So in this implementation it was better to use the dynamic C
array's and leave the use of those fields for another day.

Ira

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 00/27] DCD: Add support for Dynamic Capacity Devices (DCD)
  2024-10-30 14:48 ` [PATCH v5 00/27] DCD: Add support for Dynamic Capacity Devices (DCD) Jonathan Cameron
@ 2024-10-31 15:55   ` Dave Jiang
  0 siblings, 0 replies; 13+ messages in thread
From: Dave Jiang @ 2024-10-31 15:55 UTC (permalink / raw)
  To: Jonathan Cameron, Ira Weiny
  Cc: Fan Ni, Navneet Singh, Jonathan Corbet, Andrew Morton,
	Dan Williams, Davidlohr Bueso, Alison Schofield, Vishal Verma,
	linux-cxl, linux-doc, nvdimm, linux-kernel, Chris Mason,
	Josef Bacik, David Sterba, linux-btrfs, Johannes Thumshirn,
	Robert Moore, Len Brown, Rafael J. Wysocki, linux-acpi,
	acpica-devel, Li Ming, Kees Cook, Gustavo A. R. Silva,
	linux-hardening



On 10/30/24 7:48 AM, Jonathan Cameron wrote:
> On Tue, 29 Oct 2024 15:34:35 -0500
> Ira Weiny <ira.weiny@intel.com> wrote:
> 
>> A git tree of this series can be found here:
>>
>> 	https://github.com/weiny2/linux-kernel/tree/dcd-v4-2024-10-29
>>
>> Series info
>> ===========
>>
>> This series has 4 parts:
>>
>> Patch 1: Add core range_overlaps() function
>> Patch 2-6: CXL clean up/prelim patches
>> Patch 7-25: Core DCD support
>> Patch 26-27: cxl_test support
> 
> Other than a few trivial comments and that one build bot reported
> issue all looks good to me. Nice work Ira, Navneet etc.
> 
> Maybe optimistic to hit 6.13, but I'd love it if it did.
> If not, Dave, how about shaving a few off the front so at least
> there is less to remember for v6 onwards :)

I'd like to take it for 6.13. Just seeing if Dan has any last minute complaints :) We should be able to take 1-6 at least.

> 
> Jonathan


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device
  2024-10-31  1:34   ` Davidlohr Bueso
@ 2024-10-31 16:00     ` Fan Ni
  2024-10-31 22:16       ` Ira Weiny
  0 siblings, 1 reply; 13+ messages in thread
From: Fan Ni @ 2024-10-31 16:00 UTC (permalink / raw)
  To: Davidlohr Bueso
  Cc: ira.weiny, Dave Jiang, Jonathan Cameron, Navneet Singh,
	Jonathan Corbet, Andrew Morton, Dan Williams, Alison Schofield,
	Vishal Verma, linux-cxl, linux-doc, nvdimm, linux-kernel,
	Kees Cook, Gustavo A. R. Silva, linux-hardening

On Wed, Oct 30, 2024 at 06:34:41PM -0700, Davidlohr Bueso wrote:
> On Tue, 29 Oct 2024, ira.weiny@intel.com wrote:
> 
> > +/* See CXL 3.1 Table 8-164 get dynamic capacity config Output Payload */
> > +struct cxl_mbox_get_dc_config_out {
> > +	u8 avail_region_count;
> > +	u8 regions_returned;
> > +	u8 rsvd[6];
> > +	/* See CXL 3.1 Table 8-165 */
> > +	struct cxl_dc_region_config {
> > +		__le64 region_base;
> > +		__le64 region_decode_length;
> > +		__le64 region_length;
> > +		__le64 region_block_size;
> > +		__le32 region_dsmad_handle;
> > +		u8 flags;
> > +		u8 rsvd[3];
> > +	} __packed region[] __counted_by(regions_retunred);
> > +	/* Trailing fields unused */
> > +} __packed;
> > +#define CXL_DYNAMIC_CAPACITY_SANITIZE_ON_RELEASE_FLAG BIT(0)
> 
> Fan, is this something qemu wants to support?
Currently in Qemu the flag is not used, from emulation perspective, I do
not see a good reaon to support it for now. Maybe we will need to support it
later when we consider security?

Fan

-- 
Fan Ni

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device
  2024-10-31 16:00     ` Fan Ni
@ 2024-10-31 22:16       ` Ira Weiny
  0 siblings, 0 replies; 13+ messages in thread
From: Ira Weiny @ 2024-10-31 22:16 UTC (permalink / raw)
  To: Fan Ni, Davidlohr Bueso
  Cc: ira.weiny, Dave Jiang, Jonathan Cameron, Navneet Singh,
	Jonathan Corbet, Andrew Morton, Dan Williams, Alison Schofield,
	Vishal Verma, linux-cxl, linux-doc, nvdimm, linux-kernel,
	Kees Cook, Gustavo A. R. Silva, linux-hardening

Fan Ni wrote:
> On Wed, Oct 30, 2024 at 06:34:41PM -0700, Davidlohr Bueso wrote:
> > On Tue, 29 Oct 2024, ira.weiny@intel.com wrote:
> > 
> > > +/* See CXL 3.1 Table 8-164 get dynamic capacity config Output Payload */
> > > +struct cxl_mbox_get_dc_config_out {
> > > +	u8 avail_region_count;
> > > +	u8 regions_returned;
> > > +	u8 rsvd[6];
> > > +	/* See CXL 3.1 Table 8-165 */
> > > +	struct cxl_dc_region_config {
> > > +		__le64 region_base;
> > > +		__le64 region_decode_length;
> > > +		__le64 region_length;
> > > +		__le64 region_block_size;
> > > +		__le32 region_dsmad_handle;
> > > +		u8 flags;
> > > +		u8 rsvd[3];
> > > +	} __packed region[] __counted_by(regions_retunred);
> > > +	/* Trailing fields unused */
> > > +} __packed;
> > > +#define CXL_DYNAMIC_CAPACITY_SANITIZE_ON_RELEASE_FLAG BIT(0)
> > 
> > Fan, is this something qemu wants to support?
> Currently in Qemu the flag is not used, from emulation perspective, I do
> not see a good reaon to support it for now. Maybe we will need to support it
> later when we consider security?

FWIW I see those fields being more applicable to an FM or orchestrator who is
looking for the devices capabilities.  But I'm unsure how those fields are used
in those connections or if they may need to bubble up on a host implementation.
Regardless I think those fields should be added when a real use for them
arises.  But I wanted to make the comment here so that future implementers know
they were omitted on purpose.

Ira

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device
  2024-10-29 20:34 ` [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device ira.weiny
                     ` (2 preceding siblings ...)
  2024-10-31  1:34   ` Davidlohr Bueso
@ 2024-11-04 17:09   ` Davidlohr Bueso
  2024-11-05  1:53     ` Ira Weiny
  3 siblings, 1 reply; 13+ messages in thread
From: Davidlohr Bueso @ 2024-11-04 17:09 UTC (permalink / raw)
  To: ira.weiny
  Cc: Dave Jiang, Fan Ni, Jonathan Cameron, Navneet Singh,
	Jonathan Corbet, Andrew Morton, Dan Williams, Alison Schofield,
	Vishal Verma, linux-cxl, linux-doc, nvdimm, linux-kernel,
	Kees Cook, Gustavo A. R. Silva, linux-hardening

On Tue, 29 Oct 2024, ira.weiny@intel.com wrote:

>+/* See CXL 3.1 Table 8-164 get dynamic capacity config Output Payload */
>+struct cxl_mbox_get_dc_config_out {
>+	u8 avail_region_count;
>+	u8 regions_returned;
>+	u8 rsvd[6];
>+	/* See CXL 3.1 Table 8-165 */
>+	struct cxl_dc_region_config {
>+		__le64 region_base;
>+		__le64 region_decode_length;
>+		__le64 region_length;
>+		__le64 region_block_size;
>+		__le32 region_dsmad_handle;
>+		u8 flags;
>+		u8 rsvd[3];
>+	} __packed region[] __counted_by(regions_retunred);

s/retunred/returned

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device
  2024-11-04 17:09   ` Davidlohr Bueso
@ 2024-11-05  1:53     ` Ira Weiny
  0 siblings, 0 replies; 13+ messages in thread
From: Ira Weiny @ 2024-11-05  1:53 UTC (permalink / raw)
  To: Davidlohr Bueso, ira.weiny
  Cc: Dave Jiang, Fan Ni, Jonathan Cameron, Navneet Singh,
	Jonathan Corbet, Andrew Morton, Dan Williams, Alison Schofield,
	Vishal Verma, linux-cxl, linux-doc, nvdimm, linux-kernel,
	Kees Cook, Gustavo A. R. Silva, linux-hardening

Davidlohr Bueso wrote:
> On Tue, 29 Oct 2024, ira.weiny@intel.com wrote:
> 
> >+/* See CXL 3.1 Table 8-164 get dynamic capacity config Output Payload */
> >+struct cxl_mbox_get_dc_config_out {
> >+	u8 avail_region_count;
> >+	u8 regions_returned;
> >+	u8 rsvd[6];
> >+	/* See CXL 3.1 Table 8-165 */
> >+	struct cxl_dc_region_config {
> >+		__le64 region_base;
> >+		__le64 region_decode_length;
> >+		__le64 region_length;
> >+		__le64 region_block_size;
> >+		__le32 region_dsmad_handle;
> >+		u8 flags;
> >+		u8 rsvd[3];
> >+	} __packed region[] __counted_by(regions_retunred);
> 
> s/retunred/returned

Thanks.

The bots caught that too since my compiler was too old to test it.

Ira

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-11-05  1:53 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-29 20:34 [PATCH v5 00/27] DCD: Add support for Dynamic Capacity Devices (DCD) Ira Weiny
2024-10-29 20:34 ` [PATCH v5 08/27] cxl/mem: Read dynamic capacity configuration from the device ira.weiny
2024-10-30 14:05   ` Jonathan Cameron
2024-10-30 16:28     ` Ira Weiny
2024-10-31  0:24   ` Davidlohr Bueso
2024-10-31 14:48     ` Ira Weiny
2024-10-31  1:34   ` Davidlohr Bueso
2024-10-31 16:00     ` Fan Ni
2024-10-31 22:16       ` Ira Weiny
2024-11-04 17:09   ` Davidlohr Bueso
2024-11-05  1:53     ` Ira Weiny
2024-10-30 14:48 ` [PATCH v5 00/27] DCD: Add support for Dynamic Capacity Devices (DCD) Jonathan Cameron
2024-10-31 15:55   ` Dave Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox