Should probably modify: (char *) ldtstore -> (union descriptor *) ldt and all relevant calls then it should link, at least. Index: sys/arch/amd64/conf/GENERIC =================================================================== RCS file: /cvsroot/src/sys/arch/amd64/conf/GENERIC,v retrieving revision 1.437 diff -u -p -u -r1.437 GENERIC --- sys/arch/amd64/conf/GENERIC 7 Aug 2016 10:44:05 -0000 1.437 +++ sys/arch/amd64/conf/GENERIC 27 Sep 2016 22:07:15 -0000 @@ -1308,6 +1308,8 @@ pseudo-device pad # userland interface to drivers, including autoconf and properties retrieval pseudo-device drvctl +options USER_LDT + options FILEASSOC # fileassoc(9) - required for Veriexec # Veriexec Index: sys/arch/amd64/include/segments.h =================================================================== RCS file: /cvsroot/src/sys/arch/amd64/include/segments.h,v retrieving revision 1.28 diff -u -p -u -r1.28 segments.h --- sys/arch/amd64/include/segments.h 2 Sep 2016 08:52:12 -0000 1.28 +++ sys/arch/amd64/include/segments.h 27 Sep 2016 22:07:15 -0000 @@ -208,12 +208,20 @@ struct gate_descriptor { uint64_t gd_xx3:19; /* reserved */ } __packed; +typedef unsigned long __vaddr_t; /* segments.h ??? */ +struct ldt_descriptor { + __vaddr_t ld_base; + uint32_t ld_entries; +} __packed; + /* * Generic descriptor (8 bytes). Note: it does not include system segment * descriptors and gate descriptors, since these are 16-byte-long. */ union descriptor { struct mem_segment_descriptor sd; + struct gate_descriptor gd; + struct ldt_descriptor ld; uint32_t raw[2]; uint64_t raw64; } __packed; @@ -381,6 +389,8 @@ void cpu_fsgs_reload(struct lwp *, int, #define LBSDICALLS_SEL 128 /* BSDI system call gate */ /* 136 second half */ +#define NGDT 23 +#define NLDT 17 #define LDT_SIZE 144 #define LSYSRETBASE_SEL LUCODE32_SEL Index: sys/arch/x86/x86/sys_machdep.c =================================================================== RCS file: /cvsroot/src/sys/arch/x86/x86/sys_machdep.c,v retrieving revision 1.30 diff -u -p -u -r1.30 sys_machdep.c --- sys/arch/x86/x86/sys_machdep.c 24 Sep 2016 21:13:44 -0000 1.30 +++ sys/arch/x86/x86/sys_machdep.c 27 Sep 2016 22:07:16 -0000 @@ -69,7 +69,6 @@ __KERNEL_RCSID(0, "$NetBSD: sys_machdep. #ifdef __x86_64__ /* Need to be checked. */ -#undef USER_LDT #undef PERFCTRS #undef IOPERM #else @@ -272,7 +271,7 @@ x86_set_ldt1(struct lwp *l, struct x86_s if (desc->gd.gd_p != 0 && !ISLDT(desc->gd.gd_selector) && ((IDXSEL(desc->gd.gd_selector) >= NGDT) || - (gdt[IDXSEL(desc->gd.gd_selector)].sd.sd_dpl != + (ci->ci_gdt[IDXSEL(desc->gd.gd_selector)].sd.sd_dpl != SEL_UPL))) { return EACCES; }