kvm, x86: Adding support for SE mode execution
Review Request #2313 - Created July 11, 2014 and submitted
| Information | |
|---|---|
| Alexandru Dutu | |
| gem5 | |
| default | |
| Reviewers | |
| Default | |
Changeset 10548:8f97f4918e7c --------------------------- kvm, x86: Adding support for SE mode execution This patch adds methods in KvmCPU model to handle KVM exits caused by syscall instructions and page faults. These types of exits will be encountered if KvmCPU is run in SE mode.
Quick regressions passed.
Issue Summary
24
5
18
1
| Description | From | Last Updated | Status |
|---|---|---|---|
| You need to make more checks here as this patch only adds SE support(?) for X86. | Andreas Sandberg | July 14, 2014, 9:42 a.m. | Open |
| All changes to this file should be a separate patch. It has nothing to do with the KVM-based cpu. | Andreas Sandberg | July 14, 2014, 9:42 a.m. | Open |
| Large portions of this code is identical to X86System::initState. Please refactor (as a separate patch) and reuse that code here. | Andreas Sandberg | July 14, 2014, 9:42 a.m. | Open |
| Shouldn't this be in process.hh since it is SE specific? | Andreas Sandberg | July 14, 2014, 9:42 a.m. | Open |
| SE-specific? | Andreas Sandberg | July 14, 2014, 9:42 a.m. | Open |
Posted (July 14, 2014, 9:42 a.m.)
I have two high-level comments that need to be fixed: * This is should be four different commits (configuration, CPUID updates, segment initialization, kvm, process). * Write a proper commit message (see http://www.m5sim.org/Commit_Access). Specifically, include a short one-line summary and a longer description of what the patch does and why. I'm also a bit unsure about the design of this patch. From RB2312, it /seems/ like the useArchPT flag is supposed to enable page tables in SE emulation mode, however in this patch you seem to overload it to mean "use magic syscall redirection". Could you clean that up a bit? Could you redesign the syscall & fault handler to use the memory mapped m5ops interface instead? That way, the code would in the kvm CPU would be much cleaner and you'd get rid of the magic ports. As a side effect, we could potentially scrap the SE-specific bits of the ISA (this is definitely something I'd like to see long term).
-
configs/example/se.py (Diff revision 1) -
You need to make more checks here as this patch only adds SE support(?) for X86.
-
configs/example/se.py (Diff revision 1) -
This is x86-specific, make sure to guard it properly.
-
src/arch/x86/cpuid.cc (Diff revision 1) -
All changes to this file should be a separate patch. It has nothing to do with the KVM-based cpu.
-
src/arch/x86/process.cc (Diff revision 1) -
Large portions of this code is identical to X86System::initState. Please refactor (as a separate patch) and reuse that code here.
-
src/arch/x86/process.cc (Diff revision 1) -
Style
-
src/arch/x86/process.cc (Diff revision 1) -
Why is this still here?
-
src/arch/x86/system.hh (Diff revision 1) -
Shouldn't this be in process.hh since it is SE specific?
-
src/arch/x86/system.hh (Diff revision 1) -
SE-specific?
-
src/arch/x86/system.hh (Diff revision 1) -
This shouldn't be a part of the patch.
-
src/arch/x86/system.cc (Diff revision 1) -
This actually makes the whole initialization much less readable and error prone. Can't you just create a base segment descriptor with the default values that you assign to the segment descriptors at initialization time and only change the relevant values. For example: SegDescriptor csDesc = baseDesc; csDesc.type.codeOrData = 1; csDesc.privilege = 0;
-
src/cpu/kvm/base.hh (Diff revision 1) -
This doesn't seem to be needed or used. Please remove it.
-
src/cpu/kvm/base.cc (Diff revision 1) -
Why is this line changed?
-
src/cpu/kvm/x86_cpu.cc (Diff revision 1) -
Is this really needed here?
Review request changed
Updated (Aug. 1, 2014, 8:52 a.m.)
Change Summary:
Broke this patch down in 4 patches, solved most the of the raised issues. Still could not find a good way of refactoring the segment initialization code, I find it quite different from X86System::initState.
Summary: |
|
||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description: |
|
||||||||||||||||||||||||
Diff: |
Revision 2 (+99 -3) |
Posted (Aug. 14, 2014, 3:05 a.m.)
I'm really not happy about the use of kvm-specific ports magic here. It would have been nicer having a m5ops based interface that just passes the fault/syscall to the arch-specific code from any CPU model that uses the m5ops interface. Specifically, I'm a bit concerned about what would happen if you switch in the syscall or fault handler code before you enter into gem5. In this case the fault/syscall will be lost since the simulated CPUs don't know how to handle the port magic. If you have a good reason to believe that this won't be an issue, I'm happy to have this committed. I have fixed quite a few switching bugs in the past and I know that things like these are likely to come back and bite you and are a pain to diagnose.
Review request changed
Updated (Sept. 16, 2014, 8:34 a.m.)
Change Summary:
MMIO changes included.
Description: |
|
|||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 3 (+76 -11) |
Posted (Sept. 19, 2014, 2:19 a.m.)
-
src/arch/x86/tlb.cc (Diff revision 3) -
Could you get rid of this code duplication before committing? I'd suggest that you rewrite it something like this: if (m5opRange) { ... } else if (FullSystem) { ... } -
src/cpu/kvm/base.hh (Diff revision 3) -
Is this supposed to be here?
-
src/sim/pseudo_inst.cc (Diff revision 3) -
I think these are reserved for temporary user extensions, so you should probably use another range. I'd suggest that you just number the functions as 0x60 and 0x61 and make a note that the 0x60-0x6f range is intended for SE mode calls.
Looks good overall, but there are some minor issues I'd like you to look into. As far as I'm concerned, you can go ahead and commit this patch when you have fixed them.
Review request changed
Updated (Sept. 30, 2014, 9:21 a.m.)
Change Summary:
I have fixed the rised issues and created ISA specific PseudoInst namespaces for m5syscall and m5pagefault functions. Mainly reposting for PseudoInst changes.
Description: |
|
|||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 4 (+264 -16) |
Posted (Oct. 13, 2014, 1:08 p.m.)
-
src/sim/pseudo_inst.cc (Diff revision 4) -
You use 0x56 and 0x57 in m5ops.h and 0x60 and 0x61 here. Is it ok that these do not match?
Posted (Nov. 18, 2014, 2:43 p.m.)
-
src/arch/x86/pseudo_inst.hh (Diff revision 4) -
I think this can probably be in the main X86ISA namespace. That would remove the need for a new magic macro up in src/SConscript.
-
src/arch/x86/pseudo_inst.hh (Diff revision 4) -
These should be camel case, not all lower case. ie. m5Syscall and m5PageFault, depending on what you consider the boundary between words. These should also be called gem5*.
-
src/arch/x86/pseudo_inst.cc (Diff revision 4) -
Don't put spaces inside the parenthesis.
-
src/arch/x86/pseudo_inst.cc (Diff revision 4) -
Put spaces around the operator.
-
src/arch/x86/pseudo_inst.cc (Diff revision 4) -
Remove extra space.
-
util/m5/m5ops.h (Diff revision 4) -
Why do we need psuedo ops for syscalls when there are actual syscall instructions? The same goes for page faults. I'm not saying I know that we don't, I'm just surprised that that would be necessary. It seems unlikely that a program is going to realize it's about to cause a pagefault and obligingly call a special instruction first.
Posted (Nov. 19, 2014, 6:18 a.m.)
-
src/arch/arm/pseudo_inst.cc (Diff revision 4) -
I'd suggest that you simplify this and get rid of all the arch-specific panic code and write it once in arch/generic/pseudo_inst.(cc|hh) and then import it in arch/XX/pseudo_inst.hh. See arch/mips/mmapped_ipr.hh and arch/generic/mmapped_ipr.hh for an example.
Except for the issues pointed out by Gabe and Nilay, I think this looks good.
Review request changed
Updated (Nov. 19, 2014, 4:36 p.m.)
Change Summary:
Addressed all the raised issues. In addition, it seems that exitGroup syscall has been changed such that each thread context is halted. In the case of KvmCPU, BaseKVMCPU::haltContext calls BaseKVMCPU::suspendContext and, in this case, the _status can be something different than Running inside suspendContext. I don't see a strong reason to have a haltContext implementation independent of suspendContext, as the difference between the 2 methods will be just one assert. Therefore I have broaden a bit the assert condition in suspendContext.
Description: |
|
|||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 5 (+312 -17) |
