linux/arch/mips/kvm
Mark Rutland 72e3244512 kvm/mips: rework guest entry logic
In kvm_arch_vcpu_ioctl_run() we use guest_enter_irqoff() and
guest_exit_irqoff() directly, with interrupts masked between these. As
we don't handle any timer ticks during this window, we will not account
time spent within the guest as guest time, which is unfortunate.

Additionally, we do not inform lockdep or tracing that interrupts will
be enabled during guest execution, which caan lead to misleading traces
and warnings that interrupts have been enabled for overly-long periods.

This patch fixes these issues by using the new timing and context
entry/exit helpers to ensure that interrupts are handled during guest
vtime but with RCU watching, with a sequence:

	guest_timing_enter_irqoff();

	guest_state_enter_irqoff();
	< run the vcpu >
	guest_state_exit_irqoff();

	< take any pending IRQs >

	guest_timing_exit_irqoff();

In addition, as guest exits during the "run the vcpu" step are handled
by kvm_mips_handle_exit(), a wrapper function is added which ensures
that such exists are handled with a sequence:

	guest_state_exit_irqoff();
	< handle the exit >
	guest_state_enter_irqoff();

This means that exits which stop the vCPU running will have a redundant
guest_state_enter_irqoff() .. guest_state_exit_irqoff() sequence, which
can be addressed with future rework.

Since instrumentation may make use of RCU, we must also ensure that no
instrumented code is run during the EQS. I've split out the critical
section into a new kvm_mips_enter_exit_vcpu() helper which is marked
noinstr.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Message-Id: <20220201132926.3301912-6-mark.rutland@arm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-02-01 08:51:53 -05:00
..
callback.c MIPS: KVM: Convert EXPORT_SYMBOL to _GPL 2016-01-24 03:13:24 +01:00
emulate.c KVM: Rename kvm_vcpu_block() => kvm_vcpu_halt() 2021-12-08 04:24:51 -05:00
entry.c MIPS: Remove NETLOGIC support 2021-10-24 17:24:47 +02:00
fpu.S MIPS: KVM: Fix fpu.S misassembly with r6 2016-07-05 16:09:11 +02:00
hypcall.c KVM: MIPS: Implement HYPCALL emulation 2017-03-28 14:53:33 +01:00
interrupt.c MIPS: Remove KVM_TE support 2021-03-10 15:18:48 +01:00
interrupt.h MIPS: Remove KVM_TE support 2021-03-10 15:18:48 +01:00
Kconfig KVM: Use interval tree to do fast hva lookup in memslots 2021-12-08 04:24:32 -05:00
loongson_ipi.c KVM: mips: Use kvm_get_vcpu() instead of open-coded access 2021-12-08 04:24:13 -05:00
Makefile KVM: mips: Use Makefile.kvm for common files 2021-12-09 12:58:37 -05:00
mips.c kvm/mips: rework guest entry logic 2022-02-01 08:51:53 -05:00
mmu.c MIPS: Return true/false (not 1/0) from bool functions 2021-08-21 10:37:30 +02:00
msa.S MIPS: KVM: Add base guest MSA support 2015-03-27 21:25:19 +00:00
stats.c MIPS: KVM: Clean up kvm_exit trace event 2016-06-14 11:16:23 +02:00
tlb.c mips/kvm: Use BUG_ON instead of if condition followed by BUG 2021-06-21 11:40:54 +02:00
trace.h KVM: MIPS/VZ: Trace guest mode changes 2017-03-28 14:54:00 +01:00
vz.c KVM: MIPS: Remove a "set but not used" variable 2021-09-06 06:52:10 -04:00