Skip to content

Commit

Permalink
pkey: remove the ltp_ prefix from pkey functions
Browse files Browse the repository at this point in the history
Suggested-by: Petr Vorel <[email protected]>
Signed-off-by: Li Wang <[email protected]>
Reviewed-by: Petr Vorel <[email protected]>
  • Loading branch information
wangli5665 committed Aug 6, 2024
1 parent a12abbf commit adc878f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
14 changes: 5 additions & 9 deletions include/lapi/pkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,25 @@
#endif

#ifndef HAVE_PKEY_MPROTECT
inline int ltp_pkey_mprotect(void *addr, size_t len, int prot, int pkey)
inline int pkey_mprotect(void *addr, size_t len, int prot, int pkey)
{
return tst_syscall(__NR_pkey_mprotect, addr, len, prot, pkey);
}

inline int ltp_pkey_alloc(unsigned int flags, unsigned int access_rights)
inline int pkey_alloc(unsigned int flags, unsigned int access_rights)
{
return tst_syscall(__NR_pkey_alloc, flags, access_rights);
}

inline int ltp_pkey_free(int pkey)
inline int pkey_free(int pkey)
{
return tst_syscall(__NR_pkey_free, pkey);
}
#else
#define ltp_pkey_alloc pkey_alloc
#define ltp_pkey_free pkey_free
#define ltp_pkey_mprotect pkey_mprotect
#endif /* HAVE_PKEY_MPROTECT */

static inline void check_pkey_support(void)
{
int pkey = ltp_pkey_alloc(0, 0);
int pkey = tst_syscall(__NR_pkey_alloc, 0, 0);

if (pkey == -1) {
if (errno == ENOSYS)
Expand All @@ -50,7 +46,7 @@ static inline void check_pkey_support(void)
tst_brk(TCONF, "pkeys are not available for test");
}

ltp_pkey_free(pkey);
tst_syscall(__NR_pkey_free, pkey);
}

#endif /* PKEYS_H__ */
6 changes: 3 additions & 3 deletions testcases/kernel/syscalls/mseal/mseal01.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ static void test_pkey_mprotect(void)

check_pkey_support();

pkey = ltp_pkey_alloc(0, 0);
pkey = pkey_alloc(0, 0);
if (pkey == -1)
tst_brk(TBROK | TERRNO, "pkey_alloc failed");

TST_EXP_FAIL(ltp_pkey_mprotect(
TST_EXP_FAIL(pkey_mprotect(
mem_addr, mem_size,
PROT_NONE,
pkey),
EPERM);

if (ltp_pkey_free(pkey) == -1)
if (pkey_free(pkey) == -1)
tst_brk(TBROK | TERRNO, "pkey_free() error");
}

Expand Down
8 changes: 4 additions & 4 deletions testcases/kernel/syscalls/pkeys/pkey01.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ static void pkey_test(struct tcase *tc, struct mmap_param *mpa)

buffer = SAFE_MMAP(NULL, size, mpa->prot, mpa->flags, fd, 0);

pkey = ltp_pkey_alloc(tc->flags, tc->access_rights);
pkey = pkey_alloc(tc->flags, tc->access_rights);
if (pkey == -1)
tst_brk(TBROK | TERRNO, "pkey_alloc failed");

tst_res(TINFO, "Set %s on (%s) buffer", tc->name, flag_to_str(mpa->flags));
if (ltp_pkey_mprotect(buffer, size, mpa->prot, pkey) == -1)
if (pkey_mprotect(buffer, size, mpa->prot, pkey) == -1)
tst_brk(TBROK | TERRNO, "pkey_mprotect failed");

pid = SAFE_FORK();
Expand Down Expand Up @@ -176,7 +176,7 @@ static void pkey_test(struct tcase *tc, struct mmap_param *mpa)
tst_res(TFAIL, "Child: %s", tst_strstatus(status));

tst_res(TINFO, "Remove %s from the buffer", tc->name);
if (ltp_pkey_mprotect(buffer, size, mpa->prot, 0x0) == -1)
if (pkey_mprotect(buffer, size, mpa->prot, 0x0) == -1)
tst_brk(TBROK | TERRNO, "pkey_mprotect failed");

switch (mpa->prot) {
Expand All @@ -199,7 +199,7 @@ static void pkey_test(struct tcase *tc, struct mmap_param *mpa)

SAFE_MUNMAP(buffer, size);

if (ltp_pkey_free(pkey) == -1)
if (pkey_free(pkey) == -1)
tst_brk(TBROK | TERRNO, "pkey_free failed");
}

Expand Down

0 comments on commit adc878f

Please sign in to comment.