From: Andrew Morton <akpm@linux-foundation.org>
To: akpm@linux-foundation.org, andriy.shevchenko@intel.com,
aryabinin@virtuozzo.com, bot@kernelci.org, bp@alien8.de,
brgerst@gmail.com, dja@axtens.net, elver@google.com,
hpa@zytor.com, ilie.halip@gmail.com, jesse.brandeburg@intel.com,
linux-mm@kvack.org, luc.vanoostenryck@gmail.com,
mingo@redhat.com, mm-commits@vger.kernel.org,
natechancellor@gmail.com, ndesaulniers@google.com,
paulmck@kernel.org, peterz@infradead.org, sedat.dilek@gmail.com,
tglx@linutronix.de, torvalds@linux-foundation.org,
yamada.masahiro@socionext.com
Subject: [patch 02/11] x86: bitops: fix build regression
Date: Fri, 22 May 2020 22:22:45 -0700 [thread overview]
Message-ID: <20200523052245.o_gif23zt%akpm@linux-foundation.org> (raw)
In-Reply-To: <20200522222217.ee14ad7eda7aab1e6697da6c@linux-foundation.org>
From: Nick Desaulniers <ndesaulniers@google.com>
Subject: x86: bitops: fix build regression
This is easily reproducible via CC=clang+CONFIG_STAGING=y+CONFIG_VT6656=m.
It turns out that if your config tickles __builtin_constant_p via
differences in choices to inline or not, these statements produce invalid
assembly:
$ cat foo.c
long a(long b, long c) {
asm("orb %1, %0" : "+q"(c): "r"(b));
return c;
}
$ gcc foo.c
foo.c: Assembler messages:
foo.c:2: Error: `%rax' not allowed with `orb'
Use the `%b` "x86 Operand Modifier" to instead force register allocation
to select a lower-8-bit GPR operand.
The "q" constraint only has meaning on -m32 otherwise is treated as
"r". Not all GPRs have low-8-bit aliases for -m32.
Link: http://lkml.kernel.org/r/20200508183230.229464-1-ndesaulniers@google.com
Link: https://github.com/ClangBuiltLinux/linux/issues/961
Link: https://lore.kernel.org/lkml/20200504193524.GA221287@google.com/
Link: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#x86Operandmodifiers
Fixes: 1651e700664b4 ("x86: Fix bitops.h warning with a moved cast")
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Reported-by: kernelci.org bot <bot@kernelci.org>
Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Suggested-by: Brian Gerst <brgerst@gmail.com>
Suggested-by: H. Peter Anvin <hpa@zytor.com>
Suggested-by: Ilie Halip <ilie.halip@gmail.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-By: Brian Gerst <brgerst@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com> [build, clang-11]
Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Marco Elver <elver@google.com>
Cc: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Daniel Axtens <dja@axtens.net>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
arch/x86/include/asm/bitops.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
--- a/arch/x86/include/asm/bitops.h~x86-bitops-fix-build-regression
+++ a/arch/x86/include/asm/bitops.h
@@ -52,9 +52,9 @@ static __always_inline void
arch_set_bit(long nr, volatile unsigned long *addr)
{
if (__builtin_constant_p(nr)) {
- asm volatile(LOCK_PREFIX "orb %1,%0"
+ asm volatile(LOCK_PREFIX "orb %b1,%0"
: CONST_MASK_ADDR(nr, addr)
- : "iq" (CONST_MASK(nr) & 0xff)
+ : "iq" (CONST_MASK(nr))
: "memory");
} else {
asm volatile(LOCK_PREFIX __ASM_SIZE(bts) " %1,%0"
@@ -72,9 +72,9 @@ static __always_inline void
arch_clear_bit(long nr, volatile unsigned long *addr)
{
if (__builtin_constant_p(nr)) {
- asm volatile(LOCK_PREFIX "andb %1,%0"
+ asm volatile(LOCK_PREFIX "andb %b1,%0"
: CONST_MASK_ADDR(nr, addr)
- : "iq" (CONST_MASK(nr) ^ 0xff));
+ : "iq" (~CONST_MASK(nr)));
} else {
asm volatile(LOCK_PREFIX __ASM_SIZE(btr) " %1,%0"
: : RLONG_ADDR(addr), "Ir" (nr) : "memory");
@@ -123,9 +123,9 @@ static __always_inline void
arch_change_bit(long nr, volatile unsigned long *addr)
{
if (__builtin_constant_p(nr)) {
- asm volatile(LOCK_PREFIX "xorb %1,%0"
+ asm volatile(LOCK_PREFIX "xorb %b1,%0"
: CONST_MASK_ADDR(nr, addr)
- : "iq" ((u8)CONST_MASK(nr)));
+ : "iq" (CONST_MASK(nr)));
} else {
asm volatile(LOCK_PREFIX __ASM_SIZE(btc) " %1,%0"
: : RLONG_ADDR(addr), "Ir" (nr) : "memory");
_
next prev parent reply other threads:[~2020-05-23 5:22 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-23 5:22 incoming Andrew Morton
2020-05-23 5:22 ` [patch 01/11] device-dax: don't leak kernel memory to user space after unloading kmem Andrew Morton
2020-05-23 5:22 ` Andrew Morton [this message]
2020-05-23 5:22 ` [patch 03/11] rapidio: fix an error in get_user_pages_fast() error handling Andrew Morton
2020-05-23 5:22 ` [patch 04/11] selftests/vm/.gitignore: add mremap_dontunmap Andrew Morton
2020-05-23 5:22 ` [patch 05/11] selftests/vm/write_to_hugetlbfs.c: fix unused variable warning Andrew Morton
2020-05-23 5:22 ` [patch 06/11] kasan: disable branch tracing for core runtime Andrew Morton
2020-05-23 5:23 ` [patch 07/11] sh: include linux/time_types.h for sockios Andrew Morton
2020-05-23 5:23 ` [patch 08/11] MAINTAINERS: update email address for Naoya Horiguchi Andrew Morton
2020-05-23 5:23 ` [patch 09/11] sparc32: use PUD rather than PGD to get PMD in srmmu_nocache_init() Andrew Morton
2020-05-23 19:01 ` Mike Rapoport
2020-05-23 19:10 ` Linus Torvalds
2020-05-23 19:57 ` Mike Rapoport
2020-05-23 5:23 ` [patch 10/11] z3fold: fix use-after-free when freeing handles Andrew Morton
2020-05-23 5:23 ` [patch 11/11] MAINTAINERS: add files related to kdump Andrew Morton
2020-05-25 5:10 ` mmotm 2020-05-24-22-09 uploaded Andrew Morton
2020-05-25 23:57 ` mmotm 2020-05-25-16-56 uploaded Andrew Morton
2020-05-26 3:49 ` mmotm 2020-05-25-16-56 uploaded (drm/nouveau) Randy Dunlap
2020-05-26 4:23 ` Dave Airlie
2020-05-26 4:31 ` Randy Dunlap
2020-05-26 6:56 ` mmotm 2020-05-25-16-56 uploaded (mtd/nand/raw/arasan-nand-controller) Randy Dunlap
2020-05-26 19:37 ` Miquel Raynal
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=20200523052245.o_gif23zt%akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=andriy.shevchenko@intel.com \
--cc=aryabinin@virtuozzo.com \
--cc=bot@kernelci.org \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dja@axtens.net \
--cc=elver@google.com \
--cc=hpa@zytor.com \
--cc=ilie.halip@gmail.com \
--cc=jesse.brandeburg@intel.com \
--cc=linux-mm@kvack.org \
--cc=luc.vanoostenryck@gmail.com \
--cc=mingo@redhat.com \
--cc=mm-commits@vger.kernel.org \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=sedat.dilek@gmail.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=yamada.masahiro@socionext.com \
/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).