gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Macros | Functions | Variables
x86_cpu.cc File Reference
#include "cpu/kvm/x86_cpu.hh"
#include <linux/kvm.h>
#include <algorithm>
#include <cerrno>
#include <memory>
#include "arch/registers.hh"
#include "arch/x86/cpuid.hh"
#include "arch/x86/regs/msr.hh"
#include "arch/x86/utility.hh"
#include "cpu/kvm/base.hh"
#include "debug/Drain.hh"
#include "debug/Kvm.hh"
#include "debug/KvmContext.hh"
#include "debug/KvmIO.hh"
#include "debug/KvmInt.hh"

Go to the source code of this file.

Classes

struct  FXSave
 

Macros

#define MSR_TSC   0x10
 
#define IO_PCI_CONF_ADDR   0xCF8
 
#define IO_PCI_CONF_DATA_BASE   0xCFC
 
#define SEG_SYS_TYPE_TSS_AVAILABLE   9
 
#define SEG_SYS_TYPE_TSS_BUSY   11
 
#define SEG_CS_TYPE_ACCESSED   9
 
#define SEG_CS_TYPE_READ_ACCESSED   11
 
#define SEG_TYPE_BIT_ACCESSED   1
 
#define FOREACH_IREG()
 
#define FOREACH_SREG()
 
#define FOREACH_DREG()
 
#define FOREACH_SEGMENT()
 
#define FOREACH_DTABLE()
 
#define APPLY_IREG(kreg, mreg)   inform("\t" # kreg ": 0x%llx\n", regs.kreg)
 
#define APPLY_SREG(kreg, mreg)   inform("\t" # kreg ": 0x%llx\n", sregs.kreg);
 
#define APPLY_SEGMENT(kreg, idx)   dumpKvm(# kreg, sregs.kreg);
 
#define APPLY_DTABLE(kreg, idx)   dumpKvm(# kreg, sregs.kreg);
 
#define APPLY_IREG(kreg, mreg)   regs.kreg = tc->readIntReg(mreg)
 
#define APPLY_SREG(kreg, mreg)   sregs.kreg = tc->readMiscRegNoEffect(mreg)
 
#define APPLY_SEGMENT(kreg, idx)   setKvmSegmentReg(tc, sregs.kreg, idx)
 
#define APPLY_DTABLE(kreg, idx)   setKvmDTableReg(tc, sregs.kreg, idx)
 
#define APPLY_SEGMENT(kreg, idx)   checkSeg(# kreg, idx + MISCREG_SEG_SEL_BASE, sregs.kreg, sregs)
 
#define APPLY_IREG(kreg, mreg)   tc->setIntReg(mreg, regs.kreg)
 
#define APPLY_SREG(kreg, mreg)   tc->setMiscRegNoEffect(mreg, sregs.kreg)
 
#define APPLY_SEGMENT(kreg, idx)   setContextSegment(tc, sregs.kreg, idx)
 
#define APPLY_DTABLE(kreg, idx)   setContextSegment(tc, sregs.kreg, idx)
 

Functions

template<typename STRUCT , typename ENTRY >
static STRUCT * newVarStruct (size_t entries)
 
static void dumpKvm (const struct kvm_regs &regs)
 
static void dumpKvm (const char *reg_name, const struct kvm_segment &seg)
 
static void dumpKvm (const char *reg_name, const struct kvm_dtable &dtable)
 
static void dumpKvm (const struct kvm_sregs &sregs)
 
static void dumpFpuSpec (const struct FXSave &xs)
 
static void dumpFpuSpec (const struct kvm_fpu &fpu)
 
template<typename T >
static void dumpFpuCommon (const T &fpu)
 
static void dumpKvm (const struct kvm_fpu &fpu)
 
static void dumpKvm (const struct kvm_xsave &xsave)
 
static void dumpKvm (const struct kvm_msrs &msrs)
 
static void dumpKvm (const struct kvm_xcrs &regs)
 
static void dumpKvm (const struct kvm_vcpu_events &events)
 
static bool isCanonicalAddress (uint64_t addr)
 
static void checkSeg (const char *name, const int idx, const struct kvm_segment &seg, struct kvm_sregs sregs)
 
static void setKvmSegmentReg (ThreadContext *tc, struct kvm_segment &kvm_seg, const int index)
 
static void setKvmDTableReg (ThreadContext *tc, struct kvm_dtable &kvm_dtable, const int index)
 
static void forceSegAccessed (struct kvm_segment &seg)
 
template<typename T >
static void updateKvmStateFPUCommon (ThreadContext *tc, T &fpu)
 
void setContextSegment (ThreadContext *tc, const struct kvm_segment &kvm_seg, const int index)
 
void setContextSegment (ThreadContext *tc, const struct kvm_dtable &kvm_dtable, const int index)
 
template<typename T >
static void updateThreadContextFPUCommon (ThreadContext *tc, const T &fpu)
 
static struct kvm_cpuid_entry2 makeKvmCpuid (uint32_t function, uint32_t index, CpuidResult &result)
 

Variables

struct FXSave M5_ATTR_PACKED
 

Macro Definition Documentation

#define APPLY_DTABLE (   kreg,
  idx 
)    dumpKvm(# kreg, sregs.kreg);
#define APPLY_DTABLE (   kreg,
  idx 
)    setKvmDTableReg(tc, sregs.kreg, idx)
#define APPLY_DTABLE (   kreg,
  idx 
)    setContextSegment(tc, sregs.kreg, idx)
#define APPLY_IREG (   kreg,
  mreg 
)    inform("\t" # kreg ": 0x%llx\n", regs.kreg)
#define APPLY_IREG (   kreg,
  mreg 
)    regs.kreg = tc->readIntReg(mreg)
#define APPLY_IREG (   kreg,
  mreg 
)    tc->setIntReg(mreg, regs.kreg)
#define APPLY_SEGMENT (   kreg,
  idx 
)    dumpKvm(# kreg, sregs.kreg);
#define APPLY_SEGMENT (   kreg,
  idx 
)    setKvmSegmentReg(tc, sregs.kreg, idx)
#define APPLY_SEGMENT (   kreg,
  idx 
)    checkSeg(# kreg, idx + MISCREG_SEG_SEL_BASE, sregs.kreg, sregs)
#define APPLY_SEGMENT (   kreg,
  idx 
)    setContextSegment(tc, sregs.kreg, idx)
#define APPLY_SREG (   kreg,
  mreg 
)    inform("\t" # kreg ": 0x%llx\n", sregs.kreg);
#define APPLY_SREG (   kreg,
  mreg 
)    sregs.kreg = tc->readMiscRegNoEffect(mreg)
#define APPLY_SREG (   kreg,
  mreg 
)    tc->setMiscRegNoEffect(mreg, sregs.kreg)
#define FOREACH_DREG ( )
Value:
do { \
APPLY_DREG(db[0], MISCREG_DR0); \
APPLY_DREG(db[1], MISCREG_DR1); \
APPLY_DREG(db[2], MISCREG_DR2); \
APPLY_DREG(db[3], MISCREG_DR3); \
APPLY_DREG(dr6, MISCREG_DR6); \
APPLY_DREG(dr7, MISCREG_DR7); \
} while (0)

Definition at line 135 of file x86_cpu.cc.

#define FOREACH_DTABLE ( )
#define FOREACH_IREG ( )
Value:
do { \
APPLY_IREG(rax, INTREG_RAX); \
APPLY_IREG(rbx, INTREG_RBX); \
APPLY_IREG(rcx, INTREG_RCX); \
APPLY_IREG(rdx, INTREG_RDX); \
APPLY_IREG(rsi, INTREG_RSI); \
APPLY_IREG(rdi, INTREG_RDI); \
APPLY_IREG(rsp, INTREG_RSP); \
APPLY_IREG(rbp, INTREG_RBP); \
} while (0)
#define APPLY_IREG(kreg, mreg)

Definition at line 104 of file x86_cpu.cc.

Referenced by dumpKvm(), X86KvmCPU::updateKvmStateRegs(), and X86KvmCPU::updateThreadContextRegs().

#define FOREACH_SEGMENT ( )
#define FOREACH_SREG ( )
#define IO_PCI_CONF_ADDR   0xCF8

Definition at line 54 of file x86_cpu.cc.

Referenced by X86KvmCPU::handleKvmExitIO().

#define IO_PCI_CONF_DATA_BASE   0xCFC

Definition at line 55 of file x86_cpu.cc.

Referenced by X86KvmCPU::handleKvmExitIO().

#define MSR_TSC   0x10

Definition at line 52 of file x86_cpu.cc.

Referenced by X86KvmCPU::getHostCycles().

#define SEG_CS_TYPE_ACCESSED   9

Definition at line 63 of file x86_cpu.cc.

Referenced by X86KvmCPU::updateKvmStateSRegs().

#define SEG_CS_TYPE_READ_ACCESSED   11

Definition at line 65 of file x86_cpu.cc.

Referenced by X86KvmCPU::updateKvmStateSRegs().

#define SEG_SYS_TYPE_TSS_AVAILABLE   9

Definition at line 58 of file x86_cpu.cc.

Referenced by X86KvmCPU::updateKvmStateSRegs().

#define SEG_SYS_TYPE_TSS_BUSY   11

Definition at line 60 of file x86_cpu.cc.

Referenced by X86KvmCPU::updateKvmStateSRegs().

#define SEG_TYPE_BIT_ACCESSED   1

Definition at line 69 of file x86_cpu.cc.

Referenced by forceSegAccessed().

Function Documentation

static void checkSeg ( const char *  name,
const int  idx,
const struct kvm_segment &  seg,
struct kvm_sregs  sregs 
)
static
template<typename T >
static void dumpFpuCommon ( const T &  fpu)
static
static void dumpFpuSpec ( const struct FXSave xs)
static

Definition at line 244 of file x86_cpu.cc.

References FXSave::ctrl64, inform, and FXSave::mxcsr_mask.

Referenced by dumpFpuCommon().

static void dumpFpuSpec ( const struct kvm_fpu &  fpu)
static

Definition at line 252 of file x86_cpu.cc.

References inform.

static void dumpKvm ( const struct kvm_regs &  regs)
static
static void dumpKvm ( const char *  reg_name,
const struct kvm_segment &  seg 
)
static

Definition at line 186 of file x86_cpu.cc.

References inform.

static void dumpKvm ( const char *  reg_name,
const struct kvm_dtable &  dtable 
)
static

Definition at line 196 of file x86_cpu.cc.

References inform.

static void dumpKvm ( const struct kvm_sregs &  sregs)
static

Definition at line 203 of file x86_cpu.cc.

References FOREACH_DTABLE, FOREACH_SEGMENT, FOREACH_SREG, ArmISA::i, and inform.

static void dumpKvm ( const struct kvm_fpu &  fpu)
static

Definition at line 310 of file x86_cpu.cc.

References dumpFpuCommon(), and inform.

static void dumpKvm ( const struct kvm_xsave &  xsave)
static

Definition at line 317 of file x86_cpu.cc.

References dumpFpuCommon(), and inform.

static void dumpKvm ( const struct kvm_msrs &  msrs)
static

Definition at line 324 of file x86_cpu.cc.

References X86ISA::e, ArmISA::i, and inform.

static void dumpKvm ( const struct kvm_xcrs &  regs)
static

Definition at line 336 of file x86_cpu.cc.

References ArmISA::i, and inform.

static void dumpKvm ( const struct kvm_vcpu_events &  events)
static

Definition at line 349 of file x86_cpu.cc.

References inform.

static void forceSegAccessed ( struct kvm_segment &  seg)
static

Definition at line 739 of file x86_cpu.cc.

References SEG_TYPE_BIT_ACCESSED.

Referenced by X86KvmCPU::updateKvmStateSRegs().

static bool isCanonicalAddress ( uint64_t  addr)
static

Definition at line 370 of file x86_cpu.cc.

Referenced by checkSeg().

static struct kvm_cpuid_entry2 makeKvmCpuid ( uint32_t  function,
uint32_t  index,
CpuidResult result 
)
static

Definition at line 1408 of file x86_cpu.cc.

References ArmISA::e, and MipsISA::index.

Referenced by X86KvmCPU::updateCPUID().

template<typename STRUCT , typename ENTRY >
static STRUCT* newVarStruct ( size_t  entries)
static

Definition at line 164 of file x86_cpu.cc.

void setContextSegment ( ThreadContext tc,
const struct kvm_segment &  kvm_seg,
const int  index 
)
inline
void setContextSegment ( ThreadContext tc,
const struct kvm_dtable &  kvm_dtable,
const int  index 
)
inline
static void setKvmDTableReg ( ThreadContext tc,
struct kvm_dtable &  kvm_dtable,
const int  index 
)
inlinestatic
static void setKvmSegmentReg ( ThreadContext tc,
struct kvm_segment &  kvm_seg,
const int  index 
)
inlinestatic
template<typename T >
static void updateKvmStateFPUCommon ( ThreadContext tc,
T &  fpu 
)
static
template<typename T >
static void updateThreadContextFPUCommon ( ThreadContext tc,
const T &  fpu 
)
static

Variable Documentation

struct FXSave M5_ATTR_PACKED

Generated on Fri Jun 9 2017 13:03:56 for gem5 by doxygen 1.8.6