Skip to content

Commit 285b8de

Browse files
kernel and virtualization updates.
Signed-off-by: Leon <[email protected]>
1 parent 6c7a812 commit 285b8de

27 files changed

+532
-8
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,6 @@
6565

6666
## 主题
6767
- [KPTI](https://github.com/freelancer-leon/notes/blob/master/kernel/issues/kpti/kpti.md)
68+
69+
# Virtualization
70+
- [docker](https://github.com/freelancer-leon/notes/blob/master/virtualization/docker/docker.md)

kernel/issues/kpti/kpti.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,3 +892,4 @@ do_fork()
892892
- [lwn: The current state of kernel page-table isolation](https://lwn.net/Articles/741878/)
893893
- [KAISER github](https://github.com/IAIK/KAISER)
894894
- [Meltdown & Spectre 攻击及缓解措施(一)](https://paper.seebug.org/501/)
895+
- [PCID & 与PTI的结合](http://happyseeker.github.io/kernel/2018/05/04/pti-and-pcid.html)

kernel/networking/arp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
#### arp_filter 参数的值及其含义
5454
0 - (默认)内核可以用其他接口的地址回复 ARP 请求。
55-
* 这看起来好像与问题,但通常是合理的,因为这样增加了成功通信的机会。IP 地址是属于整个 Linux 主机的,而不是某个特定接口的。
55+
* 这看起来好像有问题,但通常是合理的,因为这样增加了成功通信的机会。IP 地址是属于整个 Linux 主机的,而不是某个特定接口的。
5656
* 只有在更复杂的设置的时候,如负载均衡,这种行为才会引起问题。
5757

5858
1 - 允许多个网络接口在同一子网,并根据内核是否将来自 ARP 的 IP 的数据包路由到该接口,来回答每个接口的 ARP(因此,必须使用 source based routing 做这个工作)。

kernel/networking/route.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,75 @@
1+
# 路由基本概念
2+
## 搜索顺序
3+
* 搜索主机地址
4+
* 搜索网络地址
5+
* 搜索默认路由
6+
7+
## 主机路由条目
8+
* IP 目的地址需要与路由条目的 IP 地址完全匹配的
9+
* `route -n`看到的 **H** flag 的条目
10+
* 对于非主机路由条目,匹配的是网络地址部分
11+
12+
## 直接路由与间接路由
13+
* **直接路由**:顾名思义,与主机直接相连的路由条目
14+
* 表明 IP 目的地址与 MAC 地址是同一主机
15+
* `route -n``Gateway`地址为外出 IP 地址,通常是外出 interface 的 IP 地址
16+
* `route -n`不带 **G** flag 的条目
17+
* **间接路由**:与主机间接相连的路由条目,需要路由器转发到其他子网
18+
* IP 地址仍然是目的地址,但 MAC 地址得是路由器的 MAC 地址
19+
* `route -n``Gateway`地址为路由器的地址
20+
* `route -n`**G** flag 的条目
21+
* *直接路由**间接路由**主机路由条目* 没直接联系,H、G、GH,都可能出现
22+
23+
# 路由表
24+
### table id
25+
* 添加路由表项的时候可以指定路由表 id。
26+
* 路由表 id 可以是来自`/etc/iproute2/rt_tables`的数字或者字符串。
27+
```
28+
$ cat /etc/iproute2/rt_tables
29+
#
30+
# reserved values
31+
#
32+
255 local
33+
254 main
34+
253 default
35+
0 unspec
36+
#
37+
# local
38+
#
39+
#1 inr.ruhep
40+
```
41+
* 添加路由表项时,如果忽略此参数,默认加到 main 表
42+
* local,broadcast,NAT 路由例外,它们会被加到 local 表
43+
44+
### scope
45+
* 目的的 scope 由路由前缀覆盖
46+
* scope 可以是来自`/etc/iproute2/rt_scopes`的数字或者字符串。
47+
```
48+
$ cat /etc/iproute2/rt_scopes
49+
#
50+
# reserved values
51+
#
52+
0 global
53+
255 nowhere
54+
254 host
55+
253 link
56+
#
57+
# pseudo-reserved
58+
#
59+
200 site
60+
```
61+
* 添加路由表项时,如果忽略此参数,所有的 gatewayed unicast 路由默认加到 **global** scope
62+
* 直接单播和广播路由加到 **link** scope
63+
* 本地路由加到 **host** scope
64+
65+
# 路由表缓存
66+
```
67+
/proc/net/stat/rt_cache
68+
entries in_hit in_slow_tot in_slow_mc in_no_route in_brd in_martian_dst in_martian_src out_hit out_slow_tot out_slow_mc gc_total gc_ignored gc_goal_miss gc_dst_overflow in_hlist_search out_hlist_search
69+
00000032 00000000 00000198 0000000f 0000000a 00000192 00000000 00000000 00000000 00008901 00000189 00000000 00000000 00000000 00000000 00000000 00000000
70+
00000032 00000000 0000001a 00000001 00000001 00000019 00000000 00000000 00000000 000088d5 0000012f 00000000 00000000 00000000 00000000 00000000 00000000
71+
```
72+
173
# References
274
- [Guide to IP Layer Network Administration with Linux - 4.8. Routing Tables](http://linux-ip.net/html/routing-tables.html)
375
- [ip-route (8) - Linux Man Pages](https://www.systutorials.com/docs/linux/man/8-ip-route/)

kernel/page_cache.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,13 @@ struct address_space_operations {
157157
* radix tree即`struct radix_tree_root page_tree`域。
158158

159159
# The Buffer Cache
160-
* 独立的磁盘块通过block I/O buffer也要被存入page cache中
161-
* 一个buffer是一个物理磁盘块在内存里的表示,buffer的作用就是映射内存中的page到磁盘块
162-
* 这样page cache在block I/O时也减少了磁盘访问,因为它缓存磁盘块和减少block I/O操作
163-
* 这个缓存通常称为 **缓冲区高速缓存(buffer cache)**,它没有作为独立缓存,而是作为page cache的一部分
164-
* buffer是用page来映射block的,所以它正好在page cache中
160+
* 独立的磁盘块通过 block I/O buffer 也要被存入 page cache 中
161+
* 一个 buffer 是一个物理磁盘块在内存里的表示,buffer 的作用就是映射内存中的 page 到磁盘块
162+
* 这样 page cache 在 block I/O 时也减少了磁盘访问,因为它缓存磁盘块和减少 block I/O 操作
163+
* 这个缓存通常称为 **缓冲区高速缓存(buffer cache)**,它没有作为独立缓存,而是作为 page cache 的一部分
164+
* buffer 是用 page 来映射 block 的,所以它正好在 page cache 中
165165

166-
* 关于buffer和cache,一个能观测到的地方是`free`命令,解释见[此处](http://linuxperf.com/?p=32)
166+
* 这里所说的 buffer cache 与`free`命令观测到的`buffers`不同,`free`命令的`buffers`解释见[此处](http://linuxperf.com/?p=32)
167167
```
168168
>free
169169
total used free shared buffers cached

kernel/pic/SegmentDescriptor.svg

Lines changed: 106 additions & 0 deletions
Loading

kernel/pic/gdt-xpl.gif

6.26 KB
Loading
54.8 KB
Loading

kernel/pic/segmentSelector.png

6.27 KB
Loading

kernel/profiling/perf.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ SYSCALL_DEFINE5(perf_event_open,
415415
f_flags);
416416
...
417417
}
418-
...*```
418+
...__```
419419
```
420420
421421
### 性能分析的计数模式

kernel/segmentation.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Segmentation
2+
3+
* 段选择符 segment selector
4+
![http://static.duartes.org/img/blogPosts/segmentSelector.png](pic/segmentSelector.png)
5+
* 段描述符 segment descriptors
6+
![https://upload.wikimedia.org/wikipedia/commons/0/0a/SegmentDescriptor.svg](pic/SegmentDescriptor.svg)
7+
* CPL,RPL,DPL
8+
![https://pdos.csail.mit.edu/6.828/2005/readings/i386/fig6-3.gif](pic/gdt-xpl.gif)
9+
* 保护模式寻址
10+
![http://static.duartes.org/img/blogPosts/protectedModeSegmentation.png](pic/protectedModeSegmentation.png)
11+
12+
# References
13+
* [Global Descriptor Table - wikipedia](https://en.wikipedia.org/wiki/Global_Descriptor_Table)
14+
* [LDT- OSDev Wiki](https://wiki.osdev.org/LDT)
15+
* [CVE-2017-17053(Linux kernel LDT use after free) 漏洞分析](https://www.anquanke.com/post/id/90295)
16+
* [Intel 80386 Reference Programmer's Manual](https://pdos.csail.mit.edu/6.828/2005/readings/i386/toc.htm)
17+
* [Memory Translation and Segmentation](https://manybutfinite.com/post/memory-translation-and-segmentation/)

0 commit comments

Comments
 (0)