From fe8b8bf778689d7b155e3e39af5cb09bf4edcb49 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Thu, 14 Apr 2005 16:57:58 +0000 Subject: [PATCH] Implement 32-bit compatable fsbase/gsbase methods so that we can run (newer) unmodified static i386 binaries again. --- sys/amd64/amd64/sys_machdep.c | 21 +++++++++++++++++++++ sys/amd64/include/sysarch.h | 5 +++++ 2 files changed, 26 insertions(+) diff --git a/sys/amd64/amd64/sys_machdep.c b/sys/amd64/amd64/sys_machdep.c index fcc657a033f..25fbb6f0d04 100644 --- a/sys/amd64/amd64/sys_machdep.c +++ b/sys/amd64/amd64/sys_machdep.c @@ -56,8 +56,29 @@ sysarch(td, uap) { int error = 0; struct pcb *pcb = curthread->td_pcb; + uint32_t i386base; switch(uap->op) { + case I386_GET_FSBASE: + i386base = pcb->pcb_fsbase; + error = copyout(&i386base, uap->parms, sizeof(i386base)); + break; + case I386_SET_FSBASE: + error = copyin(uap->parms, &i386base, sizeof(i386base)); + pcb->pcb_fsbase = i386base; + if (!error) + wrmsr(MSR_FSBASE, pcb->pcb_fsbase); + break; + case I386_GET_GSBASE: + i386base = pcb->pcb_gsbase; + error = copyout(&i386base, uap->parms, sizeof(i386base)); + break; + case I386_SET_GSBASE: + error = copyin(uap->parms, &i386base, sizeof(i386base)); + pcb->pcb_gsbase = i386base; + if (!error) + wrmsr(MSR_KGSBASE, pcb->pcb_gsbase); + break; case AMD64_GET_FSBASE: error = copyout(&pcb->pcb_fsbase, uap->parms, sizeof(pcb->pcb_fsbase)); break; diff --git a/sys/amd64/include/sysarch.h b/sys/amd64/include/sysarch.h index 6918a0a11f5..67c8a4ae99b 100644 --- a/sys/amd64/include/sysarch.h +++ b/sys/amd64/include/sysarch.h @@ -35,6 +35,11 @@ #ifndef _MACHINE_SYSARCH_H_ #define _MACHINE_SYSARCH_H_ +#define I386_GET_FSBASE 7 +#define I386_SET_FSBASE 8 +#define I386_GET_GSBASE 9 +#define I386_SET_GSBASE 10 + /* Leave space for 0-127 for to avoid translating syscalls */ #define AMD64_GET_FSBASE 128 #define AMD64_SET_FSBASE 129