Re: [RFC] powerpc/kvm: Fix spinlock member access for PREEMPT_RT
From: Michael Ellerman
Date: Thu Oct 10 2024 - 22:57:36 EST
Paolo Bonzini <pbonzini@xxxxxxxxxx> writes:
> On 10/10/24 20:09, Vishal Chourasia wrote:
>> Hi,
>>
>> While building the kernel with CONFIG_PREEMPT_RT, I encountered several
>> compilation errors in the PowerPC KVM code. The issues appear in
>> book3s_hv_rm_mmu.c where it tries to access the 'rlock' member of struct
>> spinlock, which doesn't exist in the RT configuration.
>
> How was this tested? I suspect that putting to sleep a task that is
> running in real mode is a huge no-no.
Yeah.
Even without preempt, spin_lock() can end up in debug/tracing code that
will blow up in real mode.
Vishal, if you look at the history of that file you'll see eg:
87013f9c602c ("powerpc/kvm/book3s: switch from raw_spin_*lock to arch_spin_lock.")
> The actual solution would have to
> be to split mmu_lock into a spin_lock and a raw_spin_lock, but that's a
> huge amount of work probably. I'd just add a "depends on !PPC ||
> !KVM_BOOK3S_64_HV" or something like that, to prevent enabling KVM-HV on
> PREEMPT_RT kernels.
Yeah that should work to get something building.
The bulk (or all?) of that file is not used for Radix guests, only for
hash page table MMU guests.
So I think it should be possible to hide that code behind a new CONFIG
option that controls support for HPT guests. And then that option could
be incompatible with PREEMPT_RT. But that will require unstitching some
of the connections between that code and the other ppc KVM code.
cheers