Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

metag: ptrace: Implement NT_METAG_TLS

Implement functionality to get the TLS pointer for the metag
architecture using regsets.

This provides multi-threaded debug support for GDB.

Signed-off-by: Paul Clothier <Paul.Clothier@imgtec.com>
Signed-off-by: James Hogan <james.hogan@imgtec.com>

authored by

Paul Clothier and committed by
James Hogan
876d6dcd 2b8660ed

+35
+34
arch/metag/kernel/ptrace.c
··· 288 288 return metag_rp_state_copyin(regs, pos, count, kbuf, ubuf); 289 289 } 290 290 291 + static int metag_tls_get(struct task_struct *target, 292 + const struct user_regset *regset, 293 + unsigned int pos, unsigned int count, 294 + void *kbuf, void __user *ubuf) 295 + { 296 + void __user *tls = target->thread.tls_ptr; 297 + return user_regset_copyout(&pos, &count, &kbuf, &ubuf, &tls, 0, -1); 298 + } 299 + 300 + static int metag_tls_set(struct task_struct *target, 301 + const struct user_regset *regset, 302 + unsigned int pos, unsigned int count, 303 + const void *kbuf, const void __user *ubuf) 304 + { 305 + int ret; 306 + void __user *tls; 307 + 308 + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &tls, 0, -1); 309 + if (ret) 310 + return ret; 311 + 312 + target->thread.tls_ptr = tls; 313 + return ret; 314 + } 315 + 291 316 enum metag_regset { 292 317 REGSET_GENERAL, 293 318 REGSET_CBUF, 294 319 REGSET_READPIPE, 320 + REGSET_TLS, 295 321 }; 296 322 297 323 static const struct user_regset metag_regsets[] = { ··· 344 318 .align = sizeof(long long), 345 319 .get = metag_rp_state_get, 346 320 .set = metag_rp_state_set, 321 + }, 322 + [REGSET_TLS] = { 323 + .core_note_type = NT_METAG_TLS, 324 + .n = 1, 325 + .size = sizeof(void *), 326 + .align = sizeof(void *), 327 + .get = metag_tls_get, 328 + .set = metag_tls_set, 347 329 }, 348 330 }; 349 331
+1
include/uapi/linux/elf.h
··· 397 397 #define NT_ARM_HW_WATCH 0x403 /* ARM hardware watchpoint registers */ 398 398 #define NT_METAG_CBUF 0x500 /* Metag catch buffer registers */ 399 399 #define NT_METAG_RPIPE 0x501 /* Metag read pipeline state */ 400 + #define NT_METAG_TLS 0x502 /* Metag TLS pointer */ 400 401 401 402 402 403 /* Note header in a PT_NOTE section */