Messages in this thread | | | From | Thomas Gleixner <> | Subject | Re: [PATCH 16/19] kvm: x86: Introduce KVM_{G|S}ET_XSAVE2 ioctl | Date | Mon, 13 Dec 2021 11:10:47 +0100 |
| |
On Fri, Dec 10 2021 at 17:30, Paolo Bonzini wrote: > On 12/8/21 01:03, Yang Zhong wrote: >> +static int kvm_vcpu_ioctl_x86_set_xsave2(struct kvm_vcpu *vcpu, u8 *state) >> +{ >> + if (fpstate_is_confidential(&vcpu->arch.guest_fpu)) >> + return 0; >> + >> + return fpu_copy_uabi_to_guest_fpstate(&vcpu->arch.guest_fpu, state, >> + supported_xcr0, &vcpu->arch.pkru); >> +} >> + > > I think fpu_copy_uabi_to_guest_fpstate (and therefore > copy_uabi_from_kernel_to_xstate) needs to check that the size is > compatible with the components in the input.
fpu_copy_uabi_to_guest_fpstate() expects that the input buffer is correctly sized. We surely can add a size check there.
> Also, IIUC the size of the AMX state will vary in different processors. > Is this correct? If so, this should be handled already by > KVM_GET/SET_XSAVE2 and therefore should be part of the > arch/x86/kernel/fpu APIs. In the future we want to support migrating a > "small AMX" host to a "large AMX" host; and also migrating from a "large > AMX" host to a "small AMX" host if the guest CPUID is compatible with > the destination of the migration.
How is that supposed to work? If the AMX state size differs then the hosts are not compatible.
Thanks,
tglx
| |