Re: [PATCH v2 4/5] powerpc: kvm: drop 32-bit book3s

Arnd Bergmann
2024-12-22T21:10:20Z

On Sun, Dec 22, 2024, at 03:13, A. Wilcox wrote:
> On Dec 21, 2024, at 3:42 PM, Arnd Bergmann <arnd@kernel.org> wrote:
>>
>
>
> I can confirm that running 6.12.5 on a P9 host, trying to boot a 6.6
> 32-bit kernel gave me:
>
> Detected RAM kernel at 400000 (1330c8c bytes)
> Welcome to Open Firmware
>
> Copyright (c) 2004, 2017 IBM Corporation All rights reserved.
> This program and the accompanying materials are made available
> under the terms of the BSD License available at
> http://www.opensource.org/licenses/bsd-license.php
>
> Booting from memory...
>
> ( 380 ) Data Segment Exception [ -bfc00000 ]
>
>
> R0 .. R7 R8 .. R15 R16 .. R23 R24 .. R31
> 00000000014a1124 0000000000000000 000000000135b4ac 0000000000000000
> 000000000dc70f30 ffffffffc0000000 000000000dc70fa4 000000000173600c
> 0000000000000000 000000000e477010 0000000000000000 0000000000400000
> ffffffff0141be4c 000000000149ab74 00000000ffffffff 0000000000000008
> 00000000c0014b6c 0000000020000402 0000000040400000 00000000016f2000
> ffffffff40400000 0000000000000000 0000000000000000 000000000dc70f60
> 0000000000000000 0000000000000000 000000000e73d490 000000000149f000
> 0000000000000000 000000000e756118 000000000dc70fa0 ffffffff40400000
>
> CR / XER LR / CTR SRR0 / SRR1 DAR / DSISR
> 80000402 00000000014a1124 00000000014a1128 ffffffff0141be4c
> 0000000020040000 0000000000000000 8000000000003000 00000000
>
>
> 2 >
>
> Which is the same thing that happens if you boot a 32-bit Linux kernel
> on a physical 64-bit Power machine. This is probably because KVM is
> so much more accurate than TCG for Power emulation :)

Did you ask kvm to emulate a 32-bit platform though? Since the
register dump shows 64-bit registers, my guess is that this is the
result of trying to load a 32-bit kernel on "-machine pseries
-cpu native", which is not supported by the guest kernel. I would
expect that you need at least a 32-bit machine type (mac99,
pegasos2) and likely also a 32-bit CPU (7447a, e600).

According to what Paolo said, that may require PR state instead
of HV mode:
https://lore.kernel.org/lkml/79b9abfe-cfb8-4ef0-8a4b-7b87787e6549@redhat.com/

I am not familiar enough with the details, but from the source code
I see that this is not usually enabled, and you may have to turn
off CONFIG_VIRT_CPU_ACCOUNTING_GEN and CONFIG_CONTEXT_TRACKING_USER
in order to enable CONFIG_KVM_BOOK3S_64_PR, as well as possibly
turning off CONFIG_KVM_BOOK3S_64_HV (it looks like it should
be possible to have both HV and PR coexist, but there may be bugs).
You also need to ensure that you have loaded kvm_pr.ko instead
of kvm_hv.ko, and that CONFIG_PPC_RADIX_MMU is turned off if
you are running on a power9 host, otherwise kvm_pr.ko fails to load,
see kvmppc_core_check_processor_compat_pr().

> That said, I would like to keep the support alive for more than just
> ppc32 kernel testing. There are plenty of Power Macs with enough
> memory to run some environments within KVM. Adélie’s new release
> boots a full XFCE desktop in under 300 MB RAM, so even a 1 GB machine
> has enough memory to run AmigaOS, Mac OS 9, or another XFCE in KVM.
>
> I have found a few bugs in testing newer kernels, and one of them
> affects all targets lower than Power7, which means 32-bit and 64-bit BE.
> I am preparing to send those patches in. I will continue shaking out
> any remaining bugs on my 32-bit host. I hope that these patches can
> be useful, and possibly stimulate more interest so 32-bit support can
> be maintained again.

Do you mean 32-bit host KVM support specifically, or more generally
powerpc32 kernels? As far as I can tell, powerpc32 kernel support
itself remains actively maintained, though almost all of the work
is on the embedded freescale parts rather than on desktop.
PowerMac and KVM on book3s32 were marked as orphaned last year,
but hadn't seen much activity for a while before that.

> In fairness, I do agree that there is very little value in keeping 32-bit
> MIPS or RISC-V support since the chips that support it are so limited.
> 32-bit Power however serves actual purposes. 32-bit x86 could be useful
> to make sure “KVM on 32-bit in general” is easier to keep going,
> but if it is causing maintenance issues then I suppose it can go.

I think it comes down to how much of a hassle the book3s32 KVM support
is for both the continued book3s32 architecture support and the KVM
book3s64 codebase. I think both of these benefit from no longer
having to worry about the orphaned book3s32 kvm code, but I can't
tell how that should be weighed against how useful it is for you
and other users that occasionally use KVM on that hardware.

Arnd