diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index cb3dad0..9906cc5 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -25,6 +25,9 @@ #include #endif #include +#ifdef __sun +#include +#endif #include "kvm.h" #include "hw/apic.h" @@ -506,9 +509,19 @@ int kvm_arch_qemu_create_context(void) { int r; struct utsname utsname; + char sysinfo_arch[20]; uname(&utsname); - lm_capable_kernel = strcmp(utsname.machine, "x86_64") == 0; + if(strcmp(utsname.sysname, "SunOS") == 0) { + sysinfo(SI_ARCHITECTURE_K, sysinfo_arch, sizeof(sysinfo_arch)); + if(strcmp(sysinfo_arch, "amd64") == 0) { + lm_capable_kernel = 1; + } else { + lm_capable_kernel = 0; + } + } + else + lm_capable_kernel = strcmp(utsname.machine, "x86_64") == 0; if (kvm_shadow_memory) { kvm_set_shadow_pages(kvm_context, kvm_shadow_memory); @@ -723,11 +736,12 @@ void kvm_arch_push_nmi(void *opaque) static int kvm_reset_msrs(CPUState *env) { struct { - struct kvm_msrs info; + uint32_t nmsrs; /* number of msrs in entries */ + uint32_t pad; struct kvm_msr_entry entries[100]; - } msr_data; + } kvm_msrs; int n; - struct kvm_msr_entry *msrs = msr_data.entries; + struct kvm_msr_entry *msrs = kvm_msrs.entries; uint32_t index; uint64_t data; @@ -747,9 +761,9 @@ static int kvm_reset_msrs(CPUState *env) kvm_msr_entry_set(&msrs[n], kvm_msr_list->indices[n], data); } - msr_data.info.nmsrs = n; + kvm_msrs.nmsrs = n; - return kvm_vcpu_ioctl(env, KVM_SET_MSRS, &msr_data); + return kvm_vcpu_ioctl(env, KVM_SET_MSRS, &kvm_msrs); } diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 8f28911..a870947 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -837,10 +837,11 @@ static void kvm_msr_entry_set(struct kvm_msr_entry *entry, static int kvm_put_msrs(CPUState *env, int level) { struct { - struct kvm_msrs info; + uint32_t nmsrs; /* number of msrs in entries */ + uint32_t pad; struct kvm_msr_entry entries[100]; - } msr_data; - struct kvm_msr_entry *msrs = msr_data.entries; + } kvm_msrs; + struct kvm_msr_entry *msrs = kvm_msrs.entries; int n = 0; kvm_msr_entry_set(&msrs[n++], MSR_IA32_SYSENTER_CS, env->sysenter_cs); @@ -903,9 +904,9 @@ static int kvm_put_msrs(CPUState *env, int level) } #endif - msr_data.info.nmsrs = n; + kvm_msrs.nmsrs = n; - return kvm_vcpu_ioctl(env, KVM_SET_MSRS, &msr_data); + return kvm_vcpu_ioctl(env, KVM_SET_MSRS, &kvm_msrs); } @@ -1091,10 +1092,11 @@ static int kvm_get_sregs(CPUState *env) static int kvm_get_msrs(CPUState *env) { struct { - struct kvm_msrs info; + uint32_t nmsrs; /* number of msrs in entries */ + uint32_t pad; struct kvm_msr_entry entries[100]; - } msr_data; - struct kvm_msr_entry *msrs = msr_data.entries; + } kvm_msrs; + struct kvm_msr_entry *msrs = kvm_msrs.entries; int ret, i, n; n = 0; @@ -1134,8 +1136,8 @@ static int kvm_get_msrs(CPUState *env) } #endif - msr_data.info.nmsrs = n; - ret = kvm_vcpu_ioctl(env, KVM_GET_MSRS, &msr_data); + kvm_msrs.nmsrs = n; + ret = kvm_vcpu_ioctl(env, KVM_GET_MSRS, &kvm_msrs); if (ret < 0) { return ret; }