Powered by Linux
Re: SMATCH indicates warning to almost all files in Linux Kernel + ARM — Semantic Matching Tool

Re: SMATCH indicates warning to almost all files in Linux Kernel + ARM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Christopher, Luc

Thank you for your help

> >>   CC      sound/soc/soc-dapm.o
> >>   CHK     kernel/config_data.h
> >> linux/arch/arm64/include/asm/lse.h:14:28: warning: Unknown escape 'l'
> >> linux/arch/arm64/include/asm/lse.h:14:37: warning: Unknown escape 'l'
> >> linux/arch/arm64/include/asm/alternative.h:172:28: warning: Unknown escape 'o'
(snip)
> It seems that ARM has some very interesting assembly
> directly embed into the C source code. That is not support
> by sparse. Those section of code is protected by
> __ASSEMBLY__ macro.
>
> Can you try to turn off  __ASSEMBLY__ definition in the
> sparse invocation?

I tried it, but it couldn't solve my issue.
Doesn't smatch check #if ? see below.

But it seems this issue was already solved (?)

	> This is solved in sparse since commit f83c2b8f0b5fcb8f60342b5a2fa51a84901f355a:
	>     "warn on unknown escapes after preprocessing"

I couldn't find this commit on latest smatch git.
Maybe it will be added/merged for next version ?
I'm happy to update smatch then :)

Here, I will report what I tried.
I'm using this smatch now

	7cbe6f9055d5e2e52ab68a6898be366720f69daf
	("type_val: fix a type bug parsing global assignments")

and latest Linux Kernel.
My ARM compiler is

	> aarch64-linux-gnu-gcc -v                                                                                                          [~/WORK/linux]
	...
	gcc version 6.2.1 20161016 (Linaro GCC 6.2-2016.11) 

I'm using this command

	ARCH=arm64 CROSS_COMPILE="ccache aarch64-linux-gnu-" make CHECK="/path/smatch/smatch -p=kernel"

# note is that I'm just smatch user, I don't know detail
# of smatch etc...

I tried variously things, and it seems smatch doesn't check #if ?
This lse.h file is this construction.

--- lse.h ----------
	...
	#if defined(CONFIG_AS_LSE) && defined(CONFIG_ARM64_LSE_ATOMICS)

	#include <linux/stringify.h>
	#include <asm/alternative.h>

	#ifdef __ASSEMBLER__

	.arch_extension	lse

	.macro alt_lse, llsc, lse
		alternative_insn "\llsc", "\lse", ARM64_HAS_LSE_ATOMICS
	.endm

	#else	/* __ASSEMBLER__ */
	...
----------------------

1st, I removed "-D__ASSEMBLER__" from Makefile, but warning didn't disappear.
2nd, I added #undef __ASSEMBLER__ on this file, but this warning didn't disappear,

--- lse.h ----------
	...
	#if defined(CONFIG_AS_LSE) && defined(CONFIG_ARM64_LSE_ATOMICS)

	#include <linux/stringify.h>
	#include <asm/alternative.h>

+	#undef __ASSEMBLER__
	#ifdef __ASSEMBLER__

	.arch_extension	lse

	.macro alt_lse, llsc, lse
=>		alternative_insn "\llsc", "\lse", ARM64_HAS_LSE_ATOMICS
	.endm

	#else	/* __ASSEMBLER__ */
	...
----------------------

3rd, I added dummy code on this file to check compiler / smatch behavior.
Compiler indicates error on "dummy" line.
This is same as my expectation.

--- lse.h ----------
	#ifndef __ASM_LSE_H
	#define __ASM_LSE_H

+	dummy;

	#if defined(CONFIG_AS_LSE) && defined(CONFIG_ARM64_LSE_ATOMICS)

	#include <linux/stringify.h>
	#include <asm/alternative.h>

	#ifdef __ASSEMBLER__

	.arch_extension	lse

	.macro alt_lse, llsc, lse
		alternative_insn "\llsc", "\lse", ARM64_HAS_LSE_ATOMICS
	.endm

	#else	/* __ASSEMBLER__ */
	...
----------------------

This case, compiler doesn't indicates error for "dummy",
but smatch indicates warning on "=>" line.
Thus, I thought smatch doesn't check #if ?

--- lse.h ----------
	#ifndef __ASM_LSE_H
	#define __ASM_LSE_H

	#if defined(CONFIG_AS_LSE) && defined(CONFIG_ARM64_LSE_ATOMICS)

+	dummy;

	#include <linux/stringify.h>
	#include <asm/alternative.h>

	#ifdef __ASSEMBLER__

	.arch_extension	lse

	.macro alt_lse, llsc, lse
=>		alternative_insn "\llsc", "\lse", ARM64_HAS_LSE_ATOMICS
	.endm

	#else	/* __ASSEMBLER__ */
	...
----------------------


Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line "unsubscribe smatch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux