Commit edd0622b authored by Paul Mackerras's avatar Paul Mackerras

[POWERPC] Fix potential duplicate entry in SLB shadow buffer

We were getting a duplicate entry in the SLB shadow buffer in
slb_flush_and_rebolt() if the kernel stack was in the same segment
as PAGE_OFFSET, which on POWER6 causes the hypervisor to terminate
the partition with an error.  This fixes it.

Also we were not creating an SLB entry (or an SLB shadow buffer
entry) for the kernel stack on secondary CPUs when starting the
CPU.  This isn't a major problem, since an appropriate entry will
be created on demand, but this fixes that also for consistency.
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent ac078602
...@@ -69,20 +69,9 @@ static inline void slb_shadow_update(unsigned long ea, ...@@ -69,20 +69,9 @@ static inline void slb_shadow_update(unsigned long ea,
smp_wmb(); smp_wmb();
} }
static inline void create_shadowed_slbe(unsigned long ea, unsigned long flags, static inline void slb_shadow_clear(unsigned long entry)
unsigned long entry)
{ {
/* get_slb_shadow()->save_area[entry].esid = 0;
* Updating the shadow buffer before writing the SLB ensures
* we don't get a stale entry here if we get preempted by PHYP
* between these two statements.
*/
slb_shadow_update(ea, flags, entry);
asm volatile("slbmte %0,%1" :
: "r" (mk_vsid_data(ea, flags)),
"r" (mk_esid_data(ea, entry))
: "memory" );
} }
void slb_flush_and_rebolt(void) void slb_flush_and_rebolt(void)
...@@ -100,11 +89,13 @@ void slb_flush_and_rebolt(void) ...@@ -100,11 +89,13 @@ void slb_flush_and_rebolt(void)
vflags = SLB_VSID_KERNEL | vmalloc_llp; vflags = SLB_VSID_KERNEL | vmalloc_llp;
ksp_esid_data = mk_esid_data(get_paca()->kstack, 2); ksp_esid_data = mk_esid_data(get_paca()->kstack, 2);
if ((ksp_esid_data & ESID_MASK) == PAGE_OFFSET) if ((ksp_esid_data & ESID_MASK) == PAGE_OFFSET) {
ksp_esid_data &= ~SLB_ESID_V; ksp_esid_data &= ~SLB_ESID_V;
slb_shadow_clear(2);
/* Only third entry (stack) may change here so only resave that */ } else {
slb_shadow_update(get_paca()->kstack, lflags, 2); /* Update stack entry; others don't change */
slb_shadow_update(get_paca()->kstack, lflags, 2);
}
/* We need to do this all in asm, so we're sure we don't touch /* We need to do this all in asm, so we're sure we don't touch
* the stack between the slbia and rebolting it. */ * the stack between the slbia and rebolting it. */
...@@ -235,16 +226,12 @@ void slb_initialize(void) ...@@ -235,16 +226,12 @@ void slb_initialize(void)
vflags = SLB_VSID_KERNEL | vmalloc_llp; vflags = SLB_VSID_KERNEL | vmalloc_llp;
/* Invalidate the entire SLB (even slot 0) & all the ERATS */ /* Invalidate the entire SLB (even slot 0) & all the ERATS */
asm volatile("isync":::"memory"); slb_shadow_update(PAGE_OFFSET, lflags, 0);
asm volatile("slbmte %0,%0"::"r" (0) : "memory"); asm volatile("isync; slbia; sync; slbmte %0,%1; isync" ::
asm volatile("isync; slbia; isync":::"memory"); "r" (get_slb_shadow()->save_area[0].vsid),
create_shadowed_slbe(PAGE_OFFSET, lflags, 0); "r" (get_slb_shadow()->save_area[0].esid) : "memory");
create_shadowed_slbe(VMALLOC_START, vflags, 1); slb_shadow_update(VMALLOC_START, vflags, 1);
/* We don't bolt the stack for the time being - we're in boot, slb_flush_and_rebolt();
* so the stack is in the bolted segment. By the time it goes
* elsewhere, we'll call _switch() which will bolt in the new
* one. */
asm volatile("isync":::"memory");
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment