官方QQ群收藏本站

百问linux嵌入式论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 422|回复: 3

[已解决] 请问一下我按照老师编写的虚拟网卡驱动怎么在register_netdev的时候爆段错误

[复制链接]

2

主题

2

帖子

12

积分

新手上路

Rank: 1

积分
12
发表于 2017-3-31 13:05:59 | 显示全部楼层 |阅读模式

file:///D:\我的文档\Tencent Files\188123964\Image\C2C\A4TN8ITICDU8}HUTNZ78L7B.png

[  107.419530] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[  107.419600] pgd = cf5a0000
[  107.419626] [00000000] *pgd=3f587031, *pte=00000000, *ppte=00000000
[  107.419688] Internal error: Oops: 17 [#1] PREEMPT
[  107.423619] last sysfs file: /sys/devices/virtual/misc/humidity/dev
[  107.429858] Modules linked in: virt_net(+) humidity ov9650 timer_irq second buzzer_drv adc_drv snd_soc_gec210_wm8960 snd_soc_wm8960
[  107.441646] CPU: 0    Not tainted  (2.6.35.7-GEC210 #1)
[  107.446852] PC is at register_netdevice+0xe4/0x40c
[  107.451610] LR is at register_netdevice+0xd4/0x40c
[  107.456379] pc : [<c042c3a0>]    lr : [<c042c390>]    psr: 60000013
[  107.456384] sp : cf585ef0  ip : cf585ef0  fp : cf585f1c
[  107.467815] r10: 00000000  r9 : cf584000  r8 : ffffffff
[  107.473015] r7 : cf5820c0  r6 : 00000001  r5 : 00000034  r4 : cf4cd800
[  107.479514] r3 : 00000000  r2 : c0875048  r1 : c07a37c8  r0 : cf4cd9a0
[  107.486015] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[  107.493120] Control: 10c5387d  Table: 3f5a0019  DAC: 00000015
[  107.498838]
[  107.498840] PC: 0xc042c320:
[  107.503083] c320  e3550000 0a000002 e59f0368 e3011363 ebf19a75 e2840f43 e59f1360 e59f2360
[  107.511228] c340  ebf820d9 e1a06005 e3e08000 ea000008 e59471c4 e59f134c e0877005 e2870010
[  107.519374] c360  e59f2344 ebf820d0 e2866001 e5878020 e2855034 e59431c8 e1560003 3afffff3
[  107.527520] c380  e2840e1a e59f131c e59f231c ebf820c6 e3e03000 e58431b0 e5843058 e59430c0
[  107.535666] c3a0  e5933000 e3530000 0a000005 e1a00004 e12fff33 e2505000 0a000001 da0000aa
[  107.543812] c3c0  ea0000a8 e1a00004 e1a01004 e3a02000 ebfffdcd e2505000 e1a06004 1a0000a5
[  107.551957] c3e0  e59f52c8 e3a08001 e5953230 e59f02c0 e2833001 e3530000 d1a03008 e5853230
[  107.560103] c400  e1a01003 e1a07003 ebffef53 e3500000 1afffff4 e5943058 e5847054 e3730001
[  107.568250]
[  107.568253] LR: 0xc042c310:
[  107.572495] c310  e3a02000 ebf20eca e3a03f8a e4 e59f134c e0877005 e2870010 e59f2344 ebf820d0 e2866001 e5878020
[  107.596933] c370  e2855034 e59431c8 e1560003 3afffff3 e2840e1a e59f131c e59f231c ebf820c6
[  107.605079] c390  e3e03000 e58431b0 e5843058 e59430c0 e5933000 e3530000 0a000005 e1a00004
[  107.613225] c3b0  e12fff33 e2505000 0a000001 da0000aa ea0000a8 e1a00004 e1a01004 e3a02000
[  107.621371] c3d0  ebfffdcd e2505000 e1a06004 1a0000a5 e59f52c8 e3a08001 e5953230 e59f02c0
[  107.629516] c3f0  e2833001 e3530000 d1a03008 e5853230 e1a01003 e1a07003 ebffef53 e3500000
[  107.637663]
[  107.637666] SP: 0xcf585e70:
[  107.641908] 5e70  c0a6f500 00000010 ff0a0210 ffffffff c00fbc5c ffffffff cf585edc 00000001
[  107.650054] 5e90  cf5820c0 ffffffff cf585f1c cf585ea8 c008ea6c c008e21c cf4cd9a0 c07a37c8
[  107.658200] 5eb0  c0875048 00000000 cf4cd800 00000034 00000001 cf5820c0 ffffffff cf584000
[  107.666346] 5ed0  00000000 cf585f1c cf585ef0 cf585ef0 c042c390 c042c3a0 60000013 ffffffff
[  107.674492] 5ef0  c05713f4 cf4cd800 00000000 cf4cd800 00000000 bf038028 00000000 c008f168
[  107.682638] 5f10  cf585f34 cf585f20 c042c70c c042c2c8 bf03820c 00000000 cf585f4c cf585f38
[  107.690783] 5f30  bf038068 c042c6d4 cf584000 bf0380e8 cf585f7c cf585f50 c008e4b8 bf038034
[  107.698929] 5f50  001e79f4 0001adee cf585f7c cf585f68 bf0380e8 00000000 001e79f4 0001adee
[  107.707076]
[  107.707078] IP: 0xcf585e70:
[  107.711321] 5e70  c0a6f500 00000010 ff0a0210 ffffffff c00fbc5c ffffffff cf585edc 00000001[  108.115407] d860  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000[  108.123556] R7: 0xcf582040:
[  108.127799] 2040  00000001 deaf1eed ffffffff ffffffff 00000012 00000000 cff49480 cf8041b0
[  108.135945] 2060  cff49480 cf9c13f0 00200200 00000000 00000000 00000000 00000000 00000000
[  108.144091] 2080  00000002 00000000 cf4c64b0 cf4c64bc 00000000 00000000 cff49480 0000007b
[  108.152237] 20a0  c07ea5b0 00000000 c48bf134 00000000 00000000 00000000 00000000 00000000
[  108.160382] 20c0  cf4cd800 00000000 00000000 00000000 00000001 dead4ead ffffffff ffffffff
[  108.168528] 20e0  ffffffff 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  108.176674] 2100  e0b02000 e0b1e000 00000005 cfe2110c 00000000 00000000 cfe21118 cfe21058
[  108.184820] 2120  00000000 00000000 cf5820c0 00000000 00000000 00000000 00000000 00000000 [  108.262381] Process insmod (pid: 123, stack limit = 0xcf5842f0)
[  108.268274] Stack: (0xcf585ef0 to 0xcf586000)
[  108.272609] 5ee0:                                     c05713f4 cf4cd800 00000000 cf4cd800
[  108.280757] 5f00: 00000000 bf038028 00000000 c008f168 cf585f34 cf585f20 c042c70c c042c2c8
[  108.288903] 5f20: bf03820c 00000000 cf585f4c cf585f38 bf038068 c042c6d4 cf584000 bf0380e8
[  108.297049] 5f40: cf585f7c cf585f50 c008e4b8 bf038034 001e79f4 0001adee cf585f7c cf585f68
[  108.305194] 5f60: bf0380e8 00000000 001e79f4 0001adee cf585fa4 cf585f80 c00e39cc c008e45c
[  108.313340] 5f80: c011b008 c011af14 00000000 becbec34 00000069 00000080 00000000 cf585fa8
[  108.321486] 5fa0: c008efc0 c00e393c 00000000 becbec34 00200070 0001adee 001e79f4 00000000
[  108.329631] 5fc0: 00000000 becbec34 00000069 00000080 becbec38 00000000 becbec38 00000000
[  108.337777] 5fe0: 00000001 becbe8d4 0001dbbc 000098d4 60000010 00200070 00000000 00000000
[  108.345917] Backtrace:
[  108.348351] [<c042c2bc>] (register_netdevice+0x0/0x40c) from [<c042c70c>] (register_netdev+0x44/0x54)
[  108.357531]  r8:c008f168 r7:00000000 r6:bf038028 r5:00000000 r4:cf4cd800
[  108.364213] [<c042c6c8>] (register_netdev+0x0/0x54) from [<bf038068>] (virtnet_init+0x40/0x68 [virt_net])
[  108.373735]  r5:00000000 r4:bf03820c
[  108.377300] [<bf038028>] (virtnet_init+0x0/0x68 [virt_net]) from [<c008e4b8>] (do_one_initcall+0x68/0x1b0)
[  108.386907]  r4:bf0380e8 r3:cf584000
[  108.390469] [<c008e450>] (do_one_initcall+0x0/0x1b0) from [<c00e39cc>] (sys_init_module+0x9c/0x1b4)
[  108.399472]  r7:0001adee r6:001e79f4 r5:00000000 r4:bf0380e8
[  108.405112] [<c00e3930>] (sys_init_module+0x0/0x1b4) from [<c008efc0>] (ret_fast_syscall+0x0/0x30)
[  108.414031]  r7:00000080 r6:00000069 r5:becbec34 r4:00000000
[  108.419669] Code: e3e03000 e58431b0 e5843058 e59430c0 (e5933000)
[  108.430622] ---[ end trace 478296d51ac4b884 ]---




代码如下
static int virtnet_init(void)
26 {
27     
28
29     /*1.分配一个net_device结构体**/
30
31     vnet_dev=alloc_netdev(0, "vnet%d", ether_setup);
32     
33     /*2.设置*/
34
35     /*3.注册*/
36     register_netdev(vnet_dev);
37     
38     return 0;
39 }



回复

使用道具 举报

56

主题

5186

帖子

7811

积分

超级版主

Rank: 8Rank: 8

积分
7811
QQ
发表于 2017-4-5 07:27:34 | 显示全部楼层
什么版本的内核?
你可以进入 register_netdevice,查看它的代码。
更新的内核里,这个函数可以需要你的 vnet_dev实现某个函数
thisway.diy
回复 支持 反对

使用道具 举报

1

主题

3

帖子

35

积分

新手上路

Rank: 1

积分
35
发表于 2018-2-28 10:35:56 | 显示全部楼层
解决了吗,我也遇到了这个问题
回复 支持 反对

使用道具 举报

1

主题

3

帖子

35

积分

新手上路

Rank: 1

积分
35
发表于 2018-2-28 11:15:23 | 显示全部楼层
已解决,我的板子是mini2440,可参考http://blog.csdn.net/cgsz1992/article/details/7606859
回复 支持 反对

使用道具 举报

技术支持
在线咨询
咨询热线
0755-86200561
微信扫一扫
获取更多资讯!

Archiver|小黑屋|百问linux嵌入式论坛     

GMT+8, 2018-10-19 00:41 , Processed in 0.489132 second(s), 20 queries , File On.

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc. Template By 【未来科技】【 www.wekei.cn 】

快速回复 返回顶部 返回列表