diff options
Diffstat (limited to 'drivers/kvm/vmx.c')
-rw-r--r-- | drivers/kvm/vmx.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c index bfa0ce42ea92..fbbf9d6b299f 100644 --- a/drivers/kvm/vmx.c +++ b/drivers/kvm/vmx.c | |||
@@ -618,7 +618,7 @@ static void fix_pmode_dataseg(int seg, struct kvm_save_segment *save) | |||
618 | { | 618 | { |
619 | struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg]; | 619 | struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg]; |
620 | 620 | ||
621 | if (vmcs_readl(sf->base) == save->base) { | 621 | if (vmcs_readl(sf->base) == save->base && (save->base & AR_S_MASK)) { |
622 | vmcs_write16(sf->selector, save->selector); | 622 | vmcs_write16(sf->selector, save->selector); |
623 | vmcs_writel(sf->base, save->base); | 623 | vmcs_writel(sf->base, save->base); |
624 | vmcs_write32(sf->limit, save->limit); | 624 | vmcs_write32(sf->limit, save->limit); |
@@ -1888,6 +1888,27 @@ again: | |||
1888 | [cr2]"i"(offsetof(struct kvm_vcpu, cr2)) | 1888 | [cr2]"i"(offsetof(struct kvm_vcpu, cr2)) |
1889 | : "cc", "memory" ); | 1889 | : "cc", "memory" ); |
1890 | 1890 | ||
1891 | /* | ||
1892 | * Reload segment selectors ASAP. (it's needed for a functional | ||
1893 | * kernel: x86 relies on having __KERNEL_PDA in %fs and x86_64 | ||
1894 | * relies on having 0 in %gs for the CPU PDA to work.) | ||
1895 | */ | ||
1896 | if (fs_gs_ldt_reload_needed) { | ||
1897 | load_ldt(ldt_sel); | ||
1898 | load_fs(fs_sel); | ||
1899 | /* | ||
1900 | * If we have to reload gs, we must take care to | ||
1901 | * preserve our gs base. | ||
1902 | */ | ||
1903 | local_irq_disable(); | ||
1904 | load_gs(gs_sel); | ||
1905 | #ifdef CONFIG_X86_64 | ||
1906 | wrmsrl(MSR_GS_BASE, vmcs_readl(HOST_GS_BASE)); | ||
1907 | #endif | ||
1908 | local_irq_enable(); | ||
1909 | |||
1910 | reload_tss(); | ||
1911 | } | ||
1891 | ++kvm_stat.exits; | 1912 | ++kvm_stat.exits; |
1892 | 1913 | ||
1893 | save_msrs(vcpu->guest_msrs, NR_BAD_MSRS); | 1914 | save_msrs(vcpu->guest_msrs, NR_BAD_MSRS); |
@@ -1905,22 +1926,6 @@ again: | |||
1905 | kvm_run->exit_reason = vmcs_read32(VM_INSTRUCTION_ERROR); | 1926 | kvm_run->exit_reason = vmcs_read32(VM_INSTRUCTION_ERROR); |
1906 | r = 0; | 1927 | r = 0; |
1907 | } else { | 1928 | } else { |
1908 | if (fs_gs_ldt_reload_needed) { | ||
1909 | load_ldt(ldt_sel); | ||
1910 | load_fs(fs_sel); | ||
1911 | /* | ||
1912 | * If we have to reload gs, we must take care to | ||
1913 | * preserve our gs base. | ||
1914 | */ | ||
1915 | local_irq_disable(); | ||
1916 | load_gs(gs_sel); | ||
1917 | #ifdef CONFIG_X86_64 | ||
1918 | wrmsrl(MSR_GS_BASE, vmcs_readl(HOST_GS_BASE)); | ||
1919 | #endif | ||
1920 | local_irq_enable(); | ||
1921 | |||
1922 | reload_tss(); | ||
1923 | } | ||
1924 | /* | 1929 | /* |
1925 | * Profile KVM exit RIPs: | 1930 | * Profile KVM exit RIPs: |
1926 | */ | 1931 | */ |