7275acdfe2
As KVM/arm64 is looming on the horizon, it makes sense to move some of the common code to a single location in order to reduce duplication. The code could live anywhere. Actually, most of KVM is already built with a bunch of ugly ../../.. hacks in the various Makefiles, so we're not exactly talking about style here. But maybe it is time to start moving into a less ugly direction. The include files must be in a "public" location, as they are accessed from non-KVM files (arch/arm/kernel/asm-offsets.c). For this purpose, introduce two new locations: - virt/kvm/arm/ : x86 and ia64 already share the ioapic code in virt/kvm, so this could be seen as a (very ugly) precedent. - include/kvm/ : there is already an include/xen, and while the intent is slightly different, this seems as good a location as any Eventually, we should probably have independant Makefiles at every levels (just like everywhere else in the kernel), but this is just the first step. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Gleb Natapov <gleb@redhat.com>
86 lines
2.3 KiB
C
86 lines
2.3 KiB
C
/*
|
|
* Copyright (C) 2012 ARM Ltd.
|
|
* Author: Marc Zyngier <marc.zyngier@arm.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
#ifndef __ASM_ARM_KVM_ARCH_TIMER_H
|
|
#define __ASM_ARM_KVM_ARCH_TIMER_H
|
|
|
|
#include <linux/clocksource.h>
|
|
#include <linux/hrtimer.h>
|
|
#include <linux/workqueue.h>
|
|
|
|
struct arch_timer_kvm {
|
|
#ifdef CONFIG_KVM_ARM_TIMER
|
|
/* Is the timer enabled */
|
|
bool enabled;
|
|
|
|
/* Virtual offset */
|
|
cycle_t cntvoff;
|
|
#endif
|
|
};
|
|
|
|
struct arch_timer_cpu {
|
|
#ifdef CONFIG_KVM_ARM_TIMER
|
|
/* Registers: control register, timer value */
|
|
u32 cntv_ctl; /* Saved/restored */
|
|
cycle_t cntv_cval; /* Saved/restored */
|
|
|
|
/*
|
|
* Anything that is not used directly from assembly code goes
|
|
* here.
|
|
*/
|
|
|
|
/* Background timer used when the guest is not running */
|
|
struct hrtimer timer;
|
|
|
|
/* Work queued with the above timer expires */
|
|
struct work_struct expired;
|
|
|
|
/* Background timer active */
|
|
bool armed;
|
|
|
|
/* Timer IRQ */
|
|
const struct kvm_irq_level *irq;
|
|
#endif
|
|
};
|
|
|
|
#ifdef CONFIG_KVM_ARM_TIMER
|
|
int kvm_timer_hyp_init(void);
|
|
int kvm_timer_init(struct kvm *kvm);
|
|
void kvm_timer_vcpu_init(struct kvm_vcpu *vcpu);
|
|
void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu);
|
|
void kvm_timer_sync_hwstate(struct kvm_vcpu *vcpu);
|
|
void kvm_timer_vcpu_terminate(struct kvm_vcpu *vcpu);
|
|
#else
|
|
static inline int kvm_timer_hyp_init(void)
|
|
{
|
|
return 0;
|
|
};
|
|
|
|
static inline int kvm_timer_init(struct kvm *kvm)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void kvm_timer_vcpu_init(struct kvm_vcpu *vcpu) {}
|
|
static inline void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu) {}
|
|
static inline void kvm_timer_sync_hwstate(struct kvm_vcpu *vcpu) {}
|
|
static inline void kvm_timer_vcpu_terminate(struct kvm_vcpu *vcpu) {}
|
|
#endif
|
|
|
|
#endif
|