<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 25, 2019 at 5:01 PM Jan Stancek <<a href="mailto:jstancek@redhat.com">jstancek@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
----- Original Message -----<br>
> +<br>
> +#ifndef PKEYS_H<br>
> +#define PKEYS_H<br>
> +<br>
> +#include "tst_test.h"<br>
> +#include "lapi/syscalls.h"<br>
> +<br>
> +#ifndef PKEY_DISABLE_ACCESS<br>
> +# define PKEY_DISABLE_ACCESS 0x1<br>
> +# define PKEY_DISABLE_WRITE  0x2<br>
> +#endif<br>
> +<br>
> +#ifndef HAVE_PKEY_MPROTECT<br>
> +static inline int pkey_mprotect(void *addr, size_t len, int prot, int pkey)<br>
> +{<br>
> +     return tst_syscall(SYS_pkey_mprotect, addr, len, prot, pkey);<br>
<br>
Hi,<br>
<br>
This should be __NR_*:<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Exactly. Sorry about that mistake.</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
In file included from pkey01.c:32:<br>
pkey.h: In function ‘pkey_mprotect’:<br>
pkey.h:20: error: ‘SYS_pkey_mprotect’ undeclared (first use in this function)<br>
pkey.h:20: error: (Each undeclared identifier is reported only once<br>
pkey.h:20: error: for each function it appears in.)<br>
pkey.h: In function ‘pkey_alloc’:<br>
pkey.h:25: error: ‘SYS_pkey_alloc’ undeclared (first use in this function)<br>
pkey.h: In function ‘pkey_free’:<br>
pkey.h:30: error: ‘SYS_pkey_free’ undeclared (first use in this function)<br>
<br>
> +static void setup(void)<br>
> +{<br>
> +     int i, fd;<br>
> +<br>
> +     if (access("/proc/sys/vm/nr_hugepages", F_OK)) {<br>
> +             tst_res(TINFO, "Huge page is not supported");<br>
> +             size = getpagesize();<br>
> +             no_hugepage = 1;<br>
> +     } else {<br>
> +             SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 1);<br>
<br>
There are 2 problems here, both related to fact that this file exists,<br>
but may return EOPNOTSUPP on read/write.<br>
<br>
1. save_restore should ignore also read/open errors if path is prefixed with '?'<br>
   I'll send this separately.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Thank you for that patch.</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
2. SAFE_FILE_PRINTF in pkey01.c shouldn't be safe, because we need to somehow<br>
   detect that write worked<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">Yes, we should verify if that value has been wrote.</div><div class="gmail_default" style="font-size:small"></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
# ls -la /proc/sys/vm/nr_hugepages<br>
-rw-r--r--. 1 root root 0 Jun 25 04:12 /proc/sys/vm/nr_hugepages<br>
<br>
# cat /proc/sys/vm/nr_hugepages<br>
cat: /proc/sys/vm/nr_hugepages: Operation not supported<br>
<br>
> +static struct tst_test test = {<br>
> +     .tcnt = ARRAY_SIZE(tcases),<br>
> +     .forks_child = 1,<br>
> +     .test = verify_pkey,<br>
> +     .setup = setup,<br>
> +     .cleanup = cleanup,<br>
> +     .save_restore = save_restore,<br>
<br>
.needs_root = 1 as well, since we write to /proc and mount tmpfs<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">Agree.</div><div class="gmail_default" style="font-size:small"></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Rest looks good to me, but I haven't found yet system that could run the test.<br>
<br>
Regards,<br>
Jan<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>