tag 568176 patch
thanks

-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko

diff -ur memtest86+-4.20/head.S memtest86+-4.20-mod/head.S
--- memtest86+-4.20/head.S	2012-04-12 21:42:42.000000000 +0200
+++ memtest86+-4.20-mod/head.S	2012-04-12 21:45:24.639055516 +0200
@@ -17,7 +17,7 @@
 #include "defs.h"
 #include "config.h"
 #include "test.h"
-#include "multiboot.h"
+#include "multiboot_impl.h"
 
 /*
  * References to members of the boot_cpu_data structure.
@@ -78,7 +78,33 @@
 	/* Move MBI pointer to a safe place */
 	testl	%ecx, %ecx
 	je	0f
-	movl	%ecx, mbiptr@GOTOFF(%ebx)
+	movl    $1, have_mbi@GOTOFF(%ebx)
+	leal    mbi@GOTOFF(%ebx), %edi
+	movl    %ecx, %esi
+	mov     %ecx, %edx
+	movl    0(%esi), %eax
+	movl    $(MAX_MBI_SIZE / 4), %ecx
+	rep     movsl
+	test    $MULTIBOOT_INFO_CMDLINE, %eax
+	jz      1f
+	movl    %edx, %esi
+	movl    0x10(%esi), %eax
+	movl    %eax, %esi
+	leal    mbi_cmdline@GOTOFF(%ebx), %edi
+	movl    $(MAX_MBI_CMDLINE_SIZE / 4), %ecx
+	rep     movsl	
+1:
+	movl    %edx, %esi
+	movl    0(%esi), %eax
+	test    $MULTIBOOT_INFO_MEM_MAP, %eax
+	jz      1f
+	movl    0x30(%esi), %eax
+	movl    %eax, %esi
+	leal    mbi_mem@GOTOFF(%ebx), %edi
+	movl    $(MAX_MBI_MEMINFO_SIZE / 4), %ecx
+	rep     movsl	
+1:
+
 0:
 
 	jmp	0f
@@ -1026,9 +1052,6 @@
 	movl	$1, %eax
 	ret
 
-.globl mbiptr
-mbiptr:
-	.long	0
 realptr:
 	.word	real - RSTART
 	.word	0x0000
@@ -1041,6 +1064,19 @@
 	.word	0, 0				# idt base = 0L
 
 .data
+.globl have_mbi
+have_mbi:
+	.long	0
+.globl mbi
+mbi:
+	. = . + MAX_MBI_SIZE
+.globl mbi_mem
+mbi_mem:	
+	. = . + MAX_MBI_MEMINFO_SIZE
+.globl mbi_cmdline
+mbi_cmdline:
+	. = . + MAX_MBI_CMDLINE_SIZE
+	.long   0
 zerobss:	.long	1
 clear_display:	.long	1
 .previous
diff -ur memtest86+-4.20/main.c memtest86+-4.20-mod/main.c
--- memtest86+-4.20/main.c	2012-04-12 21:42:42.000000000 +0200
+++ memtest86+-4.20-mod/main.c	2012-04-12 21:45:03.863056181 +0200
@@ -11,12 +11,10 @@
 #include "test.h"
 #include "defs.h"
 #include "config.h"
-#include "multiboot.h"
+#include "multiboot_impl.h"
 #undef TEST_TIMES
 #define DEFTESTS 9
 
-extern struct multiboot_info *mbiptr;
-
 extern void bzero();
 
 const struct tseq tseq[] = {
@@ -154,8 +152,8 @@
 	if (cmdline_parsed)
 		return;
 
-	if (mbiptr && (mbiptr->flags & MULTIBOOT_INFO_CMDLINE)) {
-		cmdline = (void *) mbiptr->cmdline;
+	if (have_mbi && (mbi.flags & MULTIBOOT_INFO_CMDLINE)) {
+		cmdline = mbi_cmdline;
 	} else {
 		if (*OLD_CL_MAGIC_ADDR != OLD_CL_MAGIC)
 			return;
diff -ur memtest86+-4.20/memtest.lds memtest86+-4.20-mod/memtest.lds
--- memtest86+-4.20/memtest.lds	2011-01-23 19:11:04.000000000 +0100
+++ memtest86+-4.20-mod/memtest.lds	2012-04-12 21:42:14.887061839 +0200
@@ -3,7 +3,7 @@
 
 ENTRY(_start); 
 SECTIONS {
-	. = 0x5000;
+	. = 0x2000;
 	_start = . ;
 	.data : {
 		*(.data)
diff -ur memtest86+-4.20/multiboot.c memtest86+-4.20-mod/multiboot.c
--- memtest86+-4.20/multiboot.c	2012-04-12 21:42:42.000000000 +0200
+++ memtest86+-4.20-mod/multiboot.c	2012-04-12 21:42:14.887061839 +0200
@@ -8,31 +8,33 @@
  * By Eric Biederman
  */
 
-#include "multiboot.h"
+#include "multiboot_impl.h"
 #include "test.h"
 
-extern struct multiboot_info *mbiptr;
-
 int query_multiboot(void)
 {
 	struct multiboot_mmap_entry *mem;
 	int i;
 
-	if (!mbiptr) {
+	if (!have_mbi) {
 		return 0;
 	}
-	if (!mbiptr->mmap_addr) {
+	if (!mbi.mmap_addr) {
 		return 1;
 	}
-	if ((mbiptr->flags & MULTIBOOT_INFO_MEM_MAP) == 0) {
+	if ((mbi.flags & MULTIBOOT_INFO_MEM_MAP) == 0) {
 		return 1;
 	}
 
-	mem = (struct multiboot_mmap_entry *) mbiptr->mmap_addr;
+	mem = mbi_mem;
 	mem_info.e820_nr = 0;
 
 	for (i = 0; i < E820MAX; i++) {
-		if ((multiboot_uint32_t) mem >= (mbiptr->mmap_addr + mbiptr->mmap_length)) {
+		if ((char *) mem >= ((char *) mbi_mem + mbi.mmap_length)
+		    || (char *) mem + sizeof (mem->size)
+		    > ((char *) mbi_mem + MAX_MBI_MEMINFO_SIZE)
+		    || (char *) mem + mem->size + sizeof (mem->size)
+		    > ((char *) mbi_mem + MAX_MBI_MEMINFO_SIZE)) {
 			break;
 		}
 
--- memtest86+-4.20/multiboot_impl.h	1970-01-01 01:00:00.000000000 +0100
+++ memtest86+-4.20-mod/multiboot_impl.h	2012-04-12 21:42:14.887061839 +0200
@@ -0,0 +1,15 @@
+#include "multiboot.h"
+
+#define MAX_MBI_SIZE 256
+#define MAX_MBI_MEMINFO_SIZE 1024
+#define MAX_MBI_CMDLINE_SIZE 256
+
+#ifndef ASM_FILE
+
+extern int have_mbi;
+
+extern struct multiboot_info mbi;
+extern char mbi_cmdline[MAX_MBI_SIZE + 1];
+extern struct multiboot_mmap_entry mbi_mem[];
+
+#endif

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to