summaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2024-01-23 08:43:10 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2024-01-23 08:43:10 +0100
commitc3e2a96606318aa5fe5e2ee197ae89e5a1ed9a8e (patch)
treebfc480e79476d40a9af2c3b63c5e0b741ecebf30 /include/linux
parent5c3624e39bca790b03081f629d2b5d35018b8e63 (diff)
parentf9c6eb75f5640065694611dde159b5d3feca12ab (diff)
downloadbarebox-c3e2a96606318aa5fe5e2ee197ae89e5a1ed9a8e.tar.gz
barebox-c3e2a96606318aa5fe5e2ee197ae89e5a1ed9a8e.tar.xz
Merge branch 'for-next/misc'
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/bug.h17
-rw-r--r--include/linux/clk.h2
-rw-r--r--include/linux/compiler_types.h6
-rw-r--r--include/linux/export.h11
-rw-r--r--include/linux/list.h20
-rw-r--r--include/linux/pci.h4
6 files changed, 41 insertions, 19 deletions
diff --git a/include/linux/bug.h b/include/linux/bug.h
index d8fc328a07..8ea5f8d1b2 100644
--- a/include/linux/bug.h
+++ b/include/linux/bug.h
@@ -6,4 +6,21 @@
#include <asm-generic/bug.h>
#include <linux/build_bug.h>
+/*
+ * Since detected data corruption should stop operation on the affected
+ * structures. Return value must be checked and sanely acted on by caller.
+ */
+static inline __must_check bool check_data_corruption(bool v) { return v; }
+#define CHECK_DATA_CORRUPTION(condition, fmt, ...) \
+ check_data_corruption(({ \
+ bool corruption = unlikely(condition); \
+ if (corruption) { \
+ if (IS_ENABLED(CONFIG_BUG_ON_DATA_CORRUPTION)) { \
+ panic(fmt, ##__VA_ARGS__); \
+ } else \
+ WARN(1, fmt, ##__VA_ARGS__); \
+ } \
+ corruption; \
+ }))
+
#endif /* _LINUX_BUG_H */
diff --git a/include/linux/clk.h b/include/linux/clk.h
index aeff020fea..1bdfb21d50 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -762,7 +762,7 @@ struct clk_hw_onecell_data {
#define CLK_OF_DECLARE(name, compat, fn) \
const struct of_device_id __clk_of_table_##name \
-__attribute__ ((unused,section (".__clk_of_table"))) \
+ __ll_elem(.__clk_of_table) \
= { .compatible = compat, .data = fn }
void of_clk_del_provider(struct device_node *np);
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 9ef8115a39..d925b3da29 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -274,6 +274,12 @@ struct ftrace_likely_data {
#define __cold __attribute__((cold))
#define __section(S) __attribute__((__section__(#S)))
+#ifdef __clang__
+#define __ll_elem(S) __section(S) __used __no_sanitize_address
+#else
+#define __ll_elem(S) __section(S) __used
+#endif
+
#ifdef CONFIG_ENABLE_MUST_CHECK
#define __must_check __attribute__((warn_unused_result))
diff --git a/include/linux/export.h b/include/linux/export.h
index 90f6ada2d5..8f47742bea 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -15,21 +15,20 @@ struct kernel_symbol
};
/* For every exported symbol, place a struct in the __ksymtab section */
-#define __EXPORT_SYMBOL(sym, sec) \
+#define __EXPORT_SYMBOL(sym) \
extern typeof(sym) sym; \
static const char __ustrtab_##sym[] \
- __attribute__((section("__usymtab_strings"))) \
+ __ll_elem(__usymtab_strings) \
= MODULE_SYMBOL_PREFIX #sym; \
static const struct kernel_symbol __usymtab_##sym \
- __used \
- __attribute__((section("__usymtab" sec), unused)) \
+ __ll_elem(__usymtab) \
= { (unsigned long)&sym, __ustrtab_##sym }
#define EXPORT_SYMBOL(sym) \
- __EXPORT_SYMBOL(sym, "")
+ __EXPORT_SYMBOL(sym)
#define EXPORT_SYMBOL_GPL(sym) \
- __EXPORT_SYMBOL(sym, "")
+ __EXPORT_SYMBOL(sym)
#else
diff --git a/include/linux/list.h b/include/linux/list.h
index 1341806b59..60b0111f46 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -37,18 +37,18 @@ static inline void INIT_LIST_HEAD(struct list_head *list)
}
#ifdef CONFIG_DEBUG_LIST
-extern bool __list_add_valid(struct list_head *new,
- struct list_head *prev,
- struct list_head *next);
-extern bool __list_del_entry_valid(struct list_head *entry);
+extern bool __list_add_valid_or_report(struct list_head *new,
+ struct list_head *prev,
+ struct list_head *next);
+extern bool __list_del_entry_valid_or_report(struct list_head *entry);
#else
-static inline bool __list_add_valid(struct list_head *new,
- struct list_head *prev,
- struct list_head *next)
+static inline bool __list_add_valid_or_report(struct list_head *new,
+ struct list_head *prev,
+ struct list_head *next)
{
return true;
}
-static inline bool __list_del_entry_valid(struct list_head *entry)
+static inline bool __list_del_entry_valid_or_report(struct list_head *entry)
{
return true;
}
@@ -64,7 +64,7 @@ static inline void __list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next)
{
- if (!__list_add_valid(new, prev, next))
+ if (!__list_add_valid_or_report(new, prev, next))
return;
next->prev = new;
@@ -129,7 +129,7 @@ static inline void __list_del_clearprev(struct list_head *entry)
static inline void __list_del_entry(struct list_head *entry)
{
- if (!__list_del_entry_valid(entry))
+ if (!__list_del_entry_valid_or_report(entry))
return;
__list_del(entry->prev, entry->next);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 98d056624f..b3bbae36e2 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -357,8 +357,8 @@ enum pci_fixup_pass {
/* Anonymous variables would be nice... */
#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class, \
class_shift, hook) \
- static const struct pci_fixup __PASTE(__pci_fixup_##name,__LINE__) __used \
- __attribute__((__section__(#section), aligned((sizeof(void *))))) \
+ static const struct pci_fixup __PASTE(__pci_fixup_##name,__LINE__) \
+ __ll_elem(section) __aligned(sizeof(void *)) \
= { vendor, device, class, class_shift, hook };
#define DECLARE_PCI_FIXUP_CLASS_EARLY(vendor, device, class, \