Xen 3.2: Fix guest boot on AMD K8 machine
PATCH 1/1 Xen 3.2: Fix guest boot on AMD K8 machine
Hi!
A bug has been introduced in Xen 3.2.2 (and still reproducable with Xen 3.2.3) which causes the guest to freeze at boot and xen floods the console with this messages:
(XEN) platform.c:1049:d6 handle_mmio: failed to get instruction (XEN) instrlen.c:252:d6 Cannot read from address 802eb001 (eip 802eb001, mode
2)
The problem is reproducable on AMD K8 machines.
Attached patch fixes this.
Signed-off-by Christoph Egger <[email protected]>
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
xen/arch/x86/hvm/svm/emulate.c +17 -54
@@ -29,6 +29,9 @@#include <asm/hvm/svm/emulate.h> +extern int inst_copy_from_guest (unsigned char *buf,unsigned long guest_eip, +int inst_len); +#define REX_PREFIX_BASE 0x40#define REX_X 0x02#define REX_W 0x08
@@ -409,8 +412,8 @@ static const u8 *opc_bytes[INSTR_MAX_COU* Intel has a vmcs entry to give the instruction length. AMD doesn't. So we * have to do a little bit of work to find out... * -* The caller may supply a buffer of at least MAX_INST_LEN bytes, which -* the instruction will be read into. +* The caller can either pass a NULL pointer to the guest_eip_buf, or a pointer +* to enough bytes to satisfy the instruction including prefix bytes. */ int __get_instruction_length_from_list(struct vcpu *v, enum instruction_index *list, unsigned int list_count,
@@ -422,40 +425,21 @@ int __get_instruction_length_from_list(sunsigned int j;int found =0 ;enum instruction_index instr =0 ; -unsigned long fetch_addr; -int fetch_len; +u8 buffer[MAX_INST_LEN ];u8 *buf;const u8 *opcode =NULL ; -u8 temp_buffer[MAX_INST_LEN ]; -/* Use the stack if the caller didn't give us a buffer */ - buf = ( guest_eip_buf ) ? guest_eip_buf : temp_buffer; - -#define FETCH (_buf, _addr, _len) do \ - { \ - switch ( hvm_fetch_from_guest_virt((_buf), (_addr), (_len)) ) \ - { \ - case HVMCOPY_okay: \ - break; \ - case HVMCOPY_bad_gva_to_gfn: \ -/* OK just to give up; we'll have injected #PF already */ \ -return 0 ; \ -case HVMCOPY_bad_gfn_to_mfn: \ -/* Not OK: fetches from non-RAM pages are not supportable. */ \ -gdprintk (XENLOG_ERR ,"Bad instruction fetch at %#lx (%#lx)\n" , \ - (unsigned long )guest_cpu_user_regs ()->eip, fetch_addr); \ -hvm_inject_exception (TRAP_gp_fault,0 ,0 ); \ -return 0 ; \ - } \ - } while (0) - -/* Fetch up to the next page break; we'll fetch from the next page -* later if we have to. */ - fetch_addr =svm_rip2pointer (v); - fetch_len =PAGE_SIZE - (fetch_addr & ~PAGE_MASK ) ; -if ( fetch_len >MAX_INST_LEN ) - fetch_len =MAX_INST_LEN ; -FETCH (buf, fetch_addr, fetch_len); +if (guest_eip_buf) + { + buf = guest_eip_buf; + } +else + { +if (inst_copy_from_guest (buffer,svm_rip2pointer (v),MAX_INST_LEN ) + !=MAX_INST_LEN ) +return 0 ; + buf = buffer; + }for (j =0 ; j < list_count; j++) {
@@ -466,16 +450,7 @@ int __get_instruction_length_from_list(swhile (inst_len <MAX_INST_LEN &&is_prefix (buf[inst_len]) && !is_prefix (opcode[1 ])) - { inst_len++; -if ( inst_len >= fetch_len ) - { -FETCH (buf + fetch_len, - fetch_addr + fetch_len, -MAX_INST_LEN - fetch_len); - fetch_len =MAX_INST_LEN ; - } - }ASSERT (opcode[0 ] <=15 );/* Make sure the table is correct. */ found =1 ;
@@ -486,14 +461,6 @@ int __get_instruction_length_from_list(sif (i == opcode[0 ]-1 && opcode[i+1 ] ==0 )break ; -if ( inst_len + i >= fetch_len ) - { -FETCH (buf + fetch_len, - fetch_addr + fetch_len, -MAX_INST_LEN - fetch_len); - fetch_len =MAX_INST_LEN ; - } -if (buf[inst_len+i] != opcode[i+1 ]) { found =0 ;
@@ -520,11 +487,7 @@ int __get_instruction_length_from_list(sprintk ("%s: Mismatch between expected and actual instruction bytes: " "eip = %lx\n" , __func__, (unsigned long )vmcb->rip); -hvm_inject_exception (TRAP_gp_fault,0 ,0 );return 0 ; - -#undef FETCH - }/*
xen/arch/x86/hvm/svm/svm.c +34 -27
118 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel