Received: from eggs.gnu.org ([2001:4830:134:3::10]:47316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byfcR-0004p7-Sf for qemu-devel@nongnu.org; Mon, 24 Oct 2016 09:48:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byfcN-0006sQ-Cy for qemu-devel@nongnu.org; Mon, 24 Oct 2016 09:48:51 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:35457) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1byfcN-0006qY-6r for qemu-devel@nongnu.org; Mon, 24 Oct 2016 09:48:47 -0400 Received: by mail-wm0-x243.google.com with SMTP id o81so9900253wma.2 for ; Mon, 24 Oct 2016 06:48:47 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 24 Oct 2016 15:47:35 +0200 Message-Id: <1477316855-42218-51-git-send-email-pbonzini@redhat.com> In-Reply-To: <1477316855-42218-1-git-send-email-pbonzini@redhat.com> References: <1477316855-42218-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 50/50] exec.c: workaround regression caused by alignment change in d2f39ad List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Haozhong Zhang From: Haozhong Zhang Commit d2f39ad "exec.c: Ensure right alignment also for file backed ram" added an additional alignment requirement on the size of backend file besides the previous page size. On x86, the alignment is changed from 4KB in QEMU 2.6 to 2MB in QEMU 2.7. This change breaks certain usages in QEMU 2.7 on x86, e.g. -object memory-backend-file,id=mem1,mem-path=/tmp/,size=$SZ -device pc-dimm,id=dimm1,memdev=mem1 where $SZ is multiple of 4KB but not 2MB (e.g. 1023M). QEMU 2.7 reports the following error message and aborts: qemu-system-x86_64: -device pc-dimm,memdev=mem1,id=nv1: backend memory size must be multiple of 0x200000 The same regression may also happen in other platforms as indicated by Igor Mammedov. This change is however necessary for s390 according to the commit message of d2f39ad, so we workaround the regression by taking the change only on s390. Signed-off-by: Haozhong Zhang Reported-by: "Xu, Anthony" Signed-off-by: Paolo Bonzini --- exec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index e63c5a1..6d7f600 100644 --- a/exec.c +++ b/exec.c @@ -1254,7 +1254,12 @@ static void *file_ram_alloc(RAMBlock *block, } block->page_size = qemu_fd_getpagesize(fd); - block->mr->align = MAX(block->page_size, QEMU_VMALLOC_ALIGN); + block->mr->align = block->page_size; +#if defined(__s390x__) + if (kvm_enabled()) { + block->mr->align = MAX(block->mr->align, QEMU_VMALLOC_ALIGN); + } +#endif if (memory < block->page_size) { error_setg(errp, "memory size 0x" RAM_ADDR_FMT " must be equal to " -- 1.8.3.1