Kernel crash at startup when enabling RTNet + RTIPv4
Hello list,
I've been struggling to get the RTNet + RTIPv4 part to work on a Zynq 7000 board. Using source code from stable Xenomai 3.0.9 tarball, and patching a vanilla 4.4.189 linux. I consistently had the kernel crash (0 pointer dereference error) at startup when enabling either RTIPv4, RTCFG or RTMAC.
I finally found that there "might" be a problem with the Makefile in kernel/drivers/net/stack.
It turns out that (on my system at least), the order in which the protocol stacks appear in the Makefile is wrong because (I running a kernel with everything builtin, no modules) the protocols are loaded in that order, and thus, (in my case) RTIPv4 gets initialized before stack_mgr does which cause it to fail while registering (calling __rtdev_add_pack with a not initialized rt_packets array).
When I reorder the protocols in the Makefile, everything works flawlessly.
I can provide a patch if this needs to be fixed.
Thanks
François
Quoted 6 lines · François Legal via Xenomai
Hello list,
I've been struggling to get the RTNet + RTIPv4 part to work on a Zynq 7000 board. Using source code from stable Xenomai 3.0.9 tarball, and patching a vanilla 4.4.189 linux. I consistently had the kernel crash (0 pointer dereference error) at startup when enabling either RTIPv4, RTCFG or RTMAC.
Quoted 7 lines
I finally found that there "might" be a problem with the
Makefilein kernel/drivers/net/stack.
It turns out that (on my system at least), the order in which the protocol stacks appear in theMakefileis wrong because (I running a kernel with everything builtin, no modules) the protocols are loaded in that order, and thus, (in my case) RTIPv4 gets initialized beforestack_mgrdoes which cause it to fail while registering (calling __rtdev_add_pack with a not initialized rt_packets array).When I reorder the protocols in the
Makefile, everything works flawlessly.I can provide a patch if this needs to be fixed.
Upstream does not support built-in RTnet. I suspect we need to sort this and more issues out systematically in order to permit that. Also, the glue scripting will need adjustments because of assumptions that RTnet comes in modules.
That said, contributions in that directions are welcome!
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux
Hello,
Could you please clarify what "upstream" is ? RTNet project ? There does not seem to be activity there since 2012 ? I'll be happy to contribute on this. You mention "glue scripting", could you be more precise to let me try to fix that part too.
Shall I send the patch to this list ?
Thanks
François
Le Mardi, Octobre 01, 2019 15:10 CEST, Jan Kiszka <[email protected]> a écrit:
Quoted 6 lines · François Legal via Xenomai
Hello list,
I've been struggling to get the RTNet + RTIPv4 part to work on a Zynq 7000 board. Using source code from stable Xenomai 3.0.9 tarball, and patching a vanilla 4.4.189 linux. I consistently had the kernel crash (0 pointer dereference error) at startup when enabling either RTIPv4, RTCFG or RTMAC.
Quoted 7 lines
I finally found that there "might" be a problem with the
Makefilein kernel/drivers/net/stack.
It turns out that (on my system at least), the order in which the protocol stacks appear in theMakefileis wrong because (I running a kernel with everything builtin, no modules) the protocols are loaded in that order, and thus, (in my case) RTIPv4 gets initialized beforestack_mgrdoes which cause it to fail while registering (calling __rtdev_add_pack with a not initialized rt_packets array).When I reorder the protocols in the
Makefile, everything works flawlessly.I can provide a patch if this needs to be fixed.
Upstream does not support built-in RTnet. I suspect we need to sort this and more issues out systematically in order to permit that. Also, the glue scripting will need adjustments because of assumptions that RTnet comes in modules.
That said, contributions in that directions are welcome!
Jan
--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux
Quoted 3 lines · François Legal
Hello,
Could you please clarify what "upstream" is ? RTNet project ? There does not seem to be activity there since 2012 ?
RTnet was merged into Xenomai 2014. I thought you knew when you were posting here ;).
Quoted 1 line
I'll be happy to contribute on this. You mention "glue scripting", could you be more precise to let me try to fix that part too.
xenomai/utils/net/rtnet.in. But I suspect that will be rather simple.
More tricky is a stable init ordering, ideally something that does not depend on link ordering. And maybe there is more.
Quoted 2 lines
Shall I send the patch to this list ?
Exactly. Against the master branch. If it's a fix, we can consider backporting to 3.0.x and 3.1.x (3.1 is already in feature freeze state).
Jan
Quoted 39 lines
Thanks
François
Quoted 30 lines · Jan Kiszka
Quoted 4 lines · François Legal via Xenomai
Hello list,
I've been struggling to get the RTNet + RTIPv4 part to work on a Zynq 7000
board. Using source code from stable Xenomai 3.0.9 tarball, and patching a vanilla 4.4.189 linux.
Quoted 1 line
I consistently had the kernel crash (0 pointer dereference error) at startup
when enabling either RTIPv4, RTCFG or RTMAC.
Quoted 2 lines
I finally found that there "might" be a problem with the
Makefilein kernel/drivers/net/stack.
Quoted 1 line
It turns out that (on my system at least), the order in which the protocol
stacks appear in the
Makefileis wrong because (I running a kernel with everything builtin, no modules) the protocols are loaded in that order, and thus, (in my case) RTIPv4 gets initialized beforestack_mgrdoes which cause it to fail while registering (calling __rtdev_add_pack with a not initialized rt_packets array).Quoted 5 lines
When I reorder the protocols in the
Makefile, everything works flawlessly.I can provide a patch if this needs to be fixed.
Upstream does not support built-in RTnet. I suspect we need to sort this and more issues out systematically in order to permit that. Also, the glue scripting will need adjustments because of assumptions that RTnet comes in modules.
That said, contributions in that directions are welcome!
Jan
--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux
Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux
Le Mardi, Octobre 01, 2019 16:37 CEST, Jan Kiszka <[email protected]> a écrit:
Quoted 4 lines · François Legal
Hello,
Could you please clarify what "upstream" is ? RTNet project ? There does not seem to be activity there since 2012 ?
RTnet was merged into Xenomai 2014. I thought you knew when you were posting here ;).That's what I though, but I was surprised by the mention to "upstream".
Quoted 2 lines
I'll be happy to contribute on this. You mention "glue scripting", could you be more precise to let me try to fix that part too.
xenomai/utils/net/rtnet.in. But I suspect that will be rather simple.So the attached patch (against master) allows one to get the RTNet code builtin, plus the rtnet script modified to take that into account. I can make a patch to 3.0.9 available if that's needed. About the stable init that does not depend on link order, I'll be glad to work on that, but I need some hints on where to start if possible.
More tricky is a stable init ordering, ideally something that does not depend on
link ordering. And maybe there is more.
Quoted 2 lines
Shall I send the patch to this list ?
Exactly. Against the master branch. If it's a fix, we can consider backporting to 3.0.x and 3.1.x (3.1 is already in feature freeze state).
Jan
Quoted 44 lines
Thanks
François
Quoted 35 lines · Jan Kiszka
Quoted 4 lines · François Legal via Xenomai
Hello list,
I've been struggling to get the RTNet + RTIPv4 part to work on a Zynq 7000
board. Using source code from stable Xenomai 3.0.9 tarball, and patching a vanilla 4.4.189 linux.
Quoted 1 line
I consistently had the kernel crash (0 pointer dereference error) at startup
when enabling either RTIPv4, RTCFG or RTMAC.
Quoted 2 lines
I finally found that there "might" be a problem with the
Makefilein kernel/drivers/net/stack.
Quoted 1 line
It turns out that (on my system at least), the order in which the protocol
stacks appear in the
Makefileis wrong because (I running a kernel with everything builtin, no modules) the protocols are loaded in that order, and thus, (in my case) RTIPv4 gets initialized beforestack_mgrdoes which cause it to fail while registering (calling __rtdev_add_pack with a not initialized rt_packets array).Quoted 5 lines
When I reorder the protocols in the
Makefile, everything works flawlessly.I can provide a patch if this needs to be fixed.
Upstream does not support built-in RTnet. I suspect we need to sort this and more issues out systematically in order to permit that. Also, the glue scripting will need adjustments because of assumptions that RTnet comes in modules.
That said, contributions in that directions are welcome!
Jan
--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux
--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-builtin
Type: application/octet-stream
Size: 6156 bytes
Desc: not available
URL: <http://xenomai.org/pipermail/xenomai/attachments/20191002/5549df57/attachment.obj>
Quoted 11 lines · François Legal
Quoted 8 lines · Jan Kiszka
Quoted 4 lines · François Legal
Hello,
Could you please clarify what "upstream" is ? RTNet project ? There does not seem to be activity there since 2012 ?
RTnet was merged into Xenomai 2014. I thought you knew when you were posting here ;).
That's what I though, but I was surprised by the mention to "upstream".
Yeah, I didn't mean the upstream kernel - if that was your first thought.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
I'll be happy to contribute on this. You mention "glue scripting", could you be more precise to let me try to fix that part too.
xenomai/utils/net/rtnet.in. But I suspect that will be rather simple.
So the attached patch (against master) allows one to get the RTNet code builtin, plus the rtnet script modified to take that into account. I can make a patch to 3.0.9 available if that's needed. About the stable init that does not depend on link order, I'll be glad to work on that, but I need some hints on where to start if possible.
Just cross-checked with the kernel documentation, and it's actually correct to build the initialization order from the link order. So please format your changes into a proper patch against next, see CONTRIBUTING.md and also other patches on the list for the structuring.
Thanks,
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux
This is the good one.
Quoted 1 line
From
19a61adb4ce04889c1fe772b16bbdc32abfb8c22Mon Sep 17 00:00:00 2001
From: dev <[email protected]>
Date: Wed, 2 Oct 2019 11:56:00 +0200
Subject: [PATCH] Allow RTNet to be builtin kernel
--- kernel/drivers/net/Kconfig | 1 - kernel/drivers/net/addons/Kconfig | 4 +- kernel/drivers/net/stack/Makefile | 16 ++--- utils/net/rtnet.in | 148 +++++++++++++++++++++++--------------- 4 files changed, 101 insertions(+), 68 deletions(-)
kernel/drivers/net/Kconfig +0 -1
@@ -1,7 +1,6 @@ menu "RTnet" config XENO_DRIVERS_NET - depends on m select NET tristate "RTnet, TCP/IP socket interface"
kernel/drivers/net/addons/Kconfig +2 -2
@@ -2,7 +2,7 @@ menu "Add-Ons" depends on XENO_DRIVERS_NET config XENO_DRIVERS_NET_ADDON_RTCAP - depends on XENO_DRIVERS_NET && m + depends on XENO_DRIVERS_NET select ETHERNET tristate "Real-Time Capturing Support" default n
@@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP For further information see Documentation/README.rtcap. config XENO_DRIVERS_NET_ADDON_PROXY - depends on XENO_DRIVERS_NET_RTIPV4 && m + depends on XENO_DRIVERS_NET_RTIPV4 select ETHERNET tristate "IP protocol proxy for Linux" default n
kernel/drivers/net/stack/Makefile +8 -8
@@ -1,13 +1,5 @@ ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/ -obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/ - -obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/ - -obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/ - -obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/ - obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o rtnet-y := \
@@ -23,4 +15,12 @@ rtnet-y := \ stack_mgr.o \ eth.o +obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/ + +obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/ + +obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/ + +obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/ + rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o
utils/net/rtnet.in +91 -57
178 lines not on this page · raw message
--
2.1.4
Quoted 7 lines · François Legal
This is the good one.
From
19a61adb4ce04889c1fe772b16bbdc32abfb8c22Mon Sep 17 00:00:00 2001
From: dev <[email protected]>
Date: Wed, 2 Oct 2019 11:56:00 +0200
Subject: [PATCH] Allow RTNet to be builtin kernel
Missing signed-off at least. Some word on why you changed the Makefile would be good (for the record, I know this still).
Could you also summarize how you tested the result?
Quoted 77 lines
--- kernel/drivers/net/Kconfig | 1 - kernel/drivers/net/addons/Kconfig | 4 +- kernel/drivers/net/stack/Makefile | 16 ++--- utils/net/rtnet.in | 148 +++++++++++++++++++++++--------------- 4 files changed, 101 insertions(+), 68 deletions(-)kernel/drivers/net/Kconfig +0
-1@@ -1,7 +1,6 @@ menu "RTnet" config XENO_DRIVERS_NET - depends on m select NET tristate "RTnet, TCP/IP socket interface"kernel/drivers/net/addons/Kconfig +2
-2@@ -2,7 +2,7 @@ menu "Add-Ons" depends on XENO_DRIVERS_NET config XENO_DRIVERS_NET_ADDON_RTCAP - depends on XENO_DRIVERS_NET && m + depends on XENO_DRIVERS_NET select ETHERNET tristate "Real-Time Capturing Support" default n@@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP For further information see Documentation/README.rtcap. config XENO_DRIVERS_NET_ADDON_PROXY - depends on XENO_DRIVERS_NET_RTIPV4 && m + depends on XENO_DRIVERS_NET_RTIPV4 select ETHERNET tristate "IP protocol proxy for Linux" default nkernel/drivers/net/stack/Makefile +8
-8@@ -1,13 +1,5 @@ ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/ -obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/ - -obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/ - -obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/ - -obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/ - obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o rtnet-y := \@@ -23,4 +15,12 @@ rtnet-y := \ stack_mgr.o \ eth.o +obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/ + +obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/ + +obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/ + +obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/ + rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.outils/net/rtnet.in +0
-0
utils/net/rtnet.in EOF · line 35
Quoted 8 lines
utils/net/rtnet.in +2
-3@@ -31,44 +31,62 @@ EOF } init_rtnet() { - modprobe rtnet >/dev/null || exit 1 - modprobe rtipv4 >/dev/null || exit 1 - modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1 + if [ ! -d /proc/rtnet ]; then + modprobe rtnet >/dev/null || exit 1
Maybe we should add "set -x" to the script so that every unhandled failure becomes visible. Can be done separately, though.
utils/net/rtnet.in EOF · line 42
Quoted 13 lines
utils/net/rtnet.in +6
-6+ fi - for dev in $REBIND_RT_NICS; do - if [ -d /sys/bus/pci/devices/$dev/driver ]; then - echo $dev > /sys/bus/pci/devices/$dev/driver/unbind - fi - echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind - done + if [ ! -d /proc/rtnet/ipv4 ]; then + modprobe rtipv4 >/dev/null || exit 1 + for PROTOCOL in $RT_PROTOCOLS; do + modprobe rt$PROTOCOL >/dev/null || exit 1 + done
rtpacket does not depend on rtipv4.
Quoted 38 lines
utils/net/rtnet.in +20
-7+ fi - for PROTOCOL in $RT_PROTOCOLS; do - modprobe rt$PROTOCOL >/dev/null || exit 1 - done + $(cat /proc/rtnet/devices | grep -q rteth0) + if [ $? -eq 1 ]; then + modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1 + + for dev in $REBIND_RT_NICS; do + if [ -d /sys/bus/pci/devices/$dev/driver ]; then + echo $dev > /sys/bus/pci/devices/$dev/driver/unbind + fi + echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind + done + fi if [ $RT_LOOPBACK = "yes" ]; then - modprobe rt_loopback >/dev/null || exit 1 + $(cat /proc/rtnet/devices | grep -q rtlo) + if [ $? -eq 1 ]; then + + modprobe rt_loopback >/dev/null || exit 1 + fi fi - if [ $RTCAP = "yes" ]; then - modprobe rtcap >/dev/null || exit 1 + if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then + modprobe rtcap >/dev/null || exit 1 fi if [ $RT_LOOPBACK = "yes" ]; then - $RTIFCONFIG rtlo up 127.0.0.1 + $RTIFCONFIG rtlo up 127.0.0.1 fi if [ $RTCAP = "yes" ]; then
utils/net/rtnet.in EOF · line 78
Quoted 10 lines
utils/net/rtnet.in +5
-5- ifconfig rteth0 up - ifconfig rteth0-mac up - if [ $RT_LOOPBACK = "yes" ]; then - ifconfig rtlo up - fi + ifconfig rteth0 up + ifconfig rteth0-mac up + if [ $RT_LOOPBACK = "yes" ]; then + ifconfig rtlo up + fi
Reformatting is appreciated, but this is better done separately, to ease my review. :)
Quoted 101 lines
utils/net/rtnet.in +53
-34fi - modprobe rtcfg >/dev/null - modprobe rtmac >/dev/null - modprobe tdma >/dev/null + if [ ! -d /proc/rtnet/rtcfg ]; then + modprobe rtcfg >/dev/null + fi + if [ ! -d /proc/rtnet/rtmac ]; then + modprobe rtmac >/dev/null + fi + if [ ! -f /proc/tdma ]; then + modprobe tdma >/dev/null + fi } submit_cfg() {@@ -329,43 +347,59 @@ case "$1" in ;; master) - shift - init_rtnet - TDMA_SLAVES=$* - start_master - ;; + shift + init_rtnet + TDMA_SLAVES=$* + start_master + ;; capture) - modprobe rtnet >/dev/null || exit 1 - modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1 - modprobe rtcap >/dev/null || exit 1 - $RTIFCONFIG rteth0 up promisc - ifconfig rteth0 up - ifconfig rteth0-mac up - ;; + if [ ! -d /proc/rtnet ]; then + modprobe rtnet >/dev/null || exit 1 + fi + $(cat /proc/rtnet/devices | grep -q rteth0) + if [ $? -eq 1 ]; then + modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1 + fi + if [ ! -d /sys/modules/rtcap ]; then + modprobe rtcap >/dev/null || exit 1 + fi + $RTIFCONFIG rteth0 up promisc + ifconfig rteth0 up + ifconfig rteth0-mac up + ;; loopback) - modprobe rtnet >/dev/null || exit 1 - modprobe rtipv4 >/dev/null || exit 1 - - for PROTOCOL in $RT_PROTOCOLS; do - modprobe rt$PROTOCOL >/dev/null || exit 1 - done - - modprobe rt_loopback >/dev/null || exit 1 - - if [ $RTCAP = "yes" ]; then - modprobe rtcap >/dev/null || exit 1 - fi - - $RTIFCONFIG rtlo up 127.0.0.1 - - if [ $RTCAP = "yes" ]; then - ifconfig rtlo up - fi - ;; + if [ ! -d /proc/rtnet ]; then + modprobe rtnet >/dev/null || exit 1 + fi + if [ ! -d /proc/rtnet/ipv4 ]; then + modprobe rtipv4 >/dev/null || exit 1 + for PROTOCOL in $RT_PROTOCOLS; do + modprobe rt$PROTOCOL >/dev/null || exit 1 + done + fi + + if [ $RT_LOOPBACK = "yes" ]; then + $(cat /proc/rtnet/devices | grep -q rtlo) + if [ $? -eq 1 ]; then + + modprobe rt_loopback >/dev/null || exit 1 + fi + fi + + if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then + modprobe rtcap >/dev/null || exit 1 + fi + + $RTIFCONFIG rtlo up 127.0.0.1 + + if [ $RTCAP = "yes" ]; then
utils/net/rtnet.in case "$1" in · line 405
Quoted 10 lines
utils/net/rtnet.in +5
-2+ ifconfig rtlo up + fi + ;; *) - usage - exit 1 + usage + exit 1 esac
I think you are missing the rmmod in the "stop" path.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux