summaryrefslogtreecommitdiff
path: root/debian/patches
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches')
-rw-r--r--debian/patches/series10
-rw-r--r--debian/patches/sysenter0001-xxx-sysenter-prototype.patch506
-rw-r--r--debian/patches/sysenter0002-use-pcb-stack.patch84
-rw-r--r--debian/patches/sysenter0003-XXX-i386-less-magic.patch34
-rw-r--r--debian/patches/sysenter0004-thread_syscall_return-kinda-works.patch57
-rw-r--r--debian/patches/sysenter0005-thread_syscall_return-works.patch110
-rw-r--r--debian/patches/sysenter0006-optimize.patch31
-rw-r--r--debian/patches/sysenter0007-document.patch65
-rw-r--r--debian/patches/sysenter0008-document-check-for-sysenter-at-the-right-location.patch71
-rw-r--r--debian/patches/sysenter0009-be-less-stoopid.patch38
-rw-r--r--debian/patches/sysenter0010-fix-error-handling.patch76
11 files changed, 0 insertions, 1082 deletions
diff --git a/debian/patches/series b/debian/patches/series
index 041c72c..cc6414e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -11,16 +11,6 @@ reorder-ipc_port.patch
error-handling0001-kern-gracefully-handle-resource-shortage.patch
error-handling0002-vm-gracefully-handle-resource-shortage.patch
error-handling0003-kern-gracefully-handle-resource-shortage.patch
-sysenter0001-xxx-sysenter-prototype.patch
-sysenter0002-use-pcb-stack.patch
-sysenter0003-XXX-i386-less-magic.patch
-sysenter0004-thread_syscall_return-kinda-works.patch
-sysenter0005-thread_syscall_return-works.patch
-sysenter0006-optimize.patch
-sysenter0007-document.patch
-sysenter0008-document-check-for-sysenter-at-the-right-location.patch
-sysenter0009-be-less-stoopid.patch
-sysenter0010-fix-error-handling.patch
0001-kern-import-macros.h-from-x15.patch
0002-kern-add-radix-tree-library.patch
0003-ipc-undo-manual-inlining-of-ipc_entry_X-functions.patch
diff --git a/debian/patches/sysenter0001-xxx-sysenter-prototype.patch b/debian/patches/sysenter0001-xxx-sysenter-prototype.patch
deleted file mode 100644
index d759d3c..0000000
--- a/debian/patches/sysenter0001-xxx-sysenter-prototype.patch
+++ /dev/null
@@ -1,506 +0,0 @@
-From d0002a6b8f21e9b4738663972dfb877348ee8688 Mon Sep 17 00:00:00 2001
-From: Justus Winter <4winter@informatik.uni-hamburg.de>
-Date: Mon, 27 Apr 2015 11:05:52 +0200
-Subject: [PATCH gnumach 01/10] xxx sysenter prototype
-
----
- i386/Makefrag.am | 2 +
- i386/i386/gdt.c | 17 +++++
- i386/i386/gdt.h | 7 +-
- i386/i386/locore.S | 177 ++++++++++++++++++++++++++++++++++++++++++++++++
- 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 +
- 10 files changed, 335 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);
- #ifndef MACH_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 @@
- #define USER_GDT 0x48 /* user-defined GDT entries */
- #define USER_GDT_SLOTS 2
-
--#define GDTSZ (USER_GDT/8 + USER_GDT_SLOTS)
-+#define KERNEL_ENTER_CS (0x58 | SEL_PL_K) /* kernel code */
-+#define KERNEL_ENTER_DS (0x60 | SEL_PL_K) /* kernel data */
-+#define USER_EXIT_CS (0x68 | SEL_PL_U) /* user code */
-+#define USER_EXIT_DS (0x70 | SEL_PL_U) /* user data */
-+
-+#define GDTSZ (USER_EXIT_DS/8 + 1)
-
- extern struct real_descriptor gdt[GDTSZ];
-
-diff --git a/i386/i386/locore.S b/i386/i386/locore.S
-index cfda86f..aa13c6b 100644
---- a/i386/i386/locore.S
-+++ b/i386/i386/locore.S
-@@ -592,6 +592,7 @@ ENTRY(thread_syscall_return)
- or $(KERNEL_STACK_SIZE-1),%ecx
- movl -3-IKS_SIZE(%ecx),%esp /* switch back to PCB stack */
- movl %eax,R_EAX(%esp) /* save return value */
-+ /* XXX make this work with sysenter */
- jmp _return_from_trap
-
- ENTRY(call_continuation)
-@@ -978,6 +979,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.
-@@ -1171,6 +1184,170 @@ syscall_addr:
- jmp _take_trap /* treat as a trap */
-
-
-+/* User stub for calling the kernel using the sysenter instruction. */
-+ .globl user_sysenter_stub_start
-+user_sysenter_stub_start:
-+ push %ebp
-+ mov %esp, %ebp
-+ pushf
-+ push %ebx
-+ push %esi
-+ push %edi /* xxxmore callee-saved registers? */
-+ mov 8(%ebp), %eax /* Move syscall number into %eax. */
-+ mov 12(%ebp), %ebx /* Move first argument into %ebx. */
-+ mov 16(%ebp), %ecx /* Move second argument into %ecx. */
-+ mov 20(%ebp), %edx /* Move third argument into %edx. */
-+ mov 24(%ebp), %esi /* Move fourth argument into %esi. */
-+ call get_ip /* compute location of sysexit */
-+get_ip: pop %edi /* load current ip */
-+ add $8, %edi /* userspace return address */
-+ movl %esp, %ebp /* userspace stack pointer */
-+ sysenter
-+ pop %edi
-+ pop %esi
-+ pop %ebx
-+ popf
-+ pop %ebp
-+ ret
-+ .globl user_sysenter_stub_end
-+user_sysenter_stub_end:
-+
-+/*
-+ * SYSENTER entry point.
-+ *
-+ * Calling convention:
-+ * %eax - syscall number
-+ * %ebx - syscall argument 1
-+ * %ecx - syscall argument 2
-+ * %edx - syscall argument 3
-+ * %esi - syscall argument 4
-+ * %edi - userspace return address
-+ * %ebp - userspace stack pointer
-+ *
-+ * Kernel Stack layout:
-+ * kernel stack base -> EAX
-+ * ECX
-+ * EDX
-+ * EBX
-+ * ESP
-+ * EBP
-+ * ESI
-+ * EDI
-+ * XXX: make this look like a trap save area to make thread_syscall_return work
-+ */
-+/* Offsets from %ebp */
-+#define SE_EAX (4 * 7)
-+#define SE_ECX (4 * 6)
-+#define SE_EDX (4 * 5)
-+#define SE_EBX (4 * 4)
-+#define SE_ESX (4 * 3)
-+#define SE_EBP (4 * 2)
-+#define SE_ESI (4 * 1)
-+#define SE_EDI (4 * 0)
-+#define SE_STACK_POINTER SE_EBP
-+#define SE_RETURN_ADDRESS SE_EDI
-+
-+#define SE_USER_SKIP 20 /* skip past the scratchpad */
-+
-+ENTRY(sysenter_entry)
-+ pusha /* save all registers */
-+ mov %esp, %ebp /* to access the sysenter stack */
-+ cld /* clear direction flag */
-+
-+ pushl %ds /* save the segment registers */
-+ pushl %es
-+ pushl %fs
-+ pushl %gs
-+
-+ mov %ss,%cx /* switch to kernel data segment */
-+ mov %cx,%ds
-+ mov %cx,%es
-+ mov %cx,%fs
-+ mov %cx,%gs
-+
-+ CPU_NUMBER(%edx)
-+ movl CX(EXT(kernel_stack),%edx),%ebx
-+ /* get current kernel stack */
-+ xchgl %ebx, %esp /* switch stacks */
-+ pushl %ebx /* save sysenter sp */
-+ movl %esp,%ebx /* save kernel sp for argument
-+ unwinding */
-+
-+ negl %eax /* get system call number */
-+ /* xxx sysenter_mach_call_range */
-+ jl mach_call_range /* out of range if it was positive */
-+ cmpl EXT(mach_trap_count),%eax /* check system call table bounds */
-+ /* xxx sysenter_mach_call_range */
-+ jg mach_call_range /* error if out of range */
-+
-+ shll $4,%eax /* manual indexing */
-+ movl EXT(mach_trap_table)(%eax),%ecx
-+ /* get number of arguments */
-+
-+ cmp $4, %ecx
-+ ja se_args_5plus
-+ je se_args_4
-+ cmp $2, %ecx
-+ ja se_args_3
-+ je se_args_2
-+ cmp $1, %ecx
-+ je se_args_1
-+ jmp se_args_0
-+
-+se_args_5plus:
-+
-+ sub $4, %ecx /* skip the four first arguments */
-+ movl SE_STACK_POINTER(%ebp), %esi
-+ /* get user stack pointer */
-+ lea (4 /* skip user return address */\
-+ +4 /* point past last argument */\
-+ +16 /* skip register arguments */\
-+ +SE_USER_SKIP)(%esi,%ecx,4),%esi
-+ /* and skip past the userspace
-+ local storage */
-+
-+ movl $USER_DS,%edx /* use user data segment for accesses */
-+ mov %dx,%fs
-+
-+0: subl $4,%esi
-+ RECOVER(sysenter_mach_call_addr_push)
-+ pushl %fs:(%esi) /* push argument on stack */
-+ loop 0b /* loop for all arguments */
-+
-+se_args_4:
-+ push SE_ESI(%ebp) /* push fourth argument */
-+se_args_3:
-+ push SE_EDX(%ebp) /* push third argument */
-+se_args_2:
-+ push SE_ECX(%ebp) /* push second argument */
-+se_args_1:
-+ push SE_EBX(%ebp) /* push first argument */
-+se_args_0:
-+ sti /* xxx: sti/cli where ? */
-+ call *EXT(mach_trap_table)+4(%eax)
-+ /* call procedure */
-+ cli /* xxx: sti/cli where ? */
-+ movl %ebx, %esp /* clean parameters from stack */
-+return_from_sysenter:
-+ /* xxx: process ast */
-+ popl %esp /* restore sysenter sp */
-+ popl %gs /* restore segment registers */
-+ popl %fs
-+ popl %es
-+ popl %ds
-+
-+ movl SE_RETURN_ADDRESS(%ebp), %edx
-+ movl SE_STACK_POINTER(%ebp), %ecx
-+ sti /* xxx: sti/cli where ? */
-+ sysexit
-+
-+sysenter_mach_call_addr_push:
-+ movl %ebx,%esp /* clean parameters from stack */
-+ /* xxx signal page-fault */
-+ jmp sysenter_mach_call_addr_push
-+#undef SE_STACK_POINTER
-+#undef SE_RETURN_ADDRESS
-+
- .data
- DATA(cpu_features)
- .long 0
-diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c
-index e8040c8..2da3804 100644
---- a/i386/i386/pcb.c
-+++ b/i386/i386/pcb.c
-@@ -391,12 +391,12 @@ void pcb_init(thread_t thread)
- * Guarantee that the bootstrapped thread will be in user
- * mode.
- */
-- pcb->iss.cs = USER_CS;
-- pcb->iss.ss = USER_DS;
-- pcb->iss.ds = USER_DS;
-- pcb->iss.es = USER_DS;
-- pcb->iss.fs = USER_DS;
-- pcb->iss.gs = USER_DS;
-+ pcb->iss.cs = USER_EXIT_CS;
-+ pcb->iss.ss = USER_EXIT_DS;
-+ pcb->iss.ds = USER_EXIT_DS;
-+ pcb->iss.es = USER_EXIT_DS;
-+ pcb->iss.fs = USER_EXIT_DS;
-+ pcb->iss.gs = USER_EXIT_DS;
- pcb->iss.efl = EFL_USER_SET;
-
- thread->pcb = pcb;
-@@ -524,12 +524,12 @@ kern_return_t thread_setstatus(
- * 386 mode. Set segment registers for flat
- * 32-bit address space.
- */
-- saved_state->cs = USER_CS;
-- saved_state->ss = USER_DS;
-- saved_state->ds = USER_DS;
-- saved_state->es = USER_DS;
-- saved_state->fs = USER_DS;
-- saved_state->gs = USER_DS;
-+ saved_state->cs = USER_EXIT_CS;
-+ saved_state->ss = USER_EXIT_DS;
-+ saved_state->ds = USER_EXIT_DS;
-+ saved_state->es = USER_EXIT_DS;
-+ saved_state->fs = USER_EXIT_DS;
-+ saved_state->gs = USER_EXIT_DS;
- }
- else {
- /*
-diff --git a/i386/i386/syscall.c b/i386/i386/syscall.c
-new file mode 100644
-index 0000000..e9b17d0
---- /dev/null
-+++ b/i386/i386/syscall.c
-@@ -0,0 +1,103 @@
-+#include <mach/vm_param.h>
-+#include <mach/vm_prot.h>
-+#include <vm/pmap.h>
-+#include <vm/vm_kern.h>
-+#include <string.h>
-+#include <kern/debug.h>
-+
-+#include <machine/tss.h>
-+#include <i386/i386/ktss.h>
-+#include <i386/i386/gdt.h>
-+#include <i386/i386/locore.h>
-+
-+#include "syscall.h"
-+
-+#include <kern/printf.h> // xxx
-+
-+static vm_offset_t msyscall = 0;
-+
-+void user_trapgate_stub_start();
-+void user_trapgate_stub_end();
-+
-+void user_sysenter_stub_start();
-+void user_sysenter_stub_end();
-+
-+void
-+syscall_init(void)
-+{
-+ kern_return_t kr;
-+ vm_offset_t user_stub_start;
-+ vm_offset_t user_stub_end;
-+
-+ kr = kmem_alloc_wired(kernel_map, &msyscall, PAGE_SIZE);
-+ if (kr != KERN_SUCCESS)
-+ panic("syscall_init");
-+
-+ memset((void *) msyscall, 0, PAGE_SIZE);
-+
-+ if (CPU_HAS_FEATURE (CPU_FEATURE_SEP)) {
-+ printf ("syscall: using SYSENTER/SYSEXIT\n");
-+ user_stub_start = (vm_offset_t) user_sysenter_stub_start;
-+ user_stub_end = (vm_offset_t) user_sysenter_stub_end;
-+ } else {
-+ printf ("syscall: using trap gate\n");
-+ user_stub_start = (vm_offset_t) user_trapgate_stub_start;
-+ user_stub_end = (vm_offset_t) user_trapgate_stub_end;
-+ }
-+
-+ memcpy((void *) msyscall, (void *) user_stub_start,
-+ (size_t) (user_stub_end - user_stub_start));
-+
-+ syscall_init_cpu();
-+}
-+
-+static void
-+wrmsr(unsigned int msr, unsigned long long val)
-+{
-+ __asm__ __volatile__("wrmsr"
-+ : /* no Outputs */
-+ : "c" (msr), "A" (val));
-+}
-+
-+#define MSR_IA32_SYSENTER_CS 0x00000174
-+#define MSR_IA32_SYSENTER_ESP 0x00000175
-+#define MSR_IA32_SYSENTER_EIP 0x00000176
-+
-+extern void sysenter_entry(void);
-+
-+void
-+syscall_init_cpu(void)
-+{
-+ if (! CPU_HAS_FEATURE (CPU_FEATURE_SEP))
-+ return;
-+
-+ //struct task_tss *tss = curr_ktss (cpu_number ());
-+ struct task_tss *tss = &ktss;
-+
-+ wrmsr(MSR_IA32_SYSENTER_CS, KERNEL_ENTER_CS);
-+ wrmsr(MSR_IA32_SYSENTER_ESP,
-+ (unsigned long) tss->sysenter_stack + sizeof tss->sysenter_stack);
-+ wrmsr(MSR_IA32_SYSENTER_EIP, (unsigned long) sysenter_entry);
-+}
-+
-+int
-+syscall_open(dev_t dev, int flag, io_req_t ior)
-+{
-+ return 0;
-+}
-+
-+void
-+syscall_close(dev_t dev, int flag)
-+{
-+ return;
-+}
-+
-+int
-+syscall_mmap(dev_t dev, vm_offset_t off, vm_prot_t prot)
-+{
-+ if (prot & VM_PROT_WRITE)
-+ return (-1);
-+
-+ return (i386_btop(pmap_extract(pmap_kernel(),
-+ (vm_offset_t) msyscall)));
-+}
-diff --git a/i386/i386/syscall.h b/i386/i386/syscall.h
-new file mode 100644
-index 0000000..de9670c
---- /dev/null
-+++ b/i386/i386/syscall.h
-@@ -0,0 +1,7 @@
-+// XXX
-+
-+void syscall_init(void);
-+void syscall_init_cpu(void);
-+int syscall_open(dev_t dev, int flag, io_req_t ior);
-+void syscall_close(dev_t dev, int flag);
-+int syscall_mmap(dev_t dev, vm_offset_t off, vm_prot_t prot);
-diff --git a/i386/i386/tss.h b/i386/i386/tss.h
-index ff25f21..8c939c7 100644
---- a/i386/i386/tss.h
-+++ b/i386/i386/tss.h
-@@ -76,6 +76,7 @@ struct task_tss
- struct i386_tss tss;
- unsigned char iopb[IOPB_BYTES];
- unsigned char barrier;
-+ unsigned long sysenter_stack[64]; /* xxx */
- };
-
-
-diff --git a/i386/i386at/conf.c b/i386/i386at/conf.c
-index ab4f680..d7f9e6f 100644
---- a/i386/i386at/conf.c
-+++ b/i386/i386at/conf.c
-@@ -68,6 +68,9 @@
- #define hypcnname "hyp"
- #endif /* MACH_HYP */
-
-+#include <i386/syscall.h>
-+#define syscall_name "syscall"
-+
- /*
- * List of devices - console must be at slot 0
- */
-@@ -143,6 +146,11 @@ struct dev_ops dev_name_list[] =
- nodev },
- #endif /* MACH_HYP */
-
-+ { syscall_name, syscall_open, syscall_close, nulldev_read,
-+ nulldev_write, nulldev_getstat, nulldev_setstat,
-+ syscall_mmap,
-+ nodev, nulldev, nulldev_portdeath, 0,
-+ nodev },
- };
- int dev_name_count = sizeof(dev_name_list)/sizeof(dev_name_list[0]);
-
-diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c
-index bc34c9b..210e54d 100644
---- a/i386/i386at/model_dep.c
-+++ b/i386/i386at/model_dep.c
-@@ -63,6 +63,7 @@
- #include <i386/proc_reg.h>
- #include <i386/locore.h>
- #include <i386/model_dep.h>
-+#include <i386/syscall.h>
- #include <i386at/autoconf.h>
- #include <i386at/idt.h>
- #include <i386at/int_init.h>
-@@ -197,6 +198,7 @@ void machine_init(void)
- */
- pmap_unmap_page_zero();
- #endif
-+ syscall_init();
- }
-
- /* Conserve power on processor CPU. */
---
-2.1.4
-
diff --git a/debian/patches/sysenter0002-use-pcb-stack.patch b/debian/patches/sysenter0002-use-pcb-stack.patch
deleted file mode 100644
index 1c591ce..0000000
--- a/debian/patches/sysenter0002-use-pcb-stack.patch
+++ /dev/null
@@ -1,84 +0,0 @@
-From f022cb3771222d1effa738d4cb74c67ed61e86cc Mon Sep 17 00:00:00 2001
-From: Justus Winter <4winter@informatik.uni-hamburg.de>
-Date: Mon, 4 May 2015 00:45:24 +0200
-Subject: [PATCH gnumach 02/10] use pcb stack
-
----
- i386/i386/locore.S | 34 ++++++++++++++++++++++++----------
- 1 file changed, 24 insertions(+), 10 deletions(-)
-
-diff --git a/i386/i386/locore.S b/i386/i386/locore.S
-index aa13c6b..f1ef044 100644
---- a/i386/i386/locore.S
-+++ b/i386/i386/locore.S
-@@ -592,7 +592,9 @@ ENTRY(thread_syscall_return)
- or $(KERNEL_STACK_SIZE-1),%ecx
- movl -3-IKS_SIZE(%ecx),%esp /* switch back to PCB stack */
- movl %eax,R_EAX(%esp) /* save return value */
-- /* XXX make this work with sysenter */
-+ /* YYY make this work with sysenter */
-+ cmpl $0xffffffff, R_TRAPNO(%esp)
-+ je return_from_sysenter
- jmp _return_from_trap
-
- ENTRY(call_continuation)
-@@ -1254,6 +1256,22 @@ ENTRY(sysenter_entry)
- mov %esp, %ebp /* to access the sysenter stack */
- cld /* clear direction flag */
-
-+ CPU_NUMBER(%edx)
-+ movl CX(EXT(kernel_stack),%edx),%ebx
-+ /* get current kernel stack */
-+ movl %ebx, %ecx
-+ or $(KERNEL_STACK_SIZE-1),%ecx
-+ movl -3-IKS_SIZE(%ecx), %esp /* switch to PCB stack */
-+
-+ /* Create trap save area. */
-+ subl $(6 * 4), %esp /* Unused. We save the
-+ arguments in userspace. */
-+ pushl $0x7fffffff /* trap number */
-+ pushl $0x12345678 /* unused */
-+ pushl SE_STACK_POINTER(%ebp) /* ecx */
-+ pushl SE_RETURN_ADDRESS(%ebp) /* edx */
-+ subl $(5 * 4), %esp /* Unused. We save the
-+ arguments in userspace. */
- pushl %ds /* save the segment registers */
- pushl %es
- pushl %fs
-@@ -1265,11 +1283,8 @@ ENTRY(sysenter_entry)
- mov %cx,%fs
- mov %cx,%gs
-
-- CPU_NUMBER(%edx)
-- movl CX(EXT(kernel_stack),%edx),%ebx
-- /* get current kernel stack */
-- xchgl %ebx, %esp /* switch stacks */
-- pushl %ebx /* save sysenter sp */
-+ xchgl %ebx, %esp /* switch to kernel stack */
-+ pushl %ebx /* save pcb stack pointer */
- movl %esp,%ebx /* save kernel sp for argument
- unwinding */
-
-@@ -1328,16 +1343,15 @@ se_args_0:
- /* call procedure */
- cli /* xxx: sti/cli where ? */
- movl %ebx, %esp /* clean parameters from stack */
-+ popl %esp /* switch to pcb stack */
- return_from_sysenter:
-+ movl %eax, R_EAX(%esp) /* save return value */
- /* xxx: process ast */
-- popl %esp /* restore sysenter sp */
- popl %gs /* restore segment registers */
- popl %fs
- popl %es
- popl %ds
--
-- movl SE_RETURN_ADDRESS(%ebp), %edx
-- movl SE_STACK_POINTER(%ebp), %ecx
-+ popa
- sti /* xxx: sti/cli where ? */
- sysexit
-
---
-2.1.4
-
diff --git a/debian/patches/sysenter0003-XXX-i386-less-magic.patch b/debian/patches/sysenter0003-XXX-i386-less-magic.patch
deleted file mode 100644
index a8b4054..0000000
--- a/debian/patches/sysenter0003-XXX-i386-less-magic.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From 191739dfc0bf640b84b05fea024e2b6f559bb54d Mon Sep 17 00:00:00 2001
-From: Justus Winter <4winter@informatik.uni-hamburg.de>
-Date: Mon, 4 May 2015 01:56:12 +0200
-Subject: [PATCH gnumach 03/10] XXX i386: less magic
-
----
- 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
-
diff --git a/debian/patches/sysenter0004-thread_syscall_return-kinda-works.patch b/debian/patches/sysenter0004-thread_syscall_return-kinda-works.patch
deleted file mode 100644
index fcba370..0000000
--- a/debian/patches/sysenter0004-thread_syscall_return-kinda-works.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-From ba0c8d6f6e2d17c3ca9f8d550766b7be523e9d0e Mon Sep 17 00:00:00 2001
-From: Justus Winter <4winter@informatik.uni-hamburg.de>
-Date: Mon, 4 May 2015 01:56:17 +0200
-Subject: [PATCH gnumach 04/10] thread_syscall_return kinda works
-
----
- i386/i386/i386asm.sym | 1 +
- i386/i386/locore.S | 6 +++---
- 2 files changed, 4 insertions(+), 3 deletions(-)
-
-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_state iss
- offset i386_saved_state r cs
- offset i386_saved_state r uesp
- offset i386_saved_state r eax
-diff --git a/i386/i386/locore.S b/i386/i386/locore.S
-index f1ef044..f833508 100644
---- a/i386/i386/locore.S
-+++ b/i386/i386/locore.S
-@@ -592,8 +592,7 @@ ENTRY(thread_syscall_return)
- or $(KERNEL_STACK_SIZE-1),%ecx
- movl -3-IKS_SIZE(%ecx),%esp /* switch back to PCB stack */
- movl %eax,R_EAX(%esp) /* save return value */
-- /* YYY make this work with sysenter */
-- cmpl $0xffffffff, R_TRAPNO(%esp)
-+ cmpl $0x7fffffff, R_TRAPNO(%esp) /* YYY */
- je return_from_sysenter
- jmp _return_from_trap
-
-@@ -1262,6 +1261,7 @@ ENTRY(sysenter_entry)
- movl %ebx, %ecx
- or $(KERNEL_STACK_SIZE-1),%ecx
- movl -3-IKS_SIZE(%ecx), %esp /* switch to PCB stack */
-+ addl $(ISS_SIZE - 16), %esp /* point to top of structure */ //XXX: magic 16 b/c of vm86
-
- /* Create trap save area. */
- subl $(6 * 4), %esp /* Unused. We save the
-@@ -1344,8 +1344,8 @@ se_args_0:
- cli /* xxx: sti/cli where ? */
- movl %ebx, %esp /* clean parameters from stack */
- popl %esp /* switch to pcb stack */
--return_from_sysenter:
- movl %eax, R_EAX(%esp) /* save return value */
-+return_from_sysenter:
- /* xxx: process ast */
- popl %gs /* restore segment registers */
- popl %fs
---
-2.1.4
-
diff --git a/debian/patches/sysenter0005-thread_syscall_return-works.patch b/debian/patches/sysenter0005-thread_syscall_return-works.patch
deleted file mode 100644
index bb252bf..0000000
--- a/debian/patches/sysenter0005-thread_syscall_return-works.patch
+++ /dev/null
@@ -1,110 +0,0 @@
-From 469a7693ee350a8046c1925a71ffd9461962f88d Mon Sep 17 00:00:00 2001
-From: Justus Winter <4winter@informatik.uni-hamburg.de>
-Date: Mon, 4 May 2015 02:10:03 +0200
-Subject: [PATCH gnumach 05/10] thread_syscall_return works :)
-
----
- i386/i386/locore.S | 70 ++++++++++++++++++++++++++++++++----------------------
- 1 file changed, 41 insertions(+), 29 deletions(-)
-
-diff --git a/i386/i386/locore.S b/i386/i386/locore.S
-index f833508..ed51cb8 100644
---- a/i386/i386/locore.S
-+++ b/i386/i386/locore.S
-@@ -1225,26 +1225,34 @@ user_sysenter_stub_end:
- * %edi - userspace return address
- * %ebp - userspace stack pointer
- *
-- * Kernel Stack layout:
-- * kernel stack base -> EAX
-- * ECX
-- * EDX
-- * EBX
-- * ESP
-- * EBP
-- * ESI
-- * EDI
-- * XXX: make this look like a trap save area to make thread_syscall_return work
-+ * sysenter stack layout:
-+ *
-+ * sysenter stack base -> EAX
-+ * ECX
-+ * EDX
-+ * EBX
-+ * ESP
-+ * EBP
-+ * ESI
-+ * EDI
-+ * DS
-+ * ES
-+ * FS
-+ * %ebp -> GS
- */
- /* Offsets from %ebp */
--#define SE_EAX (4 * 7)
--#define SE_ECX (4 * 6)
--#define SE_EDX (4 * 5)
--#define SE_EBX (4 * 4)
--#define SE_ESX (4 * 3)
--#define SE_EBP (4 * 2)
--#define SE_ESI (4 * 1)
--#define SE_EDI (4 * 0)
-+#define SE_EAX (4 * 11)
-+#define SE_ECX (4 * 10)
-+#define SE_EDX (4 * 9)
-+#define SE_EBX (4 * 8)
-+#define SE_ESX (4 * 7)
-+#define SE_EBP (4 * 6)
-+#define SE_ESI (4 * 5)
-+#define SE_EDI (4 * 4)
-+#define SE_DS (4 * 3)
-+#define SE_ES (4 * 2)
-+#define SE_FS (4 * 1)
-+#define SE_GS (4 * 0)
- #define SE_STACK_POINTER SE_EBP
- #define SE_RETURN_ADDRESS SE_EDI
-
-@@ -1252,8 +1260,18 @@ user_sysenter_stub_end:
-
- ENTRY(sysenter_entry)
- pusha /* save all registers */
-- mov %esp, %ebp /* to access the sysenter stack */
- cld /* clear direction flag */
-+ pushl %ds /* save the segment registers */
-+ pushl %es
-+ pushl %fs
-+ pushl %gs
-+ mov %esp, %ebp /* to access the sysenter stack */
-+
-+ mov %ss,%cx /* switch to kernel data segment */
-+ mov %cx,%ds
-+ mov %cx,%es
-+ mov %cx,%fs
-+ mov %cx,%gs
-
- CPU_NUMBER(%edx)
- movl CX(EXT(kernel_stack),%edx),%ebx
-@@ -1272,16 +1290,10 @@ ENTRY(sysenter_entry)
- pushl SE_RETURN_ADDRESS(%ebp) /* edx */
- subl $(5 * 4), %esp /* Unused. We save the
- arguments in userspace. */
-- pushl %ds /* save the segment registers */
-- pushl %es
-- pushl %fs
-- pushl %gs
--
-- mov %ss,%cx /* switch to kernel data segment */
-- mov %cx,%ds
-- mov %cx,%es
-- mov %cx,%fs
-- mov %cx,%gs
-+ pushl SE_DS(%ebp) /* copy the segment registers */
-+ pushl SE_ES(%ebp)
-+ pushl SE_FS(%ebp)
-+ pushl SE_GS(%ebp)
-
- xchgl %ebx, %esp /* switch to kernel stack */
- pushl %ebx /* save pcb stack pointer */
---
-2.1.4
-
diff --git a/debian/patches/sysenter0006-optimize.patch b/debian/patches/sysenter0006-optimize.patch
deleted file mode 100644
index afdac79..0000000
--- a/debian/patches/sysenter0006-optimize.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From 936cfa5a59ef5e9b1c58ab3d06626ba791b17be7 Mon Sep 17 00:00:00 2001
-From: Justus Winter <4winter@informatik.uni-hamburg.de>
-Date: Mon, 4 May 2015 02:14:49 +0200
-Subject: [PATCH gnumach 06/10] optimize
-
----
- i386/i386/locore.S | 7 +++----
- 1 file changed, 3 insertions(+), 4 deletions(-)
-
-diff --git a/i386/i386/locore.S b/i386/i386/locore.S
-index ed51cb8..99fbfb6 100644
---- a/i386/i386/locore.S
-+++ b/i386/i386/locore.S
-@@ -1279,11 +1279,10 @@ ENTRY(sysenter_entry)
- movl %ebx, %ecx
- or $(KERNEL_STACK_SIZE-1),%ecx
- movl -3-IKS_SIZE(%ecx), %esp /* switch to PCB stack */
-- addl $(ISS_SIZE - 16), %esp /* point to top of structure */ //XXX: magic 16 b/c of vm86
-+ addl $(ISS_SIZE - 16 /* vm86 */ - 6 * 4 /* unused */), %esp
-+ /* point to trap number */
-
-- /* Create trap save area. */
-- subl $(6 * 4), %esp /* Unused. We save the
-- arguments in userspace. */
-+ /* Populate trap save area. */
- pushl $0x7fffffff /* trap number */
- pushl $0x12345678 /* unused */
- pushl SE_STACK_POINTER(%ebp) /* ecx */
---
-2.1.4
-
diff --git a/debian/patches/sysenter0007-document.patch b/debian/patches/sysenter0007-document.patch
deleted file mode 100644
index 71f7d6e..0000000
--- a/debian/patches/sysenter0007-document.patch
+++ /dev/null
@@ -1,65 +0,0 @@
-From d2ca2ffb15f04aab7210757d7c7dabb33ab720d0 Mon Sep 17 00:00:00 2001
-From: Justus Winter <4winter@informatik.uni-hamburg.de>
-Date: Tue, 5 May 2015 20:04:15 +0200
-Subject: [PATCH gnumach 07/10] document
-
----
- i386/i386/locore.S | 27 +++++++++++++++++----------
- 1 file changed, 17 insertions(+), 10 deletions(-)
-
-diff --git a/i386/i386/locore.S b/i386/i386/locore.S
-index 99fbfb6..4c2a253 100644
---- a/i386/i386/locore.S
-+++ b/i386/i386/locore.S
-@@ -1184,6 +1184,18 @@ syscall_addr:
- /* set error code - read user space */
- jmp _take_trap /* treat as a trap */
-
-+/*
-+ * SYSENTER-based system calls.
-+ *
-+ * Calling convention:
-+ * %eax - syscall number
-+ * %ebx - syscall argument 1
-+ * %ecx - syscall argument 2
-+ * %edx - syscall argument 3
-+ * %esi - syscall argument 4
-+ * %edi - userspace return address
-+ * %ebp - userspace stack pointer
-+ */
-
- /* User stub for calling the kernel using the sysenter instruction. */
- .globl user_sysenter_stub_start
-@@ -1191,9 +1203,9 @@ user_sysenter_stub_start:
- push %ebp
- mov %esp, %ebp
- pushf
-- push %ebx
-+ push %ebx /* Store callee-saved registers. */
- push %esi
-- push %edi /* xxxmore callee-saved registers? */
-+ push %edi
- mov 8(%ebp), %eax /* Move syscall number into %eax. */
- mov 12(%ebp), %ebx /* Move first argument into %ebx. */
- mov 16(%ebp), %ecx /* Move second argument into %ecx. */
-@@ -1216,14 +1228,9 @@ user_sysenter_stub_end:
- /*
- * SYSENTER entry point.
- *
-- * Calling convention:
-- * %eax - syscall number
-- * %ebx - syscall argument 1
-- * %ecx - syscall argument 2
-- * %edx - syscall argument 3
-- * %esi - syscall argument 4
-- * %edi - userspace return address
-- * %ebp - userspace stack pointer
-+ * Control enters at `sysenter_entry' with %esp pointing to the
-+ * per-cpu sysenter stack. We store all arguments here. We keep %ebp
-+ * pointing to the top of this structure to copy the arguments.
- *
- * sysenter stack layout:
- *
---
-2.1.4
-
diff --git a/debian/patches/sysenter0008-document-check-for-sysenter-at-the-right-location.patch b/debian/patches/sysenter0008-document-check-for-sysenter-at-the-right-location.patch
deleted file mode 100644
index 8386235..0000000
--- a/debian/patches/sysenter0008-document-check-for-sysenter-at-the-right-location.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-From 2a53b2da8c31676ddf53564ac95a01fcb78f2d20 Mon Sep 17 00:00:00 2001
-From: Justus Winter <4winter@informatik.uni-hamburg.de>
-Date: Tue, 5 May 2015 20:34:50 +0200
-Subject: [PATCH gnumach 08/10] document, check for sysenter at the right
- location
-
----
- i386/i386/locore.S | 19 ++++++++++---------
- 1 file changed, 10 insertions(+), 9 deletions(-)
-
-diff --git a/i386/i386/locore.S b/i386/i386/locore.S
-index 4c2a253..8b4d766 100644
---- a/i386/i386/locore.S
-+++ b/i386/i386/locore.S
-@@ -521,6 +521,9 @@ _return_to_user:
- */
-
- _return_from_kernel:
-+ cmpl $0x7fffffff, R_TRAPNO(%esp) /* YYY */
-+ je return_from_sysenter
-+
- _kret_popl_gs:
- popl %gs /* restore segment registers */
- _kret_popl_fs:
-@@ -592,8 +595,6 @@ ENTRY(thread_syscall_return)
- or $(KERNEL_STACK_SIZE-1),%ecx
- movl -3-IKS_SIZE(%ecx),%esp /* switch back to PCB stack */
- movl %eax,R_EAX(%esp) /* save return value */
-- cmpl $0x7fffffff, R_TRAPNO(%esp) /* YYY */
-- je return_from_sysenter
- jmp _return_from_trap
-
- ENTRY(call_continuation)
-@@ -1231,6 +1232,7 @@ user_sysenter_stub_end:
- * Control enters at `sysenter_entry' with %esp pointing to the
- * per-cpu sysenter stack. We store all arguments here. We keep %ebp
- * pointing to the top of this structure to copy the arguments.
-+
- *
- * sysenter stack layout:
- *
-@@ -1291,11 +1293,10 @@ ENTRY(sysenter_entry)
-
- /* Populate trap save area. */
- pushl $0x7fffffff /* trap number */
-- pushl $0x12345678 /* unused */
-- pushl SE_STACK_POINTER(%ebp) /* ecx */
-- pushl SE_RETURN_ADDRESS(%ebp) /* edx */
-- subl $(5 * 4), %esp /* Unused. We save the
-- arguments in userspace. */
-+ pushl %eax /* %eax: unused */
-+ pushl SE_STACK_POINTER(%ebp) /* %ecx: for sysexit */
-+ pushl SE_RETURN_ADDRESS(%ebp) /* %edx: for sysexit */
-+ subl $(5 * 4), %esp /* unused */
- pushl SE_DS(%ebp) /* copy the segment registers */
- pushl SE_ES(%ebp)
- pushl SE_FS(%ebp)
-@@ -1363,8 +1364,8 @@ se_args_0:
- movl %ebx, %esp /* clean parameters from stack */
- popl %esp /* switch to pcb stack */
- movl %eax, R_EAX(%esp) /* save return value */
--return_from_sysenter:
-- /* xxx: process ast */
-+ jmp _return_from_trap /* check for AST, then... */
-+return_from_sysenter: /* return here */
- popl %gs /* restore segment registers */
- popl %fs
- popl %es
---
-2.1.4
-
diff --git a/debian/patches/sysenter0009-be-less-stoopid.patch b/debian/patches/sysenter0009-be-less-stoopid.patch
deleted file mode 100644
index 1366cc8..0000000
--- a/debian/patches/sysenter0009-be-less-stoopid.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-From dd46af86ca22aa1af2f7843a624c436fefd6c51f Mon Sep 17 00:00:00 2001
-From: Justus Winter <4winter@informatik.uni-hamburg.de>
-Date: Tue, 5 May 2015 20:50:37 +0200
-Subject: [PATCH gnumach 09/10] be less stoopid
-
----
- i386/i386/locore.S | 8 ++------
- 1 file changed, 2 insertions(+), 6 deletions(-)
-
-diff --git a/i386/i386/locore.S b/i386/i386/locore.S
-index 8b4d766..0d08be5 100644
---- a/i386/i386/locore.S
-+++ b/i386/i386/locore.S
-@@ -1303,10 +1303,7 @@ ENTRY(sysenter_entry)
- pushl SE_GS(%ebp)
-
- xchgl %ebx, %esp /* switch to kernel stack */
-- pushl %ebx /* save pcb stack pointer */
-- movl %esp,%ebx /* save kernel sp for argument
-- unwinding */
--
-+ /* %ebx points to user registers */
- negl %eax /* get system call number */
- /* xxx sysenter_mach_call_range */
- jl mach_call_range /* out of range if it was positive */
-@@ -1361,8 +1358,7 @@ se_args_0:
- call *EXT(mach_trap_table)+4(%eax)
- /* call procedure */
- cli /* xxx: sti/cli where ? */
-- movl %ebx, %esp /* clean parameters from stack */
-- popl %esp /* switch to pcb stack */
-+ movl %ebx, %esp /* switch to pcb stack */
- movl %eax, R_EAX(%esp) /* save return value */
- jmp _return_from_trap /* check for AST, then... */
- return_from_sysenter: /* return here */
---
-2.1.4
-
diff --git a/debian/patches/sysenter0010-fix-error-handling.patch b/debian/patches/sysenter0010-fix-error-handling.patch
deleted file mode 100644
index 53e4681..0000000
--- a/debian/patches/sysenter0010-fix-error-handling.patch
+++ /dev/null
@@ -1,76 +0,0 @@
-From 56c1cfd4797af7367c5d830d5125baa75d4f0bdb Mon Sep 17 00:00:00 2001
-From: Justus Winter <4winter@informatik.uni-hamburg.de>
-Date: Tue, 5 May 2015 21:25:58 +0200
-Subject: [PATCH gnumach 10/10] fix error handling
-
----
- i386/i386/locore.S | 38 ++++++++++++++++++++++++++++----------
- 1 file changed, 28 insertions(+), 10 deletions(-)
-
-diff --git a/i386/i386/locore.S b/i386/i386/locore.S
-index 0d08be5..d8241a7 100644
---- a/i386/i386/locore.S
-+++ b/i386/i386/locore.S
-@@ -1305,11 +1305,12 @@ ENTRY(sysenter_entry)
- xchgl %ebx, %esp /* switch to kernel stack */
- /* %ebx points to user registers */
- negl %eax /* get system call number */
-- /* xxx sysenter_mach_call_range */
-- jl mach_call_range /* out of range if it was positive */
-- cmpl EXT(mach_trap_count),%eax /* check system call table bounds */
-- /* xxx sysenter_mach_call_range */
-- jg mach_call_range /* error if out of range */
-+ jl sysenter_mach_call_range
-+ /* out of range if it was positive */
-+ cmpl EXT(mach_trap_count),%eax
-+ /* check system call table bounds */
-+ jg sysenter_mach_call_range
-+ /* error if out of range */
-
- shll $4,%eax /* manual indexing */
- movl EXT(mach_trap_table)(%eax),%ecx
-@@ -1339,6 +1340,7 @@ se_args_5plus:
-
- movl $USER_DS,%edx /* use user data segment for accesses */
- mov %dx,%fs
-+ movl %esp,%edx /* save kernel ESP for error recovery */
-
- 0: subl $4,%esi
- RECOVER(sysenter_mach_call_addr_push)
-@@ -1370,12 +1372,28 @@ return_from_sysenter: /* return here */
- sti /* xxx: sti/cli where ? */
- sysexit
-
-+/*
-+ * Address out of range. Change to page fault.
-+ * %esi holds failing address.
-+ */
- sysenter_mach_call_addr_push:
-- movl %ebx,%esp /* clean parameters from stack */
-- /* xxx signal page-fault */
-- jmp sysenter_mach_call_addr_push
--#undef SE_STACK_POINTER
--#undef SE_RETURN_ADDRESS
-+ movl %edx,%esp /* clean parameters from stack */
-+ movl %esi,R_CR2(%ebx) /* set fault address */
-+ movl $(T_PAGE_FAULT),R_TRAPNO(%ebx)
-+ /* set page-fault trap */
-+ movl $(T_PF_USER),R_ERR(%ebx)
-+ /* set error code - read user space */
-+ jmp _take_trap /* treat as a trap */
-+
-+/*
-+ * System call out of range. Treat as invalid-instruction trap.
-+ * (? general protection?)
-+ */
-+sysenter_mach_call_range:
-+ movl $(T_INVALID_OPCODE),R_TRAPNO(%ebx)
-+ /* set invalid-operation trap */
-+ movl $0,R_ERR(%ebx) /* clear error code */
-+ jmp _take_trap /* treat as a trap */
-
- .data
- DATA(cpu_features)
---
-2.1.4
-