mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
e30492bbe9
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> |
||
---|---|---|
.. | ||
dec | ||
emma | ||
fw | ||
ip32 | ||
lasat | ||
mach-ar7 | ||
mach-ath79 | ||
mach-au1x00 | ||
mach-bcm47xx | ||
mach-bcm63xx | ||
mach-cavium-octeon | ||
mach-cobalt | ||
mach-db1x00 | ||
mach-dec | ||
mach-emma2rh | ||
mach-generic | ||
mach-ip22 | ||
mach-ip27 | ||
mach-ip28 | ||
mach-ip32 | ||
mach-jazz | ||
mach-jz4740 | ||
mach-lantiq | ||
mach-lasat | ||
mach-loongson | ||
mach-loongson1 | ||
mach-malta | ||
mach-netlogic | ||
mach-pmcs-msp71xx | ||
mach-pnx833x | ||
mach-ralink | ||
mach-rc32434 | ||
mach-rm | ||
mach-sead3 | ||
mach-sibyte | ||
mach-tx39xx | ||
mach-tx49xx | ||
mach-vr41xx | ||
mips-boards | ||
netlogic | ||
octeon | ||
pci | ||
sgi | ||
sibyte | ||
sn | ||
txx9 | ||
vr41xx | ||
xtalk | ||
abi.h | ||
addrspace.h | ||
amon.h | ||
arch_hweight.h | ||
asm-eva.h | ||
asm-offsets.h | ||
asm.h | ||
asmmacro-32.h | ||
asmmacro-64.h | ||
asmmacro.h | ||
atomic.h | ||
barrier.h | ||
bcache.h | ||
bitops.h | ||
bmips.h | ||
bootinfo.h | ||
branch.h | ||
break.h | ||
bug.h | ||
bugs.h | ||
cache.h | ||
cacheflush.h | ||
cacheops.h | ||
cevt-r4k.h | ||
checksum.h | ||
clkdev.h | ||
clock.h | ||
cmp.h | ||
cmpxchg.h | ||
compat-signal.h | ||
compat.h | ||
compiler.h | ||
cop2.h | ||
cpu-features.h | ||
cpu-info.h | ||
cpu-type.h | ||
cpu.h | ||
debug.h | ||
delay.h | ||
device.h | ||
div64.h | ||
dma-coherence.h | ||
dma-mapping.h | ||
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 | ||
ftrace.h | ||
futex.h | ||
gic.h | ||
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 | ||
irq_cpu.h | ||
irq_gt641xx.h | ||
irq_regs.h | ||
irq.h | ||
irqflags.h | ||
isadep.h | ||
jazz.h | ||
jazzdma.h | ||
jump_label.h | ||
Kbuild | ||
kdebug.h | ||
kexec.h | ||
kgdb.h | ||
kmap_types.h | ||
kprobes.h | ||
kvm_host.h | ||
linkage.h | ||
local.h | ||
m48t37.h | ||
mc146818-time.h | ||
mc146818rtc.h | ||
mips_machine.h | ||
mips_mt.h | ||
mips-cm.h | ||
mips-cpc.h | ||
mipsmtregs.h | ||
mipsprom.h | ||
mipsregs.h | ||
mmu_context.h | ||
mmu.h | ||
mmzone.h | ||
module.h | ||
msa.h | ||
msc01_ic.h | ||
nile4.h | ||
paccess.h | ||
page.h | ||
pci.h | ||
perf_event.h | ||
pgalloc.h | ||
pgtable-32.h | ||
pgtable-64.h | ||
pgtable-bits.h | ||
pgtable.h | ||
pmon.h | ||
prefetch.h | ||
processor.h | ||
prom.h | ||
ptrace.h | ||
r4k-timer.h | ||
r4kcache.h | ||
reboot.h | ||
reg.h | ||
regdef.h | ||
rm9k-ocd.h | ||
rtlx.h | ||
seccomp.h | ||
setup.h | ||
sgialib.h | ||
sgiarcs.h | ||
shmparam.h | ||
sigcontext.h | ||
siginfo.h | ||
signal.h | ||
sim.h | ||
smp-cps.h | ||
smp-ops.h | ||
smp.h | ||
smtc_ipi.h | ||
smtc_proc.h | ||
smtc.h | ||
sni.h | ||
socket.h | ||
sparsemem.h | ||
spinlock_types.h | ||
spinlock.h | ||
spram.h | ||
stackframe.h | ||
stackprotector.h | ||
stacktrace.h | ||
string.h | ||
suspend.h | ||
switch_to.h | ||
syscall.h | ||
termios.h | ||
thread_info.h | ||
time.h | ||
timex.h | ||
tlb.h | ||
tlbdebug.h | ||
tlbflush.h | ||
tlbmisc.h | ||
topology.h | ||
traps.h | ||
txx9irq.h | ||
txx9pio.h | ||
txx9tmr.h | ||
types.h | ||
uaccess.h | ||
uasm.h | ||
unaligned.h | ||
unistd.h | ||
user.h | ||
vdso.h | ||
vga.h | ||
vpe.h | ||
war.h | ||
watch.h | ||
wbflush.h |