Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ck_pr: fix ptr output operand widths on x86 and x86_64 #175

Merged
merged 1 commit into from
Aug 11, 2021

Conversation

markjdb
Copy link
Contributor

@markjdb markjdb commented Jul 22, 2021

Operations on a variable of type "ptr" specify that the output operand
can be a memory address. Most such operations specify that the output
operand is of type char, so it has width 1. Convert these to uint64_t
on x86_64 and uint32_t on x86.

No functional change intended. With clang 12.0.1 there is no difference
in the generated code before and after this change.

The compiler needs to know the true width of the destination operand in
some cases. In particular, when compiling with LLVM's MemorySanitizer
enabled, the generated code updates shadow state to mark variables as
initialized (or not) at byte granularity. When instrumenting inline
assembly, the compiler uses the width of the output operand(s) to figure
out how many bytes of shadow state to update. When the output operand
is cast to char, the runtime would only update one byte of shadow state
even though the store modified eight bytes of memory. This led to false
positives when enabling MSAN in the FreeBSD kernel.

Operations on a variable of type "ptr" specify that the output operand
can be a memory address.  Most such operations specify that the output
operand is of type char, so it has width 1.  Convert these to uint64_t
on x86_64 and uint32_t on x86.

No functional change intended.  With clang 12.0.1 there is no difference
in the generated code before and after this change.

The compiler needs to know the true width of the destination operand in
some cases.  In particular, when compiling with LLVM's MemorySanitizer
enabled, the generated code updates shadow state to mark variables as
initialized (or not) at byte granularity.  When instrumenting inline
assembly, the compiler uses the width of the output operand(s) to figure
out how many bytes of shadow state to update.  When the output operand
is cast to char, the runtime would only update one byte of shadow state
even though the store modified eight bytes of memory.  This led to false
positives when enabling MSAN in the FreeBSD kernel.
markjdb added a commit to markjdb/freebsd that referenced this pull request Aug 11, 2021
This does not appear to change generated code with the default
toolchain.  However, KMSAN makes use of output operand specifications to
instrument inline asm, and with incorrect specifications we get false
positives in code that uses the CK_(S)LIST macros.

This was submitted upstream:
concurrencykit/ck#175

The commit applies the same change locally to make KMSAN usable until
something equivalent is merged upstream.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
freebsd-git pushed a commit to freebsd/freebsd-src that referenced this pull request Aug 11, 2021
This does not appear to change generated code with the default
toolchain.  However, KMSAN makes use of output operand specifications to
instrument inline asm, and with incorrect specifications we get false
positives in code that uses the CK_(S)LIST macros.

This was submitted upstream:
concurrencykit/ck#175

The commit applies the same change locally to make KMSAN usable until
something equivalent is merged upstream.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
@sbahra sbahra merged commit 2f9acab into concurrencykit:master Aug 11, 2021
agrajag9 pushed a commit to agrajag9/freebsd-src that referenced this pull request Aug 13, 2021
This does not appear to change generated code with the default
toolchain.  However, KMSAN makes use of output operand specifications to
instrument inline asm, and with incorrect specifications we get false
positives in code that uses the CK_(S)LIST macros.

This was submitted upstream:
concurrencykit/ck#175

The commit applies the same change locally to make KMSAN usable until
something equivalent is merged upstream.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
bsdjhb pushed a commit to bsdjhb/cheribsd that referenced this pull request Dec 23, 2021
This does not appear to change generated code with the default
toolchain.  However, KMSAN makes use of output operand specifications to
instrument inline asm, and with incorrect specifications we get false
positives in code that uses the CK_(S)LIST macros.

This was submitted upstream:
concurrencykit/ck#175

The commit applies the same change locally to make KMSAN usable until
something equivalent is merged upstream.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants