Re: [RFC PATCH v2 1/1] KVM, pkeys: fix guest pkru save wrong on migration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 13/07/2017 09:37, Junkang Fu wrote:
> Pkeys self-tests (commit 5f23f6d082a9) may reports "_rdpkru: Assertion
> `pkru == shadow_pkru'  failed" on migration. The problem is that host
> pkru is restored right after
> vcpu exit (commit 1be0e61) so host pkru will be saved on migration, fix
> this by using guest_pkru explicitly in fill_save.
> 
> Reviewed-by: Yang Zhang <zy107165@xxxxxxxxxxxxxxx
> <mailto:zy107165@xxxxxxxxxxxxxxx>>
> Signed-off-by: Tianyi <junkang.fjk@xxxxxxxxxxxxxxx
> <mailto:junkang.fjk@xxxxxxxxxxxxxxx>>
> Signed-off-by: Quan Xu <wutu.xq@xxxxxxxxxxxxxxx
> <mailto:wutu.xq@xxxxxxxxxxxxxxx>>
> ---
> v2:
> - replace Yoda conditions
> 
>  arch/x86/kvm/x86.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 02363e3..c68055e 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3211,6 +3211,7 @@ static void fill_xsave(u8 *dest, struct kvm_vcpu
> *vcpu)
>         struct xregs_state *xsave = &vcpu->arch.guest_fpu.state.xsave;
>         u64 xstate_bv = xsave->header.xfeatures;
>         u64 valid;
> +       u32 guest_pkru;
> 
>         /*
>          * Copy legacy XSAVE area, to avoid complications with CPUID
> @@ -3236,7 +3237,11 @@ static void fill_xsave(u8 *dest, struct kvm_vcpu
> *vcpu)
>                         u32 size, offset, ecx, edx;
>                         cpuid_count(XSTATE_CPUID, index,
>                                     &size, &offset, &ecx, &edx);
> -                       memcpy(dest + offset, src, size);
> +                       if (feature == XFEATURE_MASK_PKRU) {
> +                               guest_pkru = kvm_x86_ops->get_pkru(vcpu);
> +                               memcpy(dest + offset, &guest_pkru, 4);
> +                       } else
> +                               memcpy(dest + offset, src, size);
>                 }
> 
>                 valid -= feature;
> --
> 1.8.3.1


You still aren't doing the same change in load_xsave.

Paolo



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux