LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: nathan@kernel.org, linuxppc-dev@lists.ozlabs.org, linkw@gcc.gnu.org
Subject: Re: [PATCH 1/2] powerpc/uaccess: Fix build errors seen with GCC 14
Date: Fri, 24 May 2024 17:09:17 +1000	[thread overview]
Message-ID: <87h6en4rfm.fsf@mail.lhotse> (raw)
In-Reply-To: <CAKwvOdm0_dAvQtuJXWfSCwh+2Jy=79DyjG+tKp9NGv9tunwj1A@mail.gmail.com>

Nick Desaulniers <ndesaulniers@google.com> writes:
> On Tue, May 21, 2024 at 5:39 AM Michael Ellerman <mpe@ellerman.id.au> wrote:
>>
>> Building ppc64le_defconfig with GCC 14 fails with assembler errors:
>>
>>     CC      fs/readdir.o
>>   /tmp/ccdQn0mD.s: Assembler messages:
>>   /tmp/ccdQn0mD.s:212: Error: operand out of domain (18 is not a multiple of 4)
>>   /tmp/ccdQn0mD.s:226: Error: operand out of domain (18 is not a multiple of 4)
>>   ... [6 lines]
>>   /tmp/ccdQn0mD.s:1699: Error: operand out of domain (18 is not a multiple of 4)
>>
>> A snippet of the asm shows:
>>
>>   # ../fs/readdir.c:210:         unsafe_copy_dirent_name(dirent->d_name, name, namlen, efault_end);
>>          ld 9,0(29)       # MEM[(u64 *)name_38(D) + _88 * 1], MEM[(u64 *)name_38(D) + _88 * 1]
>>   # 210 "../fs/readdir.c" 1
>>          1:      std 9,18(8)     # put_user       # *__pus_addr_52, MEM[(u64 *)name_38(D) + _88 * 1]
>>
>> The 'std' instruction requires a 4-byte aligned displacement because
>> it is a DS-form instruction, and as the assembler says, 18 is not a
>> multiple of 4.
>>
>> The fix is to change the constraint on the memory operand to put_user(),
>> from "m" which is a general memory reference to "YZ".
>>
>> The "Z" constraint is documented in the GCC manual PowerPC machine
>> constraints, and specifies a "memory operand accessed with indexed or
>> indirect addressing". "Y" is not documented in the manual but specifies
>> a "memory operand for a DS-form instruction". Using both allows the
>> compiler to generate a DS-form "std" or X-form "stdx" as appropriate.
>>
>> The change has to be conditional on CONFIG_PPC_KERNEL_PREFIXED because
>> the "Y" constraint does not guarantee 4-byte alignment when prefixed
>> instructions are enabled.
>>
>> Unfortunately clang doesn't support the "Y" constraint so that has to be
>> behind an ifdef.
>
> Filed: https://github.com/llvm/llvm-project/issues/92939

Thanks. I will file one to have the GCC constraint documented.

cheers

      reply	other threads:[~2024-05-24  7:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21 12:39 [PATCH 1/2] powerpc/uaccess: Fix build errors seen with GCC 14 Michael Ellerman
2024-05-21 12:39 ` [PATCH 2/2] powerpc/uaccess: Use YZ asm constraint for ld Michael Ellerman
2024-05-21 17:09 ` [PATCH 1/2] powerpc/uaccess: Fix build errors seen with GCC 14 Nick Desaulniers
2024-05-24  7:09   ` Michael Ellerman [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=87h6en4rfm.fsf@mail.lhotse \
    --to=mpe@ellerman.id.au \
    --cc=linkw@gcc.gnu.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.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