KVM in-kernel PM Timer implementation (experimental code part 1)
A message that is not in the archive (sent off-list or not yet received): 923827175.679451292327146652.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com
RFC 1/4 KVM in-kernel PM Timer implementation (experimental code part 1)
experimental code part 1 (KVM kernel)
-------------------------------------
This code introduces the actual emulation of the PM Timer register plus some helper functions to create and configure the in-kernel PM Timer. The emulation utilizes the 'kvm_io_bus' infrastructure.
arch/x86/include/asm/kvm_host.h renamed from arch/x86/include/asm/kvm_host.h.orig1 +4 -0
@@ -459,6 +459,10 @@ struct kvm_arch {/* fields used by HYPER-V emulation */ u64 hv_guest_os_id;u64 hv_hypercall; + +#ifdef KVM_CAP_PMTMR +struct kvm_pmtmr *vpmtmr; +#endif };struct kvm_vm_stat {
arch/x86/kvm/i8254.c renamed from arch/x86/kvm/i8254.c.orig1 +1 -1
@@ -51,7 +51,7 @@#define RW_STATE_WORD1 4/* Compute with 96 bit intermediate result: (a*b)/c */ -static u64 muldiv64 (u64 a,u32 b,u32 c) +u64 muldiv64 (u64 a,u32 b,u32 c) {union {u64 ll;
arch/x86/kvm/Makefile renamed from arch/x86/kvm/Makefile.orig1 +1 -1
@@ -12,7 +12,7 @@ kvm-$(CONFIG_IOMMU_API) += $(addprefix . kvm-$(CONFIG_KVM_ASYNC_PF) += $(addprefix ../../../virt/kvm/, async_pf.o) kvm-y += x86.o mmu.o emulate.o i8259.o irq.o lapic.o \ - i8254.o timer.o + i8254.o timer.o pmtmr.o kvm-intel-y += vmx.o kvm-amd-y += svm.o
arch/x86/kvm/pmtmr.c renamed from arch/x86/kvm/pmtmr.c.orig1 +151 -0
151 lines not on this page · raw message
arch/x86/kvm/pmtmr.h renamed from arch/x86/kvm/pmtmr.h.orig1 +35 -0
@@ -0,0 +1,35 @@ +#ifndef __PMTMR_H +#define __PMTMR_H + +#include "iodev.h" + +#define KVM_ACPI_PMTMR_STATS + +#define KVM_ACPI_PMTMR_FREQ 3579545 +#define KVM_ACPI_PMTMR_MASK 0xffffff + +#define KVM_ACPI_PMTMR_TMR_EN 1/* timer carry interrupt enable bit */ +/* in PM1 Enable register */ + +#define KVM_ACPI_REG_PMEN 2/* offset of PM1 enable register */ +#define KVM_ACPI_REG_PMTMR 8/* offset of PM Timer register */ + +struct kvm_pmtmr { +struct kvm_io_device dev; +gpa_t pm_io_base; +s64 clock_offset; +#define KVM_PMTMR_STATE_CREATED -1 +#define KVM_PMTMR_STATE_ENABLED 0 +#define KVM_PMTMR_STATE_DISABLED 1 +u64 state; +#ifdef KVM_ACPI_PMTMR_STATS +u64 read_count; +#endif +}; + +int kvm_create_pmtmr (struct kvm *kvm); +int kvm_configure_pmtmr (struct kvm *kvm,struct kvm_pmtmr_config *conf); + +extern u64 muldiv64 (u64 a,u32 b,u32 c);/* defined in i8254.c */ + +#endif