Re: [PATCH 2/4] riscv: support DEBUG_WX

From: Andrew Morton
Date: Sat Apr 25 2020 - 21:05:45 EST


On Tue, 21 Apr 2020 16:17:13 +0800 Zong Li <zong.li@xxxxxxxxxx> wrote:

> Support DEBUG_WX to check whether there are mapping with write and
> execute permission at the same time.
>
> --- a/arch/riscv/include/asm/ptdump.h
> +++ b/arch/riscv/include/asm/ptdump.h
> @@ -8,4 +8,10 @@
>
> void ptdump_check_wx(void);
>
> +#ifdef CONFIG_DEBUG_WX
> +#define debug_checkwx() ptdump_check_wx()
> +#else
> +#define debug_checkwx() do { } while (0)
> +#endif
> +
> #endif /* _ASM_RISCV_PTDUMP_H */

It's preferred to implement things in regular C, unless they MUST be
implemented in the preprocessor. So...

--- a/arch/riscv/include/asm/ptdump.h~riscv-support-debug_wx-fix
+++ a/arch/riscv/include/asm/ptdump.h
@@ -9,9 +9,14 @@
void ptdump_check_wx(void);

#ifdef CONFIG_DEBUG_WX
-#define debug_checkwx() ptdump_check_wx()
+static inline void debug_checkwx(void)
+{
+ ptdump_check_wx();
+}
#else
-#define debug_checkwx() do { } while (0)
+static inline void debug_checkwx(void)
+{
+}
#endif

#endif /* _ASM_RISCV_PTDUMP_H */
_