On Mon, May 26 2025, Cornelia Huck <coh...@redhat.com> wrote: > On Fri, May 23 2025, Shameerali Kolothum Thodi > <shameerali.kolothum.th...@huawei.com> wrote: > >> Hi, >> >>> -----Original Message----- >>> From: Cornelia Huck <coh...@redhat.com> >>> Sent: Monday, April 14, 2025 5:39 PM >>> To: eric.auger....@gmail.com; eric.au...@redhat.com; qemu- >>> de...@nongnu.org; qemu-...@nongnu.org; kvm...@lists.linux.dev; >>> peter.mayd...@linaro.org; richard.hender...@linaro.org; >>> alex.ben...@linaro.org; m...@kernel.org; oliver.up...@linux.dev; >>> seb...@redhat.com; Shameerali Kolothum Thodi >>> <shameerali.kolothum.th...@huawei.com>; arm...@redhat.com; >>> berra...@redhat.com; abolo...@redhat.com; jdene...@redhat.com >>> Cc: ag...@csgraf.de; shahu...@redhat.com; mark.rutl...@arm.com; >>> phi...@linaro.org; pbonz...@redhat.com; Cornelia Huck >>> <coh...@redhat.com> >>> Subject: [PATCH v3 00/10] kvm/arm: Introduce a customizable aarch64 KVM >>> host model >> >> [..] >> >> ) >>> >>> Code also available at >>> https://gitlab.com/cohuck/qemu/-/tree/arm-cpu-model- >>> rfcv3?ref_type=heads >> >> I had a spin with the above branch, but Qemu boot fails, >> >> ERROR:../target/arm/cpu64.c:57:get_sysreg_idx: code should not be reached >> Bail out! ERROR:../target/arm/cpu64.c:57:get_sysreg_idx: code should not be >> reached >> >> From a quick debug, it looks like the below path results in an invalid ID >> idx. >> >> kvm_arm_expose_idreg_properties() >> kvm_idx_to_idregs_idx(0) >> get_sysreg_idx(0xc000) --> id_register seems to start at 0xc008 >> >> Haven't debugged further. >> >> I am running against a 6.15-rc1 kernel after updating the Qemu branch by, >> ./update-aarch64-sysreg-code.sh path_to_6.15-rc1 >> >> Not sure I am missing anything. Please check and let me know. > > Thanks for trying this out; I'll try to re-create this here. > (I think I've messed up those conversion functions often enough...)
The conversion functions are not at fault here, but we're missing registers. If we have MIDR and friends writable, they show up in the masks returned by the kernel, but they are not present in the kernel's sysreg file where we generate our definitions from, and kvm_idx_to_idregs_idx() asserts instead of returning an error, which is kind of suboptimal... So I see two possible ways to fix this: - add MIDR and friends to the kernel's sysreg file - add MIDR and friends in QEMU's cpu-sysregs.h.inc file, and only append generated definitions there First option means one more round trip, second options has more potential for messing things up if we keep stuff local to QEMU.