x86: Grant AMX permission for guest
commit19db68ca68a78fa033a21d419036b6e416554564
authorYang Zhong <yang.zhong@intel.com>
Thu, 17 Feb 2022 06:04:29 +0000 (16 22:04 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 15 Mar 2022 10:50:50 +0000 (15 11:50 +0100)
treed253b2ac5ff2edc70ac2baf80be2a59c320292d8
parent1f16764f7d4515bfd5e4ae0aae814fa280a7d0c8
x86: Grant AMX permission for guest

Kernel allocates 4K xstate buffer by default. For XSAVE features
which require large state component (e.g. AMX), Linux kernel
dynamically expands the xstate buffer only after the process has
acquired the necessary permissions. Those are called dynamically-
enabled XSAVE features (or dynamic xfeatures).

There are separate permissions for native tasks and guests.

Qemu should request the guest permissions for dynamic xfeatures
which will be exposed to the guest. This only needs to be done
once before the first vcpu is created.

KVM implemented one new ARCH_GET_XCOMP_SUPP system attribute API to
get host side supported_xcr0 and Qemu can decide if it can request
dynamically enabled XSAVE features permission.
https://lore.kernel.org/all/20220126152210.3044876-1-pbonzini@redhat.com/

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Yang Zhong <yang.zhong@intel.com>
Signed-off-by: Jing Liu <jing2.liu@intel.com>
Message-Id: <20220217060434.52460-4-yang.zhong@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/cpu.c
target/i386/cpu.h
target/i386/kvm/kvm-cpu.c
target/i386/kvm/kvm.c
target/i386/kvm/kvm_i386.h