linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/crypto/crc32c-vpmsum: Fix missing preempt_disable()
@ 2017-04-06 13:34 Michael Ellerman
  2017-04-07  1:00 ` Daniel Axtens
  2017-04-12  3:39 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Ellerman @ 2017-04-06 13:34 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: anton

In crc32c_vpmsum() we call enable_kernel_altivec() without first
disabling preemption, which is not allowed:

  WARNING: CPU: 9 PID: 2949 at ../arch/powerpc/kernel/process.c:277 enable_kernel_altivec+0x100/0x120
  Modules linked in: dm_thin_pool dm_persistent_data dm_bio_prison dm_bufio libcrc32c vmx_crypto ...
  CPU: 9 PID: 2949 Comm: docker Not tainted 4.11.0-rc5-compiler_gcc-6.3.1-00033-g308ac7563944 #381
  ...
  NIP [c00000000001e320] enable_kernel_altivec+0x100/0x120
  LR [d000000003df0910] crc32c_vpmsum+0x108/0x150 [crc32c_vpmsum]
  Call Trace:
    0xc138fd09 (unreliable)
    crc32c_vpmsum+0x108/0x150 [crc32c_vpmsum]
    crc32c_vpmsum_update+0x3c/0x60 [crc32c_vpmsum]
    crypto_shash_update+0x88/0x1c0
    crc32c+0x64/0x90 [libcrc32c]
    dm_bm_checksum+0x48/0x80 [dm_persistent_data]
    sb_check+0x84/0x120 [dm_thin_pool]
    dm_bm_validate_buffer.isra.0+0xc0/0x1b0 [dm_persistent_data]
    dm_bm_read_lock+0x80/0xf0 [dm_persistent_data]
    __create_persistent_data_objects+0x16c/0x810 [dm_thin_pool]
    dm_pool_metadata_open+0xb0/0x1a0 [dm_thin_pool]
    pool_ctr+0x4cc/0xb60 [dm_thin_pool]
    dm_table_add_target+0x16c/0x3c0
    table_load+0x184/0x400
    ctl_ioctl+0x2f0/0x560
    dm_ctl_ioctl+0x38/0x50
    do_vfs_ioctl+0xd8/0x920
    SyS_ioctl+0x68/0xc0
    system_call+0x38/0xfc

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.

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: 6dd7a82cc54e ("crypto: powerpc - Add POWER8 optimised crc32c")
Cc: stable@vger.kernel.org # v4.8+
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/crypto/crc32c-vpmsum_glue.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/crypto/crc32c-vpmsum_glue.c b/arch/powerpc/crypto/crc32c-vpmsum_glue.c
index 411994551afc..f058e0c3e4d4 100644
--- a/arch/powerpc/crypto/crc32c-vpmsum_glue.c
+++ b/arch/powerpc/crypto/crc32c-vpmsum_glue.c
@@ -33,10 +33,13 @@ static u32 crc32c_vpmsum(u32 crc, unsigned char const *p, size_t len)
 	}
 
 	if (len & ~VMX_ALIGN_MASK) {
+		preempt_disable();
 		pagefault_disable();
 		enable_kernel_altivec();
 		crc = __crc32c_vpmsum(crc, p, len & ~VMX_ALIGN_MASK);
+		disable_kernel_altivec();
 		pagefault_enable();
+		preempt_enable();
 	}
 
 	tail = len & VMX_ALIGN_MASK;
-- 
2.7.4

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

* Re: [PATCH] powerpc/crypto/crc32c-vpmsum: Fix missing preempt_disable()
  2017-04-06 13:34 [PATCH] powerpc/crypto/crc32c-vpmsum: Fix missing preempt_disable() Michael Ellerman
@ 2017-04-07  1:00 ` Daniel Axtens
  2017-04-12  3:39 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Axtens @ 2017-04-07  1:00 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: anton

Hi Michael,

We'll also need a similar patch for the t10dif code that went in to
Herbert's next.

I will do a patch once I get my development environment up and going
again.

Regards,
Daniel

Michael Ellerman <mpe@ellerman.id.au> writes:

> In crc32c_vpmsum() we call enable_kernel_altivec() without first
> disabling preemption, which is not allowed:
>
>   WARNING: CPU: 9 PID: 2949 at ../arch/powerpc/kernel/process.c:277 enable_kernel_altivec+0x100/0x120
>   Modules linked in: dm_thin_pool dm_persistent_data dm_bio_prison dm_bufio libcrc32c vmx_crypto ...
>   CPU: 9 PID: 2949 Comm: docker Not tainted 4.11.0-rc5-compiler_gcc-6.3.1-00033-g308ac7563944 #381
>   ...
>   NIP [c00000000001e320] enable_kernel_altivec+0x100/0x120
>   LR [d000000003df0910] crc32c_vpmsum+0x108/0x150 [crc32c_vpmsum]
>   Call Trace:
>     0xc138fd09 (unreliable)
>     crc32c_vpmsum+0x108/0x150 [crc32c_vpmsum]
>     crc32c_vpmsum_update+0x3c/0x60 [crc32c_vpmsum]
>     crypto_shash_update+0x88/0x1c0
>     crc32c+0x64/0x90 [libcrc32c]
>     dm_bm_checksum+0x48/0x80 [dm_persistent_data]
>     sb_check+0x84/0x120 [dm_thin_pool]
>     dm_bm_validate_buffer.isra.0+0xc0/0x1b0 [dm_persistent_data]
>     dm_bm_read_lock+0x80/0xf0 [dm_persistent_data]
>     __create_persistent_data_objects+0x16c/0x810 [dm_thin_pool]
>     dm_pool_metadata_open+0xb0/0x1a0 [dm_thin_pool]
>     pool_ctr+0x4cc/0xb60 [dm_thin_pool]
>     dm_table_add_target+0x16c/0x3c0
>     table_load+0x184/0x400
>     ctl_ioctl+0x2f0/0x560
>     dm_ctl_ioctl+0x38/0x50
>     do_vfs_ioctl+0xd8/0x920
>     SyS_ioctl+0x68/0xc0
>     system_call+0x38/0xfc
>
> 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.
>
> 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: 6dd7a82cc54e ("crypto: powerpc - Add POWER8 optimised crc32c")
> Cc: stable@vger.kernel.org # v4.8+
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/crypto/crc32c-vpmsum_glue.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/arch/powerpc/crypto/crc32c-vpmsum_glue.c b/arch/powerpc/crypto/crc32c-vpmsum_glue.c
> index 411994551afc..f058e0c3e4d4 100644
> --- a/arch/powerpc/crypto/crc32c-vpmsum_glue.c
> +++ b/arch/powerpc/crypto/crc32c-vpmsum_glue.c
> @@ -33,10 +33,13 @@ static u32 crc32c_vpmsum(u32 crc, unsigned char const *p, size_t len)
>  	}
>  
>  	if (len & ~VMX_ALIGN_MASK) {
> +		preempt_disable();
>  		pagefault_disable();
>  		enable_kernel_altivec();
>  		crc = __crc32c_vpmsum(crc, p, len & ~VMX_ALIGN_MASK);
> +		disable_kernel_altivec();
>  		pagefault_enable();
> +		preempt_enable();
>  	}
>  
>  	tail = len & VMX_ALIGN_MASK;
> -- 
> 2.7.4

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

* Re: powerpc/crypto/crc32c-vpmsum: Fix missing preempt_disable()
  2017-04-06 13:34 [PATCH] powerpc/crypto/crc32c-vpmsum: Fix missing preempt_disable() Michael Ellerman
  2017-04-07  1:00 ` Daniel Axtens
@ 2017-04-12  3:39 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2017-04-12  3:39 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: anton

On Thu, 2017-04-06 at 13:34:38 UTC, Michael Ellerman wrote:
> In crc32c_vpmsum() we call enable_kernel_altivec() without first
> disabling preemption, which is not allowed:
> 
>   WARNING: CPU: 9 PID: 2949 at ../arch/powerpc/kernel/process.c:277 enable_kernel_altivec+0x100/0x120
>   Modules linked in: dm_thin_pool dm_persistent_data dm_bio_prison dm_bufio libcrc32c vmx_crypto ...
>   CPU: 9 PID: 2949 Comm: docker Not tainted 4.11.0-rc5-compiler_gcc-6.3.1-00033-g308ac7563944 #381
>   ...
>   NIP [c00000000001e320] enable_kernel_altivec+0x100/0x120
>   LR [d000000003df0910] crc32c_vpmsum+0x108/0x150 [crc32c_vpmsum]
>   Call Trace:
>     0xc138fd09 (unreliable)
>     crc32c_vpmsum+0x108/0x150 [crc32c_vpmsum]
>     crc32c_vpmsum_update+0x3c/0x60 [crc32c_vpmsum]
>     crypto_shash_update+0x88/0x1c0
>     crc32c+0x64/0x90 [libcrc32c]
>     dm_bm_checksum+0x48/0x80 [dm_persistent_data]
>     sb_check+0x84/0x120 [dm_thin_pool]
>     dm_bm_validate_buffer.isra.0+0xc0/0x1b0 [dm_persistent_data]
>     dm_bm_read_lock+0x80/0xf0 [dm_persistent_data]
>     __create_persistent_data_objects+0x16c/0x810 [dm_thin_pool]
>     dm_pool_metadata_open+0xb0/0x1a0 [dm_thin_pool]
>     pool_ctr+0x4cc/0xb60 [dm_thin_pool]
>     dm_table_add_target+0x16c/0x3c0
>     table_load+0x184/0x400
>     ctl_ioctl+0x2f0/0x560
>     dm_ctl_ioctl+0x38/0x50
>     do_vfs_ioctl+0xd8/0x920
>     SyS_ioctl+0x68/0xc0
>     system_call+0x38/0xfc
> 
> 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.
> 
> 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: 6dd7a82cc54e ("crypto: powerpc - Add POWER8 optimised crc32c")
> Cc: stable@vger.kernel.org # v4.8+
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Applied to powerpc fixes.

https://git.kernel.org/powerpc/c/4749228f022893faf54a3dbc70796f

cheers

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

end of thread, other threads:[~2017-04-12  3:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-06 13:34 [PATCH] powerpc/crypto/crc32c-vpmsum: Fix missing preempt_disable() Michael Ellerman
2017-04-07  1:00 ` Daniel Axtens
2017-04-12  3:39 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).