On Wed, 17 Jul 2019 at 16:08, Laszlo Ersek <ler...@redhat.com> wrote: > > On 07/17/19 15:46, Peter Maydell wrote: > > On Wed, 17 Jul 2019 at 14:36, Philippe Mathieu-Daudé <phi...@redhat.com> > > wrote: > >> I still wonder why this didn't assert on Peter's setup. > > > > My setup does not assert because my host kernel correctly > > provides the ID register values to QEMU. Laszlo's appears > > to be providing all-zeroes, which then obviously breaks > > assertions being made about the sanity of those ID register > > values... > > OK. Can you suggest a location that I should check in the host kernel?
I was about to write out the process of how we get these values from the kernel, but as the first step of that I read through QEMU's target/arm/kvm64.c:kvm_arm_get_host_cpu_features(), which is the function which reads these values using the KVM_GET_ONE_REG ioctl. It starts with an attempt to read ID_AA64PFR0, and has a comment for the error-handling case: /* * Before v4.15, the kernel only exposed a limited number of system * registers, not including any of the interesting AArch64 ID regs. * For the most part we could leave these fields as zero with minimal * effect, since this does not affect the values seen by the guest. * * However, it could cause problems down the line for QEMU, * so provide a minimal v8.0 default. * * ??? Could read MIDR and use knowledge from cpu64.c. * ??? Could map a page of memory into our temp guest and * run the tiniest of hand-crafted kernels to extract * the values seen by the guest. * ??? Either of these sounds like too much effort just * to work around running a modern host kernel. */ I have 4.15, and don't hit this assert; you have 4.14 and do, so I think you're going to be going through this codepath which currently sets only ahcf->isar.id_aa64pfr0 and none of the other ID register fields in the isar struct. I'm not sure exactly which kernel commits added the ID register reading support. (The relevant kernel code is in arch/arm64/kvm/sys_regs.c I think.) Anyway, I think we need to do at least one of: * enhance the "provide a minimal v8.0 default" code in this condition in kvm_arm_get_host_cpu_features() so that it populates the ID registers sufficiently to avoid asserts and other bad things * make the asserts on ID register oddnesses be only for TCG (ie where QEMU controls the values) and not for KVM thanks -- PMM