[PATCH v2] KVM: PPC: Book3S PR: Enable MSR_DR for switch_mmu_context()

Alexander Graf graf at amazon.com
Tue May 10 22:33:40 AEST 2022


On 10.05.22 13:31, Christophe Leroy wrote:
> Le 10/05/2022 à 13:18, Alexander Graf a écrit :
>> Commit 863771a28e27 ("powerpc/32s: Convert switch_mmu_context() to C")
>> moved the switch_mmu_context() to C. While in principle a good idea, it
>> meant that the function now uses the stack. The stack is not accessible
>> from real mode though.
>>
>> So to keep calling the function, let's turn on MSR_DR while we call it.
>> That way, all pointer references to the stack are handled virtually.
> Is the system ready to handle a DSI in case the stack is not mapped ?


A DSI itself will be an interrupt again which will in turn destroy the 
SPRG that we're saving. Guess I was trying to be too smart :). I'll use 
Matt's original suggestion and just put it on the stack.


>> In addition, make sure to save/restore r12 in an SPRG, as it may get
>> clobbered by the C function.
>>
>> Reported-by: Matt Evans <matt at ozlabs.org>
>> Fixes: 863771a28e27 ("powerpc/32s: Convert switch_mmu_context() to C")
> Oops, sorry for that. I didn't realise that there was other callers to
> switch_mmu_context() than switch_mm_irqs_off().


No worries, the compiled C version looks a lot nicer than the previous 
asm one - and it was a good way to identify whether there still are 
users of KVM on Book3S 32bit out there :)


Alex





Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879




More information about the Linuxppc-dev mailing list