Re: error: impossible constraint in 'asm' when compiling kernel code with -O0 option

2021-10-05 Thread Jeffrey Walton
On Tue, Oct 5, 2021 at 10:59 PM  wrote:
>
> In linux-5.4.21 code,
>
> To prevent some variables from being ‘optimized out’ during kernel code 
> analysis using gdb, I added in drivers/iommu/Makefile,
> ...
> ./include/linux/compiler-gcc.h:120:38: error: impossible constraint in 'asm'
>
>   120 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while 
> (0)
>...
>
> ./arch/arm64/include/asm/jump_label.h:38:2: note: in expansion of macro 
> 'asm_volatile_goto'
>
>38 |  asm_volatile_goto(
>
>   |  ^
>
> make[2]: *** [scripts/Makefile.build:266: drivers/iommu/io-pgtable-arm.o] 
> Error 1
>
> make[1]: *** [scripts/Makefile.build:509: drivers/iommu] Error 2
>
> make: *** [Makefile:1652: drivers] Error 2
>
> Does anybody know how can I use -O0 flag? (I tried -Og flag but some 
> variables are still optimized out).

Does goto(x) eventually paste x? I.e.,  ##x? Also see token pasting at
https://gcc.gnu.org/onlinedocs/cpp/Concatenation.html.

Jeff

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


error: impossible constraint in 'asm' when compiling kernel code with -O0 option

2021-10-05 Thread ckim
In linux-5.4.21 code,

To prevent some variables from being 'optimized out' during kernel code
analysis using gdb, I added in drivers/iommu/Makefile,

(replacing -O2 flags to -O0 flags for some files,  I found
http://www.joelfernandes.org/linux/2018/06/10/kernel-gdb.html )

CFLAGS_REMOVE_arm-smmu.o := -O2

CFLAGS_REMOVE_arm-smmu-impl.o := -O2

CFLAGS_REMOVE_io-pgtable-arm-v7s.o := -O2

CFLAGS_REMOVE_io-pgtable-arm.o := -O2

CFLAGS_REMOVE_of_iommu.o := -O2

CFLAGS_REMOVE_arm-smmu-v3.o := -O2

CFLAGS_arm-smmu.o := -O0

CFLAGS_arm-smmu-impl.o := -O0

CFLAGS_io-pgtable-arm-v7s.o := -O0

CFLAGS_io-pgtable-arm.o := -O0

CFLAGS_of_iommu.o := -O0

CFLAGS_arm-smmu-v3.o := -O0

But when I do make ARCH=arm64 CROSS_COMPILE=aarch64-none-elf- Image, I get

CALLscripts/checksyscalls.sh

  CALLscripts/atomic/check-atomics.sh

  CHK include/generated/compile.h

  CC  drivers/iommu/io-pgtable-arm.o

In file included from ././include/linux/compiler_types.h:68,

 from :

./arch/arm64/include/asm/jump_label.h: In function
'system_uses_lse_atomics':

./include/linux/compiler-gcc.h:120:38: warning: asm operand 0 probably
doesn't match constraints

  120 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while
(0)

  |  ^~~

./arch/arm64/include/asm/jump_label.h:38:2: note: in expansion of macro
'asm_volatile_goto'

   38 |  asm_volatile_goto(

  |  ^

./include/linux/compiler-gcc.h:120:38: warning: asm operand 0 probably
doesn't match constraints

  120 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while
(0)

  |  ^~~

./arch/arm64/include/asm/jump_label.h:38:2: note: in expansion of macro
'asm_volatile_goto'

   38 |  asm_volatile_goto(

  |  ^

./include/linux/compiler-gcc.h:120:38: error: impossible constraint in 'asm'

  120 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while
(0)

  |  ^~~

./arch/arm64/include/asm/jump_label.h:38:2: note: in expansion of macro
'asm_volatile_goto'

   38 |  asm_volatile_goto(

  |  ^

./include/linux/compiler-gcc.h:120:38: error: impossible constraint in 'asm'

  120 | #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while
(0)

  |  ^~~

./arch/arm64/include/asm/jump_label.h:38:2: note: in expansion of macro
'asm_volatile_goto'

   38 |  asm_volatile_goto(

  |  ^

make[2]: *** [scripts/Makefile.build:266: drivers/iommu/io-pgtable-arm.o]
Error 1

make[1]: *** [scripts/Makefile.build:509: drivers/iommu] Error 2

make: *** [Makefile:1652: drivers] Error 2

Does anybody know how can I use -O0 flag? (I tried -Og flag but some
variables are still optimized out).

Thank you!

Chan Kim

 

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: advice on checkpatch error

2021-10-05 Thread jim . cromie
On Tue, Oct 5, 2021 at 1:14 PM  wrote:
>
> so I have this macro, with some helpers,
> the helper gets a checkpatch error.
>
> DEFINE_DYNAMIC_DEBUG_CATEGORIES(debug_gvt, __gvt_debug,
> "i915/gvt bitmap desc",
> /* map each bit to a category */
> _DD_cat_(0, "gvt:cmd:"),
> _DD_cat_(1, "gvt:core:"),
> _DD_cat_(2, "gvt:dpy:"),
> _DD_cat_(3, "gvt:el:"),
> _DD_cat_(4, "gvt:irq:"),
> _DD_cat_(5, "gvt:mm:"),
> _DD_cat_(6, "gvt:mmio:"),
>
>
> +#if defined(CONFIG_DYNAMIC_DEBUG) || \
> +   (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
> +/**
> + * DEFINE_DYNAMIC_DEBUG_CATEGORIES() - bitmap control of categorized prdbgs
> + * @fsname: parameter basename under /sys
> + * @_var:C-identifier holding bitmap
> + * @desc:  string summarizing the controls provided
> + * @...:list of struct dyndbg_bitdesc initializations
> + *
> + * Intended for modules with substantial use of "categorized" prdbgs
> + * (those with some systematic prefix in the format string), this lets
> + * modules using pr_debug to control them in groups according to their
> + * format prefixes, and map them to bits 0-N of a sysfs control point.
> + * Each @... gives the index and prefix map.
> + */
> +#define DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, _var, desc, ...)   \
> +   MODULE_PARM_DESC(fsname, desc); \
> +   static struct dyndbg_bitmap_param ddcats_##_var =   \
> +   { .bits = &(_var), .map = { __VA_ARGS__, { .match = NULL }}};   \
> +   module_param_cb(fsname, _ops_dyndbg, _##_var, 0644)
> +
> +/* helper macros provide combos of '^' anchor and ' ' postfix */
> +#define _DD_cat_(N, str)   [N] = { .match = str " " }
> +#define _DD_cats_(N, str)  [N] = { .match = str }
> +#define _DD_pfx_(N, str)   [N] = { .match = "^" str " " }
> +#define _DD_pfxs_(N, str)  [N] = { .match = "^" str }
> +
>
> ERROR: space prohibited before open square bracket '['
> #250: FILE: include/linux/dynamic_debug.h:273:
> +#define _DD_cat_(N, str) [N] = { .match = str " " }
>
> Ive tried various (encapsulations) to no avail.
>
> what am I missing ?

I'll just do it more like this ...

static const struct intel_step_info kbl_revids[] = {
[1] = { .gt_step = STEP_B0, .display_step = STEP_B0 },
[2] = { .gt_step = STEP_C0, .display_step = STEP_B0 },
[3] = { .gt_step = STEP_D0, .display_step = STEP_B0 },
[4] = { .gt_step = STEP_F0, .display_step = STEP_C0 },
[5] = { .gt_step = STEP_C0, .display_step = STEP_B1 },
[6] = { .gt_step = STEP_D1, .display_step = STEP_B1 },
[7] = { .gt_step = STEP_G0, .display_step = STEP_C0 },
};

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


advice on checkpatch error

2021-10-05 Thread jim . cromie
so I have this macro, with some helpers,
the helper gets a checkpatch error.

DEFINE_DYNAMIC_DEBUG_CATEGORIES(debug_gvt, __gvt_debug,
"i915/gvt bitmap desc",
/* map each bit to a category */
_DD_cat_(0, "gvt:cmd:"),
_DD_cat_(1, "gvt:core:"),
_DD_cat_(2, "gvt:dpy:"),
_DD_cat_(3, "gvt:el:"),
_DD_cat_(4, "gvt:irq:"),
_DD_cat_(5, "gvt:mm:"),
_DD_cat_(6, "gvt:mmio:"),


+#if defined(CONFIG_DYNAMIC_DEBUG) || \
+   (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
+/**
+ * DEFINE_DYNAMIC_DEBUG_CATEGORIES() - bitmap control of categorized prdbgs
+ * @fsname: parameter basename under /sys
+ * @_var:C-identifier holding bitmap
+ * @desc:  string summarizing the controls provided
+ * @...:list of struct dyndbg_bitdesc initializations
+ *
+ * Intended for modules with substantial use of "categorized" prdbgs
+ * (those with some systematic prefix in the format string), this lets
+ * modules using pr_debug to control them in groups according to their
+ * format prefixes, and map them to bits 0-N of a sysfs control point.
+ * Each @... gives the index and prefix map.
+ */
+#define DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, _var, desc, ...)   \
+   MODULE_PARM_DESC(fsname, desc); \
+   static struct dyndbg_bitmap_param ddcats_##_var =   \
+   { .bits = &(_var), .map = { __VA_ARGS__, { .match = NULL }}};   \
+   module_param_cb(fsname, _ops_dyndbg, _##_var, 0644)
+
+/* helper macros provide combos of '^' anchor and ' ' postfix */
+#define _DD_cat_(N, str)   [N] = { .match = str " " }
+#define _DD_cats_(N, str)  [N] = { .match = str }
+#define _DD_pfx_(N, str)   [N] = { .match = "^" str " " }
+#define _DD_pfxs_(N, str)  [N] = { .match = "^" str }
+

ERROR: space prohibited before open square bracket '['
#250: FILE: include/linux/dynamic_debug.h:273:
+#define _DD_cat_(N, str) [N] = { .match = str " " }

Ive tried various (encapsulations) to no avail.

what am I missing ?

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies