From adbaa4dfde96d5aaf84adf0ae4989ef880aad726 Mon Sep 17 00:00:00 2001 From: Alexandru Dutu Date: Sun, 23 Nov 2014 18:01:08 -0800 Subject: 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. --- src/sim/pseudo_inst.cc | 11 +++++++++++ src/sim/system.cc | 10 ++++++++++ 2 files changed, 21 insertions(+) (limited to 'src/sim') diff --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc index e85e3d19a..80737003c 100644 --- a/src/sim/pseudo_inst.cc +++ b/src/sim/pseudo_inst.cc @@ -52,6 +52,7 @@ #include "arch/kernel_stats.hh" #include "arch/utility.hh" #include "arch/vtophys.hh" +#include "arch/pseudo_inst.hh" #include "base/debug.hh" #include "base/output.hh" #include "config/the_isa.hh" @@ -64,6 +65,7 @@ #include "debug/WorkItems.hh" #include "params/BaseCPU.hh" #include "sim/full_system.hh" +#include "sim/process.hh" #include "sim/pseudo_inst.hh" #include "sim/serialize.hh" #include "sim/sim_events.hh" @@ -198,6 +200,15 @@ pseudoInst(ThreadContext *tc, uint8_t func, uint8_t subfunc) warn("Unimplemented m5 op (0x%x)\n", func); break; + /* SE mode functions */ + case 0x60: // syscall_func + m5Syscall(tc); + break; + + case 0x61: // pagefault_func + m5PageFault(tc); + break; + default: warn("Unhandled m5 op: 0x%x\n", func); break; diff --git a/src/sim/system.cc b/src/sim/system.cc index 1f63dbf33..c311d65b9 100644 --- a/src/sim/system.cc +++ b/src/sim/system.cc @@ -324,6 +324,16 @@ System::allocPhysPages(int npages) { Addr return_addr = pagePtr << PageShift; pagePtr += npages; + + Addr next_return_addr = pagePtr << PageShift; + + AddrRange m5opRange(0xffff0000, 0xffffffff); + if (m5opRange.contains(next_return_addr)) { + warn("Reached m5ops MMIO region\n"); + return_addr = 0xffffffff; + pagePtr = 0xffffffff >> PageShift; + } + if ((pagePtr << PageShift) > physmem.totalSize()) fatal("Out of memory, please increase size of physical memory."); return return_addr; -- cgit v1.2.3