From patchwork Mon Oct 24 12:49:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9392025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7593A60762 for ; Mon, 24 Oct 2016 12:50:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6706F29010 for ; Mon, 24 Oct 2016 12:50:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59B3F29017; Mon, 24 Oct 2016 12:50:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D271929010 for ; Mon, 24 Oct 2016 12:50:27 +0000 (UTC) Received: from localhost ([::1]:46538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byehv-00024g-40 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 24 Oct 2016 08:50:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byehV-000230-FO for qemu-devel@nongnu.org; Mon, 24 Oct 2016 08:50:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byehR-0004yF-Id for qemu-devel@nongnu.org; Mon, 24 Oct 2016 08:50:01 -0400 Received: from mga06.intel.com ([134.134.136.31]:16066) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1byehR-0004xq-CZ for qemu-devel@nongnu.org; Mon, 24 Oct 2016 08:49:57 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP; 24 Oct 2016 05:49:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,542,1473145200"; d="scan'208";a="22930549" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.148]) by fmsmga006.fm.intel.com with ESMTP; 24 Oct 2016 05:49:54 -0700 From: Haozhong Zhang To: qemu-devel@nongnu.org Date: Mon, 24 Oct 2016 20:49:37 +0800 Message-Id: <20161024124937.17239-1-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.10.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.31 Subject: [Qemu-devel] [PATCH] exec.c: workaround regression caused by alignment change in d2f39ad X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Haozhong Zhang , chao.p.peng@intel.com, Peter Crosthwaite , Dominik Dingel , anthony.xu@intel.com, Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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" Acked-by: Christian Borntraeger --- exec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/exec.c b/exec.c index e63c5a1..55915ea 100644 --- a/exec.c +++ b/exec.c @@ -1254,7 +1254,11 @@ static void *file_ram_alloc(RAMBlock *block, } block->page_size = qemu_fd_getpagesize(fd); +#if defined(__s390x__) block->mr->align = MAX(block->page_size, QEMU_VMALLOC_ALIGN); +#else + block->mr->align = block->page_size; +#endif if (memory < block->page_size) { error_setg(errp, "memory size 0x" RAM_ADDR_FMT " must be equal to "