aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSheng Yang <sheng@linux.intel.com>2009-04-01 03:52:31 -0400
committerAvi Kivity <avi@redhat.com>2009-06-10 04:48:36 -0400
commit045471563df4b8723202a66ae54d58788b0f8e88 (patch)
tree3196c8d50992f1c27689a86fe3fdbd9ff740755e
parent7a6ce84c74a3064f6b6dda9e2d55c509cd4e78e4 (diff)
KVM: VMX: Clean up Flex Priority related
And clean paranthes on returns. Signed-off-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--arch/x86/kvm/vmx.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index aba41ae2c81f..1caa1fc6d5ec 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -216,61 +216,69 @@ static inline int is_external_interrupt(u32 intr_info)
216 216
217static inline int cpu_has_vmx_msr_bitmap(void) 217static inline int cpu_has_vmx_msr_bitmap(void)
218{ 218{
219 return (vmcs_config.cpu_based_exec_ctrl & CPU_BASED_USE_MSR_BITMAPS); 219 return vmcs_config.cpu_based_exec_ctrl & CPU_BASED_USE_MSR_BITMAPS;
220} 220}
221 221
222static inline int cpu_has_vmx_tpr_shadow(void) 222static inline int cpu_has_vmx_tpr_shadow(void)
223{ 223{
224 return (vmcs_config.cpu_based_exec_ctrl & CPU_BASED_TPR_SHADOW); 224 return vmcs_config.cpu_based_exec_ctrl & CPU_BASED_TPR_SHADOW;
225} 225}
226 226
227static inline int vm_need_tpr_shadow(struct kvm *kvm) 227static inline int vm_need_tpr_shadow(struct kvm *kvm)
228{ 228{
229 return ((cpu_has_vmx_tpr_shadow()) && (irqchip_in_kernel(kvm))); 229 return (cpu_has_vmx_tpr_shadow()) && (irqchip_in_kernel(kvm));
230} 230}
231 231
232static inline int cpu_has_secondary_exec_ctrls(void) 232static inline int cpu_has_secondary_exec_ctrls(void)
233{ 233{
234 return (vmcs_config.cpu_based_exec_ctrl & 234 return vmcs_config.cpu_based_exec_ctrl &
235 CPU_BASED_ACTIVATE_SECONDARY_CONTROLS); 235 CPU_BASED_ACTIVATE_SECONDARY_CONTROLS;
236} 236}
237 237
238static inline bool cpu_has_vmx_virtualize_apic_accesses(void) 238static inline bool cpu_has_vmx_virtualize_apic_accesses(void)
239{ 239{
240 return flexpriority_enabled; 240 return vmcs_config.cpu_based_2nd_exec_ctrl &
241 SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES;
242}
243
244static inline bool cpu_has_vmx_flexpriority(void)
245{
246 return cpu_has_vmx_tpr_shadow() &&
247 cpu_has_vmx_virtualize_apic_accesses();
241} 248}
242 249
243static inline int cpu_has_vmx_invept_individual_addr(void) 250static inline int cpu_has_vmx_invept_individual_addr(void)
244{ 251{
245 return (!!(vmx_capability.ept & VMX_EPT_EXTENT_INDIVIDUAL_BIT)); 252 return !!(vmx_capability.ept & VMX_EPT_EXTENT_INDIVIDUAL_BIT);
246} 253}
247 254
248static inline int cpu_has_vmx_invept_context(void) 255static inline int cpu_has_vmx_invept_context(void)
249{ 256{
250 return (!!(vmx_capability.ept & VMX_EPT_EXTENT_CONTEXT_BIT)); 257 return !!(vmx_capability.ept & VMX_EPT_EXTENT_CONTEXT_BIT);
251} 258}
252 259
253static inline int cpu_has_vmx_invept_global(void) 260static inline int cpu_has_vmx_invept_global(void)
254{ 261{
255 return (!!(vmx_capability.ept & VMX_EPT_EXTENT_GLOBAL_BIT)); 262 return !!(vmx_capability.ept & VMX_EPT_EXTENT_GLOBAL_BIT);
256} 263}
257 264
258static inline int cpu_has_vmx_ept(void) 265static inline int cpu_has_vmx_ept(void)
259{ 266{
260 return (vmcs_config.cpu_based_2nd_exec_ctrl & 267 return vmcs_config.cpu_based_2nd_exec_ctrl &
261 SECONDARY_EXEC_ENABLE_EPT); 268 SECONDARY_EXEC_ENABLE_EPT;
262} 269}
263 270
264static inline int vm_need_virtualize_apic_accesses(struct kvm *kvm) 271static inline int vm_need_virtualize_apic_accesses(struct kvm *kvm)
265{ 272{
266 return ((cpu_has_vmx_virtualize_apic_accesses()) && 273 return flexpriority_enabled &&
267 (irqchip_in_kernel(kvm))); 274 (cpu_has_vmx_virtualize_apic_accesses()) &&
275 (irqchip_in_kernel(kvm));
268} 276}
269 277
270static inline int cpu_has_vmx_vpid(void) 278static inline int cpu_has_vmx_vpid(void)
271{ 279{
272 return (vmcs_config.cpu_based_2nd_exec_ctrl & 280 return vmcs_config.cpu_based_2nd_exec_ctrl &
273 SECONDARY_EXEC_ENABLE_VPID); 281 SECONDARY_EXEC_ENABLE_VPID;
274} 282}
275 283
276static inline int cpu_has_virtual_nmis(void) 284static inline int cpu_has_virtual_nmis(void)
@@ -278,6 +286,11 @@ static inline int cpu_has_virtual_nmis(void)
278 return vmcs_config.pin_based_exec_ctrl & PIN_BASED_VIRTUAL_NMIS; 286 return vmcs_config.pin_based_exec_ctrl & PIN_BASED_VIRTUAL_NMIS;
279} 287}
280 288
289static inline bool report_flexpriority(void)
290{
291 return flexpriority_enabled;
292}
293
281static int __find_msr_index(struct vcpu_vmx *vmx, u32 msr) 294static int __find_msr_index(struct vcpu_vmx *vmx, u32 msr)
282{ 295{
283 int i; 296 int i;
@@ -1201,7 +1214,7 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)
1201 if (!cpu_has_vmx_ept()) 1214 if (!cpu_has_vmx_ept())
1202 enable_ept = 0; 1215 enable_ept = 0;
1203 1216
1204 if (!(vmcs_config.cpu_based_2nd_exec_ctrl & SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) 1217 if (!cpu_has_vmx_flexpriority())
1205 flexpriority_enabled = 0; 1218 flexpriority_enabled = 0;
1206 1219
1207 min = 0; 1220 min = 0;
@@ -3655,7 +3668,7 @@ static struct kvm_x86_ops vmx_x86_ops = {
3655 .check_processor_compatibility = vmx_check_processor_compat, 3668 .check_processor_compatibility = vmx_check_processor_compat,
3656 .hardware_enable = hardware_enable, 3669 .hardware_enable = hardware_enable,
3657 .hardware_disable = hardware_disable, 3670 .hardware_disable = hardware_disable,
3658 .cpu_has_accelerated_tpr = cpu_has_vmx_virtualize_apic_accesses, 3671 .cpu_has_accelerated_tpr = report_flexpriority,
3659 3672
3660 .vcpu_create = vmx_create_vcpu, 3673 .vcpu_create = vmx_create_vcpu,
3661 .vcpu_free = vmx_free_vcpu, 3674 .vcpu_free = vmx_free_vcpu,