Linux-Crypto Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] crypto: ux500/crypt: Mark expected switch fall-throughs
@ 2019-07-29 22:38 Gustavo A. R. Silva
  2019-07-30 16:58 ` Kees Cook
  2019-08-09  6:10 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2019-07-29 22:38 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller
  Cc: linux-crypto, linux-kernel, Gustavo A. R. Silva, Kees Cook

Mark switch cases where we are expecting to fall through.

This patch fixes the following warning (Building: arm):

drivers/crypto/ux500/cryp/cryp.c: In function ‘cryp_save_device_context’:
drivers/crypto/ux500/cryp/cryp.c:316:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
   ctx->key_4_r = readl_relaxed(&src_reg->key_4_r);
drivers/crypto/ux500/cryp/cryp.c:318:2: note: here
  case CRYP_KEY_SIZE_192:
  ^~~~
drivers/crypto/ux500/cryp/cryp.c:320:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
   ctx->key_3_r = readl_relaxed(&src_reg->key_3_r);
drivers/crypto/ux500/cryp/cryp.c:322:2: note: here
  case CRYP_KEY_SIZE_128:
  ^~~~
drivers/crypto/ux500/cryp/cryp.c:324:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
   ctx->key_2_r = readl_relaxed(&src_reg->key_2_r);
drivers/crypto/ux500/cryp/cryp.c:326:2: note: here
  default:
  ^~~~~~~
In file included from ./include/linux/io.h:13:0,
                 from drivers/crypto/ux500/cryp/cryp_p.h:14,
                 from drivers/crypto/ux500/cryp/cryp.c:15:
drivers/crypto/ux500/cryp/cryp.c: In function ‘cryp_restore_device_context’:
./arch/arm/include/asm/io.h:92:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
 #define __raw_writel __raw_writel
                      ^
./arch/arm/include/asm/io.h:299:29: note: in expansion of macro ‘__raw_writel’
 #define writel_relaxed(v,c) __raw_writel((__force u32) cpu_to_le32(v),c)
                             ^~~~~~~~~~~~
drivers/crypto/ux500/cryp/cryp.c:363:3: note: in expansion of macro ‘writel_relaxed’
   writel_relaxed(ctx->key_4_r, &reg->key_4_r);
   ^~~~~~~~~~~~~~
drivers/crypto/ux500/cryp/cryp.c:365:2: note: here
  case CRYP_KEY_SIZE_192:
  ^~~~
In file included from ./include/linux/io.h:13:0,
                 from drivers/crypto/ux500/cryp/cryp_p.h:14,
                 from drivers/crypto/ux500/cryp/cryp.c:15:
./arch/arm/include/asm/io.h:92:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
 #define __raw_writel __raw_writel
                      ^
./arch/arm/include/asm/io.h:299:29: note: in expansion of macro ‘__raw_writel’
 #define writel_relaxed(v,c) __raw_writel((__force u32) cpu_to_le32(v),c)
                             ^~~~~~~~~~~~
drivers/crypto/ux500/cryp/cryp.c:367:3: note: in expansion of macro ‘writel_relaxed’
   writel_relaxed(ctx->key_3_r, &reg->key_3_r);
   ^~~~~~~~~~~~~~
drivers/crypto/ux500/cryp/cryp.c:369:2: note: here
  case CRYP_KEY_SIZE_128:
  ^~~~
In file included from ./include/linux/io.h:13:0,
                 from drivers/crypto/ux500/cryp/cryp_p.h:14,
                 from drivers/crypto/ux500/cryp/cryp.c:15:
./arch/arm/include/asm/io.h:92:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
 #define __raw_writel __raw_writel
                      ^
./arch/arm/include/asm/io.h:299:29: note: in expansion of macro ‘__raw_writel’
 #define writel_relaxed(v,c) __raw_writel((__force u32) cpu_to_le32(v),c)
                             ^~~~~~~~~~~~
drivers/crypto/ux500/cryp/cryp.c:371:3: note: in expansion of macro ‘writel_relaxed’
   writel_relaxed(ctx->key_2_r, &reg->key_2_r);
   ^~~~~~~~~~~~~~
drivers/crypto/ux500/cryp/cryp.c:373:2: note: here
  default:
  ^~~~~~~

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/crypto/ux500/cryp/cryp.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/crypto/ux500/cryp/cryp.c b/drivers/crypto/ux500/cryp/cryp.c
index ece83a363e11..f22f6fa612b3 100644
--- a/drivers/crypto/ux500/cryp/cryp.c
+++ b/drivers/crypto/ux500/cryp/cryp.c
@@ -314,14 +314,17 @@ void cryp_save_device_context(struct cryp_device_data *device_data,
 	case CRYP_KEY_SIZE_256:
 		ctx->key_4_l = readl_relaxed(&src_reg->key_4_l);
 		ctx->key_4_r = readl_relaxed(&src_reg->key_4_r);
+		/* Fall through */
 
 	case CRYP_KEY_SIZE_192:
 		ctx->key_3_l = readl_relaxed(&src_reg->key_3_l);
 		ctx->key_3_r = readl_relaxed(&src_reg->key_3_r);
+		/* Fall through */
 
 	case CRYP_KEY_SIZE_128:
 		ctx->key_2_l = readl_relaxed(&src_reg->key_2_l);
 		ctx->key_2_r = readl_relaxed(&src_reg->key_2_r);
+		/* Fall through */
 
 	default:
 		ctx->key_1_l = readl_relaxed(&src_reg->key_1_l);
@@ -361,14 +364,17 @@ void cryp_restore_device_context(struct cryp_device_data *device_data,
 	case CRYP_KEY_SIZE_256:
 		writel_relaxed(ctx->key_4_l, &reg->key_4_l);
 		writel_relaxed(ctx->key_4_r, &reg->key_4_r);
+		/* Fall through */
 
 	case CRYP_KEY_SIZE_192:
 		writel_relaxed(ctx->key_3_l, &reg->key_3_l);
 		writel_relaxed(ctx->key_3_r, &reg->key_3_r);
+		/* Fall through */
 
 	case CRYP_KEY_SIZE_128:
 		writel_relaxed(ctx->key_2_l, &reg->key_2_l);
 		writel_relaxed(ctx->key_2_r, &reg->key_2_r);
+		/* Fall through */
 
 	default:
 		writel_relaxed(ctx->key_1_l, &reg->key_1_l);
-- 
2.22.0


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

* Re: [PATCH] crypto: ux500/crypt: Mark expected switch fall-throughs
  2019-07-29 22:38 [PATCH] crypto: ux500/crypt: Mark expected switch fall-throughs Gustavo A. R. Silva
@ 2019-07-30 16:58 ` Kees Cook
  2019-08-09  6:10 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2019-07-30 16:58 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Herbert Xu, David S. Miller, linux-crypto, linux-kernel

On Mon, Jul 29, 2019 at 05:38:19PM -0500, Gustavo A. R. Silva wrote:
> Mark switch cases where we are expecting to fall through.
> 
> This patch fixes the following warning (Building: arm):
> 
> drivers/crypto/ux500/cryp/cryp.c: In function ‘cryp_save_device_context’:
> drivers/crypto/ux500/cryp/cryp.c:316:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    ctx->key_4_r = readl_relaxed(&src_reg->key_4_r);
> drivers/crypto/ux500/cryp/cryp.c:318:2: note: here
>   case CRYP_KEY_SIZE_192:
>   ^~~~
> drivers/crypto/ux500/cryp/cryp.c:320:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    ctx->key_3_r = readl_relaxed(&src_reg->key_3_r);
> drivers/crypto/ux500/cryp/cryp.c:322:2: note: here
>   case CRYP_KEY_SIZE_128:
>   ^~~~
> drivers/crypto/ux500/cryp/cryp.c:324:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    ctx->key_2_r = readl_relaxed(&src_reg->key_2_r);
> drivers/crypto/ux500/cryp/cryp.c:326:2: note: here
>   default:
>   ^~~~~~~
> In file included from ./include/linux/io.h:13:0,
>                  from drivers/crypto/ux500/cryp/cryp_p.h:14,
>                  from drivers/crypto/ux500/cryp/cryp.c:15:
> drivers/crypto/ux500/cryp/cryp.c: In function ‘cryp_restore_device_context’:
> ./arch/arm/include/asm/io.h:92:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
>  #define __raw_writel __raw_writel
>                       ^
> ./arch/arm/include/asm/io.h:299:29: note: in expansion of macro ‘__raw_writel’
>  #define writel_relaxed(v,c) __raw_writel((__force u32) cpu_to_le32(v),c)
>                              ^~~~~~~~~~~~
> drivers/crypto/ux500/cryp/cryp.c:363:3: note: in expansion of macro ‘writel_relaxed’
>    writel_relaxed(ctx->key_4_r, &reg->key_4_r);
>    ^~~~~~~~~~~~~~
> drivers/crypto/ux500/cryp/cryp.c:365:2: note: here
>   case CRYP_KEY_SIZE_192:
>   ^~~~
> In file included from ./include/linux/io.h:13:0,
>                  from drivers/crypto/ux500/cryp/cryp_p.h:14,
>                  from drivers/crypto/ux500/cryp/cryp.c:15:
> ./arch/arm/include/asm/io.h:92:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
>  #define __raw_writel __raw_writel
>                       ^
> ./arch/arm/include/asm/io.h:299:29: note: in expansion of macro ‘__raw_writel’
>  #define writel_relaxed(v,c) __raw_writel((__force u32) cpu_to_le32(v),c)
>                              ^~~~~~~~~~~~
> drivers/crypto/ux500/cryp/cryp.c:367:3: note: in expansion of macro ‘writel_relaxed’
>    writel_relaxed(ctx->key_3_r, &reg->key_3_r);
>    ^~~~~~~~~~~~~~
> drivers/crypto/ux500/cryp/cryp.c:369:2: note: here
>   case CRYP_KEY_SIZE_128:
>   ^~~~
> In file included from ./include/linux/io.h:13:0,
>                  from drivers/crypto/ux500/cryp/cryp_p.h:14,
>                  from drivers/crypto/ux500/cryp/cryp.c:15:
> ./arch/arm/include/asm/io.h:92:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
>  #define __raw_writel __raw_writel
>                       ^
> ./arch/arm/include/asm/io.h:299:29: note: in expansion of macro ‘__raw_writel’
>  #define writel_relaxed(v,c) __raw_writel((__force u32) cpu_to_le32(v),c)
>                              ^~~~~~~~~~~~
> drivers/crypto/ux500/cryp/cryp.c:371:3: note: in expansion of macro ‘writel_relaxed’
>    writel_relaxed(ctx->key_2_r, &reg->key_2_r);
>    ^~~~~~~~~~~~~~
> drivers/crypto/ux500/cryp/cryp.c:373:2: note: here
>   default:
>   ^~~~~~~
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Reviewed-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  drivers/crypto/ux500/cryp/cryp.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/crypto/ux500/cryp/cryp.c b/drivers/crypto/ux500/cryp/cryp.c
> index ece83a363e11..f22f6fa612b3 100644
> --- a/drivers/crypto/ux500/cryp/cryp.c
> +++ b/drivers/crypto/ux500/cryp/cryp.c
> @@ -314,14 +314,17 @@ void cryp_save_device_context(struct cryp_device_data *device_data,
>  	case CRYP_KEY_SIZE_256:
>  		ctx->key_4_l = readl_relaxed(&src_reg->key_4_l);
>  		ctx->key_4_r = readl_relaxed(&src_reg->key_4_r);
> +		/* Fall through */
>  
>  	case CRYP_KEY_SIZE_192:
>  		ctx->key_3_l = readl_relaxed(&src_reg->key_3_l);
>  		ctx->key_3_r = readl_relaxed(&src_reg->key_3_r);
> +		/* Fall through */
>  
>  	case CRYP_KEY_SIZE_128:
>  		ctx->key_2_l = readl_relaxed(&src_reg->key_2_l);
>  		ctx->key_2_r = readl_relaxed(&src_reg->key_2_r);
> +		/* Fall through */
>  
>  	default:
>  		ctx->key_1_l = readl_relaxed(&src_reg->key_1_l);
> @@ -361,14 +364,17 @@ void cryp_restore_device_context(struct cryp_device_data *device_data,
>  	case CRYP_KEY_SIZE_256:
>  		writel_relaxed(ctx->key_4_l, &reg->key_4_l);
>  		writel_relaxed(ctx->key_4_r, &reg->key_4_r);
> +		/* Fall through */
>  
>  	case CRYP_KEY_SIZE_192:
>  		writel_relaxed(ctx->key_3_l, &reg->key_3_l);
>  		writel_relaxed(ctx->key_3_r, &reg->key_3_r);
> +		/* Fall through */
>  
>  	case CRYP_KEY_SIZE_128:
>  		writel_relaxed(ctx->key_2_l, &reg->key_2_l);
>  		writel_relaxed(ctx->key_2_r, &reg->key_2_r);
> +		/* Fall through */
>  
>  	default:
>  		writel_relaxed(ctx->key_1_l, &reg->key_1_l);
> -- 
> 2.22.0
> 

-- 
Kees Cook

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

* Re: [PATCH] crypto: ux500/crypt: Mark expected switch fall-throughs
  2019-07-29 22:38 [PATCH] crypto: ux500/crypt: Mark expected switch fall-throughs Gustavo A. R. Silva
  2019-07-30 16:58 ` Kees Cook
@ 2019-08-09  6:10 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2019-08-09  6:10 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: David S. Miller, linux-crypto, linux-kernel, Kees Cook

On Mon, Jul 29, 2019 at 05:38:19PM -0500, Gustavo A. R. Silva wrote:
> Mark switch cases where we are expecting to fall through.
> 
> This patch fixes the following warning (Building: arm):
> 
> drivers/crypto/ux500/cryp/cryp.c: In function ‘cryp_save_device_context’:
> drivers/crypto/ux500/cryp/cryp.c:316:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    ctx->key_4_r = readl_relaxed(&src_reg->key_4_r);
> drivers/crypto/ux500/cryp/cryp.c:318:2: note: here
>   case CRYP_KEY_SIZE_192:
>   ^~~~
> drivers/crypto/ux500/cryp/cryp.c:320:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    ctx->key_3_r = readl_relaxed(&src_reg->key_3_r);
> drivers/crypto/ux500/cryp/cryp.c:322:2: note: here
>   case CRYP_KEY_SIZE_128:
>   ^~~~
> drivers/crypto/ux500/cryp/cryp.c:324:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    ctx->key_2_r = readl_relaxed(&src_reg->key_2_r);
> drivers/crypto/ux500/cryp/cryp.c:326:2: note: here
>   default:
>   ^~~~~~~
> In file included from ./include/linux/io.h:13:0,
>                  from drivers/crypto/ux500/cryp/cryp_p.h:14,
>                  from drivers/crypto/ux500/cryp/cryp.c:15:
> drivers/crypto/ux500/cryp/cryp.c: In function ‘cryp_restore_device_context’:
> ./arch/arm/include/asm/io.h:92:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
>  #define __raw_writel __raw_writel
>                       ^
> ./arch/arm/include/asm/io.h:299:29: note: in expansion of macro ‘__raw_writel’
>  #define writel_relaxed(v,c) __raw_writel((__force u32) cpu_to_le32(v),c)
>                              ^~~~~~~~~~~~
> drivers/crypto/ux500/cryp/cryp.c:363:3: note: in expansion of macro ‘writel_relaxed’
>    writel_relaxed(ctx->key_4_r, &reg->key_4_r);
>    ^~~~~~~~~~~~~~
> drivers/crypto/ux500/cryp/cryp.c:365:2: note: here
>   case CRYP_KEY_SIZE_192:
>   ^~~~
> In file included from ./include/linux/io.h:13:0,
>                  from drivers/crypto/ux500/cryp/cryp_p.h:14,
>                  from drivers/crypto/ux500/cryp/cryp.c:15:
> ./arch/arm/include/asm/io.h:92:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
>  #define __raw_writel __raw_writel
>                       ^
> ./arch/arm/include/asm/io.h:299:29: note: in expansion of macro ‘__raw_writel’
>  #define writel_relaxed(v,c) __raw_writel((__force u32) cpu_to_le32(v),c)
>                              ^~~~~~~~~~~~
> drivers/crypto/ux500/cryp/cryp.c:367:3: note: in expansion of macro ‘writel_relaxed’
>    writel_relaxed(ctx->key_3_r, &reg->key_3_r);
>    ^~~~~~~~~~~~~~
> drivers/crypto/ux500/cryp/cryp.c:369:2: note: here
>   case CRYP_KEY_SIZE_128:
>   ^~~~
> In file included from ./include/linux/io.h:13:0,
>                  from drivers/crypto/ux500/cryp/cryp_p.h:14,
>                  from drivers/crypto/ux500/cryp/cryp.c:15:
> ./arch/arm/include/asm/io.h:92:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
>  #define __raw_writel __raw_writel
>                       ^
> ./arch/arm/include/asm/io.h:299:29: note: in expansion of macro ‘__raw_writel’
>  #define writel_relaxed(v,c) __raw_writel((__force u32) cpu_to_le32(v),c)
>                              ^~~~~~~~~~~~
> drivers/crypto/ux500/cryp/cryp.c:371:3: note: in expansion of macro ‘writel_relaxed’
>    writel_relaxed(ctx->key_2_r, &reg->key_2_r);
>    ^~~~~~~~~~~~~~
> drivers/crypto/ux500/cryp/cryp.c:373:2: note: here
>   default:
>   ^~~~~~~
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
>  drivers/crypto/ux500/cryp/cryp.c | 6 ++++++
>  1 file changed, 6 insertions(+)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29 22:38 [PATCH] crypto: ux500/crypt: Mark expected switch fall-throughs Gustavo A. R. Silva
2019-07-30 16:58 ` Kees Cook
2019-08-09  6:10 ` Herbert Xu

Linux-Crypto Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-crypto/0 linux-crypto/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-crypto linux-crypto/ https://lore.kernel.org/linux-crypto \
		linux-crypto@vger.kernel.org linux-crypto@archiver.kernel.org
	public-inbox-index linux-crypto


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-crypto


AGPL code for this site: git clone https://public-inbox.org/ public-inbox