linux_dsm_epyc7002/arch/mips/include/asm
James Hogan e30492bbe9 MIPS: KVM: Rewrite count/compare timer emulation
Previously the emulation of the CPU timer was just enough to get a Linux
guest running but some shortcuts were taken:
 - The guest timer interrupt was hard coded to always happen every 10 ms
   rather than being timed to when CP0_Count would match CP0_Compare.
 - The guest's CP0_Count register was based on the host's CP0_Count
   register. This isn't very portable and fails on cores without a
   CP_Count register implemented such as Ingenic XBurst. It also meant
   that the guest's CP0_Cause.DC bit to disable the CP0_Count register
   took no effect.
 - The guest's CP0_Count register was emulated by just dividing the
   host's CP0_Count register by 4. This resulted in continuity problems
   when used as a clock source, since when the host CP0_Count overflows
   from 0x7fffffff to 0x80000000, the guest CP0_Count transitions
   discontinuously from 0x1fffffff to 0xe0000000.

Therefore rewrite & fix emulation of the guest timer based on the
monotonic kernel time (i.e. ktime_get()). Internally a 32-bit count_bias
value is added to the frequency scaled nanosecond monotonic time to get
the guest's CP0_Count. The frequency of the timer is initialised to
100MHz and cannot yet be changed, but a later patch will allow the
frequency to be configured via the KVM_{GET,SET}_ONE_REG ioctl
interface.

The timer can now be stopped via the CP0_Cause.DC bit (by the guest or
via the KVM_SET_ONE_REG ioctl interface), at which point the current
CP0_Count is stored and can be read directly. When it is restarted the
bias is recalculated such that the CP0_Count value is continuous.

Due to the nature of hrtimer interrupts any read of the guest's
CP0_Count register while it is running triggers a check for whether the
hrtimer has expired, so that the guest/userland cannot observe the
CP0_Count passing CP0_Compare without queuing a timer interrupt. This is
also taken advantage of when stopping the timer to ensure that a pending
timer interrupt is queued.

This replaces the implementation of:
 - Guest read of CP0_Count
 - Guest write of CP0_Count
 - Guest write of CP0_Compare
 - Guest write of CP0_Cause
 - Guest read of HWR 2 (CC) with RDHWR
 - Host read of CP0_Count via KVM_GET_ONE_REG ioctl interface
 - Host write of CP0_Count via KVM_SET_ONE_REG ioctl interface
 - Host write of CP0_Compare via KVM_SET_ONE_REG ioctl interface
 - Host write of CP0_Cause via KVM_SET_ONE_REG ioctl interface

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Gleb Natapov <gleb@kernel.org>
Cc: kvm@vger.kernel.org
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: Sanjay Lal <sanjayl@kymasys.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-05-30 13:01:48 +02:00
..
dec
emma
fw MIPS: malta: malta-memory: Add support for the 'ememsize' variable 2014-03-26 23:09:20 +01:00
ip32
lasat
mach-ar7
mach-ath79
mach-au1x00 MIPS: Alchemy: remove duplicate UART register offset definitions 2014-03-31 10:16:53 +02:00
mach-bcm47xx MIPS: BCM47XX: Add Belkin F7Dxxxx board detection 2014-03-26 23:09:23 +01:00
mach-bcm63xx
mach-cavium-octeon
mach-cobalt
mach-db1x00 MIPS: Alchemy: fold mach-db1xxx/db1x00 headers into board code 2014-03-26 23:09:21 +01:00
mach-dec
mach-emma2rh
mach-generic
mach-ip22
mach-ip27
mach-ip28
mach-ip32
mach-jazz
mach-jz4740
mach-lantiq
mach-lasat
mach-loongson MIPS: Loongson 3: Add CPU hotplug support 2014-03-31 18:17:12 +02:00
mach-loongson1
mach-malta MIPS: malta: Add support for SMP EVA 2014-03-26 23:09:20 +01:00
mach-netlogic
mach-pmcs-msp71xx MIPS: Fix gigaton of warning building with microMIPS. 2014-03-31 18:17:12 +02:00
mach-pnx833x
mach-ralink
mach-rc32434
mach-rm
mach-sead3
mach-sibyte
mach-tx39xx
mach-tx49xx
mach-vr41xx
mips-boards MIPS: Malta: Setup PM I/O region on boot 2014-03-31 18:17:12 +02:00
netlogic
octeon
pci
sgi
sibyte
sn
txx9
vr41xx
xtalk
abi.h
addrspace.h
amon.h
arch_hweight.h
asm-eva.h MIPS: asm: Add wrappers for EVA/non-EVA instructions 2014-03-26 23:09:12 +01:00
asm-offsets.h
asm.h MIPS: Fix gigaton of warning building with microMIPS. 2014-03-31 18:17:12 +02:00
asmmacro-32.h MIPS: Don't assume 64-bit FP registers for context switch 2014-03-26 23:09:10 +01:00
asmmacro-64.h
asmmacro.h Merge branch '3.14-fixes' into mips-for-linux-next 2014-03-31 18:17:33 +02:00
atomic.h MIPS: Fix gigaton of warning building with microMIPS. 2014-03-31 18:17:12 +02:00
barrier.h
bcache.h
bitops.h MIPS: Fix gigaton of warning building with microMIPS. 2014-03-31 18:17:12 +02:00
bmips.h
bootinfo.h MIPS: Loongson 3: Add Lemote-3A machtypes definition 2014-03-31 18:17:12 +02:00
branch.h
break.h
bug.h
bugs.h
cache.h
cacheflush.h
cacheops.h
cevt-r4k.h
checksum.h MIPS: asm: checksum: Add MIPS specific csum_and_copy_from_user function 2014-03-26 23:09:17 +01:00
clkdev.h
clock.h
cmp.h
cmpxchg.h MIPS: Fix gigaton of warning building with microMIPS. 2014-03-31 18:17:12 +02:00
compat-signal.h
compat.h
compiler.h
cop2.h
cpu-features.h MIPS: asm: cpu: Add cpu flag for Enhanced Virtual Addressing 2014-03-26 23:09:18 +01:00
cpu-info.h MIPS: MT: proc: Add support for printing VPE and TC ids 2014-03-31 18:17:12 +02:00
cpu-type.h MIPS: Loongson: Add basic Loongson-3 CPU support 2014-03-31 18:17:12 +02:00
cpu.h MIPS: Loongson: Add basic Loongson-3 definition 2014-03-31 18:17:12 +02:00
debug.h
delay.h
device.h
div64.h
dma-coherence.h
dma-mapping.h MIPS: Loongson: Add swiotlb to support All-Memory DMA 2014-03-31 18:17:12 +02:00
dma.h
ds1287.h
dsp.h
edac.h
elf.h
errno.h
exec.h
fb.h
fixmap.h
floppy.h
fpregdef.h
fpu_emulator.h
fpu.h Merge branch '3.14-fixes' into mips-for-linux-next 2014-03-31 18:17:33 +02:00
ftrace.h MIPS: ftrace: Tweak safe_load()/safe_store() macros 2014-03-19 23:18:40 +01:00
futex.h MIPS: Fix gigaton of warning building with microMIPS. 2014-03-31 18:17:12 +02:00
gic.h MIPS: Add missing includes to gic.h 2014-03-06 21:25:22 +01:00
gio_device.h
gpio.h
gt64120.h
hardirq.h
hazards.h
highmem.h
hugetlb.h
hw_irq.h
i8259.h
ide.h
idle.h
inst.h
io.h MIPS: Fix gigaton of warning building with microMIPS. 2014-03-31 18:17:12 +02:00
irq_cpu.h
irq_gt641xx.h
irq_regs.h
irq.h
irqflags.h
isadep.h
jazz.h
jazzdma.h
jump_label.h
Kbuild locking/mcs: Allow architecture specific asm files to be used for contended case 2014-02-09 21:18:52 +01:00
kdebug.h
kexec.h
kgdb.h
kmap_types.h
kprobes.h
kvm_host.h MIPS: KVM: Rewrite count/compare timer emulation 2014-05-30 13:01:48 +02:00
linkage.h
local.h MIPS: Fix gigaton of warning building with microMIPS. 2014-03-31 18:17:12 +02:00
m48t37.h
mc146818-time.h
mc146818rtc.h
mips_machine.h
mips_mt.h MIPS: Provide empty mips_mt_set_cpuoptions when CONFIG_MIPS_MT=n 2014-03-31 18:17:12 +02:00
mips-cm.h MIPS: CM: use __raw_ memory access functions 2014-03-31 18:17:13 +02:00
mips-cpc.h MIPS: CPC: Use __raw_ memory access functions 2014-03-31 18:17:13 +02:00
mipsmtregs.h MIPS: MT: core_nvpes function to retrieve VPE count 2014-03-31 18:17:12 +02:00
mipsprom.h
mipsregs.h MIPS: Add MSA register definitions & access 2014-03-26 23:09:10 +01:00
mmu_context.h
mmu.h
mmzone.h
module.h MIPS: Loongson: Add basic Loongson-3 definition 2014-03-31 18:17:12 +02:00
msa.h MIPS: Basic MSA context switching support 2014-03-26 23:09:10 +01:00
msc01_ic.h
nile4.h
paccess.h
page.h MIPS: asm: page: Allow __pa_symbol overrides 2014-03-26 23:09:18 +01:00
pci.h
perf_event.h
pgalloc.h
pgtable-32.h
pgtable-64.h
pgtable-bits.h MIPS: Loongson: Add basic Loongson-3 definition 2014-03-31 18:17:12 +02:00
pgtable.h
pmon.h
prefetch.h
processor.h MIPS: Basic MSA context switching support 2014-03-26 23:09:10 +01:00
prom.h
ptrace.h MIPS: seccomp: Handle indirect system calls (o32) 2014-03-26 23:09:08 +01:00
r4k-timer.h
r4kcache.h MIPS: Fix gigaton of warning building with microMIPS. 2014-03-31 18:17:12 +02:00
reboot.h
reg.h
regdef.h
rm9k-ocd.h
rtlx.h
seccomp.h
setup.h
sgialib.h
sgiarcs.h
shmparam.h
sigcontext.h MIPS: Save/restore MSA context around signals 2014-03-26 23:09:11 +01:00
siginfo.h
signal.h
sim.h
smp-cps.h MIPS: Coherent Processing System SMP implementation 2014-03-26 23:00:12 +01:00
smp-ops.h MIPS: Fix warning when including smp-ops.h with CONFIG_SMP=n 2014-03-31 18:17:13 +02:00
smp.h MIPS: Loongson 3: Add CPU hotplug support 2014-03-31 18:17:12 +02:00
smtc_ipi.h
smtc_proc.h
smtc.h
sni.h
socket.h
sparsemem.h
spinlock_types.h
spinlock.h
spram.h
stackframe.h MIPS: Fix gigaton of warning building with microMIPS. 2014-03-31 18:17:12 +02:00
stackprotector.h
stacktrace.h
string.h
suspend.h
switch_to.h MIPS: Basic MSA context switching support 2014-03-26 23:09:10 +01:00
syscall.h Merge git://git.infradead.org/users/eparis/audit 2014-04-12 12:38:53 -07:00
termios.h
thread_info.h MIPS: Basic MSA context switching support 2014-03-26 23:09:10 +01:00
time.h
timex.h
tlb.h
tlbdebug.h
tlbflush.h
tlbmisc.h
topology.h sched: Remove unused mc_capable() and smt_capable() 2014-03-11 12:05:45 +01:00
traps.h
txx9irq.h
txx9pio.h
txx9tmr.h
types.h
uaccess.h MIPS: asm: uaccess: Add EVA support for str*_user operations 2014-03-26 23:09:16 +01:00
uasm.h
unaligned.h
unistd.h compat: let architectures define __ARCH_WANT_COMPAT_SYS_GETDENTS64 2014-03-04 09:05:33 +01:00
user.h
vdso.h
vga.h
vpe.h
war.h
watch.h
wbflush.h