qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] don't expose lm bit if kernel is not 64-bit cap


From: Alexander Graf
Subject: Re: [Qemu-devel] [PATCH] don't expose lm bit if kernel is not 64-bit capable.
Date: Tue, 3 Feb 2009 16:44:30 +0100


On 03.02.2009, at 16:04, Glauber Costa wrote:

If the kernel is not 64-bit capable (even if the host
machine is) do not expose the lm bit in guest cpuid.

Signed-off-by: Glauber Costa <address@hidden>
---
target-i386/helper.c |    6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/target-i386/helper.c b/target-i386/helper.c
index a28ab93..997e4e1 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -24,6 +24,7 @@
#include <inttypes.h>
#include <signal.h>
#include <assert.h>
+#include <sys/utsname.h>

#include "cpu.h"
#include "exec-all.h"
@@ -1520,13 +1521,16 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,

        if (kvm_enabled()) {
            uint32_t h_eax, h_edx;
+            struct utsname utsname;
+
+            uname(&utsname);

This doesn't really compile on win32, does it?

Why not check for sizeof(long) == 4? That way you'd know that you're running 32-bit code which can only handle 32-bit guests anyway, right? And if you're running 64-bit userspace code, you know that the kernel is 64-bit aware.

Alex



            host_cpuid(0x80000001, &h_eax, NULL, NULL, &h_edx);

            /* disable CPU features that the host does not support */

            /* long mode */
- if ((h_edx & 0x20000000) == 0 /* || !lm_capable_kernel */) + if ((h_edx & 0x20000000) == 0 || strcmp(utsname.machine, "x86_64"))
                *edx &= ~0x20000000;
            /* syscall */
            if ((h_edx & 0x00000800) == 0)
--
1.5.6.5








reply via email to

[Prev in Thread] Current Thread [Next in Thread]