qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Gabriel L. Somlo" <gsomlo@gmail.com>
Cc: lersek@redhat.com, qemu-devel@nongnu.org, kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 1/2] SMBIOS: Fix endian-ness when populating fields wider than 8-bit
Date: Tue, 13 May 2014 22:33:35 +0200	[thread overview]
Message-ID: <5372819F.30908@redhat.com> (raw)
In-Reply-To: <20140513202115.GO30030@ERROL.INI.CMU.EDU>

Il 13/05/2014 22:21, Gabriel L. Somlo ha scritto:
>>> > >-    t->processor_id[0] = smbios_cpuid_version;
>>> > >-    t->processor_id[1] = smbios_cpuid_features;
>>> > >+    t->processor_id[0] = smbios_cpuid_version; /* opaque, no cpu_to_le16 */
>>> > >+    t->processor_id[1] = smbios_cpuid_features; /* opaque, no cpu_to_le16 */
>> >
>> > Actually I think these should be subject to cpu_to_le32.  They
>> > correspond to CPUID values, so they are little-endian 32-bit.
> Right, my comment is wrong, should be "no need for cpu_to_le32()" instead
> of what I said ("no need for cpu_to_le16()")... :)
>
> Re. why I said "opaque, no need for endianness fix" is because they're
> a straight-through assignment from cpu->env.cpuid_version and
> cpu->env.features[FEAT_1_EDX], respectively. So they're not really
> "numbers" which need endianness adjustment.
>
> Did I get that wrong ? (I mean, besides the 16 vs. 32 in the comment) ?

I think they do need cpu_to_le32.  We assign them straight from other 
32-bit integers, but still bits 0..7 should be in byte 0, bits 8..15 
should be in byte 1, etc.  So we need to convert from host CPU 
endianness to target CPU endianness.

Paolo

  parent reply	other threads:[~2014-05-13 20:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13 18:17 [Qemu-devel] [PATCH v2 0/2] SMBIOS cleanup round Gabriel L. Somlo
2014-05-13 18:17 ` [Qemu-devel] [PATCH v2 1/2] SMBIOS: Fix endian-ness when populating fields wider than 8-bit Gabriel L. Somlo
2014-05-13 19:56   ` Laszlo Ersek
2014-05-13 20:09   ` Paolo Bonzini
2014-05-13 20:21     ` Gabriel L. Somlo
2014-05-13 20:32       ` Laszlo Ersek
2014-05-13 20:33       ` Paolo Bonzini [this message]
2014-05-13 20:46         ` Gabriel L. Somlo
2014-05-13 18:17 ` [Qemu-devel] [PATCH v2 2/2] SMBIOS: Update Type 0 struct generator for machines >= 2.1 Gabriel L. Somlo
2014-05-13 20:02   ` Laszlo Ersek

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=5372819F.30908@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=gsomlo@gmail.com \
    --cc=kraxel@redhat.com \
    --cc=lersek@redhat.com \
    --cc=qemu-devel@nongnu.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).