From: Paolo Bonzini <pbonzini@redhat.com>
To: peterz@infradead.org
Cc: Like Xu <like.xu@linux.intel.com>, Yao <yao.jin@linux.intel.com>,
Sean Christopherson <sean.j.christopherson@intel.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>
Subject: Re: [PATCH] KVM: x86/pmu: Add '.exclude_hv = 1' for guest perf_event
Date: Wed, 12 Aug 2020 15:51:13 +0200 [thread overview]
Message-ID: <40005c08-27ec-edcd-503e-9d2eaac7d2a4@redhat.com> (raw)
In-Reply-To: <20200812133150.GQ2674@hirez.programming.kicks-ass.net>
On 12/08/20 15:31, peterz@infradead.org wrote:
> This isn't about x86, I want these checks in generic code. We have the
> flag, it needs checking.
>
> unpriv users have no busniess getting anything from a possible hv.
Ah ok if it's generic that sounds good.
>> That would be the case of an unprivileged user that wants to measure
>> performance of its guests.
>
> An unpriv user can run guests?
Sure, on most distros /dev/kvm is either 0666 or 0660, usually with
group kvm if it's 0660. To run a guest you might have to be in group
kvm, but it does not require either root or CAP_SOMETHING.
>>> Also, exclude_host is really poorly defined:
>>>
>>> https://lkml.kernel.org/r/20200806091827.GY2674@hirez.programming.kicks-ass.net
>>>
>>> "Suppose we have nested virt:
>>>
>>> L0-hv
>>> |
>>> G0/L1-hv
>>> |
>>> G1
>>>
>>> And we're running in G0, then:
>>>
>>> - 'exclude_hv' would exclude L0 events
>>> - 'exclude_host' would ... exclude L1-hv events?
>>> - 'exclude_guest' would ... exclude G1 events?
>>
>> From the point of view of G0, L0 *does not exist at all*. You just
>> cannot see L0 events if you're running in G0.
>
> On x86, probably, in general, I'm not at all sure, we have that
> exclude_hv flag after all.
No, and you can quote me on that: exclude_hv is *not* about excluding
the hypervisor from a guest. It's about excluding the part of _your_
kernel which runs in a "more privileged" level (EL2 on ARM, HV on POWER).
>> exclude_host/exclude_guest are the right definition.
>
> For what?
I meant in the nested virt case you drew above.
> I still think exclude_host is absolute shit. If you set it,
> you'll not get anything even without virt.
If you dislike the name you can change it to only_guest. Anybody who
does not do virt just leaves it zero and is happy. Anybody who does not
do virt and sets it gets what they expect (or deserve). But this
definition is the same as exclude_host, and it's the correct one.
> If, as you seem to imply above, that unpriv users can create guests,
> then maybe so, but if I look at /dev/kvm it seems to have 0660
> permissions and thus really requires privileges.
Since you can be non-root and you don't need any capability either, it
doesn't require what the kernel considers to be privilege.
Paolo
prev parent reply other threads:[~2020-08-12 13:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-12 5:07 [PATCH] KVM: x86/pmu: Add '.exclude_hv = 1' for guest perf_event Like Xu
2020-08-12 10:25 ` Paolo Bonzini
2020-08-12 11:11 ` peterz
2020-08-12 11:32 ` Paolo Bonzini
2020-08-12 12:56 ` Xu, Like
2020-08-12 13:04 ` Paolo Bonzini
2020-08-12 13:14 ` Xu, Like
2020-08-12 13:31 ` peterz
2020-08-12 13:51 ` Paolo Bonzini [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=40005c08-27ec-edcd-503e-9d2eaac7d2a4@redhat.com \
--to=pbonzini@redhat.com \
--cc=acme@kernel.org \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=like.xu@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=peterz@infradead.org \
--cc=sean.j.christopherson@intel.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=yao.jin@linux.intel.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