Skip to content

Commit e28baea

Browse files
amlutobonzini
authored andcommitted
x86/kvm/vmx: Get rid of segment_base() on 64-bit kernels
It was a bit buggy (it didn't list all segment types that needed 64-bit fixups), but the bug was irrelevant because it wasn't called in any interesting context on 64-bit kernels and was only used for data segents on 32-bit kernels. To avoid confusion, make it explicitly 32-bit only. Cc: Thomas Garnier <thgarnie@google.com> Cc: Jim Mattson <jmattson@google.com> Cc: Radim Krčmář <rkrcmar@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent e0c2306 commit e28baea

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

arch/x86/kvm/vmx.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,6 +2057,12 @@ static bool update_transition_efer(struct vcpu_vmx *vmx, int efer_offset)
20572057
}
20582058
}
20592059

2060+
#ifdef CONFIG_X86_32
2061+
/*
2062+
* On 32-bit kernels, VM exits still load the FS and GS bases from the
2063+
* VMCS rather than the segment table. KVM uses this helper to figure
2064+
* out the current bases to poke them into the VMCS before entry.
2065+
*/
20602066
static unsigned long segment_base(u16 selector)
20612067
{
20622068
struct desc_ptr *gdt = this_cpu_ptr(&host_gdt);
@@ -2079,12 +2085,9 @@ static unsigned long segment_base(u16 selector)
20792085
}
20802086
d = (struct desc_struct *)(table_base + (selector & ~7));
20812087
v = get_desc_base(d);
2082-
#ifdef CONFIG_X86_64
2083-
if (d->s == 0 && (d->type == 2 || d->type == 9 || d->type == 11))
2084-
v |= ((unsigned long)((struct ldttss_desc64 *)d)->base3) << 32;
2085-
#endif
20862088
return v;
20872089
}
2090+
#endif
20882091

20892092
static void vmx_save_host_state(struct kvm_vcpu *vcpu)
20902093
{

0 commit comments

Comments
 (0)