mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-22 20:53:00 +07:00
4bb3c7a020
POWER9 has hardware bugs relating to transactional memory and thread reconfiguration (changes to hardware SMT mode). Specifically, the core does not have enough storage to store a complete checkpoint of all the architected state for all four threads. The DD2.2 version of POWER9 includes hardware modifications designed to allow hypervisor software to implement workarounds for these problems. This patch implements those workarounds in KVM code so that KVM guests see a full, working transactional memory implementation. The problems center around the use of TM suspended state, where the CPU has a checkpointed state but execution is not transactional. The workaround is to implement a "fake suspend" state, which looks to the guest like suspended state but the CPU does not store a checkpoint. In this state, any instruction that would cause a transition to transactional state (rfid, rfebb, mtmsrd, tresume) or would use the checkpointed state (treclaim) causes a "soft patch" interrupt (vector 0x1500) to the hypervisor so that it can be emulated. The trechkpt instruction also causes a soft patch interrupt. On POWER9 DD2.2, we avoid returning to the guest in any state which would require a checkpoint to be present. The trechkpt in the guest entry path which would normally create that checkpoint is replaced by either a transition to fake suspend state, if the guest is in suspend state, or a rollback to the pre-transactional state if the guest is in transactional state. Fake suspend state is indicated by a flag in the PACA plus a new bit in the PSSCR. The new PSSCR bit is write-only and reads back as 0. On exit from the guest, if the guest is in fake suspend state, we still do the treclaim instruction as we would in real suspend state, in order to get into non-transactional state, but we do not save the resulting register state since there was no checkpoint. Emulation of the instructions that cause a softpatch interrupt is handled in two paths. If the guest is in real suspend mode, we call kvmhv_p9_tm_emulation_early() to handle the cases where the guest is transitioning to transactional state. This is called before we do the treclaim in the guest exit path; because we haven't done treclaim, we can get back to the guest with the transaction still active. If the instruction is a case that kvmhv_p9_tm_emulation_early() doesn't handle, or if the guest is in fake suspend state, then we proceed to do the complete guest exit path and subsequently call kvmhv_p9_tm_emulation() in host context with the MMU on. This handles all the cases including the cases that generate program interrupts (illegal instruction or TM Bad Thing) and facility unavailable interrupts. The emulation is reasonably straightforward and is mostly concerned with checking for exception conditions and updating the state of registers such as MSR and CR0. The treclaim emulation takes care to ensure that the TEXASR register gets updated as if it were the guest treclaim instruction that had done failure recording, not the treclaim done in hypervisor state in the guest exit path. With this, the KVM_CAP_PPC_HTM capability returns true (1) even if transactional memory is not available to host userspace. Signed-off-by: Paul Mackerras <paulus@ozlabs.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
139 lines
3.2 KiB
Makefile
139 lines
3.2 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# Makefile for Kernel-based Virtual Machine module
|
|
#
|
|
|
|
subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
|
|
|
|
ccflags-y := -Ivirt/kvm -Iarch/powerpc/kvm
|
|
KVM := ../../../virt/kvm
|
|
|
|
common-objs-y = $(KVM)/kvm_main.o $(KVM)/eventfd.o
|
|
common-objs-$(CONFIG_KVM_VFIO) += $(KVM)/vfio.o
|
|
common-objs-$(CONFIG_KVM_MMIO) += $(KVM)/coalesced_mmio.o
|
|
|
|
CFLAGS_e500_mmu.o := -I.
|
|
CFLAGS_e500_mmu_host.o := -I.
|
|
CFLAGS_emulate.o := -I.
|
|
CFLAGS_emulate_loadstore.o := -I.
|
|
|
|
common-objs-y += powerpc.o emulate_loadstore.o
|
|
obj-$(CONFIG_KVM_EXIT_TIMING) += timing.o
|
|
obj-$(CONFIG_KVM_BOOK3S_HANDLER) += book3s_exports.o
|
|
|
|
AFLAGS_booke_interrupts.o := -I$(objtree)/$(obj)
|
|
|
|
kvm-e500-objs := \
|
|
$(common-objs-y) \
|
|
emulate.o \
|
|
booke.o \
|
|
booke_emulate.o \
|
|
booke_interrupts.o \
|
|
e500.o \
|
|
e500_mmu.o \
|
|
e500_mmu_host.o \
|
|
e500_emulate.o
|
|
kvm-objs-$(CONFIG_KVM_E500V2) := $(kvm-e500-objs)
|
|
|
|
kvm-e500mc-objs := \
|
|
$(common-objs-y) \
|
|
emulate.o \
|
|
booke.o \
|
|
booke_emulate.o \
|
|
bookehv_interrupts.o \
|
|
e500mc.o \
|
|
e500_mmu.o \
|
|
e500_mmu_host.o \
|
|
e500_emulate.o
|
|
kvm-objs-$(CONFIG_KVM_E500MC) := $(kvm-e500mc-objs)
|
|
|
|
kvm-book3s_64-builtin-objs-$(CONFIG_SPAPR_TCE_IOMMU) := \
|
|
book3s_64_vio_hv.o
|
|
|
|
kvm-pr-y := \
|
|
fpu.o \
|
|
emulate.o \
|
|
book3s_paired_singles.o \
|
|
book3s_pr.o \
|
|
book3s_pr_papr.o \
|
|
book3s_emulate.o \
|
|
book3s_interrupts.o \
|
|
book3s_mmu_hpte.o \
|
|
book3s_64_mmu_host.o \
|
|
book3s_64_mmu.o \
|
|
book3s_32_mmu.o
|
|
|
|
ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE
|
|
kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \
|
|
book3s_rmhandlers.o
|
|
endif
|
|
|
|
kvm-hv-y += \
|
|
book3s_hv.o \
|
|
book3s_hv_interrupts.o \
|
|
book3s_64_mmu_hv.o \
|
|
book3s_64_mmu_radix.o
|
|
|
|
kvm-hv-$(CONFIG_PPC_TRANSACTIONAL_MEM) += \
|
|
book3s_hv_tm.o
|
|
|
|
kvm-book3s_64-builtin-xics-objs-$(CONFIG_KVM_XICS) := \
|
|
book3s_hv_rm_xics.o book3s_hv_rm_xive.o
|
|
|
|
kvm-book3s_64-builtin-tm-objs-$(CONFIG_PPC_TRANSACTIONAL_MEM) += \
|
|
book3s_hv_tm_builtin.o
|
|
|
|
ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
|
|
kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \
|
|
book3s_hv_hmi.o \
|
|
book3s_hv_rmhandlers.o \
|
|
book3s_hv_rm_mmu.o \
|
|
book3s_hv_ras.o \
|
|
book3s_hv_builtin.o \
|
|
$(kvm-book3s_64-builtin-tm-objs-y) \
|
|
$(kvm-book3s_64-builtin-xics-objs-y)
|
|
endif
|
|
|
|
kvm-book3s_64-objs-$(CONFIG_KVM_XICS) += \
|
|
book3s_xics.o
|
|
|
|
kvm-book3s_64-objs-$(CONFIG_KVM_XIVE) += book3s_xive.o
|
|
kvm-book3s_64-objs-$(CONFIG_SPAPR_TCE_IOMMU) += book3s_64_vio.o
|
|
|
|
kvm-book3s_64-module-objs := \
|
|
$(common-objs-y) \
|
|
book3s.o \
|
|
book3s_rtas.o \
|
|
$(kvm-book3s_64-objs-y)
|
|
|
|
kvm-objs-$(CONFIG_KVM_BOOK3S_64) := $(kvm-book3s_64-module-objs)
|
|
|
|
kvm-book3s_32-objs := \
|
|
$(common-objs-y) \
|
|
emulate.o \
|
|
fpu.o \
|
|
book3s_paired_singles.o \
|
|
book3s.o \
|
|
book3s_pr.o \
|
|
book3s_emulate.o \
|
|
book3s_interrupts.o \
|
|
book3s_mmu_hpte.o \
|
|
book3s_32_mmu_host.o \
|
|
book3s_32_mmu.o
|
|
kvm-objs-$(CONFIG_KVM_BOOK3S_32) := $(kvm-book3s_32-objs)
|
|
|
|
kvm-objs-$(CONFIG_KVM_MPIC) += mpic.o
|
|
kvm-objs-$(CONFIG_HAVE_KVM_IRQ_ROUTING) += $(KVM)/irqchip.o
|
|
|
|
kvm-objs := $(kvm-objs-m) $(kvm-objs-y)
|
|
|
|
obj-$(CONFIG_KVM_E500V2) += kvm.o
|
|
obj-$(CONFIG_KVM_E500MC) += kvm.o
|
|
obj-$(CONFIG_KVM_BOOK3S_64) += kvm.o
|
|
obj-$(CONFIG_KVM_BOOK3S_32) += kvm.o
|
|
|
|
obj-$(CONFIG_KVM_BOOK3S_64_PR) += kvm-pr.o
|
|
obj-$(CONFIG_KVM_BOOK3S_64_HV) += kvm-hv.o
|
|
|
|
obj-y += $(kvm-book3s_64-builtin-objs-y)
|