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


Groups > linux.kernel > #1568837

Re: ibmvtpm byteswapping inconsistency

From Benjamin Herrenschmidt <benh@kernel.crashing.org>
Newsgroups linux.kernel
Subject Re: ibmvtpm byteswapping inconsistency
Date 2017-01-28 05:40 +0100
Message-ID <t4sXT-55o-3@gated-at.bofh.it> (permalink)
References (1 earlier) <t43PP-6lw-5@gated-at.bofh.it> <t44LT-6Tn-1@gated-at.bofh.it> <t4ljI-kA-11@gated-at.bofh.it> <t4lD3-ro-15@gated-at.bofh.it> <t4orf-2aJ-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, 2017-01-27 at 12:32 -0800, Tyrel Datwyler wrote:
> Its possible being the end of the week I'm just a little dense, but
> wouldn't be64_to_cpu() imply that we are byte-swapping something that is
> already, or supposedly already, in BE format to cpu endianness? Which on
> a BE cpu I would expect a no-op, and on a LE cpu the 64bit word to have
> been swapped from BE --> LE?

It's in BE format in memory. In LE mode, loading it into a register will
get it the wrong way around, thus we have to swap it again. Once in a
register it has no "endianness" per-se, what matters is that the act
of loading from memory to a register would have loaded it the wrong
way around in LE.

> In my eyes the code does seem to support what I've argued. The same
> thing is done in the scsi VIO drivers. The CRQ structure is laid out and
> annotated BE. We use cpu_to_be() calls to load any non 8bit field.
> Finally, each word is swapped to cpu endian when we hand it off for the
> hcall.
> 
> from ibmvfc_send_event():
> 
>         __be64 *crq_as_u64 = (__be64 *) &evt->crq;
> 
>         <..snip..>
> 
>         if ((rc = ibmvfc_send_crq(vhost, be64_to_cpu(crq_as_u64[0]),
>                                   be64_to_cpu(crq_as_u64[1])))) {
> 
> Again, maybe I'm missing something.

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


Thread

ibmvtpm byteswapping inconsistency Michal Suchánek <msuchanek@suse.de> - 2017-01-26 21:30 +0100
  Re: ibmvtpm byteswapping inconsistency Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2017-01-26 23:10 +0100
    Re: ibmvtpm byteswapping inconsistency Michal Suchanek <hramrach@gmail.com> - 2017-01-26 23:50 +0100
    Re: ibmvtpm byteswapping inconsistency Ashley Lai <ashleydlai@gmail.com> - 2017-01-27 00:00 +0100
  Re: ibmvtpm byteswapping inconsistency Tyrel Datwyler <tyreld@linux.vnet.ibm.com> - 2017-01-27 02:50 +0100
    Re: ibmvtpm byteswapping inconsistency Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-01-27 03:50 +0100
      Re: ibmvtpm byteswapping inconsistency Michal Suchanek <hramrach@gmail.com> - 2017-01-27 11:10 +0100
        Re: ibmvtpm byteswapping inconsistency Tyrel Datwyler <tyreld@linux.vnet.ibm.com> - 2017-01-28 02:00 +0100
          Re: ibmvtpm byteswapping inconsistency Michael Ellerman <mpe@ellerman.id.au> - 2017-01-30 05:40 +0100
      Re: ibmvtpm byteswapping inconsistency Tyrel Datwyler <tyreld@linux.vnet.ibm.com> - 2017-01-27 21:30 +0100
        Re: ibmvtpm byteswapping inconsistency Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-01-27 21:50 +0100
          Re: ibmvtpm byteswapping inconsistency Tyrel Datwyler <tyreld@linux.vnet.ibm.com> - 2017-01-28 00:50 +0100
            Re: ibmvtpm byteswapping inconsistency msuchanek <msuchanek@suse.de> - 2017-01-28 01:40 +0100
            Re: ibmvtpm byteswapping inconsistency Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-01-28 05:40 +0100
        RE: ibmvtpm byteswapping inconsistency David Laight <David.Laight@ACULAB.COM> - 2017-01-30 15:50 +0100
  RE: ibmvtpm byteswapping inconsistency David Laight <David.Laight@ACULAB.COM> - 2017-01-27 12:50 +0100

csiph-web