Skip to contentSkip to conversation

missing asm/user.h

uml-devel Daniel Gryniewicz 2 participants 6 messages Mar 24, 2007 – Mar 27, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi, all.

In their infinite wisdom, the Gentoo kernel team has decided to not ship asm/user.h with the kernel headers package anymore. Since UML (even, as far as I can tell, in the most recent versions) uses this in several places, is there a way around this? Are there plans to remove this need, or to use the ones from the UML kernel tree, or something?

Daniel

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#1 lore raw
Quoted 5 lines · Daniel Gryniewicz

In their infinite wisdom, the Gentoo kernel team has decided to not ship asm/user.h with the kernel headers package anymore. Since UML (even, as far as I can tell, in the most recent versions) uses this in several places, is there a way around this? Are there plans to remove this need, or to use the ones from the UML kernel tree, or something?

This came up on IRC a week or so ago, but the conclusion then was that this was a botch on their part since other distro headers still included it, and became unusable as a result.

BTW, several of the occurrences are in kernelspace files, which aren't affected by distro libc burps.

I have a patch ready in case this is for real, attached below. It takes care of the i386 side of things - there's an x86_64 include which I ignored for now.

Do you believe that this is going to be permanent, or just a gyration in the Gentoo kernel package?

Jeff

Signature · 38 lines
Work email - jdike at linux dot intel dot com

Index: linux-2.6.21-mm/arch/um/sys-i386/user-offsets.c
===================================================================
--- linux-2.6.21-mm.orig/arch/um/sys-i386/user-offsets.c	2007-03-23 15:05:29.000000000 -0400
+++ linux-2.6.21-mm/arch/um/sys-i386/user-offsets.c	2007-03-24 21:18:44.000000000 -0400
@@ -1,7 +1,7 @@
 #include <stdio.h>
 #include <signal.h>
 #include <asm/ptrace.h>
-#include <asm/user.h>
+#include <asm/elf.h>
 #include <stddef.h>
 #include <sys/poll.h>
 
Index: linux-2.6.21-mm/arch/um/sys-i386/ptrace_user.c
===================================================================
--- linux-2.6.21-mm.orig/arch/um/sys-i386/ptrace_user.c	2007-03-24 21:18:44.000000000 -0400
+++ linux-2.6.21-mm/arch/um/sys-i386/ptrace_user.c	2007-03-24 21:20:44.000000000 -0400
@@ -8,8 +8,6 @@
 #include <errno.h>
 #include <unistd.h>
 #include "ptrace_user.h"
-/* Grr, asm/user.h includes asm/ptrace.h, so has to follow ptrace_user.h */
-#include <asm/user.h>
 #include "kern_util.h"
 #include "sysdep/thread.h"
 #include "user.h"

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#2 lore raw
Quoted 7 lines · Jeff Dike
Quoted 5 lines · Daniel Gryniewicz

In their infinite wisdom, the Gentoo kernel team has decided to not ship asm/user.h with the kernel headers package anymore. Since UML (even, as far as I can tell, in the most recent versions) uses this in several places, is there a way around this? Are there plans to remove this need, or to use the ones from the UML kernel tree, or something?

Quoted 6 lines

This came up on IRC a week or so ago, but the conclusion then was that this was a botch on their part since other distro headers still included it, and became unusable as a result.

BTW, several of the occurrences are in kernelspace files, which aren't affected by distro libc burps.

These, of course, should be fine.

Quoted 3 lines

I have a patch ready in case this is for real, attached below. It takes care of the i386 side of things - there's an x86_64 include which I ignored for now.

Thanks for the patch. I'll try it out.

Quoted 2 lines

Do you believe that this is going to be permanent, or just a gyration in the Gentoo kernel package?

They are adamant that this is the correct thing to do and the headers won't be going back in. This means I'll have to work around the problem in the UML package. Hopefully, your patch will be enough.

Daniel

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#3 lore raw
In reply to Jeff Dike
Quoted 11 lines · Jeff Dike
Quoted 5 lines · Daniel Gryniewicz

In their infinite wisdom, the Gentoo kernel team has decided to not ship asm/user.h with the kernel headers package anymore. Since UML (even, as far as I can tell, in the most recent versions) uses this in several places, is there a way around this? Are there plans to remove this need, or to use the ones from the UML kernel tree, or something?

This came up on IRC a week or so ago, but the conclusion then was that this was a botch on their part since other distro headers still included it, and became unusable as a result.

Update: <asm/elf.h> isn't there either, but <sys/user.h> includes user_regs_struct, so that's sufficient for this problem.

The next problem is lack of <asm/page.h>. Most files failing to build with it can simply have it removed. I've temporarily replaced PAGE_SIZE with sysconf(_SC_PAGESIZE) for now, and we'll see how that works.

Daniel

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#4 lore raw
Quoted 2 lines · Daniel Gryniewicz

Update: <asm/elf.h> isn't there either, but <sys/user.h> includes user_regs_struct, so that's sufficient for this problem.

Hummph, I hope that's true of every other distro that people use UML on.

Quoted 3 lines

The next problem is lack of <asm/page.h>. Most files failing to build with it can simply have it removed. I've temporarily replaced PAGE_SIZE with sysconf(_SC_PAGESIZE) for now, and we'll see how that works.

Send patches.

BTW, the important thing about PAGE_SIZE in the userspace side of UML is not that it be the same as sysconf(_SC_PAGESIZE) but that it match the value of PAGE_SIZE in the kernelspace side. Obviously, these values will all be the same everywhere that we care about now, but I can think of one or two situations where it would matter. On an architecture with a variable page size, the UML kernel can have a PAGE_SIZE of 64K but the host's sysconf can report a page size of 4K. In this case, it's important that PAGE_SIZE in UML userspace code be 64K.

So, there's UM_KERN_PAGE_SIZE in kern_constants.h which is derived from the kernel's PAGE_SIZE and is usable in userspace files. Use that instead of sysconf().

Jeff

Signature · 11 lines
Work email - jdike at linux dot intel dot com

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#5 lore raw
Quoted 5 lines · Jeff Dike
Quoted 2 lines · Daniel Gryniewicz

Update: <asm/elf.h> isn't there either, but <sys/user.h> includes user_regs_struct, so that's sufficient for this problem.

Hummph, I hope that's true of every other distro that people use UML on.

Bad news: It has user_regs_struct, but not user_i387_struct or user_fxsr_struct (at least not on x86_64).

Quoted 16 lines
Quoted 3 lines

The next problem is lack of <asm/page.h>. Most files failing to build with it can simply have it removed. I've temporarily replaced PAGE_SIZE with sysconf(_SC_PAGESIZE) for now, and we'll see how that works.

Send patches.

BTW, the important thing about PAGE_SIZE in the userspace side of UML is not that it be the same as sysconf(_SC_PAGESIZE) but that it match the value of PAGE_SIZE in the kernelspace side. Obviously, these values will all be the same everywhere that we care about now, but I can think of one or two situations where it would matter. On an architecture with a variable page size, the UML kernel can have a PAGE_SIZE of 64K but the host's sysconf can report a page size of 4K. In this case, it's important that PAGE_SIZE in UML userspace code be 64K.

Quoted 3 lines

So, there's UM_KERN_PAGE_SIZE in kern_constants.h which is derived from the kernel's PAGE_SIZE and is usable in userspace files. Use that instead of sysconf().

Thanks for the pointer. Here's a patch I've used to test. There are two problems with it. First, as mentioned above, I couldn't find two user structs anywhere in the gentoo headers. It's possibly we could convince the maintainers to add those back, since they're for gdb. I'm not sure, tho, so I just defined them inline for now.

Second, PAGE_MASK and PAGE_SHIFT. These should be generated like UM_KERN_PAGE_SIZE above, but I wasn't able to find where they're generated (sorry, not up on my Kconfig magic...).

That said, the patch *does* work here on my x86_64 box, both in native and on SUBARCH=i386 modes. I don't have any more exotic arches than that to test on.

Daniel

arch/um/include/sysdep-i386/stub.h +0 -1
diff --exclude-from=/home/dang/bin/scripts/diffrc -up -ruN linux-2.6.20.orig/arch/um/include/sysdep-i386/stub.h linux-2.6.20/arch/um/include/sysdep-i386/stub.h
@@ -9,7 +9,6 @@
 #include <sys/mman.h>
 #include <asm/ptrace.h>
 #include <asm/unistd.h>
-#include <asm/page.h>
 #include "stub-data.h"
 #include "kern_constants.h"
 #include "uml-config.h"
arch/um/kernel/skas/clone.c +0 -1
diff --exclude-from=/home/dang/bin/scripts/diffrc -up -ruN linux-2.6.20.orig/arch/um/kernel/skas/clone.c linux-2.6.20/arch/um/kernel/skas/clone.c
@@ -3,7 +3,6 @@
 #include <sys/mman.h>
 #include <sys/time.h>
 #include <asm/unistd.h>
-#include <asm/page.h>
 #include "ptrace_user.h"
 #include "skas.h"
 #include "stub-data.h"
arch/um/os-Linux/main.c +0 -1
diff --exclude-from=/home/dang/bin/scripts/diffrc -up -ruN linux-2.6.20.orig/arch/um/os-Linux/main.c linux-2.6.20/arch/um/os-Linux/main.c
@@ -12,7 +12,6 @@
 #include <sys/resource.h>
 #include <sys/mman.h>
 #include <sys/user.h>
-#include <asm/page.h>
 #include "user_util.h"
 #include "kern_util.h"
 #include "mem_user.h"
arch/um/os-Linux/skas/mem.c +4 -3
diff --exclude-from=/home/dang/bin/scripts/diffrc -up -ruN linux-2.6.20.orig/arch/um/os-Linux/skas/mem.c linux-2.6.20/arch/um/os-Linux/skas/mem.c
@@ -8,7 +8,6 @@
 #include <string.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
-#include <asm/page.h>
 #include <asm/unistd.h>
 #include "mem_user.h"
 #include "mem.h"
@@ -109,6 +108,8 @@ static inline long do_syscall_stub(struc
 	return ret;
 }
 
+#define PAGE_MASK   (~(UM_KERN_PAGE_SIZE-1))
+#define PAGE_SHIFT  12
 long run_syscall_stub(struct mm_id * mm_idp, int syscall,
 		      unsigned long *args, long expected, void **addr,
 		      int done)
@@ -133,7 +134,7 @@ long run_syscall_stub(struct mm_id * mm_
 	multi_op_count++;
 
 	if(!done && ((((unsigned long) stack) & ~PAGE_MASK) <
-		     PAGE_SIZE - 10 * sizeof(long))){
+		     UM_KERN_PAGE_SIZE - 10 * sizeof(long))){
 		*addr = stack;
 		return 0;
 	}
@@ -152,7 +153,7 @@ long syscall_stub_data(struct mm_id * mm
 	 * Thus in this case do_syscall_stub correctly won't be called.
 	 */
 	if((((unsigned long) *addr) & ~PAGE_MASK) >=
-	   PAGE_SIZE - (10 + data_count) * sizeof(long)) {
+	   UM_KERN_PAGE_SIZE - (10 + data_count) * sizeof(long)) {
 		ret = do_syscall_stub(mm_idp, addr);
 		/* in case of error, don't overwrite data on stack */
 		if(ret)
arch/um/os-Linux/start_up.c +3 -4
diff --exclude-from=/home/dang/bin/scripts/diffrc -up -ruN linux-2.6.20.orig/arch/um/os-Linux/start_up.c linux-2.6.20/arch/um/os-Linux/start_up.c
@@ -18,7 +18,6 @@
 #include <sys/wait.h>
 #include <sys/mman.h>
 #include <asm/unistd.h>
-#include <asm/page.h>
 #include <sys/types.h>
 #include "user_util.h"
 #include "kern_util.h"
@@ -79,11 +78,11 @@ static int start_ptraced_child(void **st
 	unsigned long sp;
 	int pid, n, status;
 
-	stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
+	stack = mmap(NULL, UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
 		     MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
 	if(stack == MAP_FAILED)
 		panic("check_ptrace : mmap failed, errno = %d", errno);
-	sp = (unsigned long) stack + PAGE_SIZE - sizeof(void *);
+	sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *);
 	pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL);
 	if(pid < 0)
 		panic("start_ptraced_child : clone failed, errno = %d", errno);
@@ -128,7 +127,7 @@ static int stop_ptraced_child(int pid, v
 		ret = -1;
 	}
 
-	if(munmap(stack, PAGE_SIZE) < 0)
+	if(munmap(stack, UM_KERN_PAGE_SIZE) < 0)
 		panic("check_ptrace : munmap failed, errno = %d", errno);
 	return ret;
 }
arch/um/sys-i386/ptrace_user.c +1 -2
diff --exclude-from=/home/dang/bin/scripts/diffrc -up -ruN linux-2.6.20.orig/arch/um/sys-i386/ptrace_user.c linux-2.6.20/arch/um/sys-i386/ptrace_user.c
@@ -7,9 +7,8 @@
 #include <stddef.h>
 #include <errno.h>
 #include <unistd.h>
+#include <sys/user.h>
 #include "ptrace_user.h"
-/* Grr, asm/user.h includes asm/ptrace.h, so has to follow ptrace_user.h */
-#include <asm/user.h>
 #include "kern_util.h"
 #include "sysdep/thread.h"
 #include "user.h"
arch/um/sys-i386/user-offsets.c +29 -1
diff --exclude-from=/home/dang/bin/scripts/diffrc -up -ruN linux-2.6.20.orig/arch/um/sys-i386/user-offsets.c linux-2.6.20/arch/um/sys-i386/user-offsets.c
@@ -1,7 +1,7 @@
 #include <stdio.h>
 #include <signal.h>
 #include <asm/ptrace.h>
-#include <asm/user.h>
+#include <sys/user.h>
 #include <stddef.h>
 #include <sys/poll.h>
 
@@ -14,6 +14,34 @@
 #define OFFSET(sym, str, mem) \
 	DEFINE(sym, offsetof(struct str, mem));
 
+/* These are gone from userspace; not sure where to pull them from */
+struct user_i387_struct {
+	long	cwd;
+	long	swd;
+	long	twd;
+	long	fip;
+	long	fcs;
+	long	foo;
+	long	fos;
+	long	st_space[20];	/* 8*10 bytes for each FP-reg = 80 bytes */
+};
+
+struct user_fxsr_struct {
+	unsigned short	cwd;
+	unsigned short	swd;
+	unsigned short	twd;
+	unsigned short	fop;
+	long	fip;
+	long	fcs;
+	long	foo;
+	long	fos;
+	long	mxcsr;
+	long	reserved;
+	long	st_space[32];	/* 8*16 bytes for each FP-reg = 128 bytes */
+	long	xmm_space[32];	/* 8*16 bytes for each XMM-reg = 128 bytes */
+	long	padding[56];
+};
+
 void foo(void)
 {
 	OFFSET(HOST_SC_IP, sigcontext, eip);
arch/um/sys-x86_64/user-offsets.c +1 -1
diff --exclude-from=/home/dang/bin/scripts/diffrc -up -ruN linux-2.6.20.orig/arch/um/sys-x86_64/user-offsets.c linux-2.6.20/arch/um/sys-x86_64/user-offsets.c
@@ -12,7 +12,7 @@
  */
 typedef __u64 u64;
 typedef __u32 u32;
-#include <asm/user.h>
+#include <sys/user.h>
 
 #define DEFINE(sym, val) \
         asm volatile("\n->" #sym " %0 " #val : : "i" (val))

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel