0%

玩了这么久的Intel CPU,今天一个问题忽然闪现在我脑海:“X86_64到底有多少个寄存器”? 带着知识的渴求,我们来掰一下手指头。

通用寄存器 (general register)

Read more »

PCI以及PCIE设备非常普遍,其驱动也是内核中非常重要的一部分,受到网友的启发,借助QEMU一次性把PCI/PCIE的拓扑结构给说透(尽量)。
为了简单,这里使用virtio-scsi-pci HBA (host bus adapter)作为例子,分别来探究PCI和PCIE两种不同类型的总线。

PCI

Read more »

概述

Intel® DSA是集成在Intel处理器中的高速数据拷贝传输的加速器。用于优化应用程中用于存储、网络、persistent memory以及各种数据处理时的的那些数据流搬运和传输。
Intel® DSA取代了Intel® I/O Acceleration Technology中的Intel® QuickData Technology。

Read more »

之前写过一篇关于如何手写最小ELF的文章。但偶然间在油管上发现了一个很好的视频,参考文末链接。
可以进一步缩小ELF文件。大概思路是:

  • 将之前64bit的文件改写成32bit
  • 整个e_ident部分是可以被覆盖的
  • e_shoff e_flags e_ehsize e_shnum e_shstrndx p_flags 是可以去掉的。
  • 代码段一堆放不下,是可以用JMP跳转的
Read more »

最近因工作需要,需要精确计算CPU的performance,顺便查了下,应该如何稍微精确的计算CPU的频率。
大概网上搜到三种方法:1,使用rdtsc,通过tsc计算CPU频率;2,IA32_APERF 和 IA32_MPERF两个MSR计算;3,系统接口”/sys/devices/system/cpu/cpu/cpufreq/scaling_cur_freq”
下面来分别比较下三种方法的优劣:

rdtsc

Read more »

Advanced Matrix Extension (AMX) 高级矩阵运算,是x86平台新引入的一个矩阵相关的编程框架。AMX扩展引入了两个新的组件:二维寄存器,成为tile, 还有一组可以操作那些tile的加速器。Tile指代内存中的一个二维数组。AMX指令在指令流中依靠内存load/store操作同步的访问内存。AMX指令可以自由的于X86的传统指令集,以及其他的扩展指令并发执行,例如AVX512.
amx_architecture.svg

Palettes

Read more »

一个最简单的内核模块,其中创建一个最简单的可读可写的proc fs的模板,供大家参考和备忘。
首先创建一个文件,或者干脆把新模块文件放在<linux source>/fs/proc/文件夹中,命名debug_sy.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <linux/module.h>       /* Specifically, a module */
#include <linux/kernel.h> /* We're doing kernel work */
#include <linux/proc_fs.h> /* Necessary because we use the proc fs */
#include <asm/uaccess.h> /* for copy_from_user */
#include <linux/seq_file.h> //using seq_printf
#include <linux/slab.h> // Using kzalloc

#define PROCFS_NAME "debug_sy"

MODULE_AUTHOR("Yi Sun");
static char *str = NULL;

static int my_proc_show(struct seq_file *m,void *v){
seq_printf(m,"%s\n",str);
return 0;
}

static ssize_t my_proc_write(struct file* file,const char __user *buffer,size_t count,loff_t *f_pos){
char *tmp = kzalloc((count+1),GFP_KERNEL);
if(!tmp)return -ENOMEM;
if(copy_from_user(tmp,buffer,count)){
kfree(tmp);
return EFAULT;
}
kfree(str);
str=tmp;
return count;
}

static int my_proc_open(struct inode *inode,struct file *file){
return single_open(file,my_proc_show,NULL);
}

static const struct proc_ops my_fops={
.proc_open = my_proc_open,
.proc_release = single_release,
.proc_read = seq_read,
.proc_lseek = seq_lseek,
.proc_write = my_proc_write
};

static int __init hello_init(void){
struct proc_dir_entry *entry;
entry = proc_create(PROCFS_NAME,0777,NULL,&my_fops);
if(!entry){
return -1;
}else{
printk(KERN_INFO "create proc file successfully\n");
}
return 0;
}

static void __exit hello_exit(void){
remove_proc_entry(PROCFS_NAME,NULL);
printk(KERN_INFO "Goodbye world!\n");
}

module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
Read more »

本文我们来解释下怎样创建一个mini x86操作系统。当然这个操作系统小到并不具备一个操作系统应该具有的功能,而仅仅是打印一个字符串到显示器上。

概述

Read more »