mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bo Yan <byan@nvidia.com>
To: <robin.murphy@arm.com>
Cc: <linux-kernel@vger.kernel.org>, <luke.starrett@broadcom.com>
Subject: a question about IP checksum helper for arm64
Date: Fri, 6 Jul 2018 09:27:42 -0700	[thread overview]
Message-ID: <141d76cc-d43b-5412-fb39-426d7c2261b9@nvidia.com> (raw)

Hi Robin, Luke,

Recently I bumped into an error when running GCC undefined behavior 
sanitizer:

UBSAN: Undefined behaviour in 
kernel-4.9/arch/arm64/include/asm/checksum.h:34:6
        load of misaligned address ffffffc198c8b254 for type 'const 
__int128 unsigned'
        which requires 16 byte alignment


The relevant code:

         tmp = *(const __uint128_t *)iph;
         iph += 16;
         ihl -= 4;
         tmp += ((tmp >> 64) | (tmp << 64));
         sum = tmp >> 64;
         do {
                 sum += *(const u32 *)iph;
                 iph += 4;
         } while (--ihl);

But, I checked the generated disassembly, it doesn't look like anything 
special is generated taking advantage of that.

I'm using Linaro GCC 6.4-2017.08, expecting ldp instructions to be 
emitted, but don't see it.

There were some prior discussions about GCC behavior, like this thread: 
https://patchwork.kernel.org/patch/9081911/ , in which you talked about 
the difference between GCC4 and GCC5.3. It looks to me this is regressed 
in Linaro GCC6.4 build.

I have not checked newer GCC versions.

Will it be more stable to just do this with inline assembly instead of 
relying on __uint128_t data type?

GCC documentation says __int128 is supported for targets which have an 
integer mode wide enough to hold 128 bits. aarch64 doesn't have such an 
integer mode.

Thanks

Bo

             reply	other threads:[~2018-07-06 16:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-06 16:27 Bo Yan [this message]
2018-07-09 11:54 ` Robin Murphy
2018-07-09 19:53   ` Bo Yan

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=141d76cc-d43b-5412-fb39-426d7c2261b9@nvidia.com \
    --to=byan@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luke.starrett@broadcom.com \
    --cc=robin.murphy@arm.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

all inboxes | Powered by JetHome®