xen/mem_sharing: support forks with active vPMU state
authorTamas K Lengyel <tamas.lengyel@intel.com>
Mon, 25 Jul 2022 13:44:33 +0000 (15:44 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 25 Jul 2022 13:44:33 +0000 (15:44 +0200)
commit755087eb9b10cac418b1327382b2506d32bbfb7d
tree483bd2735ac5a4c6a9aebaddf424a012b07d5b6e
parent7c5e3cc07dc7c087af4e9175e85c2b21c8a39c81
xen/mem_sharing: support forks with active vPMU state

Currently the vPMU state from a parent isn't copied to VM forks. To enable the
vPMU state to be copied to a fork VM we export certain vPMU functions. First,
the vPMU context needs to be allocated for the fork if the parent has one. For
this we introduce vpmu->allocate_context, which has previously only been called
when the guest enables the PMU on itself. Furthermore, we export
vpmu_save_force so that the PMU context can be saved on-demand even if no
context switch took place on the parent's CPU yet. Additionally, we make sure
all relevant configuration MSRs are saved in the vPMU context so the copy is
complete and the fork starts with the same PMU config as the parent.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/cpu/vpmu.c
xen/arch/x86/cpu/vpmu_amd.c
xen/arch/x86/cpu/vpmu_intel.c
xen/arch/x86/include/asm/vpmu.h
xen/arch/x86/mm/mem_sharing.c