Author: br
Date: Wed Sep 12 08:05:33 2018
New Revision: 338608
URL: https://svnweb.freebsd.org/changeset/base/338608

Log:
  Don't mark module data as static on RISC-V.
  
  Similar to arm64, riscv compiler uses PC-relative loads/stores,
  and with static data compiler does not emit relocations.
  In result, kernel module linker has nothing to fix and data accessed
  from the wrong location.
  
  Approved by:  re (gjb)
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/net/vnet.h
  head/sys/sys/pcpu.h

Modified: head/sys/net/vnet.h
==============================================================================
--- head/sys/net/vnet.h Wed Sep 12 05:08:49 2018        (r338607)
+++ head/sys/net/vnet.h Wed Sep 12 08:05:33 2018        (r338608)
@@ -273,7 +273,7 @@ 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__)
+#if defined(KLD_MODULE) && (defined(__aarch64__) || defined(__riscv))
 /*
  * As with DPCPU_DEFINE_STATIC we are unable to mark this data as static
  * in modules on some architectures.

Modified: head/sys/sys/pcpu.h
==============================================================================
--- head/sys/sys/pcpu.h Wed Sep 12 05:08:49 2018        (r338607)
+++ head/sys/sys/pcpu.h Wed Sep 12 08:05:33 2018        (r338608)
@@ -84,7 +84,7 @@ extern uintptr_t dpcpu_off[];
 /* struct _hack is to stop this from being used with the static keyword. */
 #define        DPCPU_DEFINE(t, n)      \
     struct _hack; t DPCPU_NAME(n) __section(DPCPU_SETNAME) __used
-#if defined(KLD_MODULE) && defined(__aarch64__)
+#if defined(KLD_MODULE) && (defined(__aarch64__) || defined(__riscv))
 /*
  * On some architectures the compiler will use PC-relative load to
  * find the address of DPCPU data with the static keyword. We then
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to