From patchwork Fri Nov 6 08:02:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 540847 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 188C91402D9 for ; Fri, 6 Nov 2015 19:05:12 +1100 (AEDT) Received: from localhost ([::1]:37193 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zuc1F-00049A-BV for incoming@patchwork.ozlabs.org; Fri, 06 Nov 2015 03:05:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZubzK-0000p7-B2 for qemu-devel@nongnu.org; Fri, 06 Nov 2015 03:03:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZubzH-00007L-1j for qemu-devel@nongnu.org; Fri, 06 Nov 2015 03:03:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56883) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZubzG-00007G-U8 for qemu-devel@nongnu.org; Fri, 06 Nov 2015 03:03:07 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 8595019F98E; Fri, 6 Nov 2015 08:03:06 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (vpn1-5-235.pek2.redhat.com [10.72.5.235]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tA682oEg008144; Fri, 6 Nov 2015 03:03:01 -0500 From: Jason Wang To: mst@redhat.com, qemu-devel@nongnu.org Date: Fri, 6 Nov 2015 16:02:45 +0800 Message-Id: <1446796969-8049-3-git-send-email-jasowang@redhat.com> In-Reply-To: <1446796969-8049-1-git-send-email-jasowang@redhat.com> References: <1446796969-8049-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: cornelia.huck@de.ibm.com, Peter Maydell , Jason Wang , Paolo Bonzini , Greg Kurz Subject: [Qemu-devel] [PATCH V3 2/6] memory: don't try to adjust endianness for zero length eventfd X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org There's no need to adjust endianness for zero length eventfd since the data wrote was actually ignored by kernel. So skip the adjust in this case to fix a possible crash when trying to use wildcard mmio eventfd in ppc. Cc: Greg Kurz Cc: Peter Maydell Cc: Paolo Bonzini Acked-by: Greg Kurz Signed-off-by: Jason Wang --- memory.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/memory.c b/memory.c index c435c88..e193658 100644 --- a/memory.c +++ b/memory.c @@ -1688,7 +1688,9 @@ void memory_region_add_eventfd(MemoryRegion *mr, }; unsigned i; - adjust_endianness(mr, &mrfd.data, size); + if (size) { + adjust_endianness(mr, &mrfd.data, size); + } memory_region_transaction_begin(); for (i = 0; i < mr->ioeventfd_nb; ++i) { if (memory_region_ioeventfd_before(mrfd, mr->ioeventfds[i])) { @@ -1721,7 +1723,9 @@ void memory_region_del_eventfd(MemoryRegion *mr, }; unsigned i; - adjust_endianness(mr, &mrfd.data, size); + if (size) { + adjust_endianness(mr, &mrfd.data, size); + } memory_region_transaction_begin(); for (i = 0; i < mr->ioeventfd_nb; ++i) { if (memory_region_ioeventfd_equal(mrfd, mr->ioeventfds[i])) {