linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Tian, Kevin" <kevin.tian@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	"Nakajima, Jun" <jun.nakajima@intel.com>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: "Liu, Jing2" <jing2.liu@intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"x86@kernel.org" <x86@kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"Arjan van de Ven" <arjan@linux.intel.com>,
	Jing Liu <jing2.liu@linux.intel.com>,
	"seanjc@google.com" <seanjc@google.com>,
	"Cooper, Andrew" <andrew.cooper3@citrix.com>,
	"Bae, Chang Seok" <chang.seok.bae@intel.com>
Subject: RE: Thoughts of AMX KVM support based on latest kernel
Date: Wed, 17 Nov 2021 10:15:32 +0000	[thread overview]
Message-ID: <BN9PR11MB5433D6A1368904D9B748846B8C9A9@BN9PR11MB5433.namprd11.prod.outlook.com> (raw)
In-Reply-To: <2e2ab02c-b324-e136-924a-0376040163a8@redhat.com>

> From: Paolo Bonzini <pbonzini@redhat.com>
> Sent: Wednesday, November 17, 2021 3:31 PM
> 
> On 11/17/21 05:52, Nakajima, Jun wrote:
> > If a (creative) guest wants to set XFD[AMX] = 1 for fun while keeping
> > AMX state alive without saving the AXM state, it may lose the state
> > after VM exit/entry.
> 
> I think this should not happen, unless you also document that other
> random events (hypothetically, it could be some other core using AMX?)
> can cause the loss of XTILEDATA if XFD[AMX]=1.  Virtualization should
> not be special, I'd prefer that the guest has the same behavior as bare
> metal in this respect.
> 

The state may be lost with the simple version suggested by Thomas,
because with XFD[AMX]=1 the AMX state won't be stored to 
guest_fpstate when the vcpu thread is preempted and then get lost
when restored. To emulate the hardware behavior this will need
additional trick to force XFD[AMX]=0 if XGETBV(1) is true (ignoring 
guest XFD) in fpu_update_guest_xfd_state(void). It also implies 
that the actual guest XFD needs to be saved in a place before forcing 
XFD[AMX] to 0 and recovered (after interrupt is disabled) before 
entering the guest.

We are not sure whether such trick is worthwhile, since a sane
guest shouldn't set XFD[AMX]=1 before storing the AMX state. This
is why we want to seek SDM change to mark out that the software
should not assume XTILEDATA is still valid when XFD[AMX]=1. 

Then KVM can make a simple assumption that once XFD[AMX]=1
it implies the guest doesn't care about the AMX state. Then the
simple version from Thomas can work perfectly.

Thanks
Kevin

  reply	other threads:[~2021-11-17 10:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-10 13:01 Thoughts of AMX KVM support based on latest kernel Liu, Jing2
2021-11-16 12:18 ` Thomas Gleixner
2021-11-16 16:05   ` Sean Christopherson
2021-11-16 18:55     ` Thomas Gleixner
2021-11-16 19:49       ` Paolo Bonzini
2021-11-16 20:14         ` Sean Christopherson
2021-11-16 20:36         ` Thomas Gleixner
2021-11-16 22:11           ` Nakajima, Jun
2021-11-17  7:39           ` Paolo Bonzini
2021-11-16 20:12       ` Sean Christopherson
2021-11-16 23:35         ` Thomas Gleixner
2021-11-16 19:20 ` Thomas Gleixner
2021-11-17  4:52   ` Nakajima, Jun
2021-11-17  7:31     ` Paolo Bonzini
2021-11-17 10:15       ` Tian, Kevin [this message]
2021-11-17 12:24         ` Thomas Gleixner
2021-11-17 12:53         ` Paolo Bonzini
2021-11-18 23:17           ` Nakajima, Jun
2021-11-19 10:13             ` Thomas Gleixner
2021-11-19 15:41               ` Nakajima, Jun
2021-12-08  0:50                 ` Rewording of Setting IA32_XFD[18] (Re: Thoughts of AMX KVM support based on latest kernel) Nakajima, Jun
2021-12-08 13:57                   ` Paolo Bonzini
2021-12-10 21:53                   ` Thomas Gleixner

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=BN9PR11MB5433D6A1368904D9B748846B8C9A9@BN9PR11MB5433.namprd11.prod.outlook.com \
    --to=kevin.tian@intel.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=arjan@linux.intel.com \
    --cc=chang.seok.bae@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=jing2.liu@intel.com \
    --cc=jing2.liu@linux.intel.com \
    --cc=jun.nakajima@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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).