Add support for using the Undefined Behaviour Sanitiser
cover Add support for using the Undefined Behaviour Sanitiser
Andrew Cooper (4):
xen/tmem: Drop unnecessary noinline attribute xen/ubsan: Import ubsan implementation from Linux 4.13 xen/ubsan: Implement __ubsan_handle_nonnull_arg() xen/ubsan: Introduce and use CONFIG_UBSAN
xen/Kconfig | 6 + xen/Kconfig.debug | 8 + xen/Rules.mk | 4 + xen/arch/x86/Kconfig | 1 + xen/common/Makefile | 1 + xen/common/tmem.c | 2 +- xen/common/ubsan/Makefile | 1 + xen/common/ubsan/ubsan.c | 484 +++++++++++++++++++++++++++++++++++++++++++++ xen/common/ubsan/ubsan.h | 84 ++++++++ xen/include/xen/compiler.h | 1 + 10 files changed, 591 insertions(+), 1 deletion(-) create mode 100644 xen/common/ubsan/Makefile create mode 100644 xen/common/ubsan/ubsan.c create mode 100644 xen/common/ubsan/ubsan.h
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 1/4 xen/tmem: Drop unnecessary noinline attribute
tmem_mempool_page_get() is only referenced by address, so isn't eligable for inlining in the first place.
---
CC: Konrad Rzeszutek Wilk <[email protected]>
Not related to the rest of the series, but I stumbled across it while resolving another noinline issue.
--- xen/common/tmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/tmem.c +1 -1
@@ -200,7 +200,7 @@ static void tmem_free_page(struct tmem_pool *pool, struct page_info *pfp)atomic_dec_and_assert (global_page_count); } -static noinline void *tmem_mempool_page_get(unsigned long size) +static void *tmem_mempool_page_get (unsigned long size) {struct page_info *pi;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/4 xen/ubsan: Import ubsan implementation from Linux 4.13
In reply to Andrew CooperA future change will adjust it to compile in Xen.
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>
--- xen/common/ubsan/Makefile | 1 + xen/common/ubsan/ubsan.c | 456 ++++++++++++++++++++++++++++++++++++++++++++++ xen/common/ubsan/ubsan.h | 84 +++++++++ 3 files changed, 541 insertions(+) create mode 100644 xen/common/ubsan/Makefile create mode 100644 xen/common/ubsan/ubsan.c create mode 100644 xen/common/ubsan/ubsan.h
xen/common/ubsan/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y += ubsan.o
xen/common/ubsan/ubsan.c new file +456 -0
456 lines not on this page · raw message
xen/common/ubsan/ubsan.h new file +84 -0
84 lines not on this page · raw message
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 3/4 xen/ubsan: Implement __ubsan_handle_nonnull_arg()
In reply to Andrew CooperThis hook appears to be missing from the Linux ubsan implemention. This patch is a forward port of https://lkml.org/lkml/2014/10/20/182
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>
--- xen/common/ubsan/ubsan.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
xen/common/ubsan/ubsan.c +20 -0
@@ -328,6 +328,26 @@ void __ubsan_handle_type_mismatch(struct type_mismatch_data *data, }EXPORT_SYMBOL (__ubsan_handle_type_mismatch); +void __ubsan_handle_nonnull_arg (struct nonnull_arg_data *data) +{ +unsigned long flags; + +if (suppress_report (&data->location)) +return ; + +ubsan_prologue (&data->location, &flags); + +pr_err ("null pointer passed as argument %d, declared with nonnull attribute\n" , + data->arg_index); + +if (location_is_valid (&data->attr_location)) +print_source_location ("nonnull attribute declared in " , + &data->attr_location); + +ubsan_epilogue (&flags); +} +EXPORT_SYMBOL (__ubsan_handle_nonnull_arg); +void __ubsan_handle_nonnull_return (struct nonnull_return_data *data) {unsigned long flags;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 4/4 xen/ubsan: Introduce and use CONFIG_UBSAN
In reply to Andrew CooperTested with GCC 4.9 of Debian Jessie.
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>
TODO at some future point: Fix the following known issues:
Clang 3.9 - linker error in shadow/multi.c with fetch_type_names[]. With UBSAN enabled, it appears that dead code elimination doesn't remove the single reference to fetch_type_names[] which lives behind DEBUG_TRACE_DUMP.
Clang 4.0 - ABI change with the hooks.
--- xen/Kconfig | 6 ++++++ xen/Kconfig.debug | 8 ++++++++ xen/Rules.mk | 4 ++++ xen/arch/x86/Kconfig | 1 + xen/common/Makefile | 1 + xen/common/ubsan/ubsan.c | 22 +++++++++++++++------- xen/include/xen/compiler.h | 1 + 7 files changed, 36 insertions(+), 7 deletions(-)
xen/Kconfig +6 -0
@@ -38,4 +38,10 @@ config LTO If unsure, say N. +# +# For architectures that know their GCC __int128 support is sound +# +config ARCH_SUPPORTS_INT128 + bool + source "Kconfig.debug"
xen/Kconfig.debug +8 -0
@@ -121,6 +121,14 @@ config SCRUB_DEBUG Verify that pages that need to be scrubbed before being allocated to a guest are indeed scrubbed. +config UBSAN + bool "Undefined behaviour sanitizer" + depends on X86 + ---help--- + Enable undefined behaviour sanitizer. + + If unsure, say N here. + endif # DEBUG || EXPERT endmenu
xen/Rules.mk +4 -0
@@ -119,6 +119,10 @@ ifeq ($(CONFIG_GCOV),y) $(filter-out %.init.o $(nogcov-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -fprofile-arcs -ftest-coverage endif +ifeq ($(CONFIG_UBSAN),y) +$(filter-out %.init.o $(noubsan-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -fsanitize=undefined +endif + ifeq ($(CONFIG_LTO),y) CFLAGS += -flto LDFLAGS-$(clang) += -plugin LLVMgold.so
xen/arch/x86/Kconfig +1 -0
@@ -5,6 +5,7 @@ config X86 def_bool y select ACPI select ACPI_LEGACY_TABLES_LOOKUP + select ARCH_SUPPORTS_INT128 select COMPAT select CORE_PARKING select HAS_ALTERNATIVE
xen/common/Makefile +1 -0
@@ -75,6 +75,7 @@ tmem-$(CONFIG_COMPAT) += compat/tmem_xen.o obj-$(CONFIG_TMEM) += $(tmem-y) subdir-$(CONFIG_GCOV) += gcov +subdir-$(CONFIG_UBSAN) += ubsan subdir-y += libelf subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt
xen/common/ubsan/ubsan.c +15 -7
@@ -10,13 +10,21 @@* */ -#include <linux/bitops.h> -#include <linux/bug.h> -#include <linux/ctype.h> -#include <linux/init.h> -#include <linux/kernel.h> -#include <linux/types.h> -#include <linux/sched.h> +#include <xen/bitops.h> +#include <xen/kernel.h> +#include <xen/lib.h> +#include <xen/types.h> +#include <xen/spinlock.h> +#include <xen/percpu.h> + +#define pr_err (...) printk(XENLOG_ERR __VA_ARGS__) +struct xen_ubsan {int in_ubsan; }; +static DEFINE_PER_CPU(struct xen_ubsan[1], in_ubsan); +#undef current +#define current this_cpu(in_ubsan) +#define dump_stack dump_execution_state +#define u64 long long unsigned int +#define s64 long long int#include "ubsan.h"
xen/include/xen/compiler.h +1 -0
@@ -15,6 +15,7 @@#define noinline __attribute__((__noinline__))#define noreturn __attribute__((__noreturn__)) +#define __noreturn noreturn#define __packed __attribute__((__packed__))
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 4/4] xen/ubsan: Introduce and use CONFIG_UBSAN
Quoted 4 lines · Andrew Cooper
Tested with GCC 4.9 of Debian Jessie.
Signed-off-by Andrew Cooper <[email protected]>Signed-off-by Wei Liu <[email protected]>
Series:
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 4/4] xen/ubsan: Introduce and use CONFIG_UBSAN
In reply to Andrew CooperQuoted 5 lines · Andrew Cooper
TODO at some future point: Fix the following known issues:
Clang 3.9 - linker error in
shadow/multi.cwith fetch_type_names[]. With UBSAN enabled, it appears that dead code elimination doesn't remove the single reference to fetch_type_names[] which lives behindDEBUG_TRACE_DUMP.
FYI, the linking error is:
prelink.o: In function `_sh_propagate':
/local/xen.git/xen/arch/x86/mm/shadow/multi.c:731: undefined reference to `fetch_type_names'
And this patch works around the error:
xen/arch/x86/mm/shadow/multi.c +0 -0
@@ -75,15 +75,11 @@ typedef enum {
ft_demand_write = FETCH_TYPE_DEMAND | FETCH_TYPE_WRITE,
} fetch_type_t;
-extern const char *const fetch_type_names[];
-
-#if defined(DEBUG_TRACE_DUMP) && CONFIG_PAGING_LEVELS == GUEST_PAGING_LEVELS
-const char *const fetch_type_names[] = {
+static const char *const fetch_type_names[] = {
[ft_prefetch] = "prefetch",
[ft_demand_read] = "demand read",
[ft_demand_write] = "demand write",
};
-#endif
/**************************************************************************/ /* Hash table mapping from guest pagetables to shadows
However, this goes against the intended purpose of c/s 89173c1051a0
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 3/4] xen/ubsan: Implement __ubsan_handle_nonnull_arg()
In reply to Andrew CooperQuoted 5 lines
Quoted 1 line
Quoted 1 line · On 03.10.17 at 20:07, <[email protected]> wrote:
This hook appears to be missing from the Linux ubsan implemention. This patch is a forward port of https://lkml.org/lkml/2014/10/20/182
Signed-off-by Andrew Cooper <[email protected]>
Patch 2 as well as this one
albeit preferably with ...
Quoted 15 lines
xen/common/ubsan/ubsan.c +9
-0@@ -328,6 +328,26 @@ void __ubsan_handle_type_mismatch(struct type_mismatch_data *data, }EXPORT_SYMBOL (__ubsan_handle_type_mismatch); +void __ubsan_handle_nonnull_arg (struct nonnull_arg_data *data) +{ +unsigned long flags; + +if (suppress_report (&data->location)) +return ; + +ubsan_prologue (&data->location, &flags); +
xen/common/ubsan/ubsan.c void __ubsan_handle_type_mismatch(struct type_mismatch_data *data, · line 349
Quoted 10 lines
xen/common/ubsan/ubsan.c +10
-0+pr_err ("null pointer passed as argument %d, declared with nonnull attribute\n" , + data->arg_index); + +if (location_is_valid (&data->attr_location)) +print_source_location ("nonnull attribute declared in " , + &data->attr_location); + +ubsan_epilogue (&flags); +} +EXPORT_SYMBOL (__ubsan_handle_nonnull_arg);
... all the EXPORT_SYMBOL()s dropped - I was really hoping we could get ris of what we've left instead of adding new ones.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 4/4] xen/ubsan: Introduce and use CONFIG_UBSAN
In reply to Andrew Cooperxen/Kconfig config LTO · line 45
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 03.10.17 at 20:07, <[email protected]> wrote:
xen/Kconfig +5
-0@@ -38,4 +38,10 @@ config LTO If unsure, say N. +# +# For architectures that know their GCC __int128 support is sound +# +config ARCH_SUPPORTS_INT128 + bool
Why GCC? What about Clang?
xen/Kconfig.debug config SCRUB_DEBUG · line 126
Quoted 9 lines
xen/Kconfig.debug +3
-0@@ -121,6 +121,14 @@ config SCRUB_DEBUG Verify that pages that need to be scrubbed before being allocated to a guest are indeed scrubbed. +config UBSAN + bool "Undefined behaviour sanitizer" + depends on X86
I think we should switch away from this model of explicitly stating architectures, and instead have HAVE_* symbols selected by each architecture supporting it, and the main symbol then depending on the HAVE_* one. Us having only two architectures right now doesn't make this a big difference, but Linux has (partially?) switched to that model for a reason, I think.
xen/Rules.mk ifeq ($(CONFIG_GCOV),y) · line 124
Quoted 10 lines
xen/Rules.mk +3
-1@@ -119,6 +119,10 @@ ifeq ($(CONFIG_GCOV),y) $(filter-out %.init.o $(nogcov-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -fprofile-arcs -ftest-coverage endif +ifeq ($(CONFIG_UBSAN),y) +$(filter-out %.init.o $(noubsan-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -fsanitize=undefined +endif
You have no users of noubsan-y, other than what Wei's RFC patch had. Also neither you nor he explain why *.init.o are unilaterally excluded.
Quoted 9 lines
xen/common/ubsan/ubsan.c +0
-3@@ -10,13 +10,21 @@* */ -#include <linux/bitops.h> -#include <linux/bug.h> -#include <linux/ctype.h>
xen/common/ubsan/ubsan.c line 18
Quoted 10 lines
xen/common/ubsan/ubsan.c +6
-4-#include <linux/init.h> -#include <linux/kernel.h> -#include <linux/types.h> -#include <linux/sched.h> +#include <xen/bitops.h> +#include <xen/kernel.h> +#include <xen/lib.h> +#include <xen/types.h> +#include <xen/spinlock.h> +#include <xen/percpu.h>
I don't think all of these are needed - xen/types.h is certainly being included implicitly by several others, for example, and always will be.
xen/include/xen/compiler.h line 18
Quoted 7 lines
xen/include/xen/compiler.h +1
-0@@ -15,6 +15,7 @@#define noinline __attribute__((__noinline__))#define noreturn __attribute__((__noreturn__)) +#define __noreturn noreturn
Please let's avoid new name space violations if at all possibly, or at least restrict them to individual source files where eliminating them would be undesirable.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 4/4] xen/ubsan: Introduce and use CONFIG_UBSAN
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 03.10.17 at 20:07, <[email protected]> wrote:
xen/Kconfig +0
-0@@ -38,4 +38,10 @@ config LTO
Quoted 8 lines
xen/Kconfig config LTO · line 45
Quoted 7 lines
xen/Kconfig +5
-0If unsure, say N. +# +# For architectures that know their GCC __int128 support is sound +# +config ARCH_SUPPORTS_INT128 + boolWhy GCC? What about Clang?
This came straight from Linux. I can s/GCC/compiler/ if you like?
Quoted 7 lines
Quoted 7 lines
xen/Kconfig.debug +0
-0@@ -121,6 +121,14 @@ config SCRUB_DEBUG Verify that pages that need to be scrubbed before being allocated to a guest are indeed scrubbed.
Quoted 9 lines
xen/Kconfig.debug config SCRUB_DEBUG · line 126
Quoted 3 lines
xen/Kconfig.debug +3
-0+config UBSAN + bool "Undefined behaviour sanitizer" + depends on X86I think we should switch away from this model of explicitly stating architectures, and instead have HAVE_* symbols selected by each architecture supporting it, and the main symbol then depending on the HAVE_* one. Us having only two architectures right now doesn't make this a big difference, but Linux has (partially?) switched to that model for a reason, I think.
I'm not fussed. Which would you prefer?
Quoted 8 lines
Quoted 8 lines
xen/Rules.mk +0
-1@@ -119,6 +119,10 @@ ifeq ($(CONFIG_GCOV),y) $(filter-out %.init.o $(nogcov-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -fprofile-arcs -ftest-coverage endif
Quoted 6 lines
xen/Rules.mk ifeq ($(CONFIG_GCOV),y) · line 124
Quoted 3 lines
xen/Rules.mk +3
-0+ifeq ($(CONFIG_UBSAN),y) +$(filter-out %.init.o $(noubsan-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -fsanitize=undefined +endifYou have no users of noubsan-y, other than what Wei's RFC patch had. Also neither you nor he explain why *.init.o are unilaterally excluded.
The answer is complicated. If you want it to work with .init. files, then the following change is required:
xen/Rules.mk +0 -0
@@ -189,7 +189,7 @@ $(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)):
%.init.o: %.o Makefile
.text|.text.*|.data|.data.*|.bss) \
test $$sz != 0 || continue; \
echo "Error: size of $<:$$name is 0x$$sz" >&2; \
- exit $$(expr $$idx + 1);; \
+ # exit $$(expr $$idx + 1);; \
esac; \
done
$(OBJCOPY) $(foreach s,$(SPECIAL_DATA_SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@
I was debating whether to keep or remove the noubsan, but I figured that keeping it would be more flexible for developing with.
Quoted 7 lines
Quoted 7 lines
xen/common/ubsan/ubsan.c +0
-0@@ -10,13 +10,21 @@* */
Quoted 16 lines
xen/common/ubsan/ubsan.c line 18
Quoted 13 lines
xen/common/ubsan/ubsan.c +6
-7-#include <linux/bitops.h> -#include <linux/bug.h> -#include <linux/ctype.h> -#include <linux/init.h> -#include <linux/kernel.h> -#include <linux/types.h> -#include <linux/sched.h> +#include <xen/bitops.h> +#include <xen/kernel.h> +#include <xen/lib.h> +#include <xen/types.h> +#include <xen/spinlock.h> +#include <xen/percpu.h> I don't think all of these are needed -
xen/types.his certainly being included implicitly by several others, for example, and always will be.
Hmm. This list of headers is ~18 months old. I will see if I can prune it some more.
Quoted 11 lines
xen/include/xen/compiler.h line 18
Quoted 8 lines
xen/include/xen/compiler.h +1
-0@@ -15,6 +15,7 @@#define noinline __attribute__((__noinline__))#define noreturn __attribute__((__noreturn__)) +#define __noreturn noreturnPlease let's avoid new name space violations if at all possibly, or at least restrict them to individual source files where eliminating them would be undesirable.
This is entirely down to how much we want to diverge the Linux code. For ubsan, I've gone out of my way not to modify the Linux code at all.
I can see an argument for making this local to the file in question. However, that needs to be weighed up against other Linux source we choose to take.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 4/4] xen/ubsan: Introduce and use CONFIG_UBSAN
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 04.10.17 at 15:28, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 03.10.17 at 20:07, <[email protected]> wrote:
xen/Kconfig +0
-0@@ -38,4 +38,10 @@ config LTO If unsure, say N.
Quoted 8 lines
Quoted 6 lines
xen/Kconfig config LTO · line 45
Quoted 5 lines
xen/Kconfig +5
-0+# +# For architectures that know their GCC __int128 support is sound +# +config ARCH_SUPPORTS_INT128 + boolWhy GCC? What about Clang?
This came straight from Linux. I can s/GCC/compiler/ if you like?
Yes please (provided it's usable with Clang).
Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
xen/Kconfig.debug +0
-0@@ -121,6 +121,14 @@ config SCRUB_DEBUG Verify that pages that need to be scrubbed before being allocated to a guest are indeed scrubbed.Quoted 9 lines
xen/Kconfig.debug config SCRUB_DEBUG · line 126
Quoted 3 lines
xen/Kconfig.debug +3
-0+config UBSAN + bool "Undefined behaviour sanitizer" + depends on X86I think we should switch away from this model of explicitly stating architectures, and instead have HAVE_* symbols selected by each architecture supporting it, and the main symbol then depending on the HAVE_* one. Us having only two architectures right now doesn't make this a big difference, but Linux has (partially?) switched to that model for a reason, I think.
Quoted 1 line
I'm not fussed. Which would you prefer?
I'd prefer the combination HAVE_UBSAN plus UBSAN, as outlined.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
xen/Rules.mk +0
-1@@ -119,6 +119,10 @@ ifeq ($(CONFIG_GCOV),y) $(filter-out %.init.o $(nogcov-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -fprofile-arcs -ftest-coverage endif
Quoted 5 lines
Quoted 5 lines
xen/Rules.mk ifeq ($(CONFIG_GCOV),y) · line 124
Quoted 3 lines
xen/Rules.mk +3
-0+ifeq ($(CONFIG_UBSAN),y) +$(filter-out %.init.o $(noubsan-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -fsanitize=undefined +endifYou have no users of noubsan-y, other than what Wei's RFC patch had.
What about this part?
Quoted 22 lines
Quoted 2 lines
Also neither you nor he explain why *.init.o are unilaterally excluded.
The answer is complicated. If you want it to work with .init. files, then the following change is required:
xen/Rules.mk +0
-0@@ -189,7 +189,7 @@ $(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)):%.init.o: %.o
Makefile.text|.text.*|.data|.data.*|.bss) \ test $$sz != 0 || continue; \ echo "Error: size of $<:$$name is 0x$$sz" >&2; \xen/Rules.mk +1
-1- exit $$(expr $$idx + 1);; \ + # exit $$(expr $$idx + 1);; \ esac; \ done $(OBJCOPY) $(foreach s,$(SPECIAL_DATA_SECTIONS),--rename-section.$(s)=.init.$(s)) $< $@
Quoted 2 lines
I was debating whether to keep or remove the noubsan, but I figured that keeping it would be more flexible for developing with.
Could you mention this in the commit message then, please?
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
xen/include/xen/compiler.h +0
-0@@ -15,6 +15,7 @@#define noinline __attribute__((__noinline__))
Quoted 8 lines
Quoted 5 lines
xen/include/xen/compiler.h line 18
Quoted 2 lines
xen/include/xen/compiler.h +1
-0#define noreturn __attribute__((__noreturn__)) +#define __noreturn noreturnPlease let's avoid new name space violations if at all possibly, or at least restrict them to individual source files where eliminating them would be undesirable.
This is entirely down to how much we want to diverge the Linux code. For ubsan, I've gone out of my way not to modify the Linux code at all.
Except for the #include-s.
Quoted 3 lines
I can see an argument for making this local to the file in question. However, that needs to be weighed up against other Linux source we choose to take.
As there's no reasonable chance for us to ever be able to take a Linux file completely unmodified, if putting such #define-s into individual files is too restrictive for your taste, how about making those files identify themselves (by, say, #define LINUX_SOURCE) and enabling such compatibility things only for those?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 1/4] xen/tmem: Drop unnecessary noinline attribute
In reply to Andrew CooperQuoted 6 lines · Andrew Cooper
tmem_mempool_page_get()is only referenced by address, so isn't eligable for inlining in the first place.Signed-off-by Andrew Cooper <[email protected]>---
CC: Konrad Rzeszutek Wilk <[email protected]>
Quoted 23 lines
Not related to the rest of the series, but I stumbled across it while resolving another noinline issue.
--- xen/common/tmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/common/tmem.c +1
-1@@ -200,7 +200,7 @@ static void tmem_free_page(struct tmem_pool *pool, struct page_info *pfp)atomic_dec_and_assert (global_page_count); } -static noinline void *tmem_mempool_page_get(unsigned long size) +static void *tmem_mempool_page_get (unsigned long size) {struct page_info *pi;Signature · 1 line
2.1.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 4/4] xen/ubsan: Introduce and use CONFIG_UBSAN
In reply to Andrew Cooperxen/Kconfig.debug config SCRUB_DEBUG · line 130
Quoted 7 lines
xen/Kconfig.debug +7
-0+config UBSAN + bool "Undefined behaviour sanitizer" + depends on X86 + ---help--- + Enable undefined behaviour sanitizer. + + If unsure, say N here.
Could you perhaps expand it a bit? How does it sanitize it? With soap :-)? And what 'undefinded behaviour's are we talking about? opcodes?
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 4/4] xen/ubsan: Introduce and use CONFIG_UBSAN
Quoted 10 lines · Konrad Rzeszutek Wilk
xen/Kconfig.debug config SCRUB_DEBUG · line 130
Quoted 7 lines
xen/Kconfig.debug +7
-0+config UBSAN + bool "Undefined behaviour sanitizer" + depends on X86 + ---help--- + Enable undefined behaviour sanitizer. + + If unsure, say N here.Could you perhaps expand it a bit? How does it sanitize it? With soap :-)? And what 'undefinded behaviour's are we talking about? opcodes?
It sanitizes undefined behaviour in C.
It does so by using compiler black magic: the code in Xen is instrumented; appropriate calls to hooks are inserted; hooks are called once UB is detected during runtime.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel