Go to the documentation of this file.
40 #include <linux/kvm.h>
43 #include "debug/KvmInt.hh"
45 #include "params/BaseArmKvmCPU.hh"
46 #include "params/GenericTimer.hh"
50 #define INTERRUPT_ID(type, vcpu, irq) ( \
51 ((type) << KVM_ARM_IRQ_TYPE_SHIFT) | \
52 ((vcpu) << KVM_ARM_IRQ_VCPU_SHIFT) | \
53 ((irq) << KVM_ARM_IRQ_NUM_SHIFT))
55 #define INTERRUPT_VCPU_IRQ(vcpu) \
56 INTERRUPT_ID(KVM_ARM_IRQ_TYPE_CPU, vcpu, KVM_ARM_IRQ_CPU_IRQ)
58 #define INTERRUPT_VCPU_FIQ(vcpu) \
59 INTERRUPT_ID(KVM_ARM_IRQ_TYPE_CPU, vcpu, KVM_ARM_IRQ_CPU_FIQ)
64 irqAsserted(false), fiqAsserted(false),
65 virtTimerPin(nullptr), prevDeviceIRQLevel(0)
82 struct kvm_vcpu_init target_config;
83 memset(&target_config, 0,
sizeof(target_config));
85 vm.kvmArmPreferredTarget(target_config);
87 target_config.features[0] |= (1 << KVM_ARM_VCPU_EL1_32BIT);
93 ->getGenericTimer()->
params()->int_virt->get(
tc);
100 const bool simFIQ(interrupt->checkRaw(
INT_FIQ));
101 const bool simIRQ(interrupt->checkRaw(
INT_IRQ));
105 DPRINTF(KvmInt,
"KVM: Update FIQ state: %i\n", simFIQ);
109 DPRINTF(KvmInt,
"KVM: Update IRQ state: %i\n", simIRQ);
114 "FIQ raised by the simulated interrupt controller " \
115 "despite in-kernel GIC emulation. This is probably a bug.");
118 "IRQ raised by the simulated interrupt controller " \
119 "despite in-kernel GIC emulation. This is probably a bug.");
128 uint64_t device_irq_level =
132 (device_irq_level & KVM_ARM_DEV_EL1_VTIMER)) {
134 DPRINTF(KvmInt,
"In-kernel vtimer IRQ asserted\n");
139 !(device_irq_level & KVM_ARM_DEV_EL1_VTIMER)) {
141 DPRINTF(KvmInt,
"In-kernel vtimer IRQ disasserted\n");
158 kvm_reg_list regs_probe;
164 std::unique_ptr<struct kvm_reg_list> regs;
165 const size_t size(
sizeof(
struct kvm_reg_list) +
166 regs_probe.n *
sizeof(uint64_t));
167 regs.reset((
struct kvm_reg_list *)
operator new(size));
168 regs->n = regs_probe.n;
170 panic(
"Failed to determine register list size.\n");
181 if (
ioctl(KVM_ARM_VCPU_INIT, (
void *)&
init) == -1)
182 panic(
"KVM: Failed to initialize vCPU\n");
188 if (
ioctl(KVM_GET_REG_LIST, (
void *)®s) == -1) {
189 if (errno == E2BIG) {
192 panic(
"KVM: Failed to get vCPU register list (errno: %i)\n",
const FlagsType init
This Stat is Initialized.
const Params * params() const
virtual void clear()=0
Clear a signalled interrupt.
virtual void raise()=0
Signal an interrupt.
uint64_t Tick
Tick count type.
bool irqAsserted
Cached state of the IRQ line.
void kvmArmVCpuInit(const struct kvm_vcpu_init &init)
Tell the kernel to initialize this CPU.
Base class for KVM based CPU models.
Tick kvmRun(Tick ticks) override
Request KVM to run the guest for a given number of ticks.
uint64_t prevDeviceIRQLevel
KVM records whether each in-kernel device IRQ is asserted or disasserted in the kvmRunState->s....
RegIndexVector _regIndexList
Cached copy of the list of registers supported by KVM.
ArmInterruptPin * virtTimerPin
If the user-space GIC and the kernel-space timer are used simultaneously, set up this interrupt pin t...
std::vector< BaseInterrupts * > interrupts
#define INTERRUPT_VCPU_IRQ(vcpu)
virtual Tick kvmRun(Tick ticks)
Request KVM to run the guest for a given number of ticks.
struct kvm_run * getKvmRunState()
Get a pointer to the kvm_run structure containing all the input and output parameters from kvmRun().
const RegIndexVector & getRegList() const
Get a list of registers supported by getOneReg() and setOneReg().
int ioctl(int request, long p1) const
vCPU ioctl interface.
const long vcpuID
KVM internal ID of the vCPU.
#define warn_if(cond,...)
Conditional warning macro that checks the supplied condition and only prints a warning if the conditi...
ThreadContext * tc
ThreadContext object, provides an interface for external objects to modify this thread's state.
void setIRQLine(uint32_t irq, bool high)
Set the status of an IRQ line using KVM_IRQ_LINE.
BaseArmKvmCPU(BaseArmKvmCPUParams *params)
bool fiqAsserted
Cached state of the FIQ line.
bool hasKernelIRQChip() const
Is in-kernel IRQ chip emulation enabled?
#define INTERRUPT_VCPU_FIQ(vcpu)
#define panic(...)
This implements a cprintf based panic() function.
Generated on Wed Sep 30 2020 14:02:00 for gem5 by doxygen 1.8.17