From patchwork Thu Jan 26 14:22:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ladi Prosek X-Patchwork-Id: 9539305 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 DD08D601D7 for ; Thu, 26 Jan 2017 14:23:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA86927F99 for ; Thu, 26 Jan 2017 14:23:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDA842818E; Thu, 26 Jan 2017 14:23:15 +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 55AA027F99 for ; Thu, 26 Jan 2017 14:23:14 +0000 (UTC) Received: from localhost ([::1]:38897 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWkxE-0001w4-Jc for patchwork-qemu-devel@patchwork.kernel.org; Thu, 26 Jan 2017 09:23:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWkwm-0001v3-JV for qemu-devel@nongnu.org; Thu, 26 Jan 2017 09:22:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWkwj-0006pw-FS for qemu-devel@nongnu.org; Thu, 26 Jan 2017 09:22:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53434) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cWkwj-0006la-9k for qemu-devel@nongnu.org; Thu, 26 Jan 2017 09:22:41 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7482AC04B302 for ; Thu, 26 Jan 2017 14:22:40 +0000 (UTC) Received: from dhcp-1-107.brq.redhat.com (dhcp-1-139.brq.redhat.com [10.34.1.139]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0QEMdEo016999; Thu, 26 Jan 2017 09:22:39 -0500 From: Ladi Prosek To: qemu-devel@nongnu.org Date: Thu, 26 Jan 2017 15:22:37 +0100 Message-Id: <1485440557-10384-1-git-send-email-lprosek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 26 Jan 2017 14:22:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] memory: don't sign-extend 32-bit writes 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: pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP ldl_p has a signed return type so assigning it to uint64_t implicitly sign-extends the value. This results in devices with min_access_size = 8 seeing unexpected values passed to their write handlers. Example: guest performs a 32-bit write of 0x80000000 to an mmio region and the handler receives 0xFFFFFFFF80000000 in its value argument. Signed-off-by: Ladi Prosek --- exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exec.c b/exec.c index f2bed92..b05c5d2 100644 --- a/exec.c +++ b/exec.c @@ -2630,7 +2630,7 @@ static MemTxResult address_space_write_continue(AddressSpace *as, hwaddr addr, break; case 4: /* 32 bit write access */ - val = ldl_p(buf); + val = (uint32_t)ldl_p(buf); result |= memory_region_dispatch_write(mr, addr1, val, 4, attrs); break;