Commit c0a04f0e130fa98da8b89e74debd379c2f08d120

Authored by aliguori
1 parent c690524e

Fix up pxe boot (Glauber Costa)

As discussed in
http://lists.gnu.org/archive/html/qemu-devel/2008-08/msg00667.html,
current pxe boot is broken for some use cases. The problem
goes away if we reduce the number of allowed bits in the address space
to 32 (which has the side effect of reducing guest max mem size to 4Gb).

After digging for a while, it turns out that it happens because pxelinux
tries to access address 0x10009e9a6, which does not fit a 32-bit address.
A closer look, however, reveals this access is totally valid: It's just
0x9e9a6 with an add carry.

To avoid this, this patch casts the address passed to the POPL macro to
a 32-bit value. This is also done, although just theorectically, for
PUSHL too.

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Reported-by: Chris Lalancette <clalance@redhat.com>
CC: Eduardo Habkost <ehabkost@redhat.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5182 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 6 additions and 2 deletions
target-i386/op_helper.c
... ... @@ -590,6 +590,10 @@ do {\
590 590 #define SET_ESP(val, sp_mask) ESP = (ESP & ~(sp_mask)) | ((val) & (sp_mask))
591 591 #endif
592 592  
  593 +/* in 64-bit machines, this can overflow. So this segment addition macro
  594 + * can be used to trim the value to 32-bit whenever needed */
  595 +#define SEG_ADDL(ssp, sp, sp_mask) ((uint32_t)((ssp) + (sp & (sp_mask))))
  596 +
593 597 /* XXX: add a is_user flag to have proper security support */
594 598 #define PUSHW(ssp, sp, sp_mask, val)\
595 599 {\
... ... @@ -600,7 +604,7 @@ do {\
600 604 #define PUSHL(ssp, sp, sp_mask, val)\
601 605 {\
602 606 sp -= 4;\
603   - stl_kernel((ssp) + (sp & (sp_mask)), (val));\
  607 + stl_kernel(SEG_ADDL(ssp, sp, sp_mask), (uint32_t)(val));\
604 608 }
605 609  
606 610 #define POPW(ssp, sp, sp_mask, val)\
... ... @@ -611,7 +615,7 @@ do {\
611 615  
612 616 #define POPL(ssp, sp, sp_mask, val)\
613 617 {\
614   - val = (uint32_t)ldl_kernel((ssp) + (sp & (sp_mask)));\
  618 + val = (uint32_t)ldl_kernel(SEG_ADDL(ssp, sp, sp_mask));\
615 619 sp += 4;\
616 620 }
617 621  
... ...