drivers/cxl/pmem.c | 7 +++++++ tools/testing/cxl/test/mem.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-)
Background
==========
In Qemu environment, the default serial number of cxl-type3 device
is UI64_NULL. But we could still use it to create a nvdimm pmem region
and set a non-zero cookie of nd_interleave_set, for example:
1. create a cxl pmem region interleaved with 2 devices (one with
serial number 0 and the other with serial number 1), and the cookie
would be non-zero/valid.
2. create the second cxl pmem region by 1 device with no serial number
and this region would have a non-zero cookie because the offset of
dpa is non-zero.
Problem
=======
In a nvdimm interleave-set each device with an invalid or zero
serial number may cause pmem region initialization to fail, but in
cxl case such device could still set cookies of nd_interleave_set
and create a nvdimm pmem region.
CXL Pmem Validation
===================
This patch adds the validation of serial number in cxl pmem region creation.
The event of no serial number would cause to fail to set the cookie
and pmem region.
cxl-test
========
A mock serial number is set from the platform device id and 0 is a valid
platform device id. For cxl-test to work properly, always +1 on mock
device's serial number.
Yuquan Wang (1):
cxl/pmem: debug invalid serial number data
drivers/cxl/pmem.c | 7 +++++++
tools/testing/cxl/test/mem.c | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
--
2.34.1
On Fri, 14 Feb 2025 11:09:51 +0800 Yuquan Wang <wangyuquan1236@phytium.com.cn> wrote: > Background > ========== > In Qemu environment, the default serial number of cxl-type3 device > is UI64_NULL. Doesn't matter but technically it's just not presented by QEMU unless specified. The internal default is UI64_NULL but if we match that when creating the config space stuff we just skip the serial number capability. I'm glad to see some hardening around this as I ran into same thing long ago (that's when I realized we were missing serial number support :( Jonathan > But we could still use it to create a nvdimm pmem region > and set a non-zero cookie of nd_interleave_set, for example: > 1. create a cxl pmem region interleaved with 2 devices (one with > serial number 0 and the other with serial number 1), and the cookie > would be non-zero/valid. > 2. create the second cxl pmem region by 1 device with no serial number > and this region would have a non-zero cookie because the offset of > dpa is non-zero. > > Problem > ======= > In a nvdimm interleave-set each device with an invalid or zero > serial number may cause pmem region initialization to fail, but in > cxl case such device could still set cookies of nd_interleave_set > and create a nvdimm pmem region. > > CXL Pmem Validation > =================== > This patch adds the validation of serial number in cxl pmem region creation. > The event of no serial number would cause to fail to set the cookie > and pmem region. > > cxl-test > ======== > A mock serial number is set from the platform device id and 0 is a valid > platform device id. For cxl-test to work properly, always +1 on mock > device's serial number. > > Yuquan Wang (1): > cxl/pmem: debug invalid serial number data > > drivers/cxl/pmem.c | 7 +++++++ > tools/testing/cxl/test/mem.c | 2 +- > 2 files changed, 8 insertions(+), 1 deletion(-) >
© 2016 - 2025 Red Hat, Inc.