From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YG5yY-0004s4-Jz for qemu-devel@nongnu.org; Tue, 27 Jan 2015 08:14:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YG5yX-0008PY-SM for qemu-devel@nongnu.org; Tue, 27 Jan 2015 08:14:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33284) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YG5yX-0008PL-LG for qemu-devel@nongnu.org; Tue, 27 Jan 2015 08:14:37 -0500 Date: Tue, 27 Jan 2015 15:14:29 +0200 From: "Michael S. Tsirkin" Message-ID: <1422364369-8667-13-git-send-email-mst@redhat.com> References: <1422364369-8667-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1422364369-8667-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 12/16] smbios: Fix dimm size calculation when RAM is multiple of 16GB List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Eduardo Habkost , Juan Quintela , dgilbert@redhat.com, Anthony Liguori , Paolo Bonzini , Richard Henderson From: Eduardo Habkost 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 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Paolo Bonzini --- 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; -- MST