]> git.itanic.dy.fi Git - linux-stable/commit
cxl/memdev: Fix sanitize vs decoder setup locking
authorDan Williams <dan.j.williams@intel.com>
Thu, 5 Oct 2023 01:35:01 +0000 (18:35 -0700)
committerDan Williams <dan.j.williams@intel.com>
Fri, 6 Oct 2023 07:12:45 +0000 (00:12 -0700)
commit339818380868e34ff2c482db05031bf47a67d609
tree077496106030918f8389fc97c6cd4cb58824a1ab
parent5f2da19714465739da2449253b13ac06cb353a26
cxl/memdev: Fix sanitize vs decoder setup locking

The sanitize operation is destructive and the expectation is that the
device is unmapped while in progress. The current implementation does a
lockless check for decoders being active, but then does nothing to
prevent decoders from racing to be committed. Introduce state tracking
to resolve this race.

This incidentally cleans up unpriveleged userspace from triggering mmio
read cycles by spinning on reading the 'security/state' attribute. Which
at a minimum is a waste since the kernel state machine can cache the
completion result.

Lastly cxl_mem_sanitize() was mistakenly marked EXPORT_SYMBOL() in the
original implementation, but an export was never required.

Fixes: 0c36b6ad436a ("cxl/mbox: Add sanitization handling machinery")
Cc: Davidlohr Bueso <dave@stgolabs.net>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/core/core.h
drivers/cxl/core/hdm.c
drivers/cxl/core/mbox.c
drivers/cxl/core/memdev.c
drivers/cxl/core/port.c
drivers/cxl/core/region.c
drivers/cxl/cxlmem.h
drivers/cxl/pci.c