Linux ?? Intel ???????????????????? - PowerPoint PPT Presentation

1 / 72
About This Presentation
Title:

Linux ?? Intel ????????????????????

Description:

Title: 1 Author: Administrator Last modified by: Steven C. Hsueh ( ) Created Date: 8/29/2002 5:40:13 PM Document presentation format – PowerPoint PPT presentation

Number of Views:103
Avg rating:3.0/5.0
Slides: 73
Provided by: edut1550
Category:
Tags: intel | linux

less

Transcript and Presenter's Notes

Title: Linux ?? Intel ????????????????????


1
????
  • ??? ???????

2
???????
  • ??????????
  • Linux ?? Intel ????????????????????
  • ???? Linux ????? Intel ?????,?????????????????
  • ??????
  • ????????????????????
  • ???????????????????????????
  • ????????????????

3
??? ???????
  • ?????
  • ??????
  • Linux????
  • ??????
  • Linux????
  • ????
  • ???????
  • ??

4
?????(1)
  • Intel 80x86 ??????????
  • 3 ?????????
  • ?????????????
  • ?????? 4 GB ????????????????????
  • ?????????????????????????????
  • ???????????
  • ????????????
  • ?????,???????????????????

5
??????
6
?????(2)
  • Intel ???,??????? 2 ??
  • ????????????????????,?????????,??????????
  • ??????,?????
  • ?????????????????????
  • ??????????????????????
  • ?????????????????????????

7
?????(3)
  • ????????????????
  • ???????,??????(? GDT)????????????????????????
  • ???????????,??????????????????
  • ????????????????????????
  • ???????????????
  • ???????????????,???????????????????

8
??????(1)
  • Intel ????????????????????
  • ?????,Intel ???? 4G ??????????(??????????? 32 ??)
  • ??????????????
  • ????????????
  • ?????
  • ?????
  • ?????

9
??????(2)
  • ?????
  • ??????????,?? 6 ?,??? cs?ss?ds?es?fs ? gs
  • cs ???????????????
  • ss ??????????????
  • ds ???????????????
  • ?? 3 ????????????
  • cs ??????????? 2 ?CPL??(?? CPU ??????)
  • ? CPL ??? 0,??????
  • ? CPL ??? 3,??????
  • ? Linux ????,?? CPL ???? 0 ? 3 ??????????????????

10
??????(3)
  • ?????
  • ???????? 8 ??????????????????,????????????????????
    ????
  • ??? GDT(??????)? LDT(??????)?
  • ??????????? GDT,?????????? LDT
  • ?????,GDT ??????? gdtr ?????????? LDT ????? ldtr
    ???

11
???????
12
??????(4)
  • ???????????
  • G ???????????
  • ? G ????? 1 ,????? 4K ?????????? 1 ???
  • LIMIT?????????
  • CPU ???????? 0 ? 15 ???? 48 ? 51 ????? 20
    ????????,??? G ????????????????
  • ?? G ????? 0,??????? 1B(???)? 1MB????????? 4KB ?
    4GB
  • BASE???????????
  • CPU ????????? 16 ? 39 ???? 56 ? 63 ???? 32
    ??????????????
  • S ??
  • ????? 0,?????????????????????????????????????

13
??????(5)
  • TYPE??????????????
  • DPL(?????)????????????
  • ??? 0 ? 3,??? 0 ???????
  • D/B ??????????????
  • ???????,??? 1 ?????????? 32 ??,???? 16 ??
  • P ????? 1 ????????????
  • ? 53 ??????????,?????? 0
  • AVL?????????????? Linux ???????

14
??????(6)
  • ????????????????????
  • ??????????? 8 ???????????
  • ??????????????????,?????????????????????????
  • ?????????? GDT ? LDTCPU ???????????????
  • ????????????????? GDT ? LDT ???

15
???????????
16
??????(7)
  • ??????????
  • ???? 13 ???????????
  • TI ?????????? GDT(TI? 0)?? LDT(TI? 1)?
  • RPL(?????)?? 2 ?????,?? CPU ???????(?? CPU
    ????????????)
  • ???????? GDT ? LDT ????????????????? 13 ???????? 8

17
??????(8)
  • ??????????????
  • ?? TI ??,??????????? GDT ? LDT ?
  • ????????? 8 ??? gdtr ? ldtr ?????????????
  • ????????????????????????,?????????
  • ????????????????????

18
????????????
19
Linux ????(1)
  • Linux ???????????
  • ???????????,????????,??????
  • Linux ??????????????????????????????? GDT ?
  • Linux ?? GDT ?? gdt_table ?????,??? gdt ?????
  • ????????????(LDT),????????????? LDT
  • Linux ???????,?????????????????????????????????TSS
    ???? LDT ???

20
Linux ????(2)
  • TSS ??
  • ?????????? I/O ???????
  • ?????????????? 0xeb
  • TYPE ????? 9 ? 11
  • ????????????? TSS ??,? DPL ?? 0
  • Linux ?? 2.4 ?,????? TSS ?????,???????????? TSS
    ??????????

21
Linux????(3)
  • LDT ??
  • ????? default_ldt ?,????????????
  • ??????????????,??????? LDT ??,?????????????
    default_ldt ???,???????????? 7
  • ?????????? LDT,???????? 4096 ??????,??????? 511
    ??????,???????? LDT ?????????? GDT ?

22
Linux????(4)
  • ???????,GDT ???? TSS ??? LDT ?? 2 ?????????
  • GDT ???????????? 12 2 NR_TASKS(NR_TASKS??????
    ????)
  • ??????
  • TSS ? LDT ???????? GDT ?
  • ??????
  • trap_init( ) ???? set_tss_desc(0 ,
    init_task.tss) ??????? TSS ??????? GDT ?
  • ???????? copy_thread( ) ???????,????? clone( ) ?
    fork( ) ?????,??? set_tss_desc(nr ,
    (tasknr-gttss)) ???????? TSS ??

23
Linux????(5)
  • CPU ?????
  • ??????????????????
  • ???????????? cs ??????????? RPL ????
  • ??????????,??????????????
  • ss ????????????????????????,???? ss
    ?????????????????

24
??????(1)
  • ????
  • ???????????
  • ????????????????????????
  • ??????????????
  • ?????????????????(????????)
  • ??????????
  • ???????????,???????????

25
??????(2)
  • ???
  • ????????????????
  • ????????
  • ???????,?????????
  • Intel ????,???? cr0 ????? PG ????????
  • ? PG ?????(??? 0),??????????????????(???????)

26
??????(3)
  • ??
  • Intel ???????????? 4KB ?????
  • 32 ????????? 3 ???
  • ?? 10 ???????? 10 ????????? 12 ???????
  • ??????????,?????????????,??????,?????
  • ????
  • ????????? cr3 ?????
  • ???????????????????
  • ???????????????????,???????????
  • ????????????????
  • ?????? 12 ???,??????? 4096 ????

27
Intel 80x86 ?????
28
??????(4)
  • ?????????? 10 ???,??????????? 1024 ???
  • ?????????? 1024 1024 4096 232 ??????
  • ???????????????,??????
  • ????
  • ??? 1 ?????????????
  • ??? 0 ????????????
  • ????
  • ???????????,????????
  • ?????????????,????????

29
??????(5)
  • ????
  • ????????
  • ??????,????????????????????,???????
  • ?????????????,????????
  • ????
  • ?????????????(??/?????)
  • ????
  • ?????????????????

30
??????(6)
  • PCD ? PWT ??
  • ??????
  • PCD ?????????????????
  • PWT ????????????????
  • ???????
  • ? PCD ? PWT ??? 0 ,?????????????
  • ??????
  • ?????????
  • ????? 1 ????????? 4MB ?????

31
??????(7)
  • ????
  • Intel ? Pentium ???????
  • ???????? 4KB ? 4MB
  • ????????,????? 32 ????????????
  • ??? 10 ??????,?? 22 ???????
  • ????????????,??? cr4 ????? PSE ??
  • ??????????????????
  • ???????????????,????????????????????

32
????
33
??????(8)
  • ??????
  • Intel ????????????????? 4 ???????
  • ?? 2 ??????????
  • ?????? 1????????
  • ?? 0,??? CPL ?? 3 ????????
  • ??? 3 ?????(????????)
  • ???? 2 ?????(?????)
  • ????????????????? 0,???????????????????????

34
??????(9)
  • ?????
  • 32 ?????,????????
  • 64 ?????,???????
  • ????? 16 KB,??? 214 ???
  • ?????? 14 ???,?? 50 ?????????????????????????????
    ?????
  • Compaqs Alpha ???
  • 64 ?????,???????
  • ??????? 8KB,?????? 13 ???
  • ??????? 43 ???,??? 21 ???????? 0
  • ??? 30 ??????????? 10 ?????(????????????)

35
Linux ??????
36
Linux ????(1)
  • Linux ???????
  • ?????????????????
  • ??? 64 ?????
  • ???????????????????
  • ????????????????
  • ???????????????
  • ???????? 4 ???
  • ??????????,????????????

37
Linux ????(2)
  • ???????????????????
  • ????????,??? cr3 ????????? TSS ???
  • ????? TSS ?????? cr3 ?
  • ?????????,??????????????
  • Linux ??? 32 ??????,?????????,?????????????????
    32 ??? 64 ????????
  • ???????????????? 1,??????????????

38
Linux????(3)
  • ??????
  • Linux ??????? asm/page.h ? asm/pgtable.h
    ??????????????????????????????,????????,??????????
    ??????????????????????????????????????????
  • ??????????????????????? 32 ???????
  • ???? 32 ??????????????????????

39
Linux????(4)
  • ??????????????????????
  • ??????????
  • ???????????,?????????????????????
  • ??????????????,???????????????
  • ????????,?????????????

40
Linux????(5)
  • ????????????,?????????
  • ????????????????????,?????????????
  • ???????????????????????,?????????????????????,????
    ?????????,???????????????

41
Linux????(6)
  • ????
  • ??????????????
  • ???????????????
  • Linux ??????????????? 0x00100000 ?
  • ????????????? 2MB
  • ?????? 0x00100000 ???????????
  • ????????????
  • BIOS ??? 0 ??????????????
  • ? 0x000a0000 ? 0x000fffff ???????? BIOS ????
  • ??????????????????? 1MB ??
  • ????????????????,Linux ????????? 1MB ???

42
????? 2MB ?????
43
??? ???????
  • ?????
  • ????
  • ????
  • ????????
  • ???????
  • ??

44
????
  • Linux ??????????? 4KB
  • ??????????????,??????????????????????????????????
    ???
  • 4KB ?????????????,?? 4KB ??????,??????????????????
    ???????
  • ??????????????????

45
????(1)
  • ????
  • ???????????????????????????????????
  • ??????????????????????????
  • ?????????
  • count ???? 0 ?????????????????
    0,?????????????????????????????

46
????(2)
  • list ??????????
  • ?? flags?????????
  • ?? next_hash ? pprev_hash ????????
    page_hash_table ??????
  • ?????????????,????????,????????????
  • buffer ???????????????

47
????(3)
typedef struct page struct list_head list / ???????????? / struct address_space mapping / ?????????? inode ? / struct page next_hash atomic_t count / ???????????? / unsigned long flags struct list_head lru / ???????????? / struct page pprev_hash struct buffer_head buffers mem_map_t
48
?????????(1)
49
?????????(2)
50
????(4)
  • ??????????? mem_map ???
  • ?????????? 64 ???, 1MB ????? 4 ?????? mem_map ??
  • MAP_NR ??????????????????,????? mem_map ?????
  • ???? free_area_init() ?????????
  • ??? 2 ???
  • start_mem ?????????????????
  • end_mem ?????????????? 1
  • ?? i386_endbase ??????????????????????????
    mem_map ????
  • ?? PG_reserved ? PG_DMA ???,????????????? 0

51
?????
52
????(5)
  • men_init() ??
  • ????? PG_reserved ???? 0,????????????????
  • ???????????? 0x1000000 ???? PG_DMA ???? 0(? ISA
    DMA ?????????? 16MB ??????)
  • ???????????,????????num_physpages ??????
    PG_reserved ??????
  • ????????,?????????????????????????????????????????
    ???????????
  • ????????????? count ???? 1,??? free_page()
    ??????? nr_free_pages ?????????????????

53
????(6)
  • ?????? 4 ??????????????
  • __get_free_pages (gfp_mask , order)????? 2order
    ?????
  • __get_dma_pages(gfp_mask , order)???????? DMA
    ???,??????? __get_free_pages(gfp_mask
    GFP_DMA,order) ??
  • __get_free_page(gfp_mask)??????,???__get_free_pag
    es(gfp_mask , 0)
  • get_free_page(gfp_mask)???__get_free_page(gfp_mas
    k),??????? 0
  • gfp_mask ??????????????

54
??__get_free_pages() ? gfp_mask ?????
55
????????(1)
  • ?????????????????????????????, 2 ??????
  • ??????????????????????
  • ????????????????,Linux ??????
  • ? DMA ??????????,??????????
  • Linux ????????????????
  • ????????????? 10 ??????????,????? 1? 2? 4? 8? 16?
    32? 64? 128? 256 ? 512 ?????
  • ???????????????????????????

56
????????(2)
  • ???????????
  • ??????? 128 ?????,???????????? 128
    ???????????????
  • ??????,????? 256 ????????
  • ???,????? 128 ???????,??? 128 ????????? 128
    ??????
  • ?????? 256 ?????????????,????? 512 ????????
  • ???,???? 128 ????????,??? 384 ???,???? 256 ? 128
    ???,??????? 256 ????????? 128 ??????
  • ????? 512 ?????????,????????????????

57
????????(3)
  • ????????????,????
  • ???? 2 ???? b ????????????????? 2b ???
  • ????????
  • ? 2 ??????
  • ? 2 ????????
  • ? 1 ???,? 1 ????????? 2 b 212 ???

58
????????(4)
  • Linux ?? 2 ????????
  • ?????? ISA DMA ???
  • ??????????
  • ??????????????
  • ????? men_map ??
  • ??????? free_area_struct????? free_area,??????????
    ???????????
  • ?? free_area 0 ? free_area 1
    ????????????????,?? 10 ???
  • ??? free_area 0 ?????????? ISA DMA, free_area
    1 ???? ISA DMA
  • ????????????????????,??????????????(?????????)

59
??????????
60
????????(5)
  • free_area 0 ? free_area 1 ????????????????
    free_area_struct ???
  • ?????????????????????Linux ??? free_area_struct
    ??????????????,???????

struct free_area_struct struct page next struct page prev unsigned int map unsigned long count
61
????????(6)
  • free_area 0 ? free_area 1 ????? k ??
    free_area 0/1k ??? next ? prev ???????? 2k
    ?????????
  • ???????????????????????
  • count ??????????????????
  • map ???????????,?????????????
  • ??????? 2 ??????????
  • ????? 0,??? 2 ????????????????????? 1,??? 2 ????
    1 ?????
  • ?? 2 ?????????????,???? 2 ?????? 2 ?????

62
??? ???????
  • ?????
  • ????
  • ???????
  • Slab ???
  • Slab??
  • ??

63
???????
  • ?????????????????????????
  • ????????,???????????????????????????
  • Linux ????????????????????(???????????? 2 ???)
  • ???????? 50
  • Linux ?? Slab ???,????????????

64
Slab ???
  • ?????????????????
  • ???????????????,?????????????????????,?????????
  • Slab ??????????
  • ?????????????????????,?????????
  • ????????????
  • ?????????????,???????????? Slab
    ?????????,??????????,??????????????

65
Slab??(1)
  • ????????????????????????? slab ?????
  • ??????,???? Slab ?????????
  • Slab ????3 ?????
  • ??
  • ??????? slab
  • ?? 3 ????????? slab,?????? slab?????? slab?????
    slab
  • slab????????????????
  • ??slab ?????????

66
slab ??????
67
Slab??(2)
  • ?????slab
  • ????????????????????????,?????? slab
  • Slab ????????????????????????? slab ????????
    slab ?????????
  • ?????????????????????????? slab ?????????,?? slab
    ?????

68
Slab??(3)
  • ?????????
  • ??????????,??????????? slab,??? slab ??????????
    slab ???????????
  • Linux ???????????
  • ???????????,?????????????????????????? slab
  • ??????????????(???????????????)

69
Slab??(4)
  • ???????
  • ????? slab ??????
  • ???????????? slab??????? slab ?,??????????????
    slab
  • ?????? slab ????
  • ???????? slab ?????????????? slab ??,??????????
    slab ???

70
Slab??(5)
  • ????????, 2 ???????
  • ?????????????
  • ????????????????,??????????? slab ???
  • ???????????
  • ????????? slab ???
  • ??????? 10 ?? slab ?????????
  • ???????????? 10 ?? slab,?????? slab ???????????

71
??(1)
  • Intel x86 ???,Linux ?????????????
  • ????????16KB????????????? 4G ????????? 4K ???
  • ??
  • ???????????????????????
  • ?????????????????????????????
  • ??????????????????,????????
  • ???????????????
  • ????????????????????????,?????????????,??????

72
??(2)
  • ?????????
  • ??????????????,???????
  • Linux ????????????????,??????
  • Linux ???????????????
  • ??????????? 10 ????2???????
  • ???????????????
  • ?? 2 ?????????????,????????????
  • ?????????,????????,????????????????
  • Slab ???????????
Write a Comment
User Comments (0)
About PowerShow.com