diff mbox series

powerpc/32: Add missing context synchronisation with CONFIG_VMAP_STACK

Message ID 872477f7c7552d3bb7baf0b302398fcd42c5fcfd.1579885334.git.christophe.leroy@c-s.fr (mailing list archive)
State Superseded
Headers show
Series powerpc/32: Add missing context synchronisation with CONFIG_VMAP_STACK | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/merge (b43d1d8a77b5d5d82f8930aa5b101378df00ccca)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/next (3a9d970f17e05a7b26f782beb8f7f2118d1741ea)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linus/master (4703d9119972bf586d2cca76ec6438f819ffa30e)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/fixes (5d2e5dd5849b4ef5e8ec35e812cdb732c13cd27e)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linux-next (702ccea170f07783bd002055a353a0866c062267)
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Christophe Leroy Jan. 24, 2020, 5:03 p.m. UTC
After reactivation of data translation by modifying MSR[DR], a isync
is required to ensure the translation is effective.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
Rebased on powerpc/merge-test

@mpe: If not too late:
- change to head_32.h should be squashed into "powerpc/32: prepare for CONFIG_VMAP_STACK"
- change to head_32.S should be squashed into "powerpc/32s: Enable CONFIG_VMAP_STACK"

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/kernel/head_32.S | 1 +
 arch/powerpc/kernel/head_32.h | 2 ++
 2 files changed, 3 insertions(+)

Comments

Michael Ellerman Jan. 25, 2020, 10:30 a.m. UTC | #1
Christophe Leroy <christophe.leroy@c-s.fr> writes:
> After reactivation of data translation by modifying MSR[DR], a isync
> is required to ensure the translation is effective.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> Rebased on powerpc/merge-test
>
> @mpe: If not too late:
> - change to head_32.h should be squashed into "powerpc/32: prepare for CONFIG_VMAP_STACK"
> - change to head_32.S should be squashed into "powerpc/32s: Enable CONFIG_VMAP_STACK"

Done. Thanks.

cheers
Michael Ellerman Jan. 25, 2020, 12:15 p.m. UTC | #2
Christophe Leroy <christophe.leroy@c-s.fr> writes:
> After reactivation of data translation by modifying MSR[DR], a isync
> is required to ensure the translation is effective.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> Rebased on powerpc/merge-test
>
> @mpe: If not too late:
> - change to head_32.h should be squashed into "powerpc/32: prepare for CONFIG_VMAP_STACK"
> - change to head_32.S should be squashed into "powerpc/32s: Enable CONFIG_VMAP_STACK"
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
>  arch/powerpc/kernel/head_32.S | 1 +
>  arch/powerpc/kernel/head_32.h | 2 ++
>  2 files changed, 3 insertions(+)
>
> diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h
> index 73a035b40dbf..a6a5fbbf8504 100644
> --- a/arch/powerpc/kernel/head_32.h
> +++ b/arch/powerpc/kernel/head_32.h
> @@ -43,6 +43,7 @@
>  	.ifeq	\for_rtas
>  	li	r11, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */
>  	mtmsr	r11
> +	isync

Actually this one leads to:

  /home/michael/linux/arch/powerpc/kernel/head_8xx.S: Assembler messages:
  /home/michael/linux/arch/powerpc/kernel/head_8xx.S:151: Error: attempt to move .org backwards
  make[3]: *** [/home/michael/linux/scripts/Makefile.build:348: arch/powerpc/kernel/head_8xx.o] Error 1

For mpc885_ads_defconfig.

That's the alignment exception overflowing into the program check
handler:

/* Alignment exception */
	. = 0x600
Alignment:
	EXCEPTION_PROLOG handle_dar_dsisr=1
	save_dar_dsisr_on_stack r4, r5, r11
	li	r6, RPN_PATTERN
	mtspr	SPRN_DAR, r6	/* Tag DAR, to be used in DTLB Error */
	addi	r3,r1,STACK_FRAME_OVERHEAD
	EXC_XFER_STD(0x600, alignment_exception)

/* Program check exception */
	EXCEPTION(0x700, ProgramCheck, program_check_exception, EXC_XFER_STD)


Can't see an obvious/easy way to fix it.

cheers

>  	.endif
>  	subi	r11, r1, INT_FRAME_SIZE		/* use r1 if kernel */
>  #else
Christophe Leroy Jan. 25, 2020, 1 p.m. UTC | #3
Michael Ellerman <mpe@ellerman.id.au> a écrit :

> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>> After reactivation of data translation by modifying MSR[DR], a isync
>> is required to ensure the translation is effective.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>> ---
>> Rebased on powerpc/merge-test
>>
>> @mpe: If not too late:
>> - change to head_32.h should be squashed into "powerpc/32: prepare  
>> for CONFIG_VMAP_STACK"
>> - change to head_32.S should be squashed into "powerpc/32s: Enable  
>> CONFIG_VMAP_STACK"
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>> ---
>>  arch/powerpc/kernel/head_32.S | 1 +
>>  arch/powerpc/kernel/head_32.h | 2 ++
>>  2 files changed, 3 insertions(+)
>>
>> diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h
>> index 73a035b40dbf..a6a5fbbf8504 100644
>> --- a/arch/powerpc/kernel/head_32.h
>> +++ b/arch/powerpc/kernel/head_32.h
>> @@ -43,6 +43,7 @@
>>  	.ifeq	\for_rtas
>>  	li	r11, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */
>>  	mtmsr	r11
>> +	isync
>
> Actually this one leads to:
>
>   /home/michael/linux/arch/powerpc/kernel/head_8xx.S: Assembler messages:
>   /home/michael/linux/arch/powerpc/kernel/head_8xx.S:151: Error:  
> attempt to move .org backwards
>   make[3]: *** [/home/michael/linux/scripts/Makefile.build:348:  
> arch/powerpc/kernel/head_8xx.o] Error 1
>
> For mpc885_ads_defconfig.
>
> That's the alignment exception overflowing into the program check
> handler:
>
> /* Alignment exception */
> 	. = 0x600
> Alignment:
> 	EXCEPTION_PROLOG handle_dar_dsisr=1
> 	save_dar_dsisr_on_stack r4, r5, r11
> 	li	r6, RPN_PATTERN
> 	mtspr	SPRN_DAR, r6	/* Tag DAR, to be used in DTLB Error */
> 	addi	r3,r1,STACK_FRAME_OVERHEAD
> 	EXC_XFER_STD(0x600, alignment_exception)
>
> /* Program check exception */
> 	EXCEPTION(0x700, ProgramCheck, program_check_exception, EXC_XFER_STD)
>
>
> Can't see an obvious/easy way to fix it.

Argh !

I think the easiest is to move the EXC_XFER_STD(0x600,  
alignment_exception) somewhere else and branch to it. There is some  
space at .0xa00

Christophe

PS: I'm afk until monday
Michael Ellerman Jan. 25, 2020, 1:28 p.m. UTC | #4
Christophe Leroy <christophe.leroy@c-s.fr> writes:
> Michael Ellerman <mpe@ellerman.id.au> a écrit :
>> Christophe Leroy <christophe.leroy@c-s.fr> writes:
...
>>> diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h
>>> index 73a035b40dbf..a6a5fbbf8504 100644
>>> --- a/arch/powerpc/kernel/head_32.h
>>> +++ b/arch/powerpc/kernel/head_32.h
>>> @@ -43,6 +43,7 @@
>>>  	.ifeq	\for_rtas
>>>  	li	r11, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */
>>>  	mtmsr	r11
>>> +	isync
>>
>> Actually this one leads to:
>>
>>   /home/michael/linux/arch/powerpc/kernel/head_8xx.S: Assembler messages:
>>   /home/michael/linux/arch/powerpc/kernel/head_8xx.S:151: Error:  
>> attempt to move .org backwards
>>   make[3]: *** [/home/michael/linux/scripts/Makefile.build:348:  
>> arch/powerpc/kernel/head_8xx.o] Error 1
>>
>> For mpc885_ads_defconfig.
>>
>> That's the alignment exception overflowing into the program check
>> handler:
>>
>> /* Alignment exception */
>> 	. = 0x600
>> Alignment:
>> 	EXCEPTION_PROLOG handle_dar_dsisr=1
>> 	save_dar_dsisr_on_stack r4, r5, r11
>> 	li	r6, RPN_PATTERN
>> 	mtspr	SPRN_DAR, r6	/* Tag DAR, to be used in DTLB Error */
>> 	addi	r3,r1,STACK_FRAME_OVERHEAD
>> 	EXC_XFER_STD(0x600, alignment_exception)
>>
>> /* Program check exception */
>> 	EXCEPTION(0x700, ProgramCheck, program_check_exception, EXC_XFER_STD)
>>
>>
>> Can't see an obvious/easy way to fix it.
>
> Argh !
>
> I think the easiest is to move the EXC_XFER_STD(0x600,  
> alignment_exception) somewhere else and branch to it. There is some  
> space at .0xa00

That works, or builds at least. I'm not setup to boot test it.

Does this look OK?

cheers


From 40e7d671aa27cf4411188f978b2cd06b30a9cb6c Mon Sep 17 00:00:00 2001
From: Michael Ellerman <mpe@ellerman.id.au>
Date: Sun, 26 Jan 2020 00:20:16 +1100
Subject: [PATCH] powerpc/8xx: Move tail of alignment exception out of line

When we enable VMAP_STACK there will not be enough room for the
alignment handler at 0x600 in head_8xx.S. For now move the tail of the
alignment handler out of line, and branch to it.

Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/head_8xx.S | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
index 477933b36bde..9922306ae512 100644
--- a/arch/powerpc/kernel/head_8xx.S
+++ b/arch/powerpc/kernel/head_8xx.S
@@ -145,7 +145,7 @@ _ENTRY(_start);
 	li	r6, RPN_PATTERN
 	mtspr	SPRN_DAR, r6	/* Tag DAR, to be used in DTLB Error */
 	addi	r3,r1,STACK_FRAME_OVERHEAD
-	EXC_XFER_STD(0x600, alignment_exception)
+	b	.Lalignment_exception_ool
 
 /* Program check exception */
 	EXCEPTION(0x700, ProgramCheck, program_check_exception, EXC_XFER_STD)
@@ -153,6 +153,11 @@ _ENTRY(_start);
 /* Decrementer */
 	EXCEPTION(0x900, Decrementer, timer_interrupt, EXC_XFER_LITE)
 
+	/* With VMAP_STACK there's not enough room for this at 0x600 */
+	. = 0xa00
+.Lalignment_exception_ool:
+	EXC_XFER_STD(0x600, alignment_exception)
+
 /* System call */
 	. = 0xc00
 SystemCall:
Christophe Leroy Jan. 25, 2020, 2:35 p.m. UTC | #5
Michael Ellerman <mpe@ellerman.id.au> a écrit :

> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>> Michael Ellerman <mpe@ellerman.id.au> a écrit :
>>> Christophe Leroy <christophe.leroy@c-s.fr> writes:
> ...
>>>> diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h
>>>> index 73a035b40dbf..a6a5fbbf8504 100644
>>>> --- a/arch/powerpc/kernel/head_32.h
>>>> +++ b/arch/powerpc/kernel/head_32.h
>>>> @@ -43,6 +43,7 @@
>>>>  	.ifeq	\for_rtas
>>>>  	li	r11, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */
>>>>  	mtmsr	r11
>>>> +	isync
>>>
>>> Actually this one leads to:
>>>
>>>   /home/michael/linux/arch/powerpc/kernel/head_8xx.S: Assembler messages:
>>>   /home/michael/linux/arch/powerpc/kernel/head_8xx.S:151: Error:
>>> attempt to move .org backwards
>>>   make[3]: *** [/home/michael/linux/scripts/Makefile.build:348:
>>> arch/powerpc/kernel/head_8xx.o] Error 1
>>>
>>> For mpc885_ads_defconfig.
>>>
>>> That's the alignment exception overflowing into the program check
>>> handler:
>>>
>>> /* Alignment exception */
>>> 	. = 0x600
>>> Alignment:
>>> 	EXCEPTION_PROLOG handle_dar_dsisr=1
>>> 	save_dar_dsisr_on_stack r4, r5, r11
>>> 	li	r6, RPN_PATTERN
>>> 	mtspr	SPRN_DAR, r6	/* Tag DAR, to be used in DTLB Error */
>>> 	addi	r3,r1,STACK_FRAME_OVERHEAD
>>> 	EXC_XFER_STD(0x600, alignment_exception)
>>>
>>> /* Program check exception */
>>> 	EXCEPTION(0x700, ProgramCheck, program_check_exception, EXC_XFER_STD)
>>>
>>>
>>> Can't see an obvious/easy way to fix it.
>>
>> Argh !
>>
>> I think the easiest is to move the EXC_XFER_STD(0x600,
>> alignment_exception) somewhere else and branch to it. There is some
>> space at .0xa00
>
> That works, or builds at least. I'm not setup to boot test it.
>
> Does this look OK?

Yes it looks ok,

Thanks
Christophe

>
> cheers
>
>
> From 40e7d671aa27cf4411188f978b2cd06b30a9cb6c Mon Sep 17 00:00:00 2001
> From: Michael Ellerman <mpe@ellerman.id.au>
> Date: Sun, 26 Jan 2020 00:20:16 +1100
> Subject: [PATCH] powerpc/8xx: Move tail of alignment exception out of line
>
> When we enable VMAP_STACK there will not be enough room for the
> alignment handler at 0x600 in head_8xx.S. For now move the tail of the
> alignment handler out of line, and branch to it.
>
> Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/kernel/head_8xx.S | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
> index 477933b36bde..9922306ae512 100644
> --- a/arch/powerpc/kernel/head_8xx.S
> +++ b/arch/powerpc/kernel/head_8xx.S
> @@ -145,7 +145,7 @@ _ENTRY(_start);
>  	li	r6, RPN_PATTERN
>  	mtspr	SPRN_DAR, r6	/* Tag DAR, to be used in DTLB Error */
>  	addi	r3,r1,STACK_FRAME_OVERHEAD
> -	EXC_XFER_STD(0x600, alignment_exception)
> +	b	.Lalignment_exception_ool
>
>  /* Program check exception */
>  	EXCEPTION(0x700, ProgramCheck, program_check_exception, EXC_XFER_STD)
> @@ -153,6 +153,11 @@ _ENTRY(_start);
>  /* Decrementer */
>  	EXCEPTION(0x900, Decrementer, timer_interrupt, EXC_XFER_LITE)
>
> +	/* With VMAP_STACK there's not enough room for this at 0x600 */
> +	. = 0xa00
> +.Lalignment_exception_ool:
> +	EXC_XFER_STD(0x600, alignment_exception)
> +
>  /* System call */
>  	. = 0xc00
>  SystemCall:
> --
> 2.21.1
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S
index cb7864091641..0493fcac6409 100644
--- a/arch/powerpc/kernel/head_32.S
+++ b/arch/powerpc/kernel/head_32.S
@@ -277,6 +277,7 @@  MachineCheck:
 #ifdef CONFIG_VMAP_STACK
 	li	r11, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */
 	mtmsr	r11
+	isync
 #endif
 #ifdef CONFIG_PPC_CHRP
 	mfspr	r11, SPRN_SPRG_THREAD
diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h
index 73a035b40dbf..a6a5fbbf8504 100644
--- a/arch/powerpc/kernel/head_32.h
+++ b/arch/powerpc/kernel/head_32.h
@@ -43,6 +43,7 @@ 
 	.ifeq	\for_rtas
 	li	r11, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */
 	mtmsr	r11
+	isync
 	.endif
 	subi	r11, r1, INT_FRAME_SIZE		/* use r1 if kernel */
 #else
@@ -123,6 +124,7 @@ 
 #ifdef CONFIG_VMAP_STACK
 	li	r9, MSR_KERNEL & ~(MSR_IR | MSR_RI) /* can take DTLB miss */
 	mtmsr	r9
+	isync
 #endif
 	tovirt_vmstack r12, r12
 	tophys_novmstack r11, r11