[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <16BF8BE6-B7B1-4F3E-B972-9D82CD2F23C8@intel.com>
Date: Wed, 17 Nov 2021 04:52:35 +0000
From: "Nakajima, Jun" <jun.nakajima@...el.com>
To: Thomas Gleixner <tglx@...utronix.de>
CC: "Liu, Jing2" <jing2.liu@...el.com>,
Paolo Bonzini <pbonzini@...hat.com>,
LKML <linux-kernel@...r.kernel.org>,
"x86@...nel.org" <x86@...nel.org>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Arjan van de Ven <arjan@...ux.intel.com>,
Jing Liu <jing2.liu@...ux.intel.com>,
"seanjc@...gle.com" <seanjc@...gle.com>,
"Cooper, Andrew" <andrew.cooper3@...rix.com>,
"Bae, Chang Seok" <chang.seok.bae@...el.com>
Subject: Re: Thoughts of AMX KVM support based on latest kernel
>
> On Nov 16, 2021, at 11:20 AM, Thomas Gleixner <tglx@...utronix.de> wrote:
>
> Jing,
>
> On Wed, Nov 10 2021 at 13:01, Liu, Jing2 wrote:
>
> more thoughts.
>
>> Once we start passthrough the XFD MSR, we need to save/restore
>> them at VM exit/entry time. If we immediately resume the guest
>> without enabling interrupts/preemptions (exit fast-path), we have no
>> issues. We don't need to save the MSR.
>
> Correct.
>
>> The question is how the host XFD MSR is restored while control is in
>> KVM.
>>
>> The XSAVE(S) instruction saves the (guest) state component[x] as 0 or
>> doesn't save when XFD[x] != 0. Accordingly, XRSTOR(S) cannot restore
>> that (guest state). And it is possible that XFD != 0 and the guest is using
>> extended feature at VM exit;
>
> You mean on creative guests which just keep AMX state alive and set
> XFD[AMX] = 1 to later restore it to XFD[AMX] = 0?
Typically a (usual) guest saves the AMX state for the previous process and sets XFD[AMX] = 1 for the next at context switch time, and a VM exit can happen anytime, e.g. right after XFD[AMX] = 1.
But this case is okay because the state is already saved by the guest.
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 the right thing to do is to avoid such programming in the first place. Let me find out if we can add such notes in the programming references.
---
Jun
Powered by blists - more mailing lists