mode switch statistics
To mitigate meltdown and spectre vulnerability, the mode switch cost was increased. mode-switch-stat is a easy infrastructure to measure the cost of mode switch. In here, one mode switch trip contains user mode to kernel mode and kernel to user. At present, this tool supports x86_64
architecture only.
Prerequisites
This tool requires Linux kernel headers and NumPy. For Ubuntu/Debian, you can install these packages in advance.
$ sudo apt install linux-headers-$(uname-r)
$ sudo apt install python3-numpy
How to build & testing
Build project:
$ git clone https://github.com/eecheng87/mode-switch-stat.git
$ cd mode-switch-stat
$ make
Testing:
$ make testing
sample output:
Model name: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
Vulnerability Meltdown: Mitigation; PTI
Avg of mode switch takes 1921.45 cycles and standard deviation is 106.92
Common error
-
ERROR: could not insert module msT.ko: Operation not permitted
Solution: Disable SecureBoot (check by
mokutil --sb-state
) -
If kernel version lower than
5.7.0
, please disable KALSR or modify macroKERNEL_VERSION
to version lower than yours. It's also fine to comment it and force includesystab.h
and calculatingsyscall_table
by adding offset to original system call table.
How to contribute
Add your output as comment in issue#1