Messages in this thread | | | Date | Mon, 23 Sep 2013 17:24:20 +0200 | From | Paolo Bonzini <> | Subject | Re: [PATCH v2 2/3] KVM: x86: prevent setting unsupported XSAVE states |
| |
Il 23/09/2013 17:09, Gleb Natapov ha scritto: > On Mon, Sep 23, 2013 at 12:22:37PM +0200, Paolo Bonzini wrote: >>>> @@ -6940,6 +6948,9 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) >>>> >>>> vcpu->arch.ia32_tsc_adjust_msr = 0x0; >>>> vcpu->arch.pv_time_enabled = false; >>>> + >>>> + vcpu->arch.supported_xcr0 = XSTATE_FPSSE; >>>> + >>> Why is this needed? It will make make __kvm_set_xcr() succeed if attempt >>> is made to set SSE bit when it is not supported in cpuid. This may not >>> be an issue in practice, but for clarity it is better for supported_xcr0 >>> to contain only what is supported in guest's cpuid bits and handle the >>> fact that FP/SSE state should always be copied to/from userspace in >>> kvm_vcpu_ioctl_x86_(set|get)_xsave functions. >> >> I don't think it makes sense to disable SSE but not XSAVE. Linux even >> has this: >> >> if ((pcntxt_mask & XSTATE_FPSSE) != XSTATE_FPSSE) { >> pr_err("FP/SSE not shown under xsave features 0x%llx\n", >> pcntxt_mask); >> BUG(); >> } >> > That's why I said it may not be an issue in practice. What makes the > code confusing to me is that it is not clear what .supported_xcr0 > contains. Why not make it contain only guest cpuid bits and use > XSTATE_FPSSE explicitly in get_xsave. I mean drop this from next patch: > > vcpu->arch.supported_xcr0 = > - (best->eax | ((u64)best->edx << 32)) & > + (best->eax | ((u64)best->edx << 32) | XSTATE_FPSSE) & > host_xcr0 & KVM_SUPPORTED_XCR0; > > And change > *(u64 *)&guest_xsave->region[XSAVE_HDR_OFFSET / sizeof(u32)] != vcpu->arch.supported_xcr0; > to > *(u64 *)&guest_xsave->region[XSAVE_HDR_OFFSET / sizeof(u32)] != (vcpu->arch.supported_xcr0 | XSTATE_FPSSE);
Ok.
> >> I preferred this to adding dubiously-testable code that probed CPUID for >> SSE support (or should I check FXSR instead?)
I didn't understand you wanted the "| XSTATE_FPSSE" moved, I thought you wanted to check for SSE bits in userspace (similar to AVX). I wasn't sure whether to tie this to the SSE bit, or to FXSR. But what you propose makes sense, I'll test it.
Paolo
| |