Skip to content

Commit eea3e4d

Browse files
committed
amd64: add mc_tlsbase member to mcontext
Tested by: pho Reviewed by: olce Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D50482
1 parent 0ec7329 commit eea3e4d

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

sys/amd64/amd64/exec_machdep.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,8 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int flags)
635635
mcp->mc_gsbase = pcb->pcb_gsbase;
636636
mcp->mc_xfpustate = 0;
637637
mcp->mc_xfpustate_len = 0;
638+
mcp->mc_tlsbase = (pcb->pcb_flags & PCB_TLSBASE) != 0 ?
639+
pcb->pcb_tlsbase : 0;
638640
bzero(mcp->mc_spare, sizeof(mcp->mc_spare));
639641
return (0);
640642
}
@@ -709,6 +711,10 @@ set_mcontext(struct thread *td, mcontext_t *mcp)
709711
pcb->pcb_fsbase = mcp->mc_fsbase;
710712
pcb->pcb_gsbase = mcp->mc_gsbase;
711713
}
714+
if ((mcp->mc_flags & _MC_HASTLSBASE) != 0) {
715+
pcb->pcb_tlsbase = mcp->mc_tlsbase;
716+
set_pcb_flags(pcb, PCB_TLSBASE);
717+
}
712718
return (0);
713719
}
714720

sys/x86/include/frame.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ struct trapframe {
152152
#define TF_HASSEGS 0x1
153153
#define TF_HASBASES 0x2
154154
#define TF_HASFPXSTATE 0x4
155+
#define TF_RESERV0 0x8 /* no tlsbase in the trapframe */
155156
#endif /* __amd64__ */
156157

157158
#endif /* _MACHINE_FRAME_H_ */

sys/x86/include/ucontext.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ typedef struct __mcontext {
9999
#define _MC_HASSEGS 0x1
100100
#define _MC_HASBASES 0x2
101101
#define _MC_HASFPXSTATE 0x4
102-
#define _MC_FLAG_MASK (_MC_HASSEGS | _MC_HASBASES | _MC_HASFPXSTATE)
102+
#define _MC_HASTLSBASE 0x8
103+
#define _MC_FLAG_MASK (_MC_HASSEGS | _MC_HASBASES | _MC_HASFPXSTATE | \
104+
_MC_HASTLSBASE)
103105

104106
typedef struct __mcontext {
105107
/*
@@ -158,7 +160,9 @@ typedef struct __mcontext {
158160
__register_t mc_xfpustate;
159161
__register_t mc_xfpustate_len;
160162

161-
long mc_spare[4];
163+
__register_t mc_tlsbase;
164+
165+
long mc_spare[3];
162166
} mcontext_t;
163167
#endif /* __amd64__ */
164168

0 commit comments

Comments
 (0)