All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/crypto/crct10dif-vpmsum: Fix missing preempt_disable()
@ 2017-04-19  5:07 Michael Ellerman
  2017-04-20  0:10 ` Daniel Axtens
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Ellerman @ 2017-04-19  5:07 UTC (permalink / raw)
  To: herbert; +Cc: linuxppc-dev, dja

In crct10dif_vpmsum() we call enable_kernel_altivec() without first
disabling preemption, which is not allowed.

It used to be sufficient just to call pagefault_disable(), because that
also disabled preemption. But the two were decoupled in commit 8222dbe21e79
("sched/preempt, mm/fault: Decouple preemption from the page fault
logic") in mid 2015.

The crct10dif-vpmsum code inherited this bug from the crc32c-vpmsum code
on which it was modelled.

So add the missing preempt_disable/enable(). We should also call
disable_kernel_fp(), although it does nothing by default, there is a
debug switch to make it active and all enables should be paired with
disables.

Fixes: b01df1c16c9a ("crypto: powerpc - Add CRC-T10DIF acceleration")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/crypto/crct10dif-vpmsum_glue.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/crypto/crct10dif-vpmsum_glue.c b/arch/powerpc/crypto/crct10dif-vpmsum_glue.c
index bebfc329f746..02ea277863d1 100644
--- a/arch/powerpc/crypto/crct10dif-vpmsum_glue.c
+++ b/arch/powerpc/crypto/crct10dif-vpmsum_glue.c
@@ -44,10 +44,13 @@ static u16 crct10dif_vpmsum(u16 crci, unsigned char const *p, size_t len)
 
 	if (len & ~VMX_ALIGN_MASK) {
 		crc <<= 16;
+		preempt_disable();
 		pagefault_disable();
 		enable_kernel_altivec();
 		crc = __crct10dif_vpmsum(crc, p, len & ~VMX_ALIGN_MASK);
+		disable_kernel_altivec();
 		pagefault_enable();
+		preempt_enable();
 		crc >>= 16;
 	}
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc/crypto/crct10dif-vpmsum: Fix missing preempt_disable()
  2017-04-19  5:07 [PATCH] powerpc/crypto/crct10dif-vpmsum: Fix missing preempt_disable() Michael Ellerman
@ 2017-04-20  0:10 ` Daniel Axtens
  2017-04-20  5:37   ` Michael Ellerman
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Axtens @ 2017-04-20  0:10 UTC (permalink / raw)
  To: Michael Ellerman, herbert; +Cc: linuxppc-dev

Hi Michael,

> Fixes: b01df1c16c9a ("crypto: powerpc - Add CRC-T10DIF acceleration")

Thank you very much for doing this! (and my apologies for not doing it
myself!)

It all looks good to me.

I think an Ack is appropriate in these circumstances?
Acked-by: Daniel Axtens <dja@axtens.net>

Regards,
Daniel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc/crypto/crct10dif-vpmsum: Fix missing preempt_disable()
  2017-04-20  0:10 ` Daniel Axtens
@ 2017-04-20  5:37   ` Michael Ellerman
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2017-04-20  5:37 UTC (permalink / raw)
  To: Daniel Axtens, herbert; +Cc: linuxppc-dev

Daniel Axtens <dja@axtens.net> writes:

> Hi Michael,
>
>> Fixes: b01df1c16c9a ("crypto: powerpc - Add CRC-T10DIF acceleration")
>
> Thank you very much for doing this! (and my apologies for not doing it
> myself!)

No worries, the enable_altivec() API is ridiculous, I'm surprised we
ever get it right.

> It all looks good to me.
>
> I think an Ack is appropriate in these circumstances?
> Acked-by: Daniel Axtens <dja@axtens.net>

Thanks I've added that to v2.

cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-20  5:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-19  5:07 [PATCH] powerpc/crypto/crct10dif-vpmsum: Fix missing preempt_disable() Michael Ellerman
2017-04-20  0:10 ` Daniel Axtens
2017-04-20  5:37   ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.