32. 3.3 PopcornLinux Booting (Source Code)
32
CPU /arch/x86/include/asm/apic.h
CPU /arch/x86/kernel/apic/io_apic.c
CPU /arch/x86/kernel/cpu/common.c
CPU /arch/x86/kernel/i387.c
CPU /arch/x86/kernel/traps.c
CPU /drivers/acpi/processor_driver.c
CPU /include/linux/sched.h
Memory /arch/x86/mm/dump_pagetables.c
Memory /mm/memblock.c
Memory /mm/nobootmem.c
45. 3.5 Memory Partitioning (Overview)
45
1. Booting parameter 추가
2. Page table 조작
linux/arch/x86/kernel/e820.c
linux/arch/x86/kernel/e820.c
Memory
0M
~
8GB
Primary Linux Secondary Linux
0MB 4GB 0MB 4GB
46. 3.5 Memory Partitioning (Master Booting)
46
Memory
0M
~
8GB
1. Booting parameter 추가
memmap=4G@0M mem=4G
1. e820.c에서 0~4GB 영역을 사용 가능한 영역으로 포함 시킴
2. 메모리는 최대한 4GB만 할당함
54. 3.6 PCI Device Partitioning (Secondary Booting)
54
1. PCI black list를 Kernel 파라미터로 받음
2. 사용 가능한 PCI 목록에서 black list 제외
3. Master Kernel에서 사용하는 PCI 목록을
black list에 파라미터로 받음
4. 사용 가능한 PCI 목록에서 black list 제외
PCI 0 PCI 2 PCI 3PCI 1
1. Boot 파라미터 해석
2. Black list에 해당 PCI device 포함
3. PCI probe 단계에서 해당 PCI
device는 제외
55. 3.7 Multi-Kernel 간의 통신
55
Memory
0M
~
8GB
1. Kernel 간에 공유하는 메모리 공간 할당
2. 모든 Kernel에게 해당 공간 주소를 Kernel 파라
미터로 넘겨줌
3. Kernel들은 공유 메모리를 통해 정보를 주고 받음
linux/drivers/tty/vty.c
VTY , Tunnel 영역
56. 4.
Linux 2개 부팅 시키기
PopcornLinux 버그 수정 버전
https://github.com/packetngin/popcorn
56
75. 5.1 PacketNgin RTOS 소개 (1/4)
75
Eth IP TCP Payload Ether Block
IP Block
TCP Block
Web
Browser
Kernel Space
User Space
NICEth IP TCP Payload
IP TCP Payload
TCP Payload
Payload
General Purpose O/S
Eth IP TCP Payload Ether Block
Firewall
Kernel Space
User Space
NICEth IP TCP Payload
Eth IP TCP Payload
Network O/S
76. 5.1 PacketNgin RTOS 소개 (2/4)
76
Programmability
• Linux는 Host Network Programming 하기에 적합한 O/S
• PacketNgin은 Network Node Programming 하기에 적합한 O/S
• ARP, ICMP, IPsec 소스 코드의 양이 Linux에 비해 2/3 ~ 1/2 수준
77. 5.1 PacketNgin RTOS 소개 (3/4)
77
+ Network H/W depedent code
+ deliver_skb()
+ ret = pt_prev->func(skb, skb->dev, pt_prev);
+ ip_rcv()
+ nf_hook()
+ ip_rcv_finish()
+ ip_route_input()
+ dst_input()->ip_forward() or ip_input()
+ ip_input // Remove the IPv4 header
+ ip_input_finish
+ ret = ipprot->handler(&skb, &nhoff);
+ xfrm4_rcv()
+ xfrm_input()
+ xfrm4_parse_spi()
+ xfrm_state_lookup() // lookup IPsec SA
+ xfrm_beet_input(skb, x) //To change to inner IP header.
+ nexthdr = x->type->input(x, xfrm.decap, skb) // ==
esp_input
+ esp_input() // process ESP based on inner
address
+ returns 0 ;
+ /* beet handling in xfrm_rcv_spi */
+ netif_rx()
+ // ip_input_finish returns 0
+ // netif_receive_skb returns 0
+netif_receive_skb // Now we have an IPv4 packet. So the input flow is
for v4 packet.
+ deliver_skb()
+ ret = pt_prev->func(skb, skb->dev, pt_prev);
+ ip_rcv()
+ nf_hook() //This calls ip_rcv_finish(skb)
+ ip_rcv_finish() // Here the skb->dst is NULL and so is filled for
the input side.
+ ip6_route_input()
+ dst_input()->ip_forward() or ip_input()
+ ip_input // Remove the IPv4 header
+ ip_input_finish
+ …
+ Network H/W depedent code
+ nic_process_output()
+ fifo_push()
+ ni_input()
+ ipsec_inbound()
+ sad_get()
+ ipsec_decrypt()
+ spd_get()
+ ni_output()
80. 5.3 Porting – Kernel 변경
80
Booting logic 변경
1. BSP Booting – Grub과 호환
2. AP Booting – 자체 제작 loader에서
16bit -> 32bit 전환
Standard I/O 방식 변경
1. VGA Buffer에 직접 출력하는 방식
2. 자체 제작한 VGA 드라이버 사용
1. BSP Booting 필요 없음
2. Kexec와 호환되도록 loader 수정
1. Master Linux Kernel과 충돌
2. Serial 통신으로 대체
3. (차후)VTY와 호환 되도록 수정
81. 5.3 Porting – Kernel 변경
81
Memory map 변경
1. PacketNgin Kernel은 2~6MB 사용
Kernel parameter 전달 방식 변경
1. Grub2에서 제공되는
Multiboot2 스펙
1. Linux Kernel과 PacketNgin
Kernel 영역이 겹치는 문제
2. PacketNgin Kernel을 4~8MB로
이동
1. Linux boot parameter 스펙과
호환되도록 변경
82. 5.3 Porting – Kernel 변경
82
Linux Inter-Processor Interrupt와 호환되도록 변경
1. Linux IPI 번호 체계와
PacketNgin IP 번호 체계 충돌
1. Linux에서 사용하지 않는 IPI 번호를
PacketNgin IPI 번호로 할당함
83. 5.3 Porting – Manager App 변경
83
PacketNgin Manager -> Linux로 포팅
1. PacketNgin Shell
2. PacketNgin Manage API
3. VM 관리 API
4. App 관리 API
1. Linux Shell로 대체
2. Linux에서 동작하는 Manage API
3. Linux에서 동작하는 VM 관리 API
4. Linux에서 동작하는 App 관리 API
84. 5.3 Porting – Network I/O 고속화
84
Interrupt 방식 -> Polling 방식 변경
1. Polling 방식으로 고속으로 I/O
2. PacketNgin 자체
Device Driver 사용
1. Linux의 NAPI 최대한 활용
2. Interrupt와 Polling 방식 병행
3. Linux Device Driver 최소한으로
수정
Packet Processing API 변경
1. PacketNgin 자체 Packet 구조체
1. sk_buff <-> Packet 구조체 간
변환 로직 구현
90. Linux
6.3 Network I/O– Linux vs PacketNgin
90
NIC
Core 0 Core 1 Core 2 Core 3
0M
~
8GB
UDP
Echo
Eth IP UDP Payload Ether Block
IP Block
UDP Block
UDP
Echo
Kernel Space
User Space
NICEth IP UDP Payload
IP UDP Payload
UDP Payload
Payload
91. 6.3 Network I/O– Linux vs PacketNgin
91
UDP
Echo
Eth IP UDP Payload Ether Block
UDP Echo
Kernel Space
User Space
NICEth IP UDP Payload
Eth IP UDP Payload
NIC
Core 0 Core 1 Core 2 Core 3
0M
~
8GB
Linux PacketNgin