mbox series

[v2,0/8] QEMU CXL Provide mock CXL events and irq support

Message ID 20221221-ira-cxl-events-2022-11-17-v2-0-2ce2ecc06219@intel.com
Headers show
Series QEMU CXL Provide mock CXL events and irq support | expand

Message

Ira Weiny Dec. 22, 2022, 4:24 a.m. UTC
CXL Event records inform the OS of various CXL device events.  Thus far CXL
memory devices are emulated and therefore don't naturally generate events.

Add an event infrastructure and mock event injection.  Previous versions
included a bulk insertion of lots of events.  However, this series focuses on
providing the ability to inject individual events through QMP.  Only the
General Media Event is included in this series as an example.  Other events can
be added pretty easily once the infrastructure is acceptable.

In addition, this version updates the code to be in line with the
specification based on discussions around the kernel patches.

This series is based on Jonathan's CXL branch here:
https://gitlab.com/jic23/qemu/-/tree/cxl-2022-11-17

Kernel code found here:
https://lore.kernel.org/all/20221212070627.1372402-1-ira.weiny@intel.com/

Previous RFC (V1) version:
https://lore.kernel.org/linux-cxl/20221010222944.3923556-1-ira.weiny@intel.com/

Instructions:

Add qmp option to qemu:

	<host> $ qemu-system-x86_64 ... -qmp unix:/tmp/run_qemu_qmp_0,server,nowait ...

	OR

	<host> $ run_qemu.sh ... --qmp ...

Enable tracing of events within the guest:

	<guest> $ echo "" > /sys/kernel/tracing/trace
	<guest> $ echo 1 > /sys/kernel/tracing/events/cxl/enable
	<guest> $ echo 1 > /sys/kernel/tracing/tracing_on

	OPTIONAL: set up ndctl to monitor for events (events will show up as
		  they are injected)

	<guest> $ <path to ndctl>/cxl monitor

Trigger event generation and interrupts in the host:

	<host> $ qmpcmd="${qemusrcdir}/build/scripts/qmp/qmp-shell /tmp/run_qemu_qmp_0"

	<host> $ echo "cxl-inject-gen-media-event path=cxl-dev0 log=0 flags=1 \
			physaddr=1000 descriptor=127 type=3 transactiontype=192 \
			channel=3 rank=-1 device=5 componentid='Iras mem'" | $qmpcmd

	<Repeat for more events with different values>

View events on the guest:

	<guest> $ cat /sys/kernel/tracing/trace

To: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Michael Tsirkin <mst@redhat.com>
Cc: Ben Widawsky <bwidawsk@kernel.org>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: qemu-devel@nongnu.org
Cc: linux-cxl@vger.kernel.org
Signed-off-by: Ira Weiny <ira.weiny@intel.com>

---
Ira Weiny (8):
      qemu/bswap: Add const_le64()
      qemu/uuid: Add UUID static initializer
      hw/cxl/mailbox: Use new UUID network order define for cel_uuid
      hw/cxl/events: Add event status register
      hw/cxl/events: Wire up get/clear event mailbox commands
      hw/cxl/events: Add event interrupt support
      bswap: Add the ability to store to an unaligned 24 bit field
      hw/cxl/events: Add in inject general media event

 hw/cxl/cxl-device-utils.c   |  54 ++++++++--
 hw/cxl/cxl-events.c         | 252 ++++++++++++++++++++++++++++++++++++++++++++
 hw/cxl/cxl-mailbox-utils.c  | 160 ++++++++++++++++++++++------
 hw/cxl/meson.build          |   1 +
 hw/mem/cxl_type3.c          |  96 ++++++++++++++++-
 hw/mem/cxl_type3_stubs.c    |   8 ++
 include/hw/cxl/cxl_device.h |  56 +++++++++-
 include/hw/cxl/cxl_events.h | 126 ++++++++++++++++++++++
 include/qemu/bswap.h        |  40 +++++++
 include/qemu/uuid.h         |  12 +++
 qapi/cxl.json               |  25 +++++
 11 files changed, 785 insertions(+), 45 deletions(-)
---
base-commit: 1b4133103d20fc3fea05c7ceca4a242468a5179d
change-id: 20221221-ira-cxl-events-2022-11-17-fef53f9b9ac2

Best regards,