40 #include <linux/kvm.h> 43 #include "debug/KvmInt.hh" 44 #include "params/BaseArmKvmCPU.hh" 46 #define INTERRUPT_ID(type, vcpu, irq) ( \ 47 ((type) << KVM_ARM_IRQ_TYPE_SHIFT) | \ 48 ((vcpu) << KVM_ARM_IRQ_VCPU_SHIFT) | \ 49 ((irq) << KVM_ARM_IRQ_NUM_SHIFT)) 51 #define INTERRUPT_VCPU_IRQ(vcpu) \ 52 INTERRUPT_ID(KVM_ARM_IRQ_TYPE_CPU, vcpu, KVM_ARM_IRQ_CPU_IRQ) 54 #define INTERRUPT_VCPU_FIQ(vcpu) \ 55 INTERRUPT_ID(KVM_ARM_IRQ_TYPE_CPU, vcpu, KVM_ARM_IRQ_CPU_FIQ) 60 irqAsserted(false), fiqAsserted(false)
77 struct kvm_vcpu_init target_config;
78 memset(&target_config, 0,
sizeof(target_config));
80 vm.kvmArmPreferredTarget(target_config);
82 target_config.features[0] |= (1 << KVM_ARM_VCPU_EL1_32BIT);
91 const bool simFIQ(interrupt->checkRaw(
INT_FIQ));
92 const bool simIRQ(interrupt->checkRaw(
INT_IRQ));
96 DPRINTF(KvmInt,
"KVM: Update FIQ state: %i\n", simFIQ);
100 DPRINTF(KvmInt,
"KVM: Update IRQ state: %i\n", simIRQ);
105 "FIQ raised by the simulated interrupt controller " \
106 "despite in-kernel GIC emulation. This is probably a bug.");
109 "IRQ raised by the simulated interrupt controller " \
110 "despite in-kernel GIC emulation. This is probably a bug.");
127 kvm_reg_list regs_probe;
133 std::unique_ptr<struct kvm_reg_list> regs;
134 const size_t size(
sizeof(
struct kvm_reg_list) +
135 regs_probe.n *
sizeof(uint64_t));
136 regs.reset((
struct kvm_reg_list *)
operator new(size));
137 regs->n = regs_probe.n;
139 panic(
"Failed to determine register list size.\n");
150 if (
ioctl(KVM_ARM_VCPU_INIT, (
void *)&init) == -1)
151 panic(
"KVM: Failed to initialize vCPU\n");
157 if (
ioctl(KVM_GET_REG_LIST, (
void *)®s) == -1) {
158 if (errno == E2BIG) {
161 panic(
"KVM: Failed to get vCPU register list (errno: %i)\n",
#define panic(...)
This implements a cprintf based panic() function.
void kvmArmVCpuInit(const struct kvm_vcpu_init &init)
Tell the kernel to initialize this CPU.
BaseArmKvmCPU(BaseArmKvmCPUParams *params)
std::vector< BaseInterrupts * > interrupts
virtual Tick kvmRun(Tick ticks)
Request KVM to run the guest for a given number of ticks.
bool hasKernelIRQChip() const
Is in-kernel IRQ chip emulation enabled?
Base class for KVM based CPU models.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
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.
void startup() override
startup() is the final initialization call before simulation.
#define INTERRUPT_VCPU_IRQ(vcpu)
const RegIndexVector & getRegList() const
Get a list of registers supported by getOneReg() and setOneReg().
RegIndexVector _regIndexList
Cached copy of the list of registers supported by KVM.
uint64_t Tick
Tick count type.
#define warn_if(cond,...)
Conditional warning macro that checks the supplied condition and only prints a warning if the conditi...
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.
int ioctl(int request, long p1) const
vCPU ioctl interface.
void startup() override
startup() is the final initialization call before simulation.
bool fiqAsserted
Cached state of the FIQ line.