linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <graf@amazon.com>
To: Jim Mattson <jmattson@google.com>
Cc: Aaron Lewis <aaronlewis@google.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Sean Christopherson <sean.j.christopherson@intel.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Joerg Roedel <joro@8bytes.org>, kvm list <kvm@vger.kernel.org>,
	<linux-doc@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] KVM: x86: Deflect unknown MSR accesses to user space
Date: Wed, 29 Jul 2020 22:28:59 +0200	[thread overview]
Message-ID: <69d8c4cd-0d36-0135-d1fc-0af7d81ce062@amazon.com> (raw)
In-Reply-To: <CALMp9eSxWDPcu2=K4NHbx_ZcYjA_jmnoD7gXbUp=cnEbiU0jLA@mail.gmail.com>



On 29.07.20 20:27, Jim Mattson wrote:
> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
> 
> 
> 
> On Wed, Jul 29, 2020 at 2:06 AM Alexander Graf <graf@amazon.com> wrote:
>>
>>
>>
>> On 28.07.20 19:13, Jim Mattson wrote:
> 
>>> This sounds similar to Peter Hornyack's RFC from 5 years ago:
>>> https://www.mail-archive.com/kvm@vger.kernel.org/msg124448.html.
>>
>> Yeah, looks very similar. Do you know the history why it never got
>> merged? I couldn't spot a non-RFC version of this on the ML.
> 
> I believe Peter got frustrated with all of the pushback he was
> getting, and he moved on to other things. While Google still uses that
> code, Aaron's new approach should give us equivalent functionality
> without having to comment out the MSRs that kvm previously didn't know
> about, and which we still want redirected to userspace.
> 
>>> It seems unlikely that userspace is going to know what to do with a
>>> large number of MSRs. I suspect that a small enumerated list will
>>> suffice. In fact, +Aaron Lewis is working on upstreaming a local
>>> Google patch set that does just that.
>>
>> I tend to disagree on that sentiment. One of the motivations behind this
>> patch is to populate invalid MSR accesses into user space, to move logic
>> like "ignore_msrs"[1] into user space. This is not very useful for the
>> cloud use case, but it does come in handy when you want to have VMs that
>> can handle unimplemented MSRs in parallel to ones that do not.
>>
>> So whatever we implement, I would ideally want a mechanism at the end of
>> the day that allows me to "trap the rest" into user space.
> 
> I do think "the rest" should be explicitly specified, so that
> userspace doesn't get surprises when kvm evolves. Maybe this can be
> done using the allow-list you refer to later, along with a specified
> action for disallowed MSRs: (1) raise #GP, (2) ignore, or (3) exit to
> userspace. This actually seems orthogonal to what Aaron is working on,
> which is to request that specific MSR accesses exit to userspace. But,
> at least the plumbing for {RD,WR}MSR completion when coming back from
> userspace can be leveraged by both.


Thinking about this for a while, I am quite confident that we don't need 
to complexify this all that much. The #GP path is never performance 
critical and thus can easily be handled in user space. There are a few 
niche cases where exiting to user space is "too complicated" (think nVMX 
MSR restore path). But they are niche and just bailing out for the user 
space exit path on them is fine.

So I think a patch that allows us to allow list MSRs that should be 
handled in KVM and another patch that allows us to deflect any MSR 
inflicted #GPs into user space is all it takes to make this a flexible 
and stable ABI.

The great thing is that by untangling the two bits, we can also support 
the "user space wants to leave it all to KVM, but be able to implement 
ignore_msrs itself" use case easily. User space would just not set an 
allow list.

Meanwhile, I have cleaned up Karim's old patch to add allow listing to 
KVM and would post it if Aaron doesn't beat me to it :).


Alex



Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879



  reply	other threads:[~2020-07-29 20:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-28  0:44 [PATCH] KVM: x86: Deflect unknown MSR accesses to user space Alexander Graf
2020-07-28  8:15 ` Vitaly Kuznetsov
2020-07-28 12:41   ` Alexander Graf
2020-07-28 17:13     ` Jim Mattson
2020-07-29  8:23       ` Vitaly Kuznetsov
2020-07-29  9:09         ` Alexander Graf
2020-07-29  9:22           ` Vitaly Kuznetsov
2020-07-29  9:34             ` Alexander Graf
2020-07-29  9:06       ` Alexander Graf
2020-07-29 18:27         ` Jim Mattson
2020-07-29 20:28           ` Alexander Graf [this message]
2020-07-29 20:37             ` Jim Mattson
2020-07-29 20:45               ` Alexander Graf
2020-07-29 20:49                 ` Jim Mattson

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=69d8c4cd-0d36-0135-d1fc-0af7d81ce062@amazon.com \
    --to=graf@amazon.com \
    --cc=aaronlewis@google.com \
    --cc=corbet@lwn.net \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=sean.j.christopherson@intel.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;
as well as URLs for NNTP newsgroup(s).