[syslinux:master] core: Workaround for Xen HVM HLT-in-real-mode bug

syslinux-bot for H. Peter Anvin hpa at linux.intel.com
Tue Mar 30 15:06:15 PDT 2010


Commit-ID:  ec127e4bce415e103da3ba02d0e7adee2bcc1344
Gitweb:     http://syslinux.zytor.com/commit/ec127e4bce415e103da3ba02d0e7adee2bcc1344
Author:     H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Tue, 30 Mar 2010 15:02:36 -0700
Committer:  H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Tue, 30 Mar 2010 15:02:36 -0700

core: Workaround for Xen HVM HLT-in-real-mode bug

Xen HVM when used with the "vmxassist" program crashes if HLT is
executed in real mode.  Detect a version of Xen old enough to support
"vmxassist", and if it is found, then disable HLT.

See: https://bugzilla.redhat.com/show_bug.cgi?id=570496

Reported-by: Andrew Jones <drjones at redhat.com>
Signed-off-by: H. Peter Anvin <hpa at linux.intel.com>


---
 core/cpuinit.inc |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 core/idle.inc    |    6 ++++--
 2 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/core/cpuinit.inc b/core/cpuinit.inc
index 4d8cc2e..6af1bf8 100644
--- a/core/cpuinit.inc
+++ b/core/cpuinit.inc
@@ -1,6 +1,7 @@
 ;; -----------------------------------------------------------------------
 ;;
 ;;   Copyright 1994-2008 H. Peter Anvin - All Rights Reserved
+;;   Copyright 2010 Intel Corporation; author: H. Peter Anvin
 ;;
 ;;   This program is free software; you can redistribute it and/or modify
 ;;   it under the terms of the GNU General Public License as published by
@@ -39,6 +40,53 @@ dosram_k	equ (real_mode_seg+0x1000) >> 6	; Minimum DOS memory (K)
 enough_ram:
 skip_checks:
 
+;
+; Detect old versions Xen HVM and disable halt
+; Xen HVM older than version 3.3 might be using vmxassist, which breaks
+; if HLT is executed in real mode.
+;
+; Note: in Syslinux 4, we should probably just execute the HLT in
+; protected mode instead.
+;
+check_xen:
+		pushfd
+		pushfd
+		pop eax
+		mov edx,eax
+		xor eax,(1 << 21)		; ID flag
+		push eax
+		popfd
+		pushfd
+		pop eax
+		popfd
+		xor eax,edx
+		jz .not_xen			; No CPUID
+
+		xor ebx,ebx
+		xor ecx,ecx
+		xor edx,edx
+		mov eax,0x40000000
+		cpuid
+		cmp ebx,"XenV"
+		jne .not_xen
+		cmp ecx,"MMXe"
+		jne .not_xen
+		cmp edx,"nVMM"
+		jne .not_xen
+
+		; We're on Xen...
+		mov eax,0x40000001
+		cpuid
+		call writehex8
+		call crlf
+		cmp eax,0x00030003
+		jae .not_xen			; Xen >= 3.3, not affected
+
+		; We may be using vmxassist, so disable HLT
+		mov byte [ForceNoHalt],1
+
+.not_xen:
+
 		section .data
 err_noram	db 'It appears your computer has less than '
 		asciidec dosram_k
diff --git a/core/idle.inc b/core/idle.inc
index bd134ff..dc8d204 100644
--- a/core/idle.inc
+++ b/core/idle.inc
@@ -59,7 +59,7 @@ do_idle:
 		cmp ax,TICKS_TO_IDLE
 		jb .done
 		call [IdleHook]
-		cmp word [NoHalt],0
+		cmp dword [NoHalt],0
 		jne .done
 		hlt
 .done:
@@ -69,8 +69,10 @@ do_idle:
 .ret:		ret
 
 		section .data
+		alignb 4
+NoHalt		dw 0			; NoHalt set by user
+ForceNoHalt	dw 0			; NoHalt forced by hardware config
 IdleHook	dw do_idle.ret
-NoHalt		dw 0
 
 hlt_err		db 'ERROR: idle with IF=0', CR, LF, 0 
 



More information about the Syslinux-commits mailing list