From b6ea4c5a2ac8cb014d87ef56e9f8f74450545bb5 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 30 Jul 2018 15:05:07 +0000 Subject: [PATCH] As with DPCPU_DEFINE_STATIC make VNET_DEFINE_STATIC non-static on arm64 in modules. It also fails in the same way, we are unable to relocate static variables as the compiler uses PC-relative loads with nothing for the kernel linker to relocate. Sponsored by: DARPA, AFRL --- sys/net/vnet.h | 9 +++++++++ sys/sys/pcpu.h | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/net/vnet.h b/sys/net/vnet.h index 66d5cd85bc5..514519a327b 100644 --- a/sys/net/vnet.h +++ b/sys/net/vnet.h @@ -273,8 +273,17 @@ extern struct sx vnet_sxlock; /* struct _hack is to stop this from being used with static data */ #define VNET_DEFINE(t, n) \ struct _hack; t VNET_NAME(n) __section(VNET_SETNAME) __used +#if defined(KLD_MODULE) && defined(__aarch64__) +/* + * As with DPCPU_DEFINE_STATIC we are unable to mark this data as static + * in modules on some architectures. + */ +#define VNET_DEFINE_STATIC(t, n) \ + t VNET_NAME(n) __section(VNET_SETNAME) __used +#else #define VNET_DEFINE_STATIC(t, n) \ static t VNET_NAME(n) __section(VNET_SETNAME) __used +#endif #define _VNET_PTR(b, n) (__typeof(VNET_NAME(n))*) \ ((b) + (uintptr_t)&VNET_NAME(n)) diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h index 9057cab2069..d2084b77b3d 100644 --- a/sys/sys/pcpu.h +++ b/sys/sys/pcpu.h @@ -97,7 +97,9 @@ extern uintptr_t dpcpu_off[]; * wrong location. * * This is a workaround until a better solution can be found. -*/ + * + * VNET_DEFINE_STATIC also has the same workaround. + */ #define DPCPU_DEFINE_STATIC(t, n) \ t DPCPU_NAME(n) __section(DPCPU_SETNAME) __used #else