From: Jim Mattson <jmattson@google.com>
To: Like Xu <like.xu.linux@gmail.com>
Cc: David Dunn <daviddunn@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Joerg Roedel <joro@8bytes.org>,
Kim Phillips <kim.phillips@amd.com>,
Maxim Levitsky <mlevitsk@redhat.com>,
Sean Christopherson <seanjc@google.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Lotus Fenn <lotusf@google.com>
Subject: Re: [PATCH] KVM: x86/pmu: Fix reserved bits for AMD PerfEvtSeln register
Date: Fri, 25 Feb 2022 14:26:58 -0800 [thread overview]
Message-ID: <CALMp9eSWJevnn3vs5==9ay5vRL_djfq28bawUEP3KzBft3FOrg@mail.gmail.com> (raw)
In-Reply-To: <dc14c98c-e35a-95c0-83dd-13b5f7cffc03@gmail.com>
On Tue, Feb 15, 2022 at 11:47 PM Like Xu <like.xu.linux@gmail.com> wrote:
>
> On 12/2/2022 4:39 pm, Jim Mattson wrote:
> >> - pmu->reserved_bits = 0xffffffff00200000ull;
> >> + pmu->reserved_bits = 0xfffffff000280000ull;
> > Bits 40 and 41 are guest mode and host mode. They cannot be reserved
> > if the guest supports nested SVM.
> >
>
> Indeed, we need (some hands) to do more pmu tests on nested SVM.
Actually, it's not just nested SVM.
When we enable vPMU for an Ubuntu guest that is incapable of nested
SVM, we see errors like the following:
root@Ubuntu1804:~# perf stat -e r26 -a sleep 1
Performance counter stats for 'system wide':
0 r26
1.001070977 seconds time elapsed
Feb 23 03:59:58 Ubuntu1804 kernel: [ 405.379957] unchecked MSR access
error: WRMSR to 0xc0010200 (tried to write 0x0000020000130026) at rIP:
0xffffffff9b276a28 (native_write_msr+0x8/0x30)
Feb 23 03:59:58 Ubuntu1804 kernel: [ 405.379958] Call Trace:
Feb 23 03:59:58 Ubuntu1804 kernel: [ 405.379963]
amd_pmu_disable_event+0x27/0x90
If the standard Linux perf tool sets "exclude_guest" by default, even
when EFER.SVME is clear, then amd_core_hw_config() in the guest kernel
will set bit 41 (again, without checking EFER.SVME). This WRMSR should
not raise #GP.
Current AMD hardware doesn't raise #GP for any value written to a
PerfEvtSeln MSR. I don't think KVM should ever synthesize a #GP
either. Perhaps we should just mask off the bits that you have
indicated as reserved, above.
prev parent reply other threads:[~2022-02-25 22:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-18 13:03 Like Xu
2021-11-18 13:23 ` Paolo Bonzini
2021-11-18 14:43 ` Paolo Bonzini
2022-02-12 8:39 ` Jim Mattson
2022-02-16 7:47 ` Like Xu
2022-02-25 22:26 ` Jim Mattson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALMp9eSWJevnn3vs5==9ay5vRL_djfq28bawUEP3KzBft3FOrg@mail.gmail.com' \
--to=jmattson@google.com \
--cc=daviddunn@google.com \
--cc=joro@8bytes.org \
--cc=kim.phillips@amd.com \
--cc=kvm@vger.kernel.org \
--cc=like.xu.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lotusf@google.com \
--cc=mlevitsk@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®