打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
x86_64 swapgs 初始化

在中断或异常处理的entry代码处, 会执行swapgs 切换到kernel GS, GS.base 是存储了中断stack 的地址。也就是the first percpu variable 存放了irq stack 的底。

arch/x86/include/asm/processor.h

union irq_stack_union {                                                                                                                                                     
    char irq_stack[IRQ_STACK_SIZE];
    /*
     * GCC hardcodes the stack canary as %gs:40.  Since the
     * irq_stack is the object at %gs:0, we reserve the bottom
     * 48 bytes of the irq stack for the canary.
     */
    struct {
        char gs_base[40];
        unsigned long stack_canary;
    };
};


调用的路径:
cpu_init->
       switch_to_new_gdt->
           load_percpu_segment:

void cpu_init(void)
{
    ...
    switch_to_new_gdt(cpu);
    ...
    wrmsrl(MSR_FS_BASE, 0);
    wrmsrl(MSR_KERNEL_GS_BASE, 0);
    ...
}


void load_percpu_segment(int cpu)

{

    __loadsegment_simple(gs, 0);
    wrmsrl(MSR_GS_BASE, (unsigned long)per_cpu(irq_stack_union.gs_base, cpu));                                                                                              

    load_stack_canary_segment();
}





本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
周立功lpc21xx/lpc22xx系列ARM7启动代码分析
canary分析
Stack buffer overflow protection 學習筆記 – Stack canaries mechanism in User space – SZ Lin & Embed
ARM linux的中断处理过程
浅析Linux的软中断的实现
linux内核bug问题排查过程详细报告
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服