[PATCH gnumach 1/2] yyy sysenter prototype

2015-05-06 Thread Justus Winter
---
 i386/Makefrag.am|   2 +
 i386/i386/gdt.c |  17 
 i386/i386/gdt.h |   7 +-
 i386/i386/i386asm.sym   |   1 +
 i386/i386/locore.S  | 224 
 i386/i386/pcb.c |  24 +++---
 i386/i386/syscall.c | 103 ++
 i386/i386/syscall.h |   7 ++
 i386/i386/tss.h |   1 +
 i386/i386at/conf.c  |   8 ++
 i386/i386at/model_dep.c |   2 +
 11 files changed, 383 insertions(+), 13 deletions(-)
 create mode 100644 i386/i386/syscall.c
 create mode 100644 i386/i386/syscall.h

diff --git a/i386/Makefrag.am b/i386/Makefrag.am
index 4dd6a9f..f59ac29 100644
--- a/i386/Makefrag.am
+++ b/i386/Makefrag.am
@@ -147,6 +147,8 @@ libkernel_a_SOURCES += \
i386/i386/setjmp.h \
i386/i386/spl.S \
i386/i386/spl.h \
+   i386/i386/syscall.c \
+   i386/i386/syscall.h \
i386/i386/task.h \
i386/i386/thread.h \
i386/i386/time_stamp.h \
diff --git a/i386/i386/gdt.c b/i386/i386/gdt.c
index c895eb3..0f9d0e3 100644
--- a/i386/i386/gdt.c
+++ b/i386/i386/gdt.c
@@ -57,6 +57,23 @@ gdt_init(void)
LINEAR_MIN_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS,
LINEAR_MAX_KERNEL_ADDRESS - 
(LINEAR_MIN_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) - 1,
ACC_PL_K|ACC_DATA_W, SZ_32);
+   fill_gdt_descriptor(KERNEL_ENTER_CS,
+   LINEAR_MIN_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS,
+   LINEAR_MAX_KERNEL_ADDRESS - 
(LINEAR_MIN_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) - 1,
+   ACC_PL_K|ACC_CODE_R, SZ_32);
+   fill_gdt_descriptor(KERNEL_ENTER_DS,
+   LINEAR_MIN_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS,
+   LINEAR_MAX_KERNEL_ADDRESS - 
(LINEAR_MIN_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) - 1,
+   ACC_PL_K|ACC_DATA_W, SZ_32);
+   fill_gdt_descriptor(USER_EXIT_CS,
+   VM_MIN_ADDRESS,
+   VM_MAX_ADDRESS-VM_MIN_ADDRESS-4096,
+   /* XXX LINEAR_... */
+   ACC_PL_U|ACC_CODE_R, SZ_32);
+   fill_gdt_descriptor(USER_EXIT_DS,
+   VM_MIN_ADDRESS,
+   VM_MAX_ADDRESS-VM_MIN_ADDRESS-4096,
+   ACC_PL_U|ACC_DATA_W, SZ_32);
 #ifndefMACH_PV_DESCRIPTORS
fill_gdt_descriptor(LINEAR_DS,
0,
diff --git a/i386/i386/gdt.h b/i386/i386/gdt.h
index d865640..37ca6f5 100644
--- a/i386/i386/gdt.h
+++ b/i386/i386/gdt.h
@@ -55,7 +55,12 @@
 #defineUSER_GDT0x48/* user-defined GDT entries */
 #defineUSER_GDT_SLOTS  2
 
-#defineGDTSZ   (USER_GDT/8 + USER_GDT_SLOTS)
+#defineKERNEL_ENTER_CS (0x58 | SEL_PL_K)   /* kernel code 
*/
+#defineKERNEL_ENTER_DS (0x60 | SEL_PL_K)   /* kernel data 
*/
+#defineUSER_EXIT_CS(0x68 | SEL_PL_U)   /* user code */
+#defineUSER_EXIT_DS(0x70 | SEL_PL_U)   /* user data */
+
+#defineGDTSZ   (USER_EXIT_DS/8 + 1)
 
 extern struct real_descriptor gdt[GDTSZ];
 
diff --git a/i386/i386/i386asm.sym b/i386/i386/i386asm.sym
index dd1a2ed..e495d1a 100644
--- a/i386/i386/i386asm.sym
+++ b/i386/i386/i386asm.sym
@@ -70,6 +70,7 @@ size  i386_kernel_state   iks
 
 size   i386_exception_link iel
 
+size   i386_saved_stateiss
 offset i386_saved_stater   cs
 offset i386_saved_stater   uesp
 offset i386_saved_stater   eax
diff --git a/i386/i386/locore.S b/i386/i386/locore.S
index cfda86f..d8241a7 100644
--- a/i386/i386/locore.S
+++ b/i386/i386/locore.S
@@ -521,6 +521,9 @@ _return_to_user:
  */
 
 _return_from_kernel:
+   cmpl$0x7fff, R_TRAPNO(%esp) /* YYY */
+   je  return_from_sysenter
+
 _kret_popl_gs:
popl%gs /* restore segment registers */
 _kret_popl_fs:
@@ -978,6 +981,18 @@ ttd_from_iret_i:   /* on interrupt stack */
 
 #endif /* MACH_TTD */
 
+/* User stub for calling the kernel using the trap gate.  */
+   .globl user_trapgate_stub_start
+user_trapgate_stub_start:
+   popl %ecx   /* Pop return address into %ecx.  */
+   popl %eax   /* Pop syscall number into %eax.  */
+   pushl %ecx  /* Push back return address.  */
+   lcall $7, $0
+   subl $4, %esp   /* magic */
+   ret
+   .globl user_trapgate_stub_end
+user_trapgate_stub_end:
+
 /*
  * System call enters through a call gate.  Flags are not saved -
  * we must shuffle stack to look like trap save area.
@@ -1170,6 +1185,215 @@ syscall_addr:
/* set error code - read user space */
jmp _take_trap  /* treat as a trap */
 
+/*
+ * 

[PATCH gnumach 2/2] yyy i386: less magic

2015-05-06 Thread Justus Winter
---
 i386/i386/pcb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c
index 2da3804..888012c 100644
--- a/i386/i386/pcb.c
+++ b/i386/i386/pcb.c
@@ -96,7 +96,7 @@ void stack_attach(
/*
 *  Point top of kernel stack to user`s registers.
 */
-   STACK_IEL(stack)-saved_state = thread-pcb-iss;
+   STACK_IEL(stack)-saved_state = USER_REGS(thread);
 }
 
 /*
@@ -298,7 +298,7 @@ void stack_handoff(
 *  user registers.
 */
 
-   STACK_IEL(stack)-saved_state = new-pcb-iss;
+   STACK_IEL(stack)-saved_state = USER_REGS(new);
 
 }
 
-- 
2.1.4




Re: 'struct flock' has no member named 'l_end'

2015-05-06 Thread Samuel Thibault
Hello,

Manolis Ragkousis, le Wed 08 Apr 2015 22:21:42 +0300, a écrit :
 in libpthread commit
 8b48173fdc8f52a234ff9d3d1de5277c60d7eea4 the
 Makefile expects shm-directory.c to be present in
 sysdeps/generic/ but it is not.
 
 This file only exists in glibc 2.21 and is not yet
 implemented in our libpthread.

I have created a master-glibc-2.21 branch to host these glibc 2.21
changes, and reverted them from master. Master should thus be buildable
again against our glibc tree (I'm testing it now, so we can build
tarballs)

Samuel



Re: [PATCH gnumach 2/2] yyy i386: less magic

2015-05-06 Thread Justus Winter
Quoting Samuel Thibault (2015-05-06 21:10:08)
 Please already apply this one :)

Yes, I would have done that all by myself, it just happened to be in
that branch...

Cheers,
Justus



Re: GSoC: Manolis to work on Guix port to GNU/Hurd

2015-05-06 Thread Samuel Thibault
Hello,

Ludovic Courtès, le Wed 29 Apr 2015 21:40:13 +0200, a écrit :
 The last missing bit upstream is a libc-for-hurd tarball.

I have prepared a master-glibc branch in the libpthread repo.

$ git clone git.savannah.gnu.org:/srv/git/hurd/glibc.git/
$ cd glibc
$ git checkout tschwinge/Roger_Whittaker
$ git clone git.savannah.gnu.org:/srv/git/hurd/libpthread.git/
$ cd libpthread
$ git checkout master-glibc
$ cd ..
$ mkdir build
$ cd build
$ CFLAGS=-O2 ../configure --prefix=/ --enable-add-ons=libpthread 
--enable-pt_chown --disable-nscd
$ make
$ make check -k

seems to be going fine.  Thomas, can you have a look at uploading a
tarball of this so it can be used as a base for Guix?

Samuel



Re: Test case for fakeroot-hurd failure with a socket

2015-05-06 Thread Samuel Thibault
Hello,

Svante Signell, le Mon 04 May 2015 14:14:16 +0200, a écrit :
 Attached is the test code where fakeroot-hurd fails.
 fakeroot-hurd ./test_sockets
 bind: Operation not supported

Mmm, I don't think we want to implement it in netfs_attempt_chmod
as you are trying to do. See the code netfs_S_file_set_translator:
netfs_attempt_chmod() is called only because it's the Short circuited
translators case, i.e. when the FS can perhaps store the translator
directly in the mode. You only stored the mode in np-nn_stat.st_mode,
without calling some file_* function to actually make the change on the
underlying FS. That's why you end up with:

   67--66(pid9244)-file_set_translator (6 6 0 /hurd/ifsock  (null)) =
 0x402d (Operation not supported) 

Since the underlying node is still a normal file. You also can't just
call file_chmod since that won't change the file type.

Thus, do not modify netfs_attempt_chmod, rather implement the
netfs_set_translator stub by just calling file_set_translator on the
underlying node to set the passive translator.

Thanks,
Samuel



Re: [PATCH mig] Explicitly use gnu_inline semantics for x_server_routine functions

2015-05-06 Thread Samuel Thibault
David Michael, le Tue 05 May 2015 16:33:45 -0400, a écrit :
 Does anyone foresee problems with this method?

Well, that imposes using a gcc compiler.  But we can probably use static
inline instead?

Samuel



Re: [PATCH gnumach 2/2] yyy i386: less magic

2015-05-06 Thread Samuel Thibault
Hello,

Please already apply this one :)

Samuel