42 #include <linux/kvm.h>
44 #include "debug/KvmInt.hh"
45 #include "params/BaseArmKvmCPU.hh"
47 #define INTERRUPT_ID(type, vcpu, irq) ( \
48 ((type) << KVM_ARM_IRQ_TYPE_SHIFT) | \
49 ((vcpu) << KVM_ARM_IRQ_VCPU_SHIFT) | \
50 ((irq) << KVM_ARM_IRQ_NUM_SHIFT))
52 #define INTERRUPT_VCPU_IRQ(vcpu) \
53 INTERRUPT_ID(KVM_ARM_IRQ_TYPE_CPU, vcpu, KVM_ARM_IRQ_CPU_IRQ)
55 #define INTERRUPT_VCPU_FIQ(vcpu) \
56 INTERRUPT_ID(KVM_ARM_IRQ_TYPE_CPU, vcpu, KVM_ARM_IRQ_CPU_FIQ)
61 irqAsserted(false), fiqAsserted(false)
78 struct kvm_vcpu_init target_config;
79 memset(&target_config, 0,
sizeof(target_config));
81 vm.kvmArmPreferredTarget(target_config);
83 target_config.features[0] |= (1 << KVM_ARM_VCPU_EL1_32BIT);
91 bool simFIQ(interrupts[0]->checkRaw(
INT_FIQ));
92 bool simIRQ(interrupts[0]->checkRaw(
INT_IRQ));
96 DPRINTF(KvmInt,
"KVM: Update FIQ state: %i\n", simFIQ);
101 DPRINTF(KvmInt,
"KVM: Update IRQ state: %i\n", simIRQ);
116 kvm_reg_list regs_probe;
122 std::unique_ptr<struct kvm_reg_list> regs;
123 const size_t size(
sizeof(
struct kvm_reg_list) +
124 regs_probe.n *
sizeof(uint64_t));
125 regs.reset((
struct kvm_reg_list *)
operator new(size));
126 regs->n = regs_probe.n;
128 panic(
"Failed to determine register list size.\n");
139 if (
ioctl(KVM_ARM_VCPU_INIT, (
void *)&init) == -1)
140 panic(
"KVM: Failed to initialize vCPU\n");
146 if (
ioctl(KVM_GET_REG_LIST, (
void *)®s) == -1) {
147 if (errno == E2BIG) {
150 panic(
"KVM: Failed to get vCPU register list (errno: %i)\n",
void kvmArmVCpuInit(const struct kvm_vcpu_init &init)
Tell the kernel to initialize this CPU.
const RegIndexVector & getRegList() const
Get a list of registers supported by getOneReg() and setOneReg().
BaseArmKvmCPU(BaseArmKvmCPUParams *params)
virtual Tick kvmRun(Tick ticks)
Request KVM to run the guest for a given number of ticks.
Base class for KVM based CPU models.
void setIRQLine(uint32_t irq, bool high)
Set the status of an IRQ line using KVM_IRQ_LINE.
const long vcpuID
KVM internal ID of the vCPU.
#define INTERRUPT_VCPU_IRQ(vcpu)
RegIndexVector _regIndexList
Cached copy of the list of registers supported by KVM.
uint64_t Tick
Tick count type.
Tick kvmRun(Tick ticks) override
Request KVM to run the guest for a given number of ticks.
#define INTERRUPT_VCPU_FIQ(vcpu)
bool irqAsserted
Cached state of the IRQ line.
bool fiqAsserted
Cached state of the FIQ line.
const FlagsType init
This Stat is Initialized.
int ioctl(int request, long p1) const
vCPU ioctl interface.