mirror of
https://github.com/torvalds/linux.git
synced 2024-12-11 13:41:55 +00:00
KVM: PPC: Book3S HV P9: Only execute mtSPR if the value changed
Keep better track of the current SPR value in places where they are to be loaded with a new context, to reduce expensive mtSPR operations. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20211123095231.1036501-27-npiggin@gmail.com
This commit is contained in:
parent
9a1e530bbb
commit
9dfe7aa7bc
@ -4055,20 +4055,28 @@ static void switch_pmu_to_host(struct kvm_vcpu *vcpu,
|
||||
}
|
||||
}
|
||||
|
||||
static void load_spr_state(struct kvm_vcpu *vcpu)
|
||||
static void load_spr_state(struct kvm_vcpu *vcpu,
|
||||
struct p9_host_os_sprs *host_os_sprs)
|
||||
{
|
||||
mtspr(SPRN_DSCR, vcpu->arch.dscr);
|
||||
mtspr(SPRN_IAMR, vcpu->arch.iamr);
|
||||
mtspr(SPRN_PSPB, vcpu->arch.pspb);
|
||||
mtspr(SPRN_FSCR, vcpu->arch.fscr);
|
||||
mtspr(SPRN_TAR, vcpu->arch.tar);
|
||||
mtspr(SPRN_EBBHR, vcpu->arch.ebbhr);
|
||||
mtspr(SPRN_EBBRR, vcpu->arch.ebbrr);
|
||||
mtspr(SPRN_BESCR, vcpu->arch.bescr);
|
||||
|
||||
if (cpu_has_feature(CPU_FTR_P9_TIDR))
|
||||
mtspr(SPRN_TIDR, vcpu->arch.tid);
|
||||
mtspr(SPRN_AMR, vcpu->arch.amr);
|
||||
mtspr(SPRN_UAMOR, vcpu->arch.uamor);
|
||||
if (host_os_sprs->iamr != vcpu->arch.iamr)
|
||||
mtspr(SPRN_IAMR, vcpu->arch.iamr);
|
||||
if (host_os_sprs->amr != vcpu->arch.amr)
|
||||
mtspr(SPRN_AMR, vcpu->arch.amr);
|
||||
if (vcpu->arch.uamor != 0)
|
||||
mtspr(SPRN_UAMOR, vcpu->arch.uamor);
|
||||
if (host_os_sprs->fscr != vcpu->arch.fscr)
|
||||
mtspr(SPRN_FSCR, vcpu->arch.fscr);
|
||||
if (host_os_sprs->dscr != vcpu->arch.dscr)
|
||||
mtspr(SPRN_DSCR, vcpu->arch.dscr);
|
||||
if (vcpu->arch.pspb != 0)
|
||||
mtspr(SPRN_PSPB, vcpu->arch.pspb);
|
||||
|
||||
/*
|
||||
* DAR, DSISR, and for nested HV, SPRGs must be set with MSR[RI]
|
||||
@ -4083,20 +4091,21 @@ static void load_spr_state(struct kvm_vcpu *vcpu)
|
||||
|
||||
static void store_spr_state(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
vcpu->arch.ctrl = mfspr(SPRN_CTRLF);
|
||||
|
||||
vcpu->arch.iamr = mfspr(SPRN_IAMR);
|
||||
vcpu->arch.pspb = mfspr(SPRN_PSPB);
|
||||
vcpu->arch.fscr = mfspr(SPRN_FSCR);
|
||||
vcpu->arch.tar = mfspr(SPRN_TAR);
|
||||
vcpu->arch.ebbhr = mfspr(SPRN_EBBHR);
|
||||
vcpu->arch.ebbrr = mfspr(SPRN_EBBRR);
|
||||
vcpu->arch.bescr = mfspr(SPRN_BESCR);
|
||||
|
||||
if (cpu_has_feature(CPU_FTR_P9_TIDR))
|
||||
vcpu->arch.tid = mfspr(SPRN_TIDR);
|
||||
vcpu->arch.iamr = mfspr(SPRN_IAMR);
|
||||
vcpu->arch.amr = mfspr(SPRN_AMR);
|
||||
vcpu->arch.uamor = mfspr(SPRN_UAMOR);
|
||||
vcpu->arch.fscr = mfspr(SPRN_FSCR);
|
||||
vcpu->arch.dscr = mfspr(SPRN_DSCR);
|
||||
vcpu->arch.pspb = mfspr(SPRN_PSPB);
|
||||
|
||||
vcpu->arch.ctrl = mfspr(SPRN_CTRLF);
|
||||
}
|
||||
|
||||
static void save_p9_host_os_sprs(struct p9_host_os_sprs *host_os_sprs)
|
||||
@ -4107,6 +4116,7 @@ static void save_p9_host_os_sprs(struct p9_host_os_sprs *host_os_sprs)
|
||||
host_os_sprs->iamr = mfspr(SPRN_IAMR);
|
||||
host_os_sprs->amr = mfspr(SPRN_AMR);
|
||||
host_os_sprs->fscr = mfspr(SPRN_FSCR);
|
||||
host_os_sprs->dscr = mfspr(SPRN_DSCR);
|
||||
}
|
||||
|
||||
/* vcpu guest regs must already be saved */
|
||||
@ -4115,19 +4125,20 @@ static void restore_p9_host_os_sprs(struct kvm_vcpu *vcpu,
|
||||
{
|
||||
mtspr(SPRN_SPRG_VDSO_WRITE, local_paca->sprg_vdso);
|
||||
|
||||
mtspr(SPRN_PSPB, 0);
|
||||
mtspr(SPRN_UAMOR, 0);
|
||||
|
||||
mtspr(SPRN_DSCR, host_os_sprs->dscr);
|
||||
if (cpu_has_feature(CPU_FTR_P9_TIDR))
|
||||
mtspr(SPRN_TIDR, host_os_sprs->tidr);
|
||||
mtspr(SPRN_IAMR, host_os_sprs->iamr);
|
||||
|
||||
if (host_os_sprs->iamr != vcpu->arch.iamr)
|
||||
mtspr(SPRN_IAMR, host_os_sprs->iamr);
|
||||
if (vcpu->arch.uamor != 0)
|
||||
mtspr(SPRN_UAMOR, 0);
|
||||
if (host_os_sprs->amr != vcpu->arch.amr)
|
||||
mtspr(SPRN_AMR, host_os_sprs->amr);
|
||||
|
||||
if (host_os_sprs->fscr != vcpu->arch.fscr)
|
||||
mtspr(SPRN_FSCR, host_os_sprs->fscr);
|
||||
if (host_os_sprs->dscr != vcpu->arch.dscr)
|
||||
mtspr(SPRN_DSCR, host_os_sprs->dscr);
|
||||
if (vcpu->arch.pspb != 0)
|
||||
mtspr(SPRN_PSPB, 0);
|
||||
|
||||
/* Save guest CTRL register, set runlatch to 1 */
|
||||
if (!(vcpu->arch.ctrl & 1))
|
||||
@ -4219,7 +4230,7 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,
|
||||
#endif
|
||||
mtspr(SPRN_VRSAVE, vcpu->arch.vrsave);
|
||||
|
||||
load_spr_state(vcpu);
|
||||
load_spr_state(vcpu, &host_os_sprs);
|
||||
|
||||
if (kvmhv_on_pseries()) {
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user