设置中断标志(STI)使Linux内核崩溃

时间:2018-07-13 08:51:02

标签: linux linux-kernel interrupt sti

我编写了一个用于测试目的的简单字符设备(Linux)。 我有2个核心的VM。 CPU0和CPU1。

我在字符设备中有以下代码:

native_irq_enable(); smp_call_function_single(#Other CPU#,native_irq_enable);

如果我在不使用smp_call的情况下编译字符设备,则一切正常。 例如,如果我调用另一个函数:smp_call_function_single(#Othe CPU#,native_halt()) ,内核不会崩溃。但是,如果我调用smp_call_function_single(#Othe CPU#,native_safe_halt()),则内核将崩溃,因为我设置了IF(中断标志)。

我从第二个CPU设置IF时内核崩溃有什么原因吗? (如果我从CPU0设置IF,则内核不会崩溃。)

谢谢

1 个答案:

答案 0 :(得分:0)

当您使用render() { let {loading, error, product_categories} = this.props; if(error) { return ( <View style={styles.errorWrapperStyle}> <Text style={styles.errorTextStyle}>{error}</Text> </View> ); } if(product_categories & !loading){ const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}); this.dataSource = ds.cloneWithRows(product_categories); return ( <ListView dataSource={ this.dataSource } renderRow={ this.renderRow } enableEmptySections={ true } /> ); } return ( <Spinner size="small" /> ); } 将函数发送另一个 CPU时,该函数将由IPI处理程序执行,因此重新启用中断处理程序中的所有中断都不会不是您想做的事。特别是执行您的功能explicitly states that all IRQs must be disabled的功能的文档。

当CPU相同时,您的函数仅执行而无需发送IPI,因此smp_call_function_single和中断处理程序的限制不适用。

相关问题