Re: [patch V2 19/52] x86/kvm: Avoid looking up PKRU in XSAVE buffer

Borislav Petkov
2021-06-17T12:09:40Z

On Mon, Jun 14, 2021 at 05:44:27PM +0200, Thomas Gleixner wrote:
> @@ -4632,18 +4633,20 @@ static void load_xsave(struct kvm_vcpu *
> */
> valid = xstate_bv & ~XFEATURE_MASK_FPSSE;
> while (valid) {
> + u32 size, offset, ecx, edx;
> u64 xfeature_mask = valid & -valid;
> int xfeature_nr = fls64(xfeature_mask) - 1;
> - void *dest = get_xsave_addr(xsave, xfeature_nr);
>
> - if (dest) {
> - u32 size, offset, ecx, edx;
> - cpuid_count(XSTATE_CPUID, xfeature_nr,
> - &size, &offset, &ecx, &edx);
> - if (xfeature_nr == XFEATURE_PKRU)
> - memcpy(&vcpu->arch.pkru, src + offset,
> - sizeof(vcpu->arch.pkru));
> - else
> + cpuid_count(XSTATE_CPUID, xfeature_nr,
> + &size, &offset, &ecx, &edx);
> +
> + if (xfeature_nr == XFEATURE_PKRU) {
> + memcpy(&vcpu->arch.pkru, src + offset,
> + sizeof(vcpu->arch.pkru));
> + } else {
> + void *dest = get_xsave_addr(xsave, xfeature_nr);
> +

With that superfluous newline removed:

Reviewed-by: Borislav Petkov <bp@suse.de>

> + if (dest)
> memcpy(dest, src + offset, size);
> }

--
Regards/Gruss,
Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg