lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CALMp9eQck0dPHU9qyY-kDE+mQWK4PUuhpkEFW7PH5BbCaptJ+g@mail.gmail.com>
Date:   Thu, 6 Jan 2022 10:01:07 -0800
From:   Jim Mattson <jmattson@...gle.com>
To:     Like Xu <like.xu.linux@...il.com>
Cc:     Paolo Bonzini <pbonzini@...hat.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Joerg Roedel <joro@...tes.org>, x86@...nel.org,
        kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
        Like Xu <likexu@...cent.com>,
        Dongli Cao <caodongli@...gsoft.com>,
        Li RongQing <lirongqing@...du.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        "Thomas Gleixner (kernel-recipes.org)" <tglx@...utronix.de>,
        "Borislav Petkov (kernel-recipes.org)" <bp@...en8.de>,
        Sean Christopherson <seanjc@...gle.com>
Subject: Re: [PATCH v2] KVM: X86: Emulate APERF/MPERF to report actual vCPU frequency

On Wed, Jan 5, 2022 at 7:29 PM Like Xu <like.xu.linux@...il.com> wrote:
>
> On 6/1/2022 6:51 am, Jim Mattson wrote:
> > On Thu, Dec 30, 2021 at 11:48 PM Like Xu <like.xu.linux@...il.com> wrote:
> >>
> >> On 31/12/2021 9:29 am, Jim Mattson wrote:
> >
> >>> At sched-in:
> >>> 1. Save host APERF/MPERF values from the MSRs.
> >>> 2. Load the "current" guest APERF/MPERF values into the MSRs (if the
> >>> vCPU configuration allows for unintercepted reads).
> >>>
> >>> At sched-out:
> >>> 1. Calculate the guest APERF/MPERF deltas for use in step 3.
> >>> 2. Save the "current" guest APERF/MPERF values.
> >>> 3. "Restore" the host APERF/MPERF values, but add in the deltas from step 1.
> >>>
> >>> Without any writes to IA32_MPERF, I would expect these MSRs to be
> >>> synchronized across all logical processors, and the proposal above
> >>> would break that synchronization.
> >
> > I am learning more about IA32_APERF and IA32_MPERF this year. :-)
>
> Uh, thanks for your attention.
>
> >
> > My worry above is unfounded. These MSRs only increment in C0, so they
> > are not likely to be synchronized.
> >
> > This also raises another issue with your original fast-path
> > implementation: the host MSRs will continue to count while the guest
> > is halted. However, the guest MSRs should not count while the guest is
> > halted.
> >
>
> The emulation based on guest TSC semantics w/ low precision may work it out.
> TBH, I still haven't given up on the idea of a pass-through approach.

I believe that pass-through can work for IA32_APERF. It can also work
for IA32_MPERF on AMD hosts or when the TSC multiplier is 1 on Intel
hosts. However, I also believe that it requires KVM to load the
hardware MSRs with the guest's values prior to VM-entry, and to update
the hardware MSRs with newly calculated host values before any other
consumers on the host may read them.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ