git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] block-sha1: remove use of assembly

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Mar 9, 2022, 23:52 UTC
Message-ID
<220310.86cziulls6.gmgdl@evledraar.gmail.com>
In-Reply-To
<Yikq7POhuxeN1UPQ@nand.local>
On Wed, Mar 09 2022, Taylor Blau wrote:
Show 23 quoted lines
> On Wed, Mar 09, 2022 at 10:10:33PM +0000, brian m. carlson wrote:
>> On 2022-03-08 at 13:38:06, Ævar Arnfjörð Bjarmason wrote:
>> >
>> > On Tue, Mar 08 2022, brian m. carlson wrote:
>> >
>> > I think the $subject of the patch needs updating. It's not removing all
>> > the assemply from the file, after this patch we still have the
>> > ARM-specific assembly.
>> >
>> > I don't have a box to test that on, but I wonder if that also triggers
>> > the pedantic mode?
>> >
>> > Perhaps:
>> >
>> >     block-sha1: remove superfluous i386 and x86-64 assembly
>>
>> I suspect it has the same problem.  My inclination is to just remove it,
>> because my guess is that the compiler has gotten smarter between 2009
>> and now.
>
> Almost certainly. I don't have a machine to test it on, either, but I
> would be shocked if `make BLK_SHA=YesPlease DEVELOPER=1` worked on
> master today on an arm machine.

Why is that? The -pedantic error is specifically about "gnu-statement-expression", i.e. the bracket syntax, not the inline assembly per-se.

The ARM assembly isn't using that, and we have other code __asm__ code compiled with -pedantic. E.g. I get the __asm__ in "compat/bswap.h" by default, and it passes -pedantic (the code starting around line 38).

Show 28 quoted lines
>> I honestly intend to just remove this code in a future version because
>> everyone not using SHA1DC has a security problem and we shouldn't offer
>> insecure options.
>>
>> However, I think for now, I'm just going to reroll this with the new
>> title and then I can remove it in a future version unless somebody with
>> an ARM system can relatively quickly tell me whether it's necessary.
>
> I wonder if a good stop-gap for arm systems might be to do something
> like:
>
> --- 8< ---
>
> diff --git a/block-sha1/sha1.c b/block-sha1/sha1.c
> index 1bb6e7c069..7402d02875 100644
> --- a/block-sha1/sha1.c
> +++ b/block-sha1/sha1.c
> @@ -57,7 +57,7 @@
>  #if defined(__i386__) || defined(__x86_64__)
>    #define setW(x, val) (*(volatile unsigned int *)&W(x) = (val))
>  #elif defined(__GNUC__) && defined(__arm__)
> -  #define setW(x, val) do { W(x) = (val); __asm__("":::"memory"); } while (0)
> +  #define setW(x, val) do { W(x) = (val); __extension__ __asm__("":::"memory"); } while (0)
>  #else
>    #define setW(x, val) (W(x) = (val))
>  #endif
>
> --- >8 ---

Isn't that __extension__ only needed *if* it warns under -pedantic, which AFAICT doesn't apply to all uses of __asm__ (but your compiler version etc. may be different...).

Previous: Taylor BlauNext: Carlo Marcelo Arenas Belón
Message 8 of 12 in “block-sha1: remove use of assembly”
  1. block-sha1: remove use of assemblybrian m. carlson, Mar 7, 2022
  2. Taylor BlauMar 7, 2022
  3. brian m. carlsonMar 8, 2022
  4. block-sha1: remove use of assemblybrian m. carlson, Mar 8, 2022
  5. Ævar Arnfjörð BjarmasonMar 8, 2022
  6. brian m. carlsonMar 9, 2022
  7. Taylor BlauMar 9, 2022
  8. Ævar Arnfjörð BjarmasonMar 9, 2022
  9. Carlo Marcelo Arenas BelónMar 10, 2022
  10. Taylor BlauMar 10, 2022
  11. block-sha1: remove use of obsolete x86 assemblybrian m. carlson, Mar 10, 2022
  12. Junio C HamanoMar 10, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.