Trying to understand kernel trap code

Konstantin Belousov kostikbel at gmail.com
Thu Aug 6 10:24:39 UTC 2015


On Thu, Aug 06, 2015 at 12:09:05PM +0200, TJ Lee wrote:
> Hi,
>  
> I just started looking at FreeBSD kernel code in more detail and
> want to understand the low-level entry points into the kernel on a
> x86-64 CPU. What I'd like to know is precisely what happens when I
> execute a "syscall" instruction in user-land. More specifically, what
> instruction in what assembly source file is RIP/CS loaded with on
> executing syscall? Also where in the source code do we load the MSRs
> with these values?
>

Read the sys/amd64/amd64/exception.S, fast_syscall entry point. Grep
for MSR_*STAR msr names to see how syscall MSRs are configured, in
particular, on BSP in hammer_time(), on AP in init_secondary(). You need
to read the IA32 manual about syscall instruction to understand how it
all plays together.


More information about the freebsd-hackers mailing list