From: Paolo Bonzini <pbonzini@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>, qemu-devel@nongnu.org
Cc: "Gabriel L. Somlo" <gsomlo@gmail.com>, Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/2] smbios: Fix dimm size calculation when RAM is multiple of 16GB
Date: Wed, 07 Jan 2015 18:45:54 +0100 [thread overview]
Message-ID: <54AD70D2.7030608@redhat.com> (raw)
In-Reply-To: <1420652194-3224-2-git-send-email-ehabkost@redhat.com>
On 07/01/2015 18:36, Eduardo Habkost wrote:
> The Memory Device size calculation logic is broken when the RAM size is
> a multiple of 16GB, making the size of the last entry be 0 instead of
> 16GB. Fix the logic to handle that case correctly.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> hw/i386/smbios.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c
> index 024e594..ae7032a 100644
> --- a/hw/i386/smbios.c
> +++ b/hw/i386/smbios.c
> @@ -850,7 +850,8 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len,
> }
>
> #define MAX_DIMM_SZ (16ll * ONE_GB)
> -#define GET_DIMM_SZ ((i < dimm_cnt - 1) ? MAX_DIMM_SZ : ram_size % MAX_DIMM_SZ)
> +#define GET_DIMM_SZ ((i < dimm_cnt - 1) ? MAX_DIMM_SZ \
> + : ((ram_size - 1) % MAX_DIMM_SZ) + 1)
>
> dimm_cnt = QEMU_ALIGN_UP(ram_size, MAX_DIMM_SZ) / MAX_DIMM_SZ;
Using "dimm_size = MAX(ram_size, MAX_DIMM_SZ); ram_size -= dimm_size"
would have been less weird, but the whole code here is interesting so
your patch is just keeping with the style. We all do that. :)
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2015-01-07 17:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-07 17:36 [Qemu-devel] [PATCH 0/2] smbios: Fixes for SVVP tests Eduardo Habkost
2015-01-07 17:36 ` [Qemu-devel] [PATCH 1/2] smbios: Fix dimm size calculation when RAM is multiple of 16GB Eduardo Habkost
2015-01-07 17:45 ` Paolo Bonzini [this message]
2015-01-07 17:36 ` [Qemu-devel] [PATCH 2/2] smbios: Don't report unknown CPU speed (fix SVVP regression) Eduardo Habkost
2015-01-07 17:46 ` Paolo Bonzini
2015-01-26 18:08 ` [Qemu-devel] [PATCH 0/2] smbios: Fixes for SVVP tests Eduardo Habkost
2015-01-26 18:12 ` Michael S. Tsirkin
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=54AD70D2.7030608@redhat.com \
--to=pbonzini@redhat.com \
--cc=ehabkost@redhat.com \
--cc=gsomlo@gmail.com \
--cc=kraxel@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).