Re: [PATCH v2 6/8] perf/x86/intel/lbr: guest requesting KVM for lbr stack save/restore

From: Andi Kleen
Date: Fri Sep 07 2018 - 10:10:54 EST


> This could achieve the above #1, but how would it solve #2 above? That is,
> after the guest uses the lbr feature for a while, the lbr stack has been
> passed through, then the guest doesn't use lbr any more, but the vCPU will
> still save/restore on switching?

If nothing accesses the MSR LBRs after a context switch in the guest
nothing gets saved/restored due to:

> > Also when the LBRs haven't been set to direct access the state doesn't
> > need to be saved.


-Andi