Revision 2a4dac83
b/target-i386/kvm.c | ||
---|---|---|
1624 | 1624 |
return 0; |
1625 | 1625 |
} |
1626 | 1626 |
|
1627 |
static bool host_supports_vmx(void) |
|
1628 |
{ |
|
1629 |
uint32_t ecx, unused; |
|
1630 |
|
|
1631 |
host_cpuid(1, 0, &unused, &unused, &ecx, &unused); |
|
1632 |
return ecx & CPUID_EXT_VMX; |
|
1633 |
} |
|
1634 |
|
|
1635 |
#define VMX_INVALID_GUEST_STATE 0x80000021 |
|
1636 |
|
|
1637 |
int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run) |
|
1638 |
{ |
|
1639 |
uint64_t code; |
|
1640 |
int ret; |
|
1641 |
|
|
1642 |
switch (run->exit_reason) { |
|
1643 |
case KVM_EXIT_HLT: |
|
1644 |
DPRINTF("handle_hlt\n"); |
|
1645 |
ret = kvm_handle_halt(env); |
|
1646 |
break; |
|
1647 |
case KVM_EXIT_SET_TPR: |
|
1648 |
ret = 0; |
|
1649 |
break; |
|
1650 |
case KVM_EXIT_FAIL_ENTRY: |
|
1651 |
code = run->fail_entry.hardware_entry_failure_reason; |
|
1652 |
fprintf(stderr, "KVM: entry failed, hardware error 0x%" PRIx64 "\n", |
|
1653 |
code); |
|
1654 |
if (host_supports_vmx() && code == VMX_INVALID_GUEST_STATE) { |
|
1655 |
fprintf(stderr, |
|
1656 |
"\nIf you're runnning a guest on an Intel machine without " |
|
1657 |
"unrestricted mode\n" |
|
1658 |
"support, the failure can be most likely due to the guest " |
|
1659 |
"entering an invalid\n" |
|
1660 |
"state for Intel VT. For example, the guest maybe running " |
|
1661 |
"in big real mode\n" |
|
1662 |
"which is not supported on less recent Intel processors." |
|
1663 |
"\n\n"); |
|
1664 |
} |
|
1665 |
ret = -1; |
|
1666 |
break; |
|
1667 |
case KVM_EXIT_EXCEPTION: |
|
1668 |
fprintf(stderr, "KVM: exception %d exit (error code 0x%x)\n", |
|
1669 |
run->ex.exception, run->ex.error_code); |
|
1670 |
ret = -1; |
|
1671 |
break; |
|
1672 |
default: |
|
1673 |
fprintf(stderr, "KVM: unknown exit reason %d\n", run->exit_reason); |
|
1674 |
ret = -1; |
|
1675 |
break; |
|
1676 |
} |
|
1677 |
|
|
1678 |
return ret; |
|
1679 |
} |
|
1680 |
|
|
1681 | 1627 |
#ifdef KVM_CAP_SET_GUEST_DEBUG |
1682 | 1628 |
int kvm_arch_insert_sw_breakpoint(CPUState *env, struct kvm_sw_breakpoint *bp) |
1683 | 1629 |
{ |
... | ... | |
1860 | 1806 |
} |
1861 | 1807 |
#endif /* KVM_CAP_SET_GUEST_DEBUG */ |
1862 | 1808 |
|
1809 |
static bool host_supports_vmx(void) |
|
1810 |
{ |
|
1811 |
uint32_t ecx, unused; |
|
1812 |
|
|
1813 |
host_cpuid(1, 0, &unused, &unused, &ecx, &unused); |
|
1814 |
return ecx & CPUID_EXT_VMX; |
|
1815 |
} |
|
1816 |
|
|
1817 |
#define VMX_INVALID_GUEST_STATE 0x80000021 |
|
1818 |
|
|
1819 |
int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run) |
|
1820 |
{ |
|
1821 |
uint64_t code; |
|
1822 |
int ret; |
|
1823 |
|
|
1824 |
switch (run->exit_reason) { |
|
1825 |
case KVM_EXIT_HLT: |
|
1826 |
DPRINTF("handle_hlt\n"); |
|
1827 |
ret = kvm_handle_halt(env); |
|
1828 |
break; |
|
1829 |
case KVM_EXIT_SET_TPR: |
|
1830 |
ret = 0; |
|
1831 |
break; |
|
1832 |
case KVM_EXIT_FAIL_ENTRY: |
|
1833 |
code = run->fail_entry.hardware_entry_failure_reason; |
|
1834 |
fprintf(stderr, "KVM: entry failed, hardware error 0x%" PRIx64 "\n", |
|
1835 |
code); |
|
1836 |
if (host_supports_vmx() && code == VMX_INVALID_GUEST_STATE) { |
|
1837 |
fprintf(stderr, |
|
1838 |
"\nIf you're runnning a guest on an Intel machine without " |
|
1839 |
"unrestricted mode\n" |
|
1840 |
"support, the failure can be most likely due to the guest " |
|
1841 |
"entering an invalid\n" |
|
1842 |
"state for Intel VT. For example, the guest maybe running " |
|
1843 |
"in big real mode\n" |
|
1844 |
"which is not supported on less recent Intel processors." |
|
1845 |
"\n\n"); |
|
1846 |
} |
|
1847 |
ret = -1; |
|
1848 |
break; |
|
1849 |
case KVM_EXIT_EXCEPTION: |
|
1850 |
fprintf(stderr, "KVM: exception %d exit (error code 0x%x)\n", |
|
1851 |
run->ex.exception, run->ex.error_code); |
|
1852 |
ret = -1; |
|
1853 |
break; |
|
1854 |
default: |
|
1855 |
fprintf(stderr, "KVM: unknown exit reason %d\n", run->exit_reason); |
|
1856 |
ret = -1; |
|
1857 |
break; |
|
1858 |
} |
|
1859 |
|
|
1860 |
return ret; |
|
1861 |
} |
|
1862 |
|
|
1863 | 1863 |
bool kvm_arch_stop_on_emulation_error(CPUState *env) |
1864 | 1864 |
{ |
1865 | 1865 |
return !(env->cr[0] & CR0_PE_MASK) || |
Also available in: Unified diff