gdt初始化

//desc_struct 是内核的描述段的结构体
struct gdt_page {
    struct desc_struct gdt[GDT_ENTRIES];
} __attribute__((aligned(PAGE_SIZE)));

#ifdef CONFIG_SMP
#define PER_CPU_BASE_SECTION ".data.percpu"
#else
#define PER_CPU_BASE_SECTION ".data"
#endif

#define __PCPU_ATTRS(sec)\
    __attribute__((section(PER_CPU_BASE_SECTION sec)))  \
    PER_CPU_ATTRIBUTES


#define DECLARE_PER_CPU_SECTION(type, name, sec)\
    extern __PCPU_ATTRS(sec) __typeof__(type) per_cpu__##name


#define DEFINE_PER_CPU_SECTION(type, name, sec) \
    __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES    \
    __typeof__(type) per_cpu__##name

#define DEFINE_PER_CPU_PAGE_ALIGNED(type, name)         \
    DEFINE_PER_CPU_SECTION(type, name, ".page_aligned") \
    __aligned(PAGE_SIZE)

//common.c line 87
DEFINE_PER_CPU_PAGE_ALIGNED
//这里定义了每个cpu的gdt_page

DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
} 
};
EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);

gdt_page是一个per cpu变量

switch_to_new_gdt

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值