alistair23-linux/arch/powerpc/kvm
Nicholas Piggin 10d91611f4 powerpc/64s: Reimplement book3s idle code in C
Reimplement Book3S idle code in C, moving POWER7/8/9 implementation
speific HV idle code to the powernv platform code.

Book3S assembly stubs are kept in common code and used only to save
the stack frame and non-volatile GPRs before executing architected
idle instructions, and restoring the stack and reloading GPRs then
returning to C after waking from idle.

The complex logic dealing with threads and subcores, locking, SPRs,
HMIs, timebase resync, etc., is all done in C which makes it more
maintainable.

This is not a strict translation to C code, there are some
significant differences:

- Idle wakeup no longer uses the ->cpu_restore call to reinit SPRs,
  but saves and restores them itself.

- The optimisation where EC=ESL=0 idle modes did not have to save GPRs
  or change MSR is restored, because it's now simple to do. ESL=1
  sleeps that do not lose GPRs can use this optimization too.

- KVM secondary entry and cede is now more of a call/return style
  rather than branchy. nap_state_lost is not required because KVM
  always returns via NVGPR restoring path.

- KVM secondary wakeup from offline sequence is moved entirely into
  the offline wakeup, which avoids a hwsync in the normal idle wakeup
  path.

Performance measured with context switch ping-pong on different
threads or cores, is possibly improved a small amount, 1-3% depending
on stop state and core vs thread test for shallow states. Deep states
it's in the noise compared with other latencies.

KVM improvements:

- Idle sleepers now always return to caller rather than branch out
  to KVM first.

- This allows optimisations like very fast return to caller when no
  state has been lost.

- KVM no longer requires nap_state_lost because it controls NVGPR
  save/restore itself on the way in and out.

- The heavy idle wakeup KVM request check can be moved out of the
  normal host idle code and into the not-performance-critical offline
  code.

- KVM nap code now returns from where it is called, which makes the
  flow a bit easier to follow.

Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
[mpe: Squash the KVM changes in]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2019-04-30 22:37:48 +10:00
..
book3s.c Merge remote-tracking branch 'remotes/powerpc/topic/ppc-kvm' into kvm-ppc-next 2019-02-22 13:52:30 +11:00
book3s.h KVM: PPC: Book3S PR: Add guard code to prevent returning to guest with PR=0 and Transactional state 2018-06-01 10:30:39 +10:00
book3s_32_mmu.c KVM: PPC: Book3S PR: Add emulation for slbfee. instruction 2019-02-19 14:25:52 +11:00
book3s_32_mmu_host.c
book3s_32_sr.S
book3s_64_mmu.c KVM: PPC: Book3S PR: Add emulation for slbfee. instruction 2019-02-19 14:25:52 +11:00
book3s_64_mmu_host.c * ARM: HYP mode stub supports kexec/kdump on 32-bit; improved PMU 2017-05-08 12:37:56 -07:00
book3s_64_mmu_hv.c KVM: PPC: Book3S HV: Optimise mmio emulation for devices on FAST_MMIO_BUS 2019-02-19 16:00:15 +11:00
book3s_64_mmu_radix.c KVM: PPC: Book3S HV: Add KVM stat largepages_[2M/1G] 2019-02-19 16:00:15 +11:00
book3s_64_slb.S powerpc: clean inclusions of asm/feature-fixups.h 2018-07-30 22:48:17 +10:00
book3s_64_vio.c KVM: PPC: Book3S: Improve KVM reference counting 2019-02-22 12:51:02 +11:00
book3s_64_vio_hv.c KVM: PPC: Optimize clearing TCEs for sparse tables 2018-10-20 20:47:02 +11:00
book3s_emulate.c KVM: PPC: Book3S PR: Add emulation for slbfee. instruction 2019-02-19 14:25:52 +11:00
book3s_exports.c
book3s_hv.c powerpc: Add force enable of DAWR on P9 option 2019-04-20 22:20:45 +10:00
book3s_hv_builtin.c KVM: PPC: Book3S: Allow XICS emulation to work in nested hosts using XIVE 2019-02-19 16:00:15 +11:00
book3s_hv_hmi.c powerpc: Avoid circular header inclusion in mmu-hash.h 2019-02-23 22:31:39 +11:00
book3s_hv_interrupts.S KVM: PPC: Book3S HV: Extract PMU save/restore operations as C-callable functions 2018-10-09 16:04:27 +11:00
book3s_hv_nested.c KVM: PPC: Book3S HV: Introduce kvmhv_update_nest_rmap_rc_list() 2018-12-21 14:39:35 +11:00
book3s_hv_ras.c KVM: PPC: Book3S HV: Simplify machine check handling 2019-02-21 23:16:44 +11:00
book3s_hv_rm_mmu.c KVM: PPC: Book3S HV: Cleanups - constify memslots, fix comments 2018-12-17 10:58:43 +11:00
book3s_hv_rm_xics.c KVM: PPC: Book3S: Allow XICS emulation to work in nested hosts using XIVE 2019-02-19 16:00:15 +11:00
book3s_hv_rm_xive.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
book3s_hv_rmhandlers.S powerpc/64s: Reimplement book3s idle code in C 2019-04-30 22:37:48 +10:00
book3s_hv_tm.c KVM: PPC: Use ccr field in pt_regs struct embedded in vcpu struct 2018-10-09 16:04:27 +11:00
book3s_hv_tm_builtin.c KVM: PPC: Use ccr field in pt_regs struct embedded in vcpu struct 2018-10-09 16:04:27 +11:00
book3s_interrupts.S powerpc: move ASM_CONST and stringify_in_c() into asm-const.h 2018-07-30 22:48:16 +10:00
book3s_mmu_hpte.c sched/headers: Prepare to use <linux/rcuupdate.h> instead of <linux/rculist.h> in <linux/sched.h> 2017-03-02 08:42:38 +01:00
book3s_paired_singles.c
book3s_pr.c KVM: PPC: Pass change type down to memslot commit function 2018-12-17 10:57:27 +11:00
book3s_pr_papr.c KVM: PPC: Book3S PR: Enable in-kernel TCE handlers for PR KVM 2017-10-14 16:38:19 +11:00
book3s_rmhandlers.S powerpc: move ASM_CONST and stringify_in_c() into asm-const.h 2018-07-30 22:48:16 +10:00
book3s_rtas.c KVM: PPC: Book3S: Allow XICS emulation to work in nested hosts using XIVE 2019-02-19 16:00:15 +11:00
book3s_segment.S powerpc: clean inclusions of asm/feature-fixups.h 2018-07-30 22:48:17 +10:00
book3s_xics.c KVM: PPC: Book3S HV: Change to use DEFINE_SHOW_ATTRIBUTE macro 2018-12-14 15:39:47 +11:00
book3s_xics.h KVM: PPC: Book3S HV: Native usage of the XIVE interrupt controller 2017-04-27 21:37:29 +10:00
book3s_xive.c KVM: PPC: Book3S HV: Change to use DEFINE_SHOW_ATTRIBUTE macro 2018-12-14 15:39:47 +11:00
book3s_xive.h KVM: PPC: Book3S HV: Enable use of the new XIVE "single escalation" feature 2018-01-19 12:10:21 +11:00
book3s_xive_template.c KVM: PPC: Book3S HV: Remove left-over code in XICS-on-XIVE emulation 2018-10-09 16:04:27 +11:00
booke.c KVM: PPC: Pass change type down to memslot commit function 2018-12-17 10:57:27 +11:00
booke.h
booke_emulate.c KVM: PPC: Move nip/ctr/lr/xer registers to pt_regs in kvm_vcpu_arch 2018-05-18 15:38:23 +10:00
booke_interrupts.S
bookehv_interrupts.S powerpc/fsl: Flush branch predictor when entering KVM 2018-12-20 22:59:03 +11:00
e500.c powerpc: remove unnecessary inclusion of asm/tlbflush.h 2018-07-30 22:48:20 +10:00
e500.h powerpc/mm: move platform specific mmu-xxx.h in platform directories 2018-12-04 19:45:01 +11:00
e500_emulate.c powerpc/fsl: Emulate SPRN_BUCSR register 2018-12-20 22:59:03 +11:00
e500_mmu.c KVM: PPC: Move nip/ctr/lr/xer registers to pt_regs in kvm_vcpu_arch 2018-05-18 15:38:23 +10:00
e500_mmu_host.c KVM: Make kvm_set_spte_hva() return int 2018-12-21 11:28:41 +01:00
e500_mmu_host.h
e500mc.c powerpc: remove unnecessary inclusion of asm/tlbflush.h 2018-07-30 22:48:20 +10:00
emulate.c KVM: PPC: Use exported tb_to_ns() function in decrementer emulation 2018-10-26 21:58:58 +11:00
emulate_loadstore.c KVM: PPC: Use ccr field in pt_regs struct embedded in vcpu struct 2018-10-09 16:04:27 +11:00
fpu.S
irq.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Kconfig treewide: surround Kconfig file paths with double quotes 2018-12-22 00:25:54 +09:00
Makefile KVM: PPC: Remove -I. header search paths 2019-02-19 16:00:15 +11:00
mpic.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
powerpc.c KVM: PPC: Book3S: Add count cache flush parameters to kvmppc_get_cpu_char() 2019-03-01 15:11:14 +11:00
timing.c KVM: PPC: Use seq_puts() in kvmppc_exit_timing_show() 2018-01-11 20:36:06 +11:00
timing.h
tm.S KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable 2018-10-09 16:04:27 +11:00
trace.h KVM: PPC: Move and undef TRACE_INCLUDE_PATH/FILE 2018-11-07 23:04:38 +11:00
trace_book3s.h KVM: PPC: Book3S: Simplify external interrupt handling 2018-10-09 16:04:27 +11:00
trace_booke.h KVM: PPC: Move and undef TRACE_INCLUDE_PATH/FILE 2018-11-07 23:04:38 +11:00
trace_hv.h KVM: PPC: Move and undef TRACE_INCLUDE_PATH/FILE 2018-11-07 23:04:38 +11:00
trace_pr.h KVM: PPC: Move and undef TRACE_INCLUDE_PATH/FILE 2018-11-07 23:04:38 +11:00