From: Juergen Keil Subject: 32-bit HVM cpuid(80000001), long mode feature? Date: Mon, 2 Jun 2008 16:30:35 +0200 (CEST) Message-ID: <20080602143035.53EDD4BDC3@imap.tools.intra> Reply-To: Juergen Keil Mime-Version: 1.0 Content-Type: MULTIPART/mixed; BOUNDARY=Troop_of_Baboons_032_000 Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --Troop_of_Baboons_032_000 Content-Type: TEXT/plain; charset=us-ascii Content-MD5: I+8lYaTCnXbuywjuJg23gw== When the 32-bit version of the xen-3.3-unstable hypervisor is used on 64-bit x86 hardware, a hvm domU will currently detect the presence of the long mode feature when looking at the feature flags returned by cpuid(80000001). But when the hvm domain tries it enable long mode, the 32-bit hypervisor refuses this. xen.hg/xen/arch/x86/hvm/hvm.c checks: if ( (value & ~(EFER_FFXSE | EFER_LME | EFER_NX | EFER_SCE)) || ((sizeof(long) != 8) && (value & EFER_LME)) || <<<<<<<<<<<<<<<<<<<< (!cpu_has_nx && (value & EFER_NX)) || (!cpu_has_syscall && (value & EFER_SCE)) || (!cpu_has_ffxsr && (value & EFER_FFXSE)) ) { gdprintk(XENLOG_WARNING, "Trying to set reserved bit in " "EFER: %"PRIx64"\n", value); hvm_inject_exception(TRAP_gp_fault, 0, 0); return X86EMUL_EXCEPTION; } This confuses {Open}Solaris' version of GRUB, when we try to start an {Open}Solaris HVM domU on a 32-bit hypervisor, on a 64-bit cpu. The hvm domain crashes with an error message like this on the xen console (apparently because the bootstrap code automatically tries to boot into the 64-bit kernel): hvm.c:782:d12 Trying to set reserved bit in EFER: 900 Shouldn't the 32-bit hypervisor stop announcing the long mode feature (X86_FEATURE_LM) for hvm domains, in the default configuration? On 3.1.4 this wasn't a problem; long mode wasn't announced and OpenSolaris did boot into the 32-bit kernel. The attached patch strips the long mode X86_FEATURE_LM bit, unless we're running on a 64-bit hypervisor. --Troop_of_Baboons_032_000 Content-Type: TEXT/plain; name="hvm-32bit-cpuid.patch"; charset=us-ascii; x-unix-mode=0755 Content-Description: hvm-32bit-cpuid.patch Content-MD5: 0Yr6zJFz1ly3vNf2g9I4JA== diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c --- a/tools/libxc/xc_cpuid_x86.c +++ b/tools/libxc/xc_cpuid_x86.c @@ -35,6 +35,7 @@ int xc, domid_t domid, const unsigned int *input, unsigned int *regs) { unsigned long pae = 0; + xen_capabilities_info_t xen_caps = ""; xc_get_hvm_param(xc, domid, HVM_PARAM_PAE_ENABLED, &pae); @@ -56,6 +57,9 @@ if ( !pae ) clear_bit(X86_FEATURE_PAE & 31, regs[3]); clear_bit(X86_FEATURE_PSE36 & 31, regs[3]); + if (xc_version(xc, XENVER_capabilities, &xen_caps) == 0 && + strstr(xen_caps, "x86_64") == NULL) + clear_bit(X86_FEATURE_LM & 31, regs[3]); /* Filter all other features according to a whitelist. */ regs[2] &= (bitmaskof(X86_FEATURE_LAHF_LM) | @@ -80,6 +84,8 @@ static void intel_xc_cpuid_policy( int xc, domid_t domid, const unsigned int *input, unsigned int *regs) { + xen_capabilities_info_t xen_caps = ""; + switch ( input[0] ) { case 0x00000001: @@ -93,6 +99,10 @@ break; case 0x80000001: + if (xc_version(xc, XENVER_capabilities, &xen_caps) == 0 && + strstr(xen_caps, "x86_64") == NULL) + clear_bit(X86_FEATURE_LM & 31, regs[3]); + /* Only a few features are advertised in Intel's 0x80000001. */ regs[2] &= (bitmaskof(X86_FEATURE_LAHF_LM)); regs[3] &= (bitmaskof(X86_FEATURE_NX) | --Troop_of_Baboons_032_000 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Troop_of_Baboons_032_000--