-
-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How are System Calls implemented in gem5 x86 Full System mode? #153
Comments
Hi, Full system just simulates everything exactly like in hardware, unlike SE which fakes all of kernelland and manually reimplements all syscalls. Therefore, in fullsystem userland calls an interrupt, and then this is intercepted by the guest kernel code (normally a real llinux kernel image given to gem5 with So the only thing fullsystem does of relevance for syscalls is make interrupts do exactly what they would do in real hardware, which is basically jump to the handler location. So the only different thing would be to understand the gem5 code that generates interrupts, and the x86 specification of how handlers are setup. |
Thank you for the reply. Most of the simulator code regarding System Calls are for SE mode. And x86 does not treat system calls like faults or hardware interrupts, correct? I believe the following routines in x86 assembly perform the system call return. However, I was wondering if there is any part of the C++/python interface that intercepts the system call returns, since from the look of the below code it does not. Is my understanding correct, that these things are taken care of in assembly? Is the best way to create an intercepting point by creating my own fault/interrupt and adding some lines of assembly to execute the respective routine?
|
I think they do, I think x86 |
I think in 64-bit mode syscall instruction does not generate a software interrupt. However to do this, the OS should set up the star and lstar MSRs during booting up. Such registers can only be modified by ring-0 code. So to the question, the gem5 code in system_calls.py will be translated in the constructor of SYSCALL_64 (exists in decoder-ns.cc.inc), which one-to-one maps the assembly implementing the behavior of SYSCALL_64 into gem5 micro-ops. So there is no software interrupt generated during syscall. What gem5 does is to go through the instructions created by SYSCALL_64 (the constructor), which is further determined by system_calls.py (<- this is implemented according to the behavior of the syscall instruction.) The legacy way which indeed generates software interrupt (SYSCALL_LEGACY) is not implemented in 64-bit mode. And the switching between SYSCALL_64 and SYSCALL_LEGACY depends on the instruction mode. Hope my understanding can help. |
Hi Ciro,
I am confused how system calls are called and returned in Full System and was wondering what is the intercepting point? More specifically, where does gem5 pass the system call handling to the kernel, and where does it receive the system call's result? For example, in x86 if FullSystemInt = 1, it just has sysenter() for the opcode that normally opens up the SE system mode handler:
Thank you for your amazing guide. It has been extremely helpful.
The text was updated successfully, but these errors were encountered: