Port-amd64 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

running i386 1.0 binaries on amd64



I tried running a netbsd 1.0 binary on amd64 today and found that
it has trouble with the old call-gate-based syscall mechanism too.
the problem isn't as bad as the i386 one that I fixed a few weeks ago,
it only crashes the application and not the system.
the problem has to do with our LDT usage:

#define LSYS5CALLS_SEL  0       /* iBCS system call gate */
#define LUCODE32_SEL    8       /* 32 bit user code descriptor */
#define LUDATA_SEL      16      /* User data descriptor */
#define LUCODE_SEL      24      /* User code descriptor */
#define LSOL26CALLS_SEL 32      /* Solaris 2.6 system call gate */
#define LUDATA32_SEL    56      /* 32 bit user data descriptor (needed?)*/
#define LBSDICALLS_SEL  128     /* BSDI system call gate */

the first entry is the syscall call gate, but in long mode call gates
use two slots, so it collides with LUCODE32_SEL.  if I rearrange the entries
as in the attached patch then it works.  but I'm not sure if changing these
could cause other problems, does anyone know more about that?

-Chuck
Index: sys/arch/amd64/include/segments.h
===================================================================
RCS file: /home/chs/netbsd/cvs/src/sys/arch/amd64/include/segments.h,v
retrieving revision 1.23
diff -u -p -r1.23 segments.h
--- sys/arch/amd64/include/segments.h   16 Jun 2012 20:47:04 -0000      1.23
+++ sys/arch/amd64/include/segments.h   9 Dec 2012 17:14:51 -0000
@@ -374,12 +374,15 @@ void cpu_fsgs_reload(struct lwp *, int, 
  * Strange order because of syscall/sysret insns
  */
 #define        LSYS5CALLS_SEL  0       /* iBCS system call gate */
-#define LUCODE32_SEL   8       /* 32 bit user code descriptor */
-#define        LUDATA_SEL      16      /* User data descriptor */
-#define        LUCODE_SEL      24      /* User code descriptor */
+/*                     8          second half */
 #define        LSOL26CALLS_SEL 32      /* Solaris 2.6 system call gate */
-#define LUDATA32_SEL   56      /* 32 bit user data descriptor (needed?)*/
+/*                     40         second half */
+#define LUCODE32_SEL   48      /* 32 bit user code descriptor */
+#define        LUDATA_SEL      56      /* User data descriptor */
+#define        LUCODE_SEL      64      /* User code descriptor */
+#define LUDATA32_SEL   72      /* 32 bit user data descriptor (needed?)*/
 #define        LBSDICALLS_SEL  128     /* BSDI system call gate */
+/*                     136        second half */
 
 #define LDT_SIZE       144
 


Home | Main Index | Thread Index | Old Index