Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 对导致内核分页错误请求的原子集操作进行故障排除_C_Linux_Linux Kernel - Fatal编程技术网

C 对导致内核分页错误请求的原子集操作进行故障排除

C 对导致内核分页错误请求的原子集操作进行故障排除,c,linux,linux-kernel,C,Linux,Linux Kernel,我正在尝试解决一个导致我正在编程的linux内核驱动程序崩溃的错误。代码在另一台机器上运行良好。我已经将相同的代码迁移到另一台机器上,现在它崩溃了。我很难排除到底是什么问题。我已经把它缩小到下面的代码块 mutex_lock(&(ctl->mtx)); atomic_set(&ctl->app.enabled, 1); // this line crashes it mutex_unlock(&(ctl->mtx)); 我也试过以下方法 mutex_l

我正在尝试解决一个导致我正在编程的linux内核驱动程序崩溃的错误。代码在另一台机器上运行良好。我已经将相同的代码迁移到另一台机器上,现在它崩溃了。我很难排除到底是什么问题。我已经把它缩小到下面的代码块

mutex_lock(&(ctl->mtx));
atomic_set(&ctl->app.enabled, 1); // this line crashes it
mutex_unlock(&(ctl->mtx));
我也试过以下方法

mutex_lock(&(ctl->mtx));
atomic_set(&ctl->app.enabled, 0x01);
mutex_lock(&(ctl->mtx));
下面是涉及的结构

typedef struct ctl_struct {
    struct mutex mtx;
    struct app_struct app;
}

struct app_struct {
    atomic_t enabled;
}
这两行代码都生成以下内容

BUG: unable to handle kernel paging request at 0000000000002c28
IP: [<ffffffffa02cd847>] mod_start_trace+0x157/0x1a0 [test_mod]
Dec 22 14:02:42 test_server kernel: [41114.399186] PGD 7ef858067 PUD 7f06d2067 PMD 0
Dec 22 14:02:42 test_server kernel: [41114.399830] Oops: 0002 [#1] SMP
Dec 22 14:02:42 test_server kernel: [41114.400006] Modules linked in: test_mod     ipt_MASQUERADE iptable_nat nf_nat_ipv4 xt_CHECKSUM iptable_mangle bridge stp llc ebtable_nat ebtables ip6t_REJECT xt_hl ip6t_rt nf_conntrack_ipv6 nf_defrag_ipv6 ipt_REJECT xt_LOG xt_limit xt_tcpudp xt_addrtype nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack xfs ip6table_filter ip6_tables nf_conntrack_netbios_ns nf_conntrack_broadcast nf_nat_ftp nf_nat nf_conntrack_ftp nf_conntrack iptable_filter ip_tables x_tables libcrc32c gpio_ich coretemp ast joydev lpc_ich ttm drm_kms_helper drm i5000_edac serio_raw edac_core i2c_algo_bit syscopyarea i5k_amb sysfillrect sysimgblt shpchp lp parport tpm_infineon mac_hid ipmi_si raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq raid1 mptsas hid_generic mptscsih raid0 e1000e multipath ahci usbhid mptbase ptp usb_storage psmouse hid libahci scsi_transport_sas pps_core linear [last unloaded: test_mod]
Dec 22 14:02:42 test_server kernel: [41114.400006] CPU: 3 PID: 2820 Comm: ctl Tainted:     G           O 3.13.11.4 #1
Dec 22 14:02:42 test_server kernel: [41114.400006] Hardware name: Sun Microsystems SUN FIRE     X4150/SUN FIRE X4150, BIOS 1ADQW068 11/16/2010
Dec 22 14:02:42 test_server kernel: [41114.400006] task: ffff8807ed7c5fc0 ti: ffff8807ef498000 task.ti: ffff8807ef498000
Dec 22 14:02:42 test_server kernel: [41114.400006] RIP: 0010:[<ffffffffa02cd847>]  [<ffffffffa02cd847>] mod_start_trace+0x157/0x1a0 [test_mod]
Dec 22 14:02:42 test_server kernel: [41114.400006] RSP: 0018:ffff8807ef499e88  EFLAGS: 00010246
Dec 22 14:02:42 test_server kernel: [41114.400006] RAX: 0000000000000000 RBX: ffff88002bd3c000 RCX: 0000000000000006
Dec 22 14:02:42 test_server kernel: [41114.400006] RDX: 0000000000000007 RSI: 0000000000000046 RDI: ffffffffa02cfe71
Dec 22 14:02:42 test_server kernel: [41114.400006] RBP: ffff8807ef499ea8 R08: 0000000000000092 R09: 0000000000000afc
Dec 22 14:02:42 test_server kernel: [41114.400006] R10: 0000000000000000 R11: ffff8807ef499bb6 R12: ffffffffa02d1453
Dec 22 14:02:42 test_server kernel: [41114.400006] R13: ffff8807efe64160 R14: ffffffffa02d12a0 R15: 0000000000000000
Dec 22 14:02:42 test_server kernel: [41114.400006] FS:  00007fc797461880(0000) GS:ffff88081fcc0000(0000) knlGS:0000000000000000
Dec 22 14:02:42 test_server kernel: [41114.400006] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Dec 22 14:02:42 test_server kernel: [41114.400006] CR2: 0000000000002c28 CR3: 00000007f1295000 CR4: 00000000000027e0
Dec 22 14:02:42 test_server kernel: [41114.400006] DR0: 00000000000000a0 DR1: 0000000000000000 DR2: 0000000000000003
Dec 22 14:02:42 test_server kernel: [41114.400006] DR3: 00000000000000b0 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Dec 22 14:02:42 test_server kernel: [41114.400006] Stack:
Dec 22 14:02:42 test_server kernel: [41114.400006]  ffff8807f0bef800 00007fc79747f000 0000000000000014 ffff8807efe64160
Dec 22 14:02:42 test_server kernel: [41114.400006]  ffff8807ef499ed8 ffffffffa02ce368 ffff8807d1412480 00007fc79747f000
Dec 22 14:02:42 test_server kernel: [41114.400006]  ffff8807ef499f50 0000000000000014 ffff8807ef499ef8 ffffffff812243ad
Dec 22 14:02:42 test_server kernel: [41114.400006] Call Trace:
Dec 22 14:02:42 test_server kernel: [41114.400006]  [<ffffffffa02ce368>] mod_test_proc_control+0x548/0x5b0 [mod]
Dec 22 14:02:42 test_server kernel: [41114.400006]  [<ffffffff812243ad>] proc_reg_write+0x3d/0x80
Dec 22 14:02:42 test_server kernel: [41114.400006]  [<ffffffff811bcb54>] vfs_write+0xb4/0x1f0
Dec 22 14:02:42 test_server kernel: [41114.400006]  [<ffffffff811bd589>] SyS_write+0x49/0xa0
Dec 22 14:02:42 test_server kernel: [41114.400006]  [<ffffffff8172d42d>] system_call_fastpath+0x1a/0x1f
Dec 22 14:02:42 test_server kernel: [41114.400006] Code: 44 e1 31 c0 48 c7 c7 10 f9 2c a0 e8 54 ad 44 e1 48 85 db 74 98 4c 89 e7 e8 57 5a 45 e1 49 8b 86 a3 01 00 00 48 c7 c7 71 fe 2c a0 <c7> 80 28 2c 00 00 01 00 00 00 31 c0 e8 28 ad 44 e1 4c 89 e7 e8
Dec 22 14:02:42 gol3430-01 kernel: [41114.400006] RIP  [<ffffffffa02cd847>] mod_start_trace+0x157/0x1a0 [mod]
Dec 22 14:02:42 test_server kernel: [41114.400006]  RSP <ffff8807ef499e88>
Dec 22 14:02:42 test_server kernel: [41114.400006] CR2: 0000000000002c28
Dec 22 14:02:42 test_server kernel: [41114.440174] ---[ end trace 37ddb83f133ddac1 ]---

我以前有过这个错误,这是我的代码有问题,而bios已经过时了。我一直在做一些研究,我刚刚在bios上看到了一些东西。我刚刚开始使用原子操作编程,我尝试排除故障也造成了问题。非常感谢您提供的任何帮助或开始故障排除的方向。同样,此代码在另一台机器上也可以正常工作。谢谢

为什么您会认为在内存访问错误中,将1更改为0x01会有所不同?它们具有完全相同的值和类型。如果您可以放置完整的堆栈跟踪并与代码一起共享详细信息,这将是最好的选择?你是如何得出这段代码有问题的结论的?我不认为这会有什么不同,我只是想尝试其他的东西。我通过跟踪和反汇编函数,找到了那行代码,从而得出结论,那就是那个块。我还在那一行后面的kern.log中放了一个printk语句,但它没有放到printk语句中。再次感谢您的帮助。