rpms/libx86/F-12 libx86-mmap-offset.patch, NONE, 1.1 libx86.spec, 1.8, 1.9

Adam Jackson ajax at fedoraproject.org
Tue Nov 17 19:34:25 UTC 2009


Author: ajax

Update of /cvs/pkgs/rpms/libx86/F-12
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv18778

Modified Files:
	libx86.spec 
Added Files:
	libx86-mmap-offset.patch 
Log Message:
sync with devel

libx86-mmap-offset.patch:
 lrmi.c       |    2 +-
 thunk.c      |   12 ++++++------
 x86-common.c |   47 +++++++++++++++++++++++++++--------------------
 x86-common.h |    2 +-
 4 files changed, 35 insertions(+), 28 deletions(-)

--- NEW FILE libx86-mmap-offset.patch ---
diff -ur libx86-1.1/lrmi.c libx86-1.1.hack/lrmi.c
--- libx86-1.1/lrmi.c	2006-10-30 15:10:16.000000000 -0500
+++ libx86-1.1.hack/lrmi.c	2009-10-26 15:55:42.000000000 -0400
@@ -136,7 +136,7 @@
 	if (context.ready)
 		return 1;
 
-	if (!LRMI_common_init())
+	if (!LRMI_common_init(0))
 		return 0;
 
 	/*
diff -ur libx86-1.1/thunk.c libx86-1.1.hack/thunk.c
--- libx86-1.1/thunk.c	2008-04-02 20:48:00.000000000 -0400
+++ libx86-1.1.hack/thunk.c	2009-10-26 16:05:39.000000000 -0400
@@ -139,11 +139,11 @@
 	int i;
 	X86EMU_intrFuncs intFuncs[256];
 
-	if (!LRMI_common_init())
+	mmap_addr = LRMI_common_init(1);
+
+	if (!mmap_addr)
 		return 0;
 
-	mmap_addr = 0;
-	
 	X86EMU_pioFuncs pioFuncs = {
 		(&x_inb),
 		(&x_inw),
@@ -169,10 +169,10 @@
 	X86_ESP = 0xFFF9;
 	memset (stack, 0, 64*1024);
 
-	*((char *)0) = 0x4f; /* Make sure that we end up jumping back to a
-				halt instruction */
+	*mmap_addr = 0x4f; /* Make sure that we end up jumping back to a
+			      halt instruction */
 
-	M.mem_base = 0;
+	M.mem_base = (unsigned long)mmap_addr;
 	M.mem_size = 1024*1024;
 
 	return 1;
diff -ur libx86-1.1/x86-common.c libx86-1.1.hack/x86-common.c
--- libx86-1.1/x86-common.c	2008-05-16 12:56:23.000000000 -0400
+++ libx86-1.1.hack/x86-common.c	2009-10-26 16:03:21.000000000 -0400
@@ -45,14 +45,15 @@
 static struct {
 	int ready;
 	int count;
+	void *offset;
 	struct mem_block blocks[REAL_MEM_BLOCKS];
 } mem_info = { 0 };
 
 static int
-real_mem_init(void)
+real_mem_init(int high_page)
 {
 	void *m;
-	int fd_zero;
+	int fd_zero, flags = MAP_SHARED;
 
 	if (mem_info.ready)
 		return 1;
@@ -63,9 +64,12 @@
 		return 0;
 	}
 
+	if (!high_page)
+		flags |= MAP_FIXED;
+
 	m = mmap((void *)REAL_MEM_BASE, REAL_MEM_SIZE,
-	 PROT_READ | PROT_WRITE | PROT_EXEC,
-	 MAP_FIXED | MAP_SHARED, fd_zero, 0);
+		 PROT_READ | PROT_WRITE | PROT_EXEC,
+		 flags, fd_zero, 0);
 
 	if (m == (void *)-1) {
 		perror("mmap /dev/zero");
@@ -76,6 +80,7 @@
 	close(fd_zero);
 
 	mem_info.ready = 1;
+	mem_info.offset = m;
 	mem_info.count = 1;
 	mem_info.blocks[0].size = REAL_MEM_SIZE;
 	mem_info.blocks[0].free = 1;
@@ -87,7 +92,7 @@
 real_mem_deinit(void)
 {
 	if (mem_info.ready) {
-		munmap((void *)REAL_MEM_BASE, REAL_MEM_SIZE);
+		munmap(mem_info.offset, REAL_MEM_SIZE);
 		mem_info.ready = 0;
 	}
 }
@@ -119,7 +124,7 @@
 LRMI_alloc_real(int size)
 {
 	int i;
-	char *r = (char *)REAL_MEM_BASE;
+	char *r = (char *)mem_info.offset;
 
 	if (!mem_info.ready)
 		return NULL;
@@ -151,7 +156,7 @@
 LRMI_free_real(void *m)
 {
 	int i;
-	char *r = (char *)REAL_MEM_BASE;
+	char *r = (char *)mem_info.offset;
 
 	if (!mem_info.ready)
 		return;
@@ -200,13 +205,15 @@
 	return *(unsigned short *)(i * 4);
 }
 
-int LRMI_common_init(void)
+void *LRMI_common_init(int high_page)
 {
-	void *m;
+	void *m, *offset;
 	int fd_mem;
 
-	if (!real_mem_init())
-		return 0;
+	if (!real_mem_init(high_page))
+		return NULL;
+
+	offset = mem_info.offset - REAL_MEM_BASE;
 
 	/*
 	 Map the Interrupt Vectors (0x0 - 0x400) + BIOS data (0x400 - 0x502)
@@ -217,33 +224,33 @@
 	if (fd_mem == -1) {
 		real_mem_deinit();
 		perror("open /dev/mem");
-		return 0;
+		return NULL;
 	}
 
-	m = mmap((void *)0, 0x502,
-	 PROT_READ | PROT_WRITE | PROT_EXEC,
-	 MAP_FIXED | MAP_SHARED, fd_mem, 0);
+	m = mmap(offset, 0x502,
+		 PROT_READ | PROT_WRITE | PROT_EXEC,
+		 MAP_FIXED | MAP_SHARED, fd_mem, 0);
 
 	if (m == (void *)-1) {
 		close(fd_mem);
 		real_mem_deinit();
 		perror("mmap /dev/mem");
-		return 0;
+		return NULL;
 	}
 
-	m = mmap((void *)0xa0000, 0x100000 - 0xa0000,
+	m = mmap(offset+0xa0000, 0x100000 - 0xa0000,
 	 PROT_READ | PROT_WRITE | PROT_EXEC,
 	 MAP_FIXED | MAP_SHARED, fd_mem, 0xa0000);
 
 	if (m == (void *)-1) {
-		munmap((void *)0, 0x502);
+		munmap(offset, 0x502);
 		close(fd_mem);
 		real_mem_deinit();
 		perror("mmap /dev/mem");
-		return 0;
+		return NULL;
 	}
 
 	close(fd_mem);
 
-	return 1;
+	return offset;
 }
diff -ur libx86-1.1/x86-common.h libx86-1.1.hack/x86-common.h
--- libx86-1.1/x86-common.h	2006-09-07 18:44:27.000000000 -0400
+++ libx86-1.1.hack/x86-common.h	2009-10-26 16:01:19.000000000 -0400
@@ -40,4 +40,4 @@
 
 void *LRMI_alloc_real(int size);
 void LRMI_free_real(void *m);
-int LRMI_common_init(void);
+void *LRMI_common_init(int high_page);


Index: libx86.spec
===================================================================
RCS file: /cvs/pkgs/rpms/libx86/F-12/libx86.spec,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -p -r1.8 -r1.9
--- libx86.spec	3 Sep 2009 10:02:03 -0000	1.8
+++ libx86.spec	17 Nov 2009 19:34:25 -0000	1.9
@@ -1,6 +1,6 @@
 Name:           libx86
 Version:        1.1
-Release:        7%{?dist}
+Release:        9%{?dist}
 Summary:        Library for making real-mode x86 calls
 
 Group:          System Environment/Libraries
@@ -10,9 +10,10 @@ Source0:        http://www.codon.org.uk/
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 # does not build on ppc, ppc64 and s390* yet, due to the lack of port i/o
 # redirection and video routing
-ExcludeArch:    ppc ppc64 s390 s390x
+ExcludeArch:    ppc ppc64 s390 s390x %{sparc}
 
 Patch0: libx86-add-pkgconfig.patch
+Patch1: libx86-mmap-offset.patch
 
 %description
 A library to provide support for making real-mode x86 calls with an emulated
@@ -30,6 +31,7 @@ development of programs that will use li
 %prep
 %setup -q
 %patch0 -p1
+%patch1 -p1
 
 
 %build
@@ -60,6 +62,13 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/pkgconfig/x86.pc
 
 %changelog
+* Wed Nov 04 2009 Dennis Gilmore <dennis at ausil.us> - 1.1-9
+- Exclude sparc arches
+
+* Tue Oct 27 2009 Adam Jackson <ajax at redhat.com> 1.1-8
+- libx86-mmap-offset.patch: Attempt to make selinux happy by not mmap'ing
+  the zero page.
+
 * Thu Sep 03 2009 Karsten Hopp <karsten at redhat.com> 1.1-7
 - excludearch s390, s390x where we don't have sys/io.h
 




More information about the scm-commits mailing list