diff options
author | Eduardo Habkost | 2015-01-07 18:36:33 +0100 |
---|---|---|
committer | Michael S. Tsirkin | 2015-01-27 13:46:17 +0100 |
commit | 744c6d474791ff3ad5c2f08edc732564199fd146 (patch) | |
tree | 88cca8700f00b89d21872e2d83a13b8ae47681ac | |
parent | bios-linker-loader: move source to common location (diff) | |
download | qemu-744c6d474791ff3ad5c2f08edc732564199fd146.tar.gz qemu-744c6d474791ff3ad5c2f08edc732564199fd146.tar.xz qemu-744c6d474791ff3ad5c2f08edc732564199fd146.zip |
smbios: Fix dimm size calculation when RAM is multiple of 16GB
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>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | hw/i386/smbios.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c index 024e59445b..ae7032adda 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; |