From: Alexander Duyck <alexander.h.duyck@redhat.com>
To: David Miller <davem@davemloft.net>, alexander.duyck@gmail.com
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] flow-dissector: Fix alignment issue in __skb_flow_get_ports
Date: Fri, 10 Oct 2014 07:42:58 -0700 [thread overview]
Message-ID: <5437F072.5060502@redhat.com> (raw)
In-Reply-To: <20141010.004708.1975127853551765914.davem@davemloft.net>
On 10/09/2014 09:47 PM, David Miller wrote:
> From: alexander.duyck@gmail.com
> Date: Thu, 09 Oct 2014 21:03:28 -0700
>
>> From: Alexander Duyck <alexander.h.duyck@redhat.com>
>>
>> This patch addresses a kernel unaligned access bug seen on a sparc64 system
>> with an igb adapter. Specifically the __skb_flow_get_ports was returning a
>> be32 pointer which was then having the value directly returned.
>>
>> In order to keep the handling of the ports consistent with how we were
>> handling the IPv4 and IPv6 addresses I have instead replaced the assignment
>> with a memcpy to the flow key ports value. This way it should stay a
>> memcpy on systems that cannot handle unaligned access, and will likely be
>> converted to a 32b assignment on the systems that can support it.
>>
>> Reported-by: David S. Miller <davem@davemloft.net>
>> Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
> Guess what the compiler will output for the memcpy()....
>
> *(u32 *)dest = *(u32 *)src;
>
> Using memcpy() is never a valid way to avoid misaligned loads and
> stores.
If needed we could convert ports to a __be16 I suppose.
> If the types have a given alignment, the compiler can legitimately
> expand the memcpy() inline with suitably sized loads and stores.
That is what I get for trying to come up with a fix at the end of the
day. Although it does leave me scratching my head why the IPv4 and IPv6
addresses were not causing unaligned accesses or were they triggering
them as well?
> Please see my other reply in the original thread, we have to use
> the hardware when we can to manage this situation, by configuring
> it to output two garbage bytes before the packet contents when
> DMA'ing into power-of-2 aligned blocks of memory.
>
> Thanks.
The problem is the igb / ixgbe / fm10k hardware doesn't have a means of
inserting padding from its side. The whole point of the xxx_get_headlen
functions was to determine the size needed in order to generate the
correct memcpy so that we could generate an aligned header. It sounds
like we can't do that with this function now because there are multiple
instances where the data will be accessed unaligned if it isn't aligned
in the first place.
The way I see it now there are two possible solutions. The first one
being to update the flow hash functions to work with unaligned accesses,
and the second being to split the get_headlen code flow off and for now
use my original code which already had all the alignment issues
resolved. I'm open to suggestions either way, but for now I will try to
just address the items you have pointed out here with the current patch
and submit a v2.
Thanks,
Alex
next prev parent reply other threads:[~2014-10-10 14:43 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-10 0:12 eth_get_headlen() and unaligned accesses David Miller
2014-10-10 3:10 ` Alexander Duyck
2014-10-10 4:43 ` David Miller
2014-10-10 10:59 ` David Laight
2014-10-10 4:03 ` [PATCH] flow-dissector: Fix alignment issue in __skb_flow_get_ports alexander.duyck
2014-10-10 4:47 ` David Miller
2014-10-10 14:42 ` Alexander Duyck [this message]
2014-10-10 14:57 ` David Laight
2014-10-10 15:14 ` Alexander Duyck
2014-10-10 15:29 ` Eric Dumazet
2014-10-10 16:50 ` Alexander Duyck
2014-10-10 17:58 ` David Miller
2014-10-10 18:02 ` Alexander Duyck
2014-10-10 18:14 ` David Miller
2014-10-10 18:15 ` David Miller
2014-10-10 18:22 ` David Miller
2014-10-10 18:53 ` Alexander Duyck
2014-10-10 19:32 ` David Miller
2014-10-13 8:32 ` David Laight
2014-10-10 15:33 ` Eric Dumazet
2014-10-10 16:30 ` David Laight
2014-10-10 16:41 ` David Miller
2014-10-10 14:59 ` [PATCH v2] " alexander.duyck
2014-10-10 15:36 ` Eric Dumazet
2014-10-10 17:55 ` David Miller
2014-10-10 18:41 ` eth_get_headlen() and unaligned accesses Tom Herbert
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=5437F072.5060502@redhat.com \
--to=alexander.h.duyck@redhat.com \
--cc=alexander.duyck@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/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).