diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h index 549c60942208bb..ee6c86f445c0a1 100644 --- a/fs/xfs/xfs_buf.h +++ b/fs/xfs/xfs_buf.h @@ -247,8 +247,13 @@ xfs_buf_read( { DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); +#ifndef __wasm__ return xfs_buf_read_map(target, &map, 1, flags, bpp, ops, __builtin_return_address(0)); +#else + return xfs_buf_read_map(target, &map, 1, flags, bpp, ops, + (void*)0xdeadcafe); +#endif } static inline void diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h index f9878021e7d07d..6b126650ebb69a 100644 --- a/fs/xfs/xfs_linux.h +++ b/fs/xfs/xfs_linux.h @@ -123,14 +123,22 @@ typedef __u32 xfs_nlink_t; #define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */ #define EFSBADCRC EBADMSG /* Bad CRC detected */ +#ifndef __wasm__ #define __return_address __builtin_return_address(0) +#else +#define __return_address (void*)0xdeadcafe +#endif /* * Return the address of a label. Use barrier() so that the optimizer * won't reorder code to refactor the error jumpouts into a single * return, which throws off the reported address. */ +#ifndef __wasm__ #define __this_address ({ __label__ __here; __here: barrier(); &&__here; }) +#else +#define __this_address (void*)0xdeadcafe +#endif #define XFS_PROJID_DEFAULT 0 diff --git a/include/linux/instruction_pointer.h b/include/linux/instruction_pointer.h index cda1f706eaeb11..56bc64cf8d15e1 100644 --- a/include/linux/instruction_pointer.h +++ b/include/linux/instruction_pointer.h @@ -2,7 +2,16 @@ #ifndef _LINUX_INSTRUCTION_POINTER_H #define _LINUX_INSTRUCTION_POINTER_H +#ifndef __wasm__ #define _RET_IP_ (unsigned long)__builtin_return_address(0) +#else +#define _RET_IP_ (unsigned long)0xdeadcafe +#endif + +#ifndef __wasm__ #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) +#else +#define _THIS_IP_ (unsigned long)0xdeadcafe +#endif #endif /* _LINUX_INSTRUCTION_POINTER_H */ diff --git a/kernel/panic.c b/kernel/panic.c index da323209f58331..8c778fbe35a4ec 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -641,14 +641,23 @@ void warn_slowpath_fmt(const char *file, int line, unsigned taint, pr_warn(CUT_HERE); if (!fmt) { +#ifndef __wasm__ __warn(file, line, __builtin_return_address(0), taint, NULL, NULL); +#else + __warn(file, line, (void*)0xdeadcafe, taint, + NULL, NULL); +#endif return; } args.fmt = fmt; va_start(args.args, fmt); +#ifndef __wasm__ __warn(file, line, __builtin_return_address(0), taint, NULL, &args); +#else + __warn(file, line, (void*)0xdeadcafe, taint, NULL, &args); +#endif va_end(args.args); } EXPORT_SYMBOL(warn_slowpath_fmt); @@ -700,8 +709,13 @@ device_initcall(register_warn_debugfs); __visible noinstr void __stack_chk_fail(void) { instrumentation_begin(); +#ifndef __wasm__ panic("stack-protector: Kernel stack is corrupted in: %pB", __builtin_return_address(0)); +#else + panic("stack-protector: Kernel stack is corrupted in: %pB", + (void*)0xdeadcafe); +#endif instrumentation_end(); } EXPORT_SYMBOL(__stack_chk_fail); diff --git a/mm/util.c b/mm/util.c index 12984e76767ebd..dc30ba04a48dce 100644 --- a/mm/util.c +++ b/mm/util.c @@ -603,9 +603,15 @@ void *kvmalloc_node(size_t size, gfp_t flags, int node) * about the resulting pointer, and cannot play * protection games. */ +#ifndef __wasm__ return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END, flags, PAGE_KERNEL, VM_ALLOW_HUGE_VMAP, node, __builtin_return_address(0)); +#else + return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END, + flags, PAGE_KERNEL, VM_ALLOW_HUGE_VMAP, + node, (void*)0xdeadcafe); +#endif } EXPORT_SYMBOL(kvmalloc_node); diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 88fa40571d0c77..cccb62e158545e 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -887,7 +887,11 @@ kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason) DEBUG_NET_WARN_ON_ONCE(reason <= 0 || reason >= SKB_DROP_REASON_MAX); +#ifndef __wasm__ trace_kfree_skb(skb, __builtin_return_address(0), reason); +#else + trace_kfree_skb(skb, (void*)0xdeadcafe, reason); +#endif __kfree_skb(skb); } EXPORT_SYMBOL(kfree_skb_reason); @@ -2149,7 +2153,11 @@ void *skb_put(struct sk_buff *skb, unsigned int len) skb->tail += len; skb->len += len; if (unlikely(skb->tail > skb->end)) +#ifndef __wasm__ skb_over_panic(skb, len, __builtin_return_address(0)); +#else + skb_over_panic(skb, len, (void*)0xdeadcafe); +#endif return tmp; } EXPORT_SYMBOL(skb_put); @@ -2168,7 +2176,11 @@ void *skb_push(struct sk_buff *skb, unsigned int len) skb->data -= len; skb->len += len; if (unlikely(skb->data < skb->head)) +#ifndef __wasm__ skb_under_panic(skb, len, __builtin_return_address(0)); +#else + skb_under_panic(skb, len, (void*)0xdeadcafe); +#endif return skb->data; } EXPORT_SYMBOL(skb_push); diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h index 4b0673bf52c2e6..3a9a006ae87c14 100644 --- a/tools/include/linux/kernel.h +++ b/tools/include/linux/kernel.h @@ -15,7 +15,11 @@ #define UINT_MAX (~0U) #endif +#ifndef __wasm__ #define _RET_IP_ ((unsigned long)__builtin_return_address(0)) +#else +#define _RET_IP_ ((unsigned long)0xdeadcafe) +#endif #define PERF_ALIGN(x, a) __PERF_ALIGN_MASK(x, (typeof(x))(a)-1) #define __PERF_ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))