From: Richard Henderson <richard.henderson@linaro.org>
To: Ilya Leoshkevich <iii@linux.ibm.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] tests/tcg/multiarch: add vma-pthread.c
Date: Sat, 24 Dec 2022 07:01:45 -0800 [thread overview]
Message-ID: <4eec4a70-e450-4b46-9588-54a884c71b9d@linaro.org> (raw)
In-Reply-To: <20221223120252.513319-1-iii@linux.ibm.com>
On 12/23/22 04:02, Ilya Leoshkevich wrote:
> +static void *thread_write(void *arg)
> +{
> + struct context *ctx = arg;
> + struct timespec *ts;
> + size_t i, j;
> + int ret;
> +
> + for (i = 0; ctx->mutator_count; i++) {
> + j = (i & PAGE_IDX_MASK) | PAGE_IDX_W_MASK;
> + /* Write directly. */
> + memcpy(&ctx->ptr[j * ctx->pagesize], nop_func, sizeof(nop_func));
> + /* Write using a syscall. */
> + ts = (struct timespec *)(&ctx->ptr[(j + 1) * ctx->pagesize] -
> + sizeof(struct timespec));
> + ret = clock_gettime(CLOCK_REALTIME, ts);
> + assert(ret == 0);
With the 3 issues that you pointed out in the other email, this is the only remaining
failure. This happens because of two issues:
(1) When checking for writability, we actually check for both read+write:
#define VERIFY_WRITE (PAGE_READ | PAGE_WRITE)
This is very likely a bug, but we'd need to audit all uses to find out where we might
really want read+write.
> +static void *thread_mutate(void *arg)
> +{
> + size_t i, start_idx, end_idx, page_idx, tmp;
> + struct context *ctx = arg;
> + unsigned int seed;
> + int prot, ret;
> +
> + seed = (unsigned int)time(NULL);
> + for (i = 0; i < 50000; i++) {
> + start_idx = rand_r(&seed) & PAGE_IDX_MASK;
> + end_idx = rand_r(&seed) & PAGE_IDX_MASK;
> + if (start_idx > end_idx) {
> + tmp = start_idx;
> + start_idx = end_idx;
> + end_idx = tmp;
> + }
> + prot = rand_r(&seed) & (PROT_READ | PROT_WRITE | PROT_EXEC);
> + for (page_idx = start_idx & REGION_MASK; page_idx <= end_idx;
> + page_idx += PAGES_PER_REGION) {
> + if (page_idx & PAGE_IDX_R_MASK) {
> + prot |= PROT_READ;
> + }
> + if (page_idx & PAGE_IDX_W_MASK) {
> + prot |= PROT_WRITE;
> + }
> + if (page_idx & PAGE_IDX_X_MASK) {
> + prot |= PROT_EXEC;
> + }
... and here we can wind up with write-only pages.
(2) Certain hardware, like x86_64, does not support write-only pages -- writable implies
readable -- so the testcase runs on some hardware. It is a bug that we don't model this
as well.
r~
prev parent reply other threads:[~2022-12-24 15:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20221223115348.tgfwdlektsulebxk@heavy>
2022-12-23 12:02 ` [PATCH] tests/tcg/multiarch: add vma-pthread.c Ilya Leoshkevich
2022-12-23 12:09 ` Ilya Leoshkevich
2022-12-24 15:01 ` Richard Henderson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4eec4a70-e450-4b46-9588-54a884c71b9d@linaro.org \
--to=richard.henderson@linaro.org \
--cc=iii@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).