Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1498180

igb driver can cause cache invalidation of non-owned memory?

From Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Newsgroups linux.kernel
Subject igb driver can cause cache invalidation of non-owned memory?
Date 2016-10-10 11:00 +0200
Message-ID <sqEBc-7uz-11@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Hi


DMA mapping scheme introduced in commit cbc8e55f6fda ('igb: Map entire
page and sync half instead of mapping and unmapping half pages') back in
2012, and used up to now, can probably cause breakage of unrelated code
on archs with non-coherent caches.

With this scheme, page used for Rx is completely dma_map()ed at
allocation time, split into two buffers, and individual buffer is
sync_to_cpu()ed AND PASSED TO NETWORK STACK via skb_add_rx_frag() -
while driver driver still uses other buffer. Later, when driver decides
to no longer use this page, it will dma_unmap() it completely - which on
archs with non-coherent caches means cache invalidation. This cache
invalidation will include area that is already passed elsewhere. If
external code has performed any writes to that area and writes still are
in cache only, cache invalidation will cause writes to be lost.


I'm not sure if this breakage is indeed possible. I did not face it,
just found while checking how things work.

Code in question is in kernel already for 4 years. However, since (1)
igb is mostly used on x86 where caches are coherent, and (2) Rx buffers
are normally not written to, it could stay unnoticed all that time.

Could somebody please comment on this?


Nikita Yushchenko

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

igb driver can cause cache invalidation of non-owned memory? Nikita Yushchenko <nikita.yoush@cogentembedded.com> - 2016-10-10 11:00 +0200
  Re: igb driver can cause cache invalidation of non-owned memory? David Miller <davem@davemloft.net> - 2016-10-10 11:10 +0200
    Re: igb driver can cause cache invalidation of non-owned memory? Nikita Yushchenko <nikita.yoush@cogentembedded.com> - 2016-10-10 12:00 +0200
      Re: igb driver can cause cache invalidation of non-owned memory? David Miller <davem@davemloft.net> - 2016-10-10 14:00 +0200
        Re: igb driver can cause cache invalidation of non-owned memory? Nikita Yushchenko <nikita.yoush@cogentembedded.com> - 2016-10-10 14:30 +0200
          Re: igb driver can cause cache invalidation of non-owned memory? Nikita Yushchenko <nikita.yoush@cogentembedded.com> - 2016-10-10 14:40 +0200
          Re: igb driver can cause cache invalidation of non-owned memory? Alexander Duyck <alexander.duyck@gmail.com> - 2016-10-10 17:20 +0200
            Re: igb driver can cause cache invalidation of non-owned memory? Nikita Yushchenko <nikita.yoush@cogentembedded.com> - 2016-10-10 19:10 +0200
              Re: igb driver can cause cache invalidation of non-owned memory? Alexander Duyck <alexander.duyck@gmail.com> - 2016-10-10 19:50 +0200
                Re: igb driver can cause cache invalidation of non-owned memory? Nikita Yushchenko <nikita.yoush@cogentembedded.com> - 2016-10-12 09:00 +0200
                Re: igb driver can cause cache invalidation of non-owned memory? Alexander Duyck <alexander.duyck@gmail.com> - 2016-10-12 17:40 +0200
                RE: igb driver can cause cache invalidation of non-owned memory? David Laight <David.Laight@ACULAB.COM> - 2016-10-12 18:10 +0200
                Re: igb driver can cause cache invalidation of non-owned memory? Nikita Yushchenko <nikita.yoush@cogentembedded.com> - 2016-10-12 18:40 +0200
                Re: igb driver can cause cache invalidation of non-owned memory? Alexander Duyck <alexander.duyck@gmail.com> - 2016-10-12 20:10 +0200
                Re: igb driver can cause cache invalidation of non-owned memory? Nikita Yushchenko <nikita.yoush@cogentembedded.com> - 2016-10-12 20:30 +0200
                Re: igb driver can cause cache invalidation of non-owned memory? Alexander Duyck <alexander.duyck@gmail.com> - 2016-10-12 20:40 +0200

csiph-web