Dovetail 对CPU状态寄存器中中断状态的虚拟化

Legonext 2023-12-17 15:10:19

Dovetail通过对中断屏蔽的虚拟化,其实是放弃了对CPU物理中断开关的操纵,并且只是操纵内存中特殊结构的一个比特位INBAND_STALL_BIT来表示中断的开关。

在关中断的时候,设置了INBAND_STALL_BIT。

static __always_inline void stall_inband_nocheck(void)
{
        __set_bit(INBAND_STALL_BIT, &current->stall_bits);
        barrier();
}
/**
 *      inband_irq_disable - disable interrupts for the inband stage
 *
 *      Disable interrupts for the inband stage, disabling in-band
 *      interrupts. Out-of-band interrupts can still be taken and
 *      delivered to their respective handlers though.
 */
notrace void inband_irq_disable(void)
{
        check_inband_stage();
        stall_inband_nocheck();
}
static inline notrace void arch_local_irq_disable(void)
{
        inband_irq_disable();
        barrier();
}

在打开中断的时候清掉了对应的bit 位 INBAND_STALL_BIT

static __always_inline void unstall_inband_nocheck(void)
{
        barrier();
        __clear_bit(INBAND_STALL_BIT, &current->stall_bits);
}
/**
 *      inband_irq_disable - disable interrupts for the inband stage
 *
 *      Disable interrupts for the inband stage, disabling in-band
 *      interrupts. Out-of-band interrupts can still be taken and
 *      delivered to their respective handlers though.
 */
notrace void inband_irq_disable(void)
{
        check_inband_stage();
        stall_inband_nocheck();
}
static inline notrace void arch_local_irq_disable(void)
{
        inband_irq_disable();
        barrier();
}

对CPU状态寄存器的中断位的虚拟化,也是通过利用这个BIT来实现的。

static inline notrace
unsigned long arch_irqs_virtual_to_native_flags(int stalled)
{
        return (!stalled) << X86_EFLAGS_IF_BIT;
}
static __always_inline int test_and_stall_inband_nocheck(void)
{
        return __test_and_set_bit(INBAND_STALL_BIT, &current->stall_bits);
}

/**
 *      inband_irq_save - test and disable (virtual) interrupts
 *
 *      Save the virtual interrupt state then disables interrupts for
 *      the inband stage.
 *
 *      Returns the original interrupt state.
 */
trace_on_debug unsigned long inband_irq_save(void)
{
        check_inband_stage();
        return test_and_stall_inband_nocheck();
}
EXPORT_SYMBOL(inband_irq_save);

static inline notrace unsigned long arch_local_irq_save(void)
{
        int stalled = inband_irq_save();
        barrier();
        return arch_irqs_virtual_to_native_flags(stalled);
}

通过test_and_stall_inband_nocheck获取到这个BIT是否设置,然后把它的状态虚拟成CPU状态寄存器的中断状态位。

...全文
607 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
内容概要:本文档是一份全面的《Linux命令手册大全》,系统性地整理了日常运维与开发常用的Linux命令,按实际应用场景分为22个类别,涵盖文件操作、文本处理、系统管理、网络配置、安全防火墙、容器虚拟化等核心领域。每个命令均提供简洁的作用说明和典型用法示例,并标注权限要求(如root或普通用户)、发行版差异及注意事项,部分内容还包含延伸工具和最佳实践建议。附录提供了常见故障排查流程和高危命令警示,帮助用户高效、安全地使用Linux系统。; 适合人群:具备基本Linux使用经验的开发者、运维工程师和技术支持人员,尤其适合工作1-3年需提升实操能力的技术人员;也适合作为资深用户的速查参考手册。; 使用场景及目标:①快速查找并掌握各类Linux命令的标准用法;②解决实际工作遇到的系统管理、性能调优、网络诊断等问题;③学习命令组合与管道技巧以提高自动化效率;④规避高危操作风险,规范生产环境操作行为。; 阅读建议:此资源以实用为导向,建议结合具体工作场景查阅,优先掌握高频命令及其组合用法,同时注意区分发行版差异和权限约束。初学者应配合实验环境动手练习,进阶用户可重点关注附录的排查流程与性能观测技巧。

140

社区成员

发帖
与我相关
我的任务
社区描述
Xenomai中文社区。 Upstream - xenomai.org Mirror - gitee.com/Xenomai CSDN - bbs.csdn.net/forums/Xenomai
社区管理员
  • Xenomai
  • legonext
  • Cajb
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧