ume: Add extensive documentation for user mode emulation #950
ume: Add extensive documentation for user mode emulation #950arcane-quill wants to merge 4 commits into
Conversation
|
@arcane-quill The language tutorial is a tutorial for the user of VADL. It has to explain how to use UME and has to include some examples. Therefore, in the tutorial there should not be any text about the implementation. So delete everything starting with |
AndreasKrall
left a comment
There was a problem hiding this comment.
Fixed typo, otherwise it is fine
Added section on User Mode Emulation to the tutorial.
fixed typo
51fceb6 to
479d259
Compare
There was a problem hiding this comment.
I think there are some parts missing, e.g. syscall number matching and other kinds of register definitions. E.g. using non-ABI registers, such as the actual source registers from the ISA, like X(1). Or should it only be possible to use alias registers defined in the ABI?
|
An other thing I noticed: Typically syscalls are triggered by exceptions (which are triggered by instructions). And in QEMU the execution typically checks for a specific exception and state condition to determine whether a syscall was triggered or not. Therefore, I think the Speaking of exceptions, the exception definition alone won't be sufficient to recognize a syscall. E.g. the This means the syscall trap mechanism must be a combination of an initial exception + condition check on some values. In case of However, it might be necessary to also have access to the CPU state to evaluate the condition. Unfortunately I don't have enough knowledge about different syscall mechanisms used in practice. |
It is the other way around. A syscall triggers a privileged exception changing the privilege level.
As it is the other way around, the syscall instruction does make sense and syscalls can be implemented without exceptions. Of course syscalls and exceptions are caught in privileged mode in a similar way. But in UME there is no privileged mode because the privileged mode is emulated. It is possible to implement UME without exceptions, but because the privileged exception handling is emulated and shared, they should be implemented together. For exceptions you also have to distinguish between user mode exceptions and privileged exceptions. User mode exceptions can be caught by a user mode exception handler, privileged exceptions change to privileged mode. User mode exceptions are caught be an exception handler written in assembly language which is invoked from a certain address. I believe that only few of our VADL specifications have the user mode exception handling implemented. It should be defined in the processor section. I did not look into the privileged instruction set of RISC-V to know the details. But exceptions are only implemented in a very rudimentary way in our VADL specifications.
I do not think that a specification in such a way is useful. I have to think deeper about it and read the processor documentations.
|
The trigger mechanism I was talking about was on the QEMU implementation side. In QEMU the UME is an execution loop (similar to full system emulation), where each iteration execution checks for an interrupt or exception. This means from the generator perspective, it doesn't matter which instruction causes the exception, it only matters which exception (under which condition) should be recognized as syscall. Therefore, the As we control the whole generation, we could of course also handle syscalls by defining the |
|
@arcane-quill I had a meeting with @AndreasKrall to discuss some aspects of the UME VADL definition and QEMU generation. We habe agreed on the following:
@arcane-quill If anything is unclear, please let me know. |
This PR covers issue #764 and adds extensive documentation for the user mode emulation, including examples and descriptions for various specification cases