|  | @@ -10,14 +10,6 @@
 | 
		
	
		
			
			| 10 | 10 |  
 | 
		
	
		
			
			| 11 | 11 |  FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 | 
		
	
		
			
			| 12 | 12 |  
 | 
		
	
		
			
			| 13 |  | -/*
 | 
		
	
		
			
			| 14 |  | - * The linker passes in the symbol _max_align, which is the alignment
 | 
		
	
		
			
			| 15 |  | - * that we must preserve, in bytes.
 | 
		
	
		
			
			| 16 |  | - *
 | 
		
	
		
			
			| 17 |  | - */
 | 
		
	
		
			
			| 18 |  | -extern char _max_align[];
 | 
		
	
		
			
			| 19 |  | -#define max_align ( ( size_t ) _max_align )
 | 
		
	
		
			
			| 20 |  | -
 | 
		
	
		
			
			| 21 | 13 |  /* Linker symbols */
 | 
		
	
		
			
			| 22 | 14 |  extern char _textdata[];
 | 
		
	
		
			
			| 23 | 15 |  extern char _etextdata[];
 | 
		
	
	
		
			
			|  | @@ -30,6 +22,12 @@ extern char _etextdata[];
 | 
		
	
		
			
			| 30 | 22 |   */
 | 
		
	
		
			
			| 31 | 23 |  #define MAX_ADDR (0xfff00000UL)
 | 
		
	
		
			
			| 32 | 24 |  
 | 
		
	
		
			
			|  | 25 | +/* Preserve alignment to a 4kB page
 | 
		
	
		
			
			|  | 26 | + *
 | 
		
	
		
			
			|  | 27 | + * Required for x86_64, and doesn't hurt for i386.
 | 
		
	
		
			
			|  | 28 | + */
 | 
		
	
		
			
			|  | 29 | +#define ALIGN 4096
 | 
		
	
		
			
			|  | 30 | +
 | 
		
	
		
			
			| 33 | 31 |  /**
 | 
		
	
		
			
			| 34 | 32 |   * Relocate iPXE
 | 
		
	
		
			
			| 35 | 33 |   *
 | 
		
	
	
		
			
			|  | @@ -53,11 +51,11 @@ __asmcall void relocate ( struct i386_all_regs *ix86 ) {
 | 
		
	
		
			
			| 53 | 51 |  	start = virt_to_phys ( _textdata );
 | 
		
	
		
			
			| 54 | 52 |  	end = virt_to_phys ( _etextdata );
 | 
		
	
		
			
			| 55 | 53 |  	size = ( end - start );
 | 
		
	
		
			
			| 56 |  | -	padded_size = ( size + max_align - 1 );
 | 
		
	
		
			
			|  | 54 | +	padded_size = ( size + ALIGN - 1 );
 | 
		
	
		
			
			| 57 | 55 |  
 | 
		
	
		
			
			| 58 | 56 |  	DBG ( "Relocate: currently at [%x,%x)\n"
 | 
		
	
		
			
			| 59 |  | -	      "...need %x bytes for %zd-byte alignment\n",
 | 
		
	
		
			
			| 60 |  | -	      start, end, padded_size, max_align );
 | 
		
	
		
			
			|  | 57 | +	      "...need %x bytes for %d-byte alignment\n",
 | 
		
	
		
			
			|  | 58 | +	      start, end, padded_size, ALIGN );
 | 
		
	
		
			
			| 61 | 59 |  
 | 
		
	
		
			
			| 62 | 60 |  	/* Determine maximum usable address */
 | 
		
	
		
			
			| 63 | 61 |  	max = MAX_ADDR;
 | 
		
	
	
		
			
			|  | @@ -125,7 +123,7 @@ __asmcall void relocate ( struct i386_all_regs *ix86 ) {
 | 
		
	
		
			
			| 125 | 123 |  	 * required alignemnt.
 | 
		
	
		
			
			| 126 | 124 |  	 */
 | 
		
	
		
			
			| 127 | 125 |  	new_start = new_end - padded_size;
 | 
		
	
		
			
			| 128 |  | -	new_start += ( start - new_start ) & ( max_align - 1 );
 | 
		
	
		
			
			|  | 126 | +	new_start += ( ( start - new_start ) & ( ALIGN - 1 ) );
 | 
		
	
		
			
			| 129 | 127 |  	new_end = new_start + size;
 | 
		
	
		
			
			| 130 | 128 |  
 | 
		
	
		
			
			| 131 | 129 |  	DBG ( "Relocating from [%x,%x) to [%x,%x)\n",
 |