All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mingwei Zhang <mizhang@google.com>
To: "Chang S. Bae" <chang.seok.bae@intel.com>
Cc: Aaron Lewis <aaronlewis@google.com>, "Christopherson,,
	Sean" <seanjc@google.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"jmattson@google.com" <jmattson@google.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Neel Natu <neelnatu@google.com>, Borislav Petkov <bp@alien8.de>,
	Venkatesh Srinivas <venkateshs@google.com>
Subject: Re: [PATCH v2 1/6] KVM: x86: Clear all supported MPX xfeatures if they are not all set
Date: Tue, 17 Jan 2023 14:39:47 -0800	[thread overview]
Message-ID: <CAL715WLd2PJC71ObgZPcxSKdS+0H-o8Cscsfejw0cq5BGgOx-w@mail.gmail.com> (raw)
In-Reply-To: <c3be155d-5cff-60ee-fb84-5bda693ea954@intel.com>

On Tue, Jan 17, 2023 at 12:34 PM Chang S. Bae <chang.seok.bae@intel.com> wrote:
>
> On 1/13/2023 6:43 AM, Aaron Lewis wrote:
> >
> > I'd still like to clean up CPUID.(EAX=0DH,ECX=0):EAX.XTILECFG[17] by
> > keeping it consistent with CPUID.(EAX=0DH,ECX=0):EAX.XTILEDATA[18] in
> > the guest, but it's not clear to me what the best way to do that is.
> > The crux of the issue is that xstate_get_guest_group_perm() returns
> > partial support for AMX when userspace doesn't call
> > prctl(ARCH_REQ_XCOMP_GUEST_PERM), I.e. the guest CPUID will report
> > XTILECFG=1 and XTILEDATA=0 in that case.  In that situation, XTILECFG
> > should be cleared for it to be consistent.  I can see two ways of
> > potentially doing that:
> >
> > 1. We can ensure that perm->__state_perm never stores partial support.
> >
> > 2. We can sanitize the bits in xstate_get_guest_group_perm() before
> > they are returned, to ensure KVM never sees partial support.
> >
> > I like the idea of #1, but if that has negative effects on the host or
> > XFD I'm open to #2.  Though, XFD has its own field, so I thought that
> > wouldn't be an issue.  Would it work to set __state_perm and/or
> > default_features (what originally sets __state_perm) to a consistent
> > view, so partial support is never returned from
> > xstate_get_guest_group_perm()?
>
> FWIW, I was trying to clarify that ARCH_GET_XCOMP_GUEST_PERM is a
> variant of ARCH_GET_XCOMP_PERM in the documentation [1]. So, I guess #1
> will have some side-effect (at least confusion) for this semantics.

Right, before talking in this thread, I was not aware of the other
arch_prctl(2) for AMX. But when I look into it, it looks reasonable to
me from an engineering point of view since it seems reusing almost all
of the code in the host.

ARCH_GET_XCOMP_GUEST_PERM is to ask for "guest permission", but it is
not just about the "permission" (the fp_state size increase for AMX).
It is also about the CPUID feature bits exposure. So for the host side
of AMX usage, this is fine, since there is no partial CPUID exposure
problem. But the guest side does have it.

So, can we just grant two bits instead of 1 bit? For that, I find 1)
seems more reasonable than 2). Of course, if there are many side
effects, option #2 could be considered as well. But before that, it
will be good to understand where the side effects are.

>
> There may be some ways to transform the permission bits to the
> XCR0-capable bits. For instance, when considering this permission
> support in host, the highest feature number was considered to denote the
> rest feature bits [2].

Hmm, this is out of my concern since it is about the host-level
enabling. I have no problem with the existing host side permission
control for AMX.

However, for me, [2] does not seem a little hacky but I get the point.
The concern is that how do we know in the future, the highest bit
always indicates lower bits? Will Intel CPU features always follow
this style?  Even so, there is no such guidance/guarantee that other
CPU vendors (e.g., AMD) will do the same. Also what if there are more
than 1 dynamic features for a feature? Please kindly correct me.

Thanks.
-Mingwei


>
> Thanks,
> Chang
>
> [1]
> https://lore.kernel.org/lkml/20220922195810.23248-5-chang.seok.bae@intel.com/
> [2] https://lore.kernel.org/lkml/878rz7fyhe.ffs@tglx/

  reply	other threads:[~2023-01-17 23:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-30 16:24 [PATCH v2 0/6] Clean up the supported xfeatures Aaron Lewis
2022-12-30 16:24 ` [PATCH v2 1/6] KVM: x86: Clear all supported MPX xfeatures if they are not all set Aaron Lewis
2023-01-02 15:03   ` Xiaoyao Li
2023-01-03 18:47     ` Sean Christopherson
2023-01-03 18:46   ` Sean Christopherson
2023-01-10 14:49     ` Aaron Lewis
2023-01-10 18:32       ` Chang S. Bae
2023-01-12 18:21         ` Mingwei Zhang
2023-01-12 18:44           ` Chang S. Bae
2023-01-12 19:17             ` Mingwei Zhang
2023-01-12 20:31               ` Chang S. Bae
2023-01-12 21:21                 ` Mingwei Zhang
2023-01-12 21:33                   ` Chang S. Bae
2023-01-13  0:25                     ` Mingwei Zhang
2023-01-13 14:43                       ` Aaron Lewis
2023-01-17 20:32                         ` Chang S. Bae
2023-01-17 22:39                           ` Mingwei Zhang [this message]
2023-01-18  0:34                             ` Chang S. Bae
2022-12-30 16:24 ` [PATCH v2 2/6] KVM: x86: Clear all supported AVX-512 " Aaron Lewis
2023-01-04 16:33   ` Sean Christopherson
2023-01-04 16:39     ` Sean Christopherson
2022-12-30 16:24 ` [PATCH v2 3/6] KVM: x86: Clear all supported AMX " Aaron Lewis
2022-12-30 16:24 ` [PATCH v2 4/6] KVM: selftests: Hoist XGETBV and XSETBV to make them more accessible Aaron Lewis
2022-12-30 16:24 ` [PATCH v2 5/6] KVM: selftests: Add XFEATURE masks to common code Aaron Lewis
2023-01-04 16:43   ` Sean Christopherson
2022-12-30 16:24 ` [PATCH v2 6/6] KVM: selftests: Add XCR0 Test Aaron Lewis
2023-01-04 17:13   ` Sean Christopherson
2023-01-05 22:46     ` Aaron Lewis
2023-01-05 23:10       ` Sean Christopherson

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=CAL715WLd2PJC71ObgZPcxSKdS+0H-o8Cscsfejw0cq5BGgOx-w@mail.gmail.com \
    --to=mizhang@google.com \
    --cc=aaronlewis@google.com \
    --cc=bp@alien8.de \
    --cc=chang.seok.bae@intel.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=neelnatu@google.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=venkateshs@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.