aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2025-03-20 23:58:30 +0100
committerJohannes Stoelp <johannes.stoelp@gmail.com>2025-03-23 00:34:38 +0100
commit561411a9a701610f8bb45af61aa4a2562b705790 (patch)
treee748d1d2f82e95b35522dc8cd42f0a3b0f95feb7 /src
parent9752e4e56b5a25110bb3c515cb94c7c57b901042 (diff)
downloadnotes-561411a9a701610f8bb45af61aa4a2562b705790.tar.gz
notes-561411a9a701610f8bb45af61aa4a2562b705790.zip
x86: add some interesting msrs
Diffstat (limited to 'src')
-rw-r--r--src/arch/x86_64.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/arch/x86_64.md b/src/arch/x86_64.md
index ee5455e..265bd8a 100644
--- a/src/arch/x86_64.md
+++ b/src/arch/x86_64.md
@@ -67,6 +67,16 @@ wrmsr // Write MSR register, effectively does MSR[ECX] <- EDX:EAX
```
> See [guest64-msr.S][mkvm-msr] as an example.
+#### Some interesting MSRs
+- `C000_0082: IA32_LSTAR` target address for [`syscall`][x86-syscall] instruction
+ in **IA-32e** (64 bit) mode.
+- `C000_0100: IA32_FS_BASE` storage for **%fs** segment base address.
+- `C000_0101: IA32_GS_BASE` storage for **%gs** segment base address.
+- `C000_0102: IA32_KERNEL_GS_BASE` additional register, [`swapgs`][x86-swapgs]
+ swaps **GS_BASE** and **KERNEL_GS_BASE**, without altering any register state.
+ Can be used to swap in a pointer to a kernel data structure on syscall entry,
+ as for example in [`entry_SYSCALL_64`][linux-swapgs].
+
## Size directives
Explicitly specify size of the operation.
```x86asm
@@ -478,3 +488,6 @@ itself.
[juicebox]: https://github.com/johannst/juicebox-asm
[mbr]: https://en.wikipedia.org/wiki/Master_boot_record
[mkvm-msr]: https://github.com/johannst/mini-kvm-rs/blob/main/guest/guest64-msr.S
+[linux-swapgs]: https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/entry/entry_64.S?h=v6.13#n87
+[x86-syscall]: https://www.felixcloutier.com/x86/syscall
+[x86-swapgs]: https://www.felixcloutier.com/x86/swapgs