Skip to contentSkip to conversation

syscalls/set_thread_area01: Refactor into new API

PATCH In review Ricardo B. Marlière via ltp 1 participant 2 messages Jun 23, 2025 – Jun 24, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 syscalls/set_thread_area01: Refactor into new API

From: Ricardo B. Marlière <[email protected]>

---
Changes in v5:
- Rebased now that the prerequisites are merged
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Added set_thread_area02 to runtest/syscalls
- Added missing static modifiers
- Fixed formatting issue in .bufs
- Removed struct tvariant in set_thread_area02
- Renamed entry -> u_info to follow manpage standard
- Added expected errnos to set_thread_area02 description
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Moved syscall wrappers to include/lapi/ldt.h
- Split the test into a new set_thread_area02.c file
- Used guarded buffers
- Used .supported_archs instead of #ifdef __i386__
- Used .test_variants and .tcnt+.test in set_thread_area02.c
- Tweaked test decriptions
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Used tst_test.test_all instead of .test
- Removed VALUE_AND_STRING macro
- Added local wrappers to the syscalls
- Fixed the test description
- Added a comment quote from the set_thread_area manual to add context
- Link to v1: https://lore.kernel.org/all/[email protected]

---
 include/lapi/ldt.h                                 |  10 ++
 runtest/syscalls                                   |   1 +
 .../kernel/syscalls/set_thread_area/.gitignore     |   3 +-
 .../syscalls/set_thread_area/set_thread_area.h     |  31 -----
 .../syscalls/set_thread_area/set_thread_area01.c   | 137 +++++++--------------
 .../syscalls/set_thread_area/set_thread_area02.c   |  57 +++++++++
 6 files changed, 113 insertions(+), 126 deletions(-)
include/lapi/ldt.h +10 -0
index 331f25b444a48c4c7f1833c376fb69404029846c..d9233d09bee947a90d22538e2e3cf13dece64208 100644
@@ -76,4 +76,14 @@ static inline int safe_modify_ldt(const char *file, const int lineno, int func,
 #define SAFE_MODIFY_LDT(func, ptr, bytecount) \
 	safe_modify_ldt(__FILE__, __LINE__, (func), (ptr), (bytecount))
 
+static inline int set_thread_area(const struct user_desc *u_info)
+{
+	return tst_syscall(__NR_set_thread_area, u_info);
+}
+
+static inline int get_thread_area(const struct user_desc *u_info)
+{
+	return tst_syscall(__NR_get_thread_area, u_info);
+}
+
 #endif /* LAPI_LDT_H__ */
runtest/syscalls +1 -0
index d5582ca8da01f11adba75a56d22cb6e5c4996c68..582422ac9ca8ccae598c626a11cf6ee7c30f0e3a 100644
@@ -1361,6 +1361,7 @@ set_mempolicy04 set_mempolicy04
 
 set_robust_list01 set_robust_list01
 set_thread_area01 set_thread_area01
+set_thread_area02 set_thread_area02
 set_tid_address01 set_tid_address01
 
 setdomainname01	setdomainname01
testcases/kernel/syscalls/set_thread_area/.gitignore +2 -1
index 547eb86e3c4ee86e2343067867c3bb027e0ee85a..b80ce741812c33fd9af47ecba8561ef385212e97 100644
@@ -1 +1,2 @@
-/set_thread_area01
+set_thread_area01
+set_thread_area02
testcases/kernel/syscalls/set_thread_area/set_thread_area.h deleted +0 -31
deleted file mode 100644
index 2bd2469d549ecf8c5c589a0a9485f886d043f7ed..0000000000000000000000000000000000000000
@@ -1,31 +0,0 @@
-#include <stdio.h>
-#include <errno.h>
-
-/* Harness Specific Include Files. */
-#include "test.h"
-#include "lapi/syscalls.h"
-#include "config.h"
-
-#if defined HAVE_ASM_LDT_H
-#include <linux/unistd.h>
-#include <asm/ldt.h>
-
-#if defined HAVE_STRUCT_USER_DESC
-typedef struct user_desc thread_area_s;
-#elif defined HAVE_STRUCT_MODIFY_LDT_LDT_S
-typedef struct modify_ldt_ldt_s thread_area_s;
-#else
-typedef struct user_desc {
-	unsigned int entry_number;
-	unsigned long int base_addr;
-	unsigned int limit;
-	unsigned int seg_32bit:1;
-	unsigned int contents:2;
-	unsigned int read_exec_only:1;
-	unsigned int limit_in_pages:1;
-	unsigned int seg_not_present:1;
-	unsigned int useable:1;
-	unsigned int empty:25;
-} thread_area_s;
-#endif /* HAVE_STRUCT_USER_DESC */
-#endif /* HAVE_ASM_LDT_H */
testcases/kernel/syscalls/set_thread_area/set_thread_area01.c +43 -94

154 lines not on this page · raw message

testcases/kernel/syscalls/set_thread_area/set_thread_area02.c new file +57 -0

57 lines not on this page · raw message

---
base-commit: df591113afeb31107bc45bd5ba28a99b556d1028
change-id: 20250623-conversions-set_thread_area-7b82bcf5ee58

Best regards,

Signature · 5 lines
Ricardo B. Marlière <[email protected]>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi!

Merged thanks.

- Andrea

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp