powerpc/rtas: Implement reentrant rtas call
Implement rtas_call_reentrant() for reentrant rtas-calls: "ibm,int-on", "ibm,int-off",ibm,get-xive" and "ibm,set-xive". On LoPAPR Version 1.1 (March 24, 2016), from 7.3.10.1 to 7.3.10.4, items 2 and 3 say: 2 - For the PowerPC External Interrupt option: The * call must be reentrant to the number of processors on the platform. 3 - For the PowerPC External Interrupt option: The * argument call buffer for each simultaneous call must be physically unique. So, these rtas-calls can be called in a lockless way, if using a different buffer for each cpu doing such rtas call. For this, it was suggested to add the buffer (struct rtas_args) in the PACA struct, so each cpu can have it's own buffer. The PACA struct received a pointer to rtas buffer, which is allocated in the memory range available to rtas 32-bit. Reentrant rtas calls are useful to avoid deadlocks in crashing, where rtas-calls are needed, but some other thread crashed holding the rtas.lock. This is a backtrace of a deadlock from a kdump testing environment: #0 arch_spin_lock #1 lock_rtas () #2 rtas_call (token=8204, nargs=1, nret=1, outputs=0x0) #3 ics_rtas_mask_real_irq (hw_irq=4100) #4 machine_kexec_mask_interrupts #5 default_machine_crash_shutdown #6 machine_crash_shutdown #7 __crash_kexec #8 crash_kexec #9 oops_end Signed-off-by: Leonardo Bras <leobras.c@gmail.com> [mpe: Move under #ifdef PSERIES to avoid build breakage] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20200518234245.200672-3-leobras.c@gmail.com
This commit is contained in:

committed by
Michael Ellerman

parent
783a015b74
commit
b664db8e3f
@@ -16,6 +16,7 @@
|
||||
#include <asm/kexec.h>
|
||||
#include <asm/svm.h>
|
||||
#include <asm/ultravisor.h>
|
||||
#include <asm/rtas.h>
|
||||
|
||||
#include "setup.h"
|
||||
|
||||
@@ -164,6 +165,30 @@ static struct slb_shadow * __init new_slb_shadow(int cpu, unsigned long limit)
|
||||
|
||||
#endif /* CONFIG_PPC_BOOK3S_64 */
|
||||
|
||||
#ifdef CONFIG_PPC_PSERIES
|
||||
/**
|
||||
* new_rtas_args() - Allocates rtas args
|
||||
* @cpu: CPU number
|
||||
* @limit: Memory limit for this allocation
|
||||
*
|
||||
* Allocates a struct rtas_args and return it's pointer,
|
||||
* if not in Hypervisor mode
|
||||
*
|
||||
* Return: Pointer to allocated rtas_args
|
||||
* NULL if CPU in Hypervisor Mode
|
||||
*/
|
||||
static struct rtas_args * __init new_rtas_args(int cpu, unsigned long limit)
|
||||
{
|
||||
limit = min_t(unsigned long, limit, RTAS_INSTANTIATE_MAX);
|
||||
|
||||
if (early_cpu_has_feature(CPU_FTR_HVMODE))
|
||||
return NULL;
|
||||
|
||||
return alloc_paca_data(sizeof(struct rtas_args), L1_CACHE_BYTES,
|
||||
limit, cpu);
|
||||
}
|
||||
#endif /* CONFIG_PPC_PSERIES */
|
||||
|
||||
/* The Paca is an array with one entry per processor. Each contains an
|
||||
* lppaca, which contains the information shared between the
|
||||
* hypervisor and Linux.
|
||||
@@ -202,6 +227,10 @@ void __init __nostackprotector initialise_paca(struct paca_struct *new_paca, int
|
||||
/* For now -- if we have threads this will be adjusted later */
|
||||
new_paca->tcd_ptr = &new_paca->tcd;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PPC_PSERIES
|
||||
new_paca->rtas_args_reentrant = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Put the paca pointer into r13 and SPRG_PACA */
|
||||
@@ -273,6 +302,9 @@ void __init allocate_paca(int cpu)
|
||||
#endif
|
||||
#ifdef CONFIG_PPC_BOOK3S_64
|
||||
paca->slb_shadow_ptr = new_slb_shadow(cpu, limit);
|
||||
#endif
|
||||
#ifdef CONFIG_PPC_PSERIES
|
||||
paca->rtas_args_reentrant = new_rtas_args(cpu, limit);
|
||||
#endif
|
||||
paca_struct_size += sizeof(struct paca_struct);
|
||||
}
|
||||
|
Reference in New Issue
Block a user