From 27286ca9a84a9ae13e5d3ed42fd4a3418a2d1af7 Mon Sep 17 00:00:00 2001 From: Mark Newton Date: Thu, 28 Jan 1999 11:45:49 +0000 Subject: [PATCH] Sun Bug ID 1251858 (on http://sunsolve1.sun.com) discusses the way that Sun implemented iBCS2 compatibility on Solaris >= 2.6: The emulator runs in user-mode, patching the LDT so that client programs making syscalls through the old iBCS2 call gate get handled by the emulator process. Unemulated syscalls therefore need their own call-gate that bypasses the emulator. Sun chose LDT entry 4 to implement this, which is what we've been using as LUDATA_SEL, so we need to change LUDATA_SEL if we want to run Solaris executables. Discussed with: Mike Smith --- sys/amd64/amd64/machdep.c | 12 +++++++++++- sys/amd64/include/segments.h | 5 +++-- sys/i386/i386/machdep.c | 12 +++++++++++- sys/i386/include/segments.h | 5 +++-- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 1bd6f6c5f04a..6e65e1e1a09e 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.321 1999/01/09 15:41:49 bde Exp $ + * $Id: machdep.c,v 1.322 1999/01/15 17:24:05 msmith Exp $ */ #include "apm.h" @@ -1069,6 +1069,15 @@ static struct soft_segment_descriptor ldt_segs[] = { 0, 0, 1, /* default 32 vs 16 bit size */ 1 /* limit granularity (byte/page units)*/ }, + /* Null Descriptor - overwritten by call gate */ +{ 0x0, /* segment base address */ + 0x0, /* length - all address space */ + 0, /* segment type */ + 0, /* segment descriptor priority level */ + 0, /* segment descriptor present */ + 0, 0, + 0, /* default 32 vs 16 bit size */ + 0 /* limit granularity (byte/page units)*/ }, /* Data Descriptor for user */ { 0x0, /* segment base address */ 0xfffff, /* length - all address space */ @@ -1587,6 +1596,7 @@ init386(first) /* XXX does this work? */ ldt[LBSDICALLS_SEL] = ldt[LSYS5CALLS_SEL]; + ldt[LSOL26CALLS_SEL] = ldt[LSYS5CALLS_SEL]; /* transfer to user mode */ diff --git a/sys/amd64/include/segments.h b/sys/amd64/include/segments.h index 894e6c5f5d79..674b0f38c28e 100644 --- a/sys/amd64/include/segments.h +++ b/sys/amd64/include/segments.h @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 - * $Id: segments.h,v 1.16 1997/08/18 06:58:31 charnier Exp $ + * $Id: segments.h,v 1.17 1997/08/21 06:32:49 charnier Exp $ */ #ifndef _MACHINE_SEGMENTS_H_ @@ -229,7 +229,8 @@ struct region_descriptor { #define LSYS5SIGR_SEL 1 #define L43BSDCALLS_SEL 2 /* notyet */ #define LUCODE_SEL 3 -#define LUDATA_SEL 4 +#define LSOL26CALLS_SEL 4 /* Solaris >= 2.6 system call gate */ +#define LUDATA_SEL 5 /* separate stack, es,fs,gs sels ? */ /* #define LPOSIXCALLS_SEL 5*/ /* notyet */ #define LBSDICALLS_SEL 16 /* BSDI system call gate */ diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 1bd6f6c5f04a..6e65e1e1a09e 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.321 1999/01/09 15:41:49 bde Exp $ + * $Id: machdep.c,v 1.322 1999/01/15 17:24:05 msmith Exp $ */ #include "apm.h" @@ -1069,6 +1069,15 @@ static struct soft_segment_descriptor ldt_segs[] = { 0, 0, 1, /* default 32 vs 16 bit size */ 1 /* limit granularity (byte/page units)*/ }, + /* Null Descriptor - overwritten by call gate */ +{ 0x0, /* segment base address */ + 0x0, /* length - all address space */ + 0, /* segment type */ + 0, /* segment descriptor priority level */ + 0, /* segment descriptor present */ + 0, 0, + 0, /* default 32 vs 16 bit size */ + 0 /* limit granularity (byte/page units)*/ }, /* Data Descriptor for user */ { 0x0, /* segment base address */ 0xfffff, /* length - all address space */ @@ -1587,6 +1596,7 @@ init386(first) /* XXX does this work? */ ldt[LBSDICALLS_SEL] = ldt[LSYS5CALLS_SEL]; + ldt[LSOL26CALLS_SEL] = ldt[LSYS5CALLS_SEL]; /* transfer to user mode */ diff --git a/sys/i386/include/segments.h b/sys/i386/include/segments.h index 894e6c5f5d79..674b0f38c28e 100644 --- a/sys/i386/include/segments.h +++ b/sys/i386/include/segments.h @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 - * $Id: segments.h,v 1.16 1997/08/18 06:58:31 charnier Exp $ + * $Id: segments.h,v 1.17 1997/08/21 06:32:49 charnier Exp $ */ #ifndef _MACHINE_SEGMENTS_H_ @@ -229,7 +229,8 @@ struct region_descriptor { #define LSYS5SIGR_SEL 1 #define L43BSDCALLS_SEL 2 /* notyet */ #define LUCODE_SEL 3 -#define LUDATA_SEL 4 +#define LSOL26CALLS_SEL 4 /* Solaris >= 2.6 system call gate */ +#define LUDATA_SEL 5 /* separate stack, es,fs,gs sels ? */ /* #define LPOSIXCALLS_SEL 5*/ /* notyet */ #define LBSDICALLS_SEL 16 /* BSDI system call gate */