aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/vmx.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2015-03-30 19:46:09 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2015-03-31 12:05:09 -0400
commit1d804d079a92138d011900785193b6b00b44bc00 (patch)
tree4d683e8d6a9aacfad4e8b2e17c0f7aedc7837c18 /arch/x86/kvm/vmx.c
parent2f729b10bb74f97797beb310113f6182f262d36a (diff)
x86: Use bool function return values of true/false not 1/0
Use the normal return values for bool functions Signed-off-by: Joe Perches <joe@perches.com> Message-Id: <9f593eb2f43b456851cd73f7ed09654ca58fb570.1427759009.git.joe@perches.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/vmx.c')
-rw-r--r--arch/x86/kvm/vmx.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 63ca692fa673..0caaf56eb459 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -7314,21 +7314,21 @@ static bool nested_vmx_exit_handled_io(struct kvm_vcpu *vcpu,
7314 else if (port < 0x10000) 7314 else if (port < 0x10000)
7315 bitmap = vmcs12->io_bitmap_b; 7315 bitmap = vmcs12->io_bitmap_b;
7316 else 7316 else
7317 return 1; 7317 return true;
7318 bitmap += (port & 0x7fff) / 8; 7318 bitmap += (port & 0x7fff) / 8;
7319 7319
7320 if (last_bitmap != bitmap) 7320 if (last_bitmap != bitmap)
7321 if (kvm_read_guest(vcpu->kvm, bitmap, &b, 1)) 7321 if (kvm_read_guest(vcpu->kvm, bitmap, &b, 1))
7322 return 1; 7322 return true;
7323 if (b & (1 << (port & 7))) 7323 if (b & (1 << (port & 7)))
7324 return 1; 7324 return true;
7325 7325
7326 port++; 7326 port++;
7327 size--; 7327 size--;
7328 last_bitmap = bitmap; 7328 last_bitmap = bitmap;
7329 } 7329 }
7330 7330
7331 return 0; 7331 return false;
7332} 7332}
7333 7333
7334/* 7334/*
@@ -7344,7 +7344,7 @@ static bool nested_vmx_exit_handled_msr(struct kvm_vcpu *vcpu,
7344 gpa_t bitmap; 7344 gpa_t bitmap;
7345 7345
7346 if (!nested_cpu_has(vmcs12, CPU_BASED_USE_MSR_BITMAPS)) 7346 if (!nested_cpu_has(vmcs12, CPU_BASED_USE_MSR_BITMAPS))
7347 return 1; 7347 return true;
7348 7348
7349 /* 7349 /*
7350 * The MSR_BITMAP page is divided into four 1024-byte bitmaps, 7350 * The MSR_BITMAP page is divided into four 1024-byte bitmaps,
@@ -7363,10 +7363,10 @@ static bool nested_vmx_exit_handled_msr(struct kvm_vcpu *vcpu,
7363 if (msr_index < 1024*8) { 7363 if (msr_index < 1024*8) {
7364 unsigned char b; 7364 unsigned char b;
7365 if (kvm_read_guest(vcpu->kvm, bitmap + msr_index/8, &b, 1)) 7365 if (kvm_read_guest(vcpu->kvm, bitmap + msr_index/8, &b, 1))
7366 return 1; 7366 return true;
7367 return 1 & (b >> (msr_index & 7)); 7367 return 1 & (b >> (msr_index & 7));
7368 } else 7368 } else
7369 return 1; /* let L1 handle the wrong parameter */ 7369 return true; /* let L1 handle the wrong parameter */
7370} 7370}
7371 7371
7372/* 7372/*
@@ -7388,7 +7388,7 @@ static bool nested_vmx_exit_handled_cr(struct kvm_vcpu *vcpu,
7388 case 0: 7388 case 0:
7389 if (vmcs12->cr0_guest_host_mask & 7389 if (vmcs12->cr0_guest_host_mask &
7390 (val ^ vmcs12->cr0_read_shadow)) 7390 (val ^ vmcs12->cr0_read_shadow))
7391 return 1; 7391 return true;
7392 break; 7392 break;
7393 case 3: 7393 case 3:
7394 if ((vmcs12->cr3_target_count >= 1 && 7394 if ((vmcs12->cr3_target_count >= 1 &&
@@ -7399,37 +7399,37 @@ static bool nested_vmx_exit_handled_cr(struct kvm_vcpu *vcpu,
7399 vmcs12->cr3_target_value2 == val) || 7399 vmcs12->cr3_target_value2 == val) ||
7400 (vmcs12->cr3_target_count >= 4 && 7400 (vmcs12->cr3_target_count >= 4 &&
7401 vmcs12->cr3_target_value3 == val)) 7401 vmcs12->cr3_target_value3 == val))
7402 return 0; 7402 return false;
7403 if (nested_cpu_has(vmcs12, CPU_BASED_CR3_LOAD_EXITING)) 7403 if (nested_cpu_has(vmcs12, CPU_BASED_CR3_LOAD_EXITING))
7404 return 1; 7404 return true;
7405 break; 7405 break;
7406 case 4: 7406 case 4:
7407 if (vmcs12->cr4_guest_host_mask & 7407 if (vmcs12->cr4_guest_host_mask &
7408 (vmcs12->cr4_read_shadow ^ val)) 7408 (vmcs12->cr4_read_shadow ^ val))
7409 return 1; 7409 return true;
7410 break; 7410 break;
7411 case 8: 7411 case 8:
7412 if (nested_cpu_has(vmcs12, CPU_BASED_CR8_LOAD_EXITING)) 7412 if (nested_cpu_has(vmcs12, CPU_BASED_CR8_LOAD_EXITING))
7413 return 1; 7413 return true;
7414 break; 7414 break;
7415 } 7415 }
7416 break; 7416 break;
7417 case 2: /* clts */ 7417 case 2: /* clts */
7418 if ((vmcs12->cr0_guest_host_mask & X86_CR0_TS) && 7418 if ((vmcs12->cr0_guest_host_mask & X86_CR0_TS) &&
7419 (vmcs12->cr0_read_shadow & X86_CR0_TS)) 7419 (vmcs12->cr0_read_shadow & X86_CR0_TS))
7420 return 1; 7420 return true;
7421 break; 7421 break;
7422 case 1: /* mov from cr */ 7422 case 1: /* mov from cr */
7423 switch (cr) { 7423 switch (cr) {
7424 case 3: 7424 case 3:
7425 if (vmcs12->cpu_based_vm_exec_control & 7425 if (vmcs12->cpu_based_vm_exec_control &
7426 CPU_BASED_CR3_STORE_EXITING) 7426 CPU_BASED_CR3_STORE_EXITING)
7427 return 1; 7427 return true;
7428 break; 7428 break;
7429 case 8: 7429 case 8:
7430 if (vmcs12->cpu_based_vm_exec_control & 7430 if (vmcs12->cpu_based_vm_exec_control &
7431 CPU_BASED_CR8_STORE_EXITING) 7431 CPU_BASED_CR8_STORE_EXITING)
7432 return 1; 7432 return true;
7433 break; 7433 break;
7434 } 7434 }
7435 break; 7435 break;
@@ -7440,14 +7440,14 @@ static bool nested_vmx_exit_handled_cr(struct kvm_vcpu *vcpu,
7440 */ 7440 */
7441 if (vmcs12->cr0_guest_host_mask & 0xe & 7441 if (vmcs12->cr0_guest_host_mask & 0xe &
7442 (val ^ vmcs12->cr0_read_shadow)) 7442 (val ^ vmcs12->cr0_read_shadow))
7443 return 1; 7443 return true;
7444 if ((vmcs12->cr0_guest_host_mask & 0x1) && 7444 if ((vmcs12->cr0_guest_host_mask & 0x1) &&
7445 !(vmcs12->cr0_read_shadow & 0x1) && 7445 !(vmcs12->cr0_read_shadow & 0x1) &&
7446 (val & 0x1)) 7446 (val & 0x1))
7447 return 1; 7447 return true;
7448 break; 7448 break;
7449 } 7449 }
7450 return 0; 7450 return false;
7451} 7451}
7452 7452
7453/* 7453/*
@@ -7470,43 +7470,43 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu)
7470 KVM_ISA_VMX); 7470 KVM_ISA_VMX);
7471 7471
7472 if (vmx->nested.nested_run_pending) 7472 if (vmx->nested.nested_run_pending)
7473 return 0; 7473 return false;
7474 7474
7475 if (unlikely(vmx->fail)) { 7475 if (unlikely(vmx->fail)) {
7476 pr_info_ratelimited("%s failed vm entry %x\n", __func__, 7476 pr_info_ratelimited("%s failed vm entry %x\n", __func__,
7477 vmcs_read32(VM_INSTRUCTION_ERROR)); 7477 vmcs_read32(VM_INSTRUCTION_ERROR));
7478 return 1; 7478 return true;
7479 } 7479 }
7480 7480
7481 switch (exit_reason) { 7481 switch (exit_reason) {
7482 case EXIT_REASON_EXCEPTION_NMI: 7482 case EXIT_REASON_EXCEPTION_NMI:
7483 if (!is_exception(intr_info)) 7483 if (!is_exception(intr_info))
7484 return 0; 7484 return false;
7485 else if (is_page_fault(intr_info)) 7485 else if (is_page_fault(intr_info))
7486 return enable_ept; 7486 return enable_ept;
7487 else if (is_no_device(intr_info) && 7487 else if (is_no_device(intr_info) &&
7488 !(vmcs12->guest_cr0 & X86_CR0_TS)) 7488 !(vmcs12->guest_cr0 & X86_CR0_TS))
7489 return 0; 7489 return false;
7490 return vmcs12->exception_bitmap & 7490 return vmcs12->exception_bitmap &
7491 (1u << (intr_info & INTR_INFO_VECTOR_MASK)); 7491 (1u << (intr_info & INTR_INFO_VECTOR_MASK));
7492 case EXIT_REASON_EXTERNAL_INTERRUPT: 7492 case EXIT_REASON_EXTERNAL_INTERRUPT:
7493 return 0; 7493 return false;
7494 case EXIT_REASON_TRIPLE_FAULT: 7494 case EXIT_REASON_TRIPLE_FAULT:
7495 return 1; 7495 return true;
7496 case EXIT_REASON_PENDING_INTERRUPT: 7496 case EXIT_REASON_PENDING_INTERRUPT:
7497 return nested_cpu_has(vmcs12, CPU_BASED_VIRTUAL_INTR_PENDING); 7497 return nested_cpu_has(vmcs12, CPU_BASED_VIRTUAL_INTR_PENDING);
7498 case EXIT_REASON_NMI_WINDOW: 7498 case EXIT_REASON_NMI_WINDOW:
7499 return nested_cpu_has(vmcs12, CPU_BASED_VIRTUAL_NMI_PENDING); 7499 return nested_cpu_has(vmcs12, CPU_BASED_VIRTUAL_NMI_PENDING);
7500 case EXIT_REASON_TASK_SWITCH: 7500 case EXIT_REASON_TASK_SWITCH:
7501 return 1; 7501 return true;
7502 case EXIT_REASON_CPUID: 7502 case EXIT_REASON_CPUID:
7503 if (kvm_register_read(vcpu, VCPU_REGS_RAX) == 0xa) 7503 if (kvm_register_read(vcpu, VCPU_REGS_RAX) == 0xa)
7504 return 0; 7504 return false;
7505 return 1; 7505 return true;
7506 case EXIT_REASON_HLT: 7506 case EXIT_REASON_HLT:
7507 return nested_cpu_has(vmcs12, CPU_BASED_HLT_EXITING); 7507 return nested_cpu_has(vmcs12, CPU_BASED_HLT_EXITING);
7508 case EXIT_REASON_INVD: 7508 case EXIT_REASON_INVD:
7509 return 1; 7509 return true;
7510 case EXIT_REASON_INVLPG: 7510 case EXIT_REASON_INVLPG:
7511 return nested_cpu_has(vmcs12, CPU_BASED_INVLPG_EXITING); 7511 return nested_cpu_has(vmcs12, CPU_BASED_INVLPG_EXITING);
7512 case EXIT_REASON_RDPMC: 7512 case EXIT_REASON_RDPMC:
@@ -7523,7 +7523,7 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu)
7523 * VMX instructions trap unconditionally. This allows L1 to 7523 * VMX instructions trap unconditionally. This allows L1 to
7524 * emulate them for its L2 guest, i.e., allows 3-level nesting! 7524 * emulate them for its L2 guest, i.e., allows 3-level nesting!
7525 */ 7525 */
7526 return 1; 7526 return true;
7527 case EXIT_REASON_CR_ACCESS: 7527 case EXIT_REASON_CR_ACCESS:
7528 return nested_vmx_exit_handled_cr(vcpu, vmcs12); 7528 return nested_vmx_exit_handled_cr(vcpu, vmcs12);
7529 case EXIT_REASON_DR_ACCESS: 7529 case EXIT_REASON_DR_ACCESS:
@@ -7534,7 +7534,7 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu)
7534 case EXIT_REASON_MSR_WRITE: 7534 case EXIT_REASON_MSR_WRITE:
7535 return nested_vmx_exit_handled_msr(vcpu, vmcs12, exit_reason); 7535 return nested_vmx_exit_handled_msr(vcpu, vmcs12, exit_reason);
7536 case EXIT_REASON_INVALID_STATE: 7536 case EXIT_REASON_INVALID_STATE:
7537 return 1; 7537 return true;
7538 case EXIT_REASON_MWAIT_INSTRUCTION: 7538 case EXIT_REASON_MWAIT_INSTRUCTION:
7539 return nested_cpu_has(vmcs12, CPU_BASED_MWAIT_EXITING); 7539 return nested_cpu_has(vmcs12, CPU_BASED_MWAIT_EXITING);
7540 case EXIT_REASON_MONITOR_INSTRUCTION: 7540 case EXIT_REASON_MONITOR_INSTRUCTION:
@@ -7544,7 +7544,7 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu)
7544 nested_cpu_has2(vmcs12, 7544 nested_cpu_has2(vmcs12,
7545 SECONDARY_EXEC_PAUSE_LOOP_EXITING); 7545 SECONDARY_EXEC_PAUSE_LOOP_EXITING);
7546 case EXIT_REASON_MCE_DURING_VMENTRY: 7546 case EXIT_REASON_MCE_DURING_VMENTRY:
7547 return 0; 7547 return false;
7548 case EXIT_REASON_TPR_BELOW_THRESHOLD: 7548 case EXIT_REASON_TPR_BELOW_THRESHOLD:
7549 return nested_cpu_has(vmcs12, CPU_BASED_TPR_SHADOW); 7549 return nested_cpu_has(vmcs12, CPU_BASED_TPR_SHADOW);
7550 case EXIT_REASON_APIC_ACCESS: 7550 case EXIT_REASON_APIC_ACCESS:
@@ -7553,7 +7553,7 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu)
7553 case EXIT_REASON_APIC_WRITE: 7553 case EXIT_REASON_APIC_WRITE:
7554 case EXIT_REASON_EOI_INDUCED: 7554 case EXIT_REASON_EOI_INDUCED:
7555 /* apic_write and eoi_induced should exit unconditionally. */ 7555 /* apic_write and eoi_induced should exit unconditionally. */
7556 return 1; 7556 return true;
7557 case EXIT_REASON_EPT_VIOLATION: 7557 case EXIT_REASON_EPT_VIOLATION:
7558 /* 7558 /*
7559 * L0 always deals with the EPT violation. If nested EPT is 7559 * L0 always deals with the EPT violation. If nested EPT is
@@ -7561,7 +7561,7 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu)
7561 * missing in the guest EPT table (EPT12), the EPT violation 7561 * missing in the guest EPT table (EPT12), the EPT violation
7562 * will be injected with nested_ept_inject_page_fault() 7562 * will be injected with nested_ept_inject_page_fault()
7563 */ 7563 */
7564 return 0; 7564 return false;
7565 case EXIT_REASON_EPT_MISCONFIG: 7565 case EXIT_REASON_EPT_MISCONFIG:
7566 /* 7566 /*
7567 * L2 never uses directly L1's EPT, but rather L0's own EPT 7567 * L2 never uses directly L1's EPT, but rather L0's own EPT
@@ -7569,11 +7569,11 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu)
7569 * (EPT on EPT). So any problems with the structure of the 7569 * (EPT on EPT). So any problems with the structure of the
7570 * table is L0's fault. 7570 * table is L0's fault.
7571 */ 7571 */
7572 return 0; 7572 return false;
7573 case EXIT_REASON_WBINVD: 7573 case EXIT_REASON_WBINVD:
7574 return nested_cpu_has2(vmcs12, SECONDARY_EXEC_WBINVD_EXITING); 7574 return nested_cpu_has2(vmcs12, SECONDARY_EXEC_WBINVD_EXITING);
7575 case EXIT_REASON_XSETBV: 7575 case EXIT_REASON_XSETBV:
7576 return 1; 7576 return true;
7577 case EXIT_REASON_XSAVES: case EXIT_REASON_XRSTORS: 7577 case EXIT_REASON_XSAVES: case EXIT_REASON_XRSTORS:
7578 /* 7578 /*
7579 * This should never happen, since it is not possible to 7579 * This should never happen, since it is not possible to
@@ -7583,7 +7583,7 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu)
7583 */ 7583 */
7584 return nested_cpu_has2(vmcs12, SECONDARY_EXEC_XSAVES); 7584 return nested_cpu_has2(vmcs12, SECONDARY_EXEC_XSAVES);
7585 default: 7585 default:
7586 return 1; 7586 return true;
7587 } 7587 }
7588} 7588}
7589 7589