From: Alexander Potapenko <glider@google.com>
To: Marco Elver <elver@google.com>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
dvyukov@google.com, linux-mm@kvack.org
Subject: Re: [PATCH] kmsan: fix memcpy tests
Date: Mon, 5 Dec 2022 15:49:37 +0100 [thread overview]
Message-ID: <CAG_fn=U-8ZkoaK9tS8EfthKEDazNZhTzi-_vrbrim-VJPzG+yQ@mail.gmail.com> (raw)
In-Reply-To: <CANpmjNOrm1ED1tRSy9Ap+48zHCrfw1yRffx1G9YHGLt-BtH90g@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1139 bytes --]
On Mon, Dec 5, 2022 at 3:12 PM Marco Elver <elver@google.com> wrote:
> On Mon, 5 Dec 2022 at 14:26, Alexander Potapenko <glider@google.com>
> wrote:
> >
> > Recent Clang changes may cause it to delete calls of memcpy(), if the
> > source is an uninitialized volatile local.
> > This happens because passing a pointer to a volatile local into memcpy()
> > discards the volatile qualifier, giving the compiler a free hand to
> > optimize the memcpy() call away.
> >
> > To outsmart the compiler, we call __msan_memcpy() instead of memcpy()
> > in test_memcpy_aligned_to_aligned(), test_memcpy_aligned_to_unaligned()
> > and test_memcpy_aligned_to_unaligned2(), because it's the behavior of
> > __msan_memcpy() we are testing here anyway.
> >
> > Signed-off-by: Alexander Potapenko <glider@google.com>
>
> It might be nice to retain memcpy() calls somehow, as that tests
> end-to-end that the compiler does the right thing here i.e. replacing
> the memcpy() calls with instrumented versions.
>
> Does OPTIMIZER_HIDE_VAR() help? This should prevent the compiler from
> seeing it's uninitialized.
>
> It indeed does, thanks!
Let me send a v2.
[-- Attachment #2: Type: text/html, Size: 1694 bytes --]
next prev parent reply other threads:[~2022-12-05 14:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-05 13:25 Alexander Potapenko
2022-12-05 14:11 ` Marco Elver
2022-12-05 14:49 ` Alexander Potapenko [this message]
2022-12-05 14:57 ` [PATCH v2] " Alexander Potapenko
2022-12-05 15:10 ` Marco Elver
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='CAG_fn=U-8ZkoaK9tS8EfthKEDazNZhTzi-_vrbrim-VJPzG+yQ@mail.gmail.com' \
--to=glider@google.com \
--cc=akpm@linux-foundation.org \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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