Revision 25d2e361 target-i386/kvm.c

b/target-i386/kvm.c
15 15
#include <sys/types.h>
16 16
#include <sys/ioctl.h>
17 17
#include <sys/mman.h>
18
#include <sys/utsname.h>
18 19

  
19 20
#include <linux/kvm.h>
20 21

  
......
53 54
#define BUS_MCEERR_AO 5
54 55
#endif
55 56

  
57
static int lm_capable_kernel;
58

  
56 59
#ifdef KVM_CAP_EXT_CPUID
57 60

  
58 61
static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max)
......
523 526
{
524 527
    int ret;
525 528

  
529
    struct utsname utsname;
530

  
531
    uname(&utsname);
532
    lm_capable_kernel = strcmp(utsname.machine, "x86_64") == 0;
533

  
526 534
    /* create vm86 tss.  KVM uses vm86 mode to emulate 16-bit code
527 535
     * directly.  In order to use vm86 mode, a TSS is needed.  Since this
528 536
     * must be part of guest physical memory, we need to allocate it.  Older
......
810 818
    if (kvm_has_msr_hsave_pa(env))
811 819
        kvm_msr_entry_set(&msrs[n++], MSR_VM_HSAVE_PA, env->vm_hsave);
812 820
#ifdef TARGET_X86_64
813
    /* FIXME if lm capable */
814
    kvm_msr_entry_set(&msrs[n++], MSR_CSTAR, env->cstar);
815
    kvm_msr_entry_set(&msrs[n++], MSR_KERNELGSBASE, env->kernelgsbase);
816
    kvm_msr_entry_set(&msrs[n++], MSR_FMASK, env->fmask);
817
    kvm_msr_entry_set(&msrs[n++], MSR_LSTAR, env->lstar);
821
    if (lm_capable_kernel) {
822
        kvm_msr_entry_set(&msrs[n++], MSR_CSTAR, env->cstar);
823
        kvm_msr_entry_set(&msrs[n++], MSR_KERNELGSBASE, env->kernelgsbase);
824
        kvm_msr_entry_set(&msrs[n++], MSR_FMASK, env->fmask);
825
        kvm_msr_entry_set(&msrs[n++], MSR_LSTAR, env->lstar);
826
    }
818 827
#endif
819 828
    if (level == KVM_PUT_FULL_STATE) {
820 829
        /*
......
1046 1055
        msrs[n++].index = MSR_VM_HSAVE_PA;
1047 1056
    msrs[n++].index = MSR_IA32_TSC;
1048 1057
#ifdef TARGET_X86_64
1049
    /* FIXME lm_capable_kernel */
1050
    msrs[n++].index = MSR_CSTAR;
1051
    msrs[n++].index = MSR_KERNELGSBASE;
1052
    msrs[n++].index = MSR_FMASK;
1053
    msrs[n++].index = MSR_LSTAR;
1058
    if (lm_capable_kernel) {
1059
        msrs[n++].index = MSR_CSTAR;
1060
        msrs[n++].index = MSR_KERNELGSBASE;
1061
        msrs[n++].index = MSR_FMASK;
1062
        msrs[n++].index = MSR_LSTAR;
1063
    }
1054 1064
#endif
1055 1065
    msrs[n++].index = MSR_KVM_SYSTEM_TIME;
1056 1066
    msrs[n++].index = MSR_KVM_WALL_CLOCK;

Also available in: Unified diff