Skip to content

Commit ace3fd5

Browse files
authored
configs,arch-riscv,cpu-o3: Fix Xiangshan raw Linux boot (#778)
* configs,arch-riscv,cpu-o3: Fix Xiangshan raw Linux boot Restore the raw linux.bin bringup path used by kmhv3.py. Inject a Xiangshan DTB for raw checkpoints, pass its address through A1, and make sfence.vma wait for older stores before committing so Linux can finish early page-table setup and boot to userspace again. Change-Id: Ie0c5105ff20df242bb37b29ae0fcae75332ce087 * tests,configs: Add Xiangshan raw Linux boot CI Add a post-merge workflow job that boots the shared raw linux.bin image with kmhv3.py and checks for the expected XiangShan banner and m5_exit completion signal. The job uses XS_LINUX_BIN when provided and otherwise falls back to the shared /nfs/home/share/gem5_ci/ready-to-run/linux.bin path on the CI runners. Change-Id: I816b141e97a74fa09fdb59796e048df666e70882 * tests: Increase CI from 10 to 30 minutes to avoid canceled Change-Id: If8a90c04b21512599457e5581ed7e8248f9b7117 * tests: only test boot linux CI Change-Id: I8b5c34bad49b70eb49b71273a6ef6ae58dd9eae2 * tests: fix boot linux CI Change-Id: I3e2ee9f179faed7d15668c7018b06688c200d36a * arch-riscv, configs: Fix Sv48 difftest Linux boot Change-Id: If6e579d718eb6d67e18528a00eacdec31fccc393 * Revert "tests: only test boot linux CI" This reverts commit 051f8de.
1 parent 2047a0f commit ace3fd5

File tree

11 files changed

+362
-119
lines changed

11 files changed

+362
-119
lines changed

.github/workflows/gem5.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,35 @@ jobs:
142142
cd $GEM5_HOME/util/xs_scripts/test_h
143143
bash ../kmh_6wide_h.sh /nfs/home/share/gem5_ci/checkpoints/gcbh_test.zstd
144144
145+
raw_linux_boot_test:
146+
runs-on: [self-hosted, open]
147+
continue-on-error: false
148+
timeout-minutes: 30
149+
name: XS-GEM5 - Boot raw Linux
150+
steps:
151+
- uses: actions/checkout@v2
152+
- uses: ./.github/actions/build-dramsim
153+
- name: Build GEM5 opt
154+
run: |
155+
CC=gcc CXX=g++ scons build/RISCV/gem5.opt --linker=gold -j64
156+
- name: Boot Xiangshan raw Linux
157+
run: |
158+
export RAW_LINUX_BIN="${XS_LINUX_BIN:-/nfs/home/share/gem5_ci/ready-to-run/linux.bin}"
159+
if [ ! -r "$RAW_LINUX_BIN" ]; then
160+
echo "Missing raw linux image: $RAW_LINUX_BIN"
161+
echo "Please provision the image at the default path or set XS_LINUX_BIN on the runner."
162+
exit 1
163+
fi
164+
165+
mkdir -p debug/raw_linux_ci
166+
./build/RISCV/gem5.opt -r -d debug/raw_linux_ci \
167+
./configs/example/kmhv3.py \
168+
--raw-cpt \
169+
--generic-rv-cpt "$RAW_LINUX_BIN" \
170+
--disable-difftest
171+
- name: Check boot result
172+
run: |
173+
test -f debug/raw_linux_ci/simout
174+
tail -n 200 debug/raw_linux_ci/simout
175+
grep -q "Hello, XiangShan!" debug/raw_linux_ci/simout
176+
grep -q "m5_exit instruction encountered" debug/raw_linux_ci/simout

configs/common/FSConfig.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,14 +658,20 @@ def makeBareMetalRiscvSystem(mem_mode, mdesc=None, cmdline=None):
658658
return self
659659

660660
def makeBareMetalXiangshanSystem(mem_mode, mdesc=None, cmdline=None, np=1, ruby=False):
661+
self = makeXiangshanPlatformSystem(mem_mode, mdesc, np=np, ruby=ruby)
662+
self.workload = RiscvBareMetal()
663+
self.workload.reset_vect = 0x80000000
664+
return self
665+
666+
667+
def makeXiangshanPlatformSystem(mem_mode, mdesc=None, np=1, ruby=False):
661668
self = System()
662669
if not mdesc:
663670
# generic system
664671
mdesc = SysConfig()
665672
self.mem_mode = mem_mode
666673
self.mem_ranges = [AddrRange(start=0x80000000, size=mdesc.mem())]
667674
print(self.mem_ranges)
668-
self.workload = RiscvBareMetal()
669675

670676
self.iobus = IOXBar()
671677
if not ruby:
@@ -698,7 +704,6 @@ def makeBareMetalXiangshanSystem(mem_mode, mdesc=None, cmdline=None, np=1, ruby=
698704
AddrRange(self.plic.pio_addr, self.plic.pio_addr + self.plic.pio_size),
699705
]
700706

701-
self.workload.reset_vect = 0x80000000
702707
if not ruby:
703708
self.system_port = self.membus.cpu_side_ports
704709
return self

configs/common/Options.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -632,38 +632,47 @@ def addFSOptions(parser):
632632
parser.add_argument("--wait-gdb", default=False, action='store_true',
633633
help="Wait for remote GDB to connect.")
634634

635-
def addXiangshanFSOptions(parser):
635+
def addXiangshanCommonOptions(parser):
636636
# Xiangshan related options
637-
parser.add_argument("--xiangshan-system", action= "store_true",
637+
parser.add_argument("--xiangshan-system", action="store_true",
638638
help="Use memory layout of Xiangshan system")
639-
640-
parser.add_argument("--enable-h-gcpt", action= "store_true",
641-
help="enable h checkpoint")
642-
parser.add_argument("--generic-rv-cpt", action= "store", type = str,
643-
default=None, required=True,
644-
help="The path of Xiangshan risc-v checkpoint")
645-
parser.add_argument("--gcpt-restorer", action="store", type = str,
646-
default=None,
647-
help="The path of generic risc-v checkpoint restorer")
648-
649-
parser.add_argument("--raw-cpt", action= "store_true",
650-
help = "The checkpoint file is not gz but binary")
651-
652639
parser.add_argument("--mmc-img", action="store", type=str,
653640
default=None, help="The path of mmc img")
654641
parser.add_argument("--mmc-cptbin", action="store",
655642
type=str, default=None, help="The path of mmc cptbin")
656643

657644
# Difftest option
645+
parser.set_defaults(enable_difftest=None)
658646
parser.add_argument("--enable-difftest",
659647
action="store_true",
648+
dest="enable_difftest",
660649
help="use NEMU as ref to do difftest")
650+
parser.add_argument("--disable-difftest",
651+
action="store_false",
652+
dest="enable_difftest",
653+
help="disable NEMU difftest")
661654

662655
parser.add_argument("--difftest-ref-so",
663656
action="store",
664657
default=None,
665658
help="The shared lib file used to do difftest")
666659

660+
661+
def addXiangshanFSOptions(parser):
662+
addXiangshanCommonOptions(parser)
663+
664+
parser.add_argument("--enable-h-gcpt", action= "store_true",
665+
help="enable h checkpoint")
666+
parser.add_argument("--generic-rv-cpt", action= "store", type = str,
667+
default=None, required=True,
668+
help="The path of Xiangshan risc-v checkpoint")
669+
parser.add_argument("--gcpt-restorer", action="store", type = str,
670+
default=None,
671+
help="The path of generic risc-v checkpoint restorer")
672+
673+
parser.add_argument("--raw-cpt", action= "store_true",
674+
help = "The checkpoint file is not gz but binary")
675+
667676
def addXiangshanTraceOptions(parser):
668677
# Add trace-specific arguments for trace-driven simulation
669678
parser.add_argument('--enable-trace-mode', action='store_true',

0 commit comments

Comments
 (0)