From patchwork Thu Sep 5 17:17:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 272916 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6D0782C00EE for ; Fri, 6 Sep 2013 03:19:29 +1000 (EST) Received: from localhost ([::1]:32926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHdDL-0003VF-8N for incoming@patchwork.ozlabs.org; Thu, 05 Sep 2013 13:19:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHdBm-0001VP-QW for qemu-devel@nongnu.org; Thu, 05 Sep 2013 13:17:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VHdBg-0000r9-Hx for qemu-devel@nongnu.org; Thu, 05 Sep 2013 13:17:50 -0400 Received: from mail-ee0-x231.google.com ([2a00:1450:4013:c00::231]:49372) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHdBg-0000pD-AY; Thu, 05 Sep 2013 13:17:44 -0400 Received: by mail-ee0-f49.google.com with SMTP id d41so1057407eek.36 for ; Thu, 05 Sep 2013 10:17:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=waayv4Gu2MKuqVBymUKIlRrLe5GoDYCMjhrTqgxDrQ0=; b=mmRQKN+oy0Pms4VZrBb1IUqM0wVtEIffAhS1hT02LTYWu6zofacMZyLopXaWEKGXme pFU4pz0K4DJEvBlh2uQ3EH6WDvYVM7SDxjnsHofyJj/szU/EWUBnpRacA85uiYW10snh Drt+qkM2IjleACX6elNiFD+j8inJYCwGzyJTZn2CR6I8wtatqKV2Qg4AiJ/G0BFG0e3K t3jF5qkbgtEjOnDhc/iQl70Cdyzx3pdVuP5mWkcN5J87e8eua6P4lTTTdwgffN3eflUH qiEgX1Uz8bfeq/gqKhM6jdKxbEAD048weXjh+Meq/sIJe1NOADLDt582TUrncm8bfrTD ZLYQ== X-Received: by 10.15.48.67 with SMTP id g43mr15050587eew.17.1378401463355; Thu, 05 Sep 2013 10:17:43 -0700 (PDT) Received: from playground.lan (net-37-117-144-28.cust.dsl.vodafone.it. [37.117.144.28]) by mx.google.com with ESMTPSA id x47sm50345071eea.16.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 05 Sep 2013 10:17:42 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 5 Sep 2013 19:17:31 +0200 Message-Id: <1378401455-583-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1378401455-583-1-git-send-email-pbonzini@redhat.com> References: <1378401455-583-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c00::231 Cc: qemu-stable@nongnu.org, anthony@codemonkey.ws Subject: [Qemu-devel] [PULL 1/5] exec: fix writing to MMIO area with non-power-of-two length 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 The problem is introduced by commit 2332616 (exec: Support 64-bit operations in address_space_rw, 2013-07-08). Before that commit, memory_access_size would only return 1/2/4. Since alignment is already handled above, reduce l to the largest power of two that is smaller than l. Cc: qemu-stable@nongnu.org Reported-by: Oleksii Shevchuk Tested-by: Oleksii Shevchuk Signed-off-by: Paolo Bonzini --- exec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/exec.c b/exec.c index 87b0b39..b52ec80 100644 --- a/exec.c +++ b/exec.c @@ -1913,6 +1913,9 @@ static int memory_access_size(MemoryRegion *mr, unsigned l, hwaddr addr) if (l > access_size_max) { l = access_size_max; } + if (l & (l - 1)) { + l = 1 << (qemu_fls(l) - 1); + } return l; }