Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1452764 > unrolled thread
| Started by | Wanpeng Li <kernellwp@gmail.com> |
|---|---|
| First post | 2016-07-31 04:40 +0200 |
| Last post | 2016-08-02 09:00 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [RFC PATCH 4/4] KVM: vmx: add support for emulating UMIP Wanpeng Li <kernellwp@gmail.com> - 2016-07-31 04:40 +0200
Re: [RFC PATCH 4/4] KVM: vmx: add support for emulating UMIP Paolo Bonzini <pbonzini@redhat.com> - 2016-08-01 17:10 +0200
Re: [RFC PATCH 4/4] KVM: vmx: add support for emulating UMIP Wanpeng Li <kernellwp@gmail.com> - 2016-08-02 09:00 +0200
| From | Wanpeng Li <kernellwp@gmail.com> |
|---|---|
| Date | 2016-07-31 04:40 +0200 |
| Subject | Re: [RFC PATCH 4/4] KVM: vmx: add support for emulating UMIP |
| Message-ID | <s0OPv-2vt-5@gated-at.bofh.it> |
2016-07-14 16:09 GMT+08:00 Paolo Bonzini <pbonzini@redhat.com>: [...] > > This is not necessary because this is how KVM computes > CPUID[EAX=7,EBX=0].ECX: > > unsigned f_umip = kvm_x86_ops->umip_emulated() ? F(UMIP) : 0; > ... > const u32 kvm_cpuid_7_0_ecx_x86_features = F(PKU) | F(UMIP); > ... > // Mask userspace-provided value against supported features > entry->ecx &= kvm_cpuid_7_0_ecx_x86_features; > // Mask userspace-provided value against host features > cpuid_mask(&entry->ecx, CPUID_7_ECX); > // Finally add emulated features > entry->ecx |= f_umip; I think you mean: - entry->ecx -> userspace-provided value - kvm_cpuid_7_0_ecx_x86_features -> supported features - CPUID_7_ECX -> host features However, entry->ecx is returned by cpuid instruction (do_cpuid_1_ent()), so why it is a userspace-provided value? Regards, Wanpeng Li
[toc] | [next] | [standalone]
| From | Paolo Bonzini <pbonzini@redhat.com> |
|---|---|
| Date | 2016-08-01 17:10 +0200 |
| Message-ID | <s1n0S-7W5-17@gated-at.bofh.it> |
| In reply to | #1452764 |
On 31/07/2016 04:32, Wanpeng Li wrote:
> 2016-07-14 16:09 GMT+08:00 Paolo Bonzini <pbonzini@redhat.com>:
> [...]
>>
>> This is not necessary because this is how KVM computes
>> CPUID[EAX=7,EBX=0].ECX:
>>
>> unsigned f_umip = kvm_x86_ops->umip_emulated() ? F(UMIP) : 0;
>> ...
>> const u32 kvm_cpuid_7_0_ecx_x86_features = F(PKU) | F(UMIP);
>> ...
>> // Mask userspace-provided value against supported features
>> entry->ecx &= kvm_cpuid_7_0_ecx_x86_features;
>> // Mask userspace-provided value against host features
>> cpuid_mask(&entry->ecx, CPUID_7_ECX);
>> // Finally add emulated features
>> entry->ecx |= f_umip;
>
> I think you mean:
>
> - entry->ecx -> userspace-provided value
> - kvm_cpuid_7_0_ecx_x86_features -> supported features
> - CPUID_7_ECX -> host features
>
> However, entry->ecx is returned by cpuid instruction
> (do_cpuid_1_ent()), so why it is a userspace-provided value?
You're right, it's this:
// Mask host processor value against supported features
entry->ecx &= kvm_cpuid_7_0_ecx_x86_features;
// Mask host processor value further, e.g. to drop
// features that the host kernel has blacklisted.
cpuid_mask(&entry->ecx, CPUID_7_ECX);
// Finally add emulated features
entry->ecx |= f_umip;
The idea is the same. :)
On the other hand, it is true that in many cases of the "switch
(function)" the call to do_cpuid_1_ent is unnecessary, and instead of
cpuid_mask you could just access boot_cpu_data.x86_capability[wordnum].
Paolo
[toc] | [prev] | [next] | [standalone]
| From | Wanpeng Li <kernellwp@gmail.com> |
|---|---|
| Date | 2016-08-02 09:00 +0200 |
| Message-ID | <s1BQe-TD-9@gated-at.bofh.it> |
| In reply to | #1453267 |
2016-08-01 23:01 GMT+08:00 Paolo Bonzini <pbonzini@redhat.com>: > > > On 31/07/2016 04:32, Wanpeng Li wrote: >> 2016-07-14 16:09 GMT+08:00 Paolo Bonzini <pbonzini@redhat.com>: >> [...] >>> >>> This is not necessary because this is how KVM computes >>> CPUID[EAX=7,EBX=0].ECX: >>> >>> unsigned f_umip = kvm_x86_ops->umip_emulated() ? F(UMIP) : 0; >>> ... >>> const u32 kvm_cpuid_7_0_ecx_x86_features = F(PKU) | F(UMIP); >>> ... >>> // Mask userspace-provided value against supported features >>> entry->ecx &= kvm_cpuid_7_0_ecx_x86_features; >>> // Mask userspace-provided value against host features >>> cpuid_mask(&entry->ecx, CPUID_7_ECX); >>> // Finally add emulated features >>> entry->ecx |= f_umip; >> >> I think you mean: >> >> - entry->ecx -> userspace-provided value >> - kvm_cpuid_7_0_ecx_x86_features -> supported features >> - CPUID_7_ECX -> host features >> >> However, entry->ecx is returned by cpuid instruction >> (do_cpuid_1_ent()), so why it is a userspace-provided value? > > You're right, it's this: > > // Mask host processor value against supported features > entry->ecx &= kvm_cpuid_7_0_ecx_x86_features; > // Mask host processor value further, e.g. to drop > // features that the host kernel has blacklisted. > cpuid_mask(&entry->ecx, CPUID_7_ECX); > // Finally add emulated features > entry->ecx |= f_umip; > Cool, more clear this time. :) > The idea is the same. :) > > On the other hand, it is true that in many cases of the "switch > (function)" the call to do_cpuid_1_ent is unnecessary, and instead of > cpuid_mask you could just access boot_cpu_data.x86_capability[wordnum]. Agreed. Regards, Wanpeng Li
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web