All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael T. Kloos" <michael@michaelkloos.com>
To: Jessica Clarke <jrtc27@jrtc27.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	linux-riscv <linux-riscv@lists.infradead.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] Fixed: Misaligned memory access. Fixed pointer comparison.
Date: Sun, 23 Jan 2022 12:15:00 -0500	[thread overview]
Message-ID: <3607326c-9d39-a9e7-8e14-65aaef2094fd@michaelkloos.com> (raw)
In-Reply-To: <485047B2-E566-4679-87CF-C4B3CAFEF108@jrtc27.com>

Yes, you are correct, but while I am not that knowledgeable in the kernel
build system, I believe that in many build systems, binutils "as" is usually
called by the "gcc" wrapper, rather than being executed directly.  This
allows for the C preprocessor to be easily and automatically run over *.S
files first.  Binutils "as" doesn't care about suffix.  It just assembles.
"gcc" will check and call the other tools as necessary to build.

Perhaps I should have been more specific in my language.  However,
I was trying to refer to the 2 different build systems in their entirety,
not their individually sub-components because I had originally test
built with gcc, not clang.

	Michael

On 1/23/22 10:44, Jessica Clarke wrote:

> On 23 Jan 2022, at 03:45, Michael T. Kloos <michael@michaelkloos.com> wrote:
>> Rewrote the riscv memmove() assembly implementation.  The
>> previous implementation did not check memory alignment and it
>> compared 2 pointers with a signed comparison.  The misaligned
>> memory access would cause the kernel to crash on systems that
>> did not emulate it in firmware and did not support it in hardware.
>> Firmware emulation is slow and may not exist.  Additionally,
>> hardware support may not exist and would likely still run slower
>> than aligned accesses even if it did.  The RISC-V spec does not
>> guarantee that support for misaligned memory accesses will exist.
>> It should not be depended on.
>>
>> This patch now checks for the maximum granularity of co-alignment
>> between the pointers and copies them with that, using single-byte
>> copy for any unaligned data at their terminations.  It also now uses
>> unsigned comparison for the pointers.
>>
>> Added half-word and, if built for 64-bit, double-word copy.
>>
>> Migrated to the	newer assembler annotations from the now deprecated
>> ones.
>>
>> Commit Message Edited on Jan 22 2022: Fixed some typos.
>>
>> [v2]
>>
>> Per kernel test robot, I have fixed the build under clang.  This
>> was broken due to a difference between gcc and clang, clang requiring
>> explict zero offsets the jalr instruction. gcc allowed them to be
>> omitted if zero.
> Unlike LLVM, GCC does not have an assembler, that’s binutils’s GNU as.
>
> Jess
>

WARNING: multiple messages have this Message-ID (diff)
From: "Michael T. Kloos" <michael@michaelkloos.com>
To: Jessica Clarke <jrtc27@jrtc27.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	linux-riscv <linux-riscv@lists.infradead.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] Fixed: Misaligned memory access. Fixed pointer comparison.
Date: Sun, 23 Jan 2022 12:15:00 -0500	[thread overview]
Message-ID: <3607326c-9d39-a9e7-8e14-65aaef2094fd@michaelkloos.com> (raw)
In-Reply-To: <485047B2-E566-4679-87CF-C4B3CAFEF108@jrtc27.com>

Yes, you are correct, but while I am not that knowledgeable in the kernel
build system, I believe that in many build systems, binutils "as" is usually
called by the "gcc" wrapper, rather than being executed directly.  This
allows for the C preprocessor to be easily and automatically run over *.S
files first.  Binutils "as" doesn't care about suffix.  It just assembles.
"gcc" will check and call the other tools as necessary to build.

Perhaps I should have been more specific in my language.  However,
I was trying to refer to the 2 different build systems in their entirety,
not their individually sub-components because I had originally test
built with gcc, not clang.

	Michael

On 1/23/22 10:44, Jessica Clarke wrote:

> On 23 Jan 2022, at 03:45, Michael T. Kloos <michael@michaelkloos.com> wrote:
>> Rewrote the riscv memmove() assembly implementation.  The
>> previous implementation did not check memory alignment and it
>> compared 2 pointers with a signed comparison.  The misaligned
>> memory access would cause the kernel to crash on systems that
>> did not emulate it in firmware and did not support it in hardware.
>> Firmware emulation is slow and may not exist.  Additionally,
>> hardware support may not exist and would likely still run slower
>> than aligned accesses even if it did.  The RISC-V spec does not
>> guarantee that support for misaligned memory accesses will exist.
>> It should not be depended on.
>>
>> This patch now checks for the maximum granularity of co-alignment
>> between the pointers and copies them with that, using single-byte
>> copy for any unaligned data at their terminations.  It also now uses
>> unsigned comparison for the pointers.
>>
>> Added half-word and, if built for 64-bit, double-word copy.
>>
>> Migrated to the	newer assembler annotations from the now deprecated
>> ones.
>>
>> Commit Message Edited on Jan 22 2022: Fixed some typos.
>>
>> [v2]
>>
>> Per kernel test robot, I have fixed the build under clang.  This
>> was broken due to a difference between gcc and clang, clang requiring
>> explict zero offsets the jalr instruction. gcc allowed them to be
>> omitted if zero.
> Unlike LLVM, GCC does not have an assembler, that’s binutils’s GNU as.
>
> Jess
>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2022-01-23 17:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-23  3:45 [PATCH v2] Fixed: Misaligned memory access. Fixed pointer comparison Michael T. Kloos
2022-01-23  3:45 ` Michael T. Kloos
2022-01-23 13:31 ` David Laight
2022-01-23 13:31   ` David Laight
2022-01-23 16:53   ` Michael T. Kloos
2022-01-23 16:53     ` Michael T. Kloos
2022-01-23 22:35     ` David Laight
2022-01-23 22:35       ` David Laight
2022-01-23 23:03       ` Michael T. Kloos
2022-01-23 23:03         ` Michael T. Kloos
2022-01-23 15:44 ` Jessica Clarke
2022-01-23 15:44   ` Jessica Clarke
2022-01-23 17:15   ` Michael T. Kloos [this message]
2022-01-23 17:15     ` Michael T. Kloos
2022-01-24  9:21 ` David Laight
2022-01-24  9:21   ` David Laight
2022-01-24 19:19   ` Michael T. Kloos
2022-01-24 19:19     ` Michael T. Kloos
2022-01-24 22:28     ` David Laight
2022-01-24 22:28       ` David Laight
2022-01-24 13:38 ` kernel test robot

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=3607326c-9d39-a9e7-8e14-65aaef2094fd@michaelkloos.com \
    --to=michael@michaelkloos.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=jrtc27@jrtc27.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.