@@ -23,7 +23,7 @@ CXL_TYPE2_MEM_SIZE=${CXL_TYPE2_MEM_SIZE:-4G}
2323GPU_DEVICE=${GPU_DEVICE:- " " }
2424
2525# Communication mode: tcp or shm (shared memory)
26- export CXL_TRANSPORT_MODE=${CXL_TRANSPORT_MODE :- shm}
26+ export CXL_TRANSPORT_MODE=shm
2727export CXL_MEMSIM_HOST=$CXL_MEMSIM_HOST
2828export CXL_MEMSIM_PORT=$CXL_MEMSIM_PORT
2929
@@ -37,12 +37,18 @@ echo "Type 2 Device Memory: $CXL_TYPE2_MEM_SIZE"
3737echo " GPU Device: ${GPU_DEVICE:- ' Not configured (simulation mode)' } "
3838echo " ==================================================================="
3939
40- # Build QEMU command
41- QEMU_CMD=" $QEMU_BINARY \
40+ # Add GPU device parameter if specified
41+ if [ -n " $GPU_DEVICE " ]; then
42+ QEMU_CMD=" $QEMU_CMD ,gpu-device=$GPU_DEVICE "
43+ echo " GPU passthrough enabled for: $GPU_DEVICE "
44+ fi
45+
46+ # Add traditional Type 3 memory device for comparison
47+ exec $QEMU_BINARY \
4248 --enable-kvm \
4349 -cpu qemu64,+xsave,+rdtscp,+avx,+avx2,+sse4.1,+sse4.2,+avx512f,+avx512dq,+avx512ifma,+avx512cd,+avx512bw,+avx512vl,+avx512vbmi,+clflushopt \
4450 -kernel ./bzImage \
45- -append \ " root=/dev/sda rw console=ttyS0,115200 ignore_loglevel nokaslr nosmp nopti nospectre_v2 mem=2G \ " \
51+ -append " root=/dev/sda rw console=ttyS0,115200 ignore_loglevel nokaslr nosmp nopti nospectre_v2" \
4652 -netdev tap,id=network0,ifname=tap1,script=no,downscript=no \
4753 -device e1000,netdev=network0,mac=52:54:00:00:00:02 \
4854 -netdev user,id=netssh0,hostfwd=tcp::10022-:22 \
@@ -54,36 +60,17 @@ QEMU_CMD="$QEMU_BINARY \
5460 -smp 4 \
5561 -device pxb-cxl,bus_nr=12,bus=pcie.0,id=cxl.1 \
5662 -device cxl-rp,port=0,bus=cxl.1,id=root_port13,chassis=0,slot=0 \
57- -device cxl-rp,port=1,bus=cxl.1,id=root_port14,chassis=0,slot=1"
58-
59- # Add CXL Type 2 device with coherent memory and GPU passthrough support
60- QEMU_CMD=" $QEMU_CMD \
63+ -device cxl-rp,port=1,bus=cxl.1,id=root_port14,chassis=0,slot=1 \
6164 -device cxl-type2,bus=root_port13,\
62- cache-size=$CXL_TYPE2_CACHE_SIZE ,\
63- mem-size=$CXL_TYPE2_MEM_SIZE ,\
64- sn=0x2,\
65- cxlmemsim-addr=$CXL_MEMSIM_HOST ,\
66- cxlmemsim-port=$CXL_MEMSIM_PORT ,\
67- coherency-enabled=true,\
68- id=cxl-type2-gpu0"
69-
70- # Add GPU device parameter if specified
71- if [ -n " $GPU_DEVICE " ]; then
72- QEMU_CMD=" $QEMU_CMD ,gpu-device=$GPU_DEVICE "
73- echo " GPU passthrough enabled for: $GPU_DEVICE "
74- fi
75-
76- # Add traditional Type 3 memory device for comparison
77- QEMU_CMD=" $QEMU_CMD \
65+ cache-size=$CXL_TYPE2_CACHE_SIZE ,\
66+ mem-size=$CXL_TYPE2_MEM_SIZE ,\
67+ sn=0x2,\
68+ cxlmemsim-addr=$CXL_MEMSIM_HOST ,\
69+ cxlmemsim-port=$CXL_MEMSIM_PORT ,\
70+ coherency-enabled=true,\
71+ id=cxl-type2-gpu0 \
7872 -device cxl-type3,bus=root_port14,persistent-memdev=cxl-mem1,lsa=cxl-lsa1,id=cxl-pmem0,sn=0x3 \
7973 -object memory-backend-file,id=cxl-mem1,share=on,mem-path=/tmp/cxltest.raw,size=128G \
8074 -object memory-backend-file,id=cxl-lsa1,share=on,mem-path=/tmp/lsa.raw,size=256M \
8175 -M cxl-fmw.0.targets.0=cxl.1,cxl-fmw.0.size=4G \
82- -nographic"
83-
84- echo " "
85- echo " Starting QEMU with CXL Type 2 device..."
86- echo " "
87-
88- # Execute QEMU
89- exec $QEMU_CMD
76+ -nographic
0 commit comments