From patchwork Sun Jul 5 21:08:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 491356 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 15AF4140DB3 for ; Mon, 6 Jul 2015 07:09:25 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=1J37FPFn; dkim-atps=neutral Received: from localhost ([::1]:47700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZBrAB-0003VW-6p for incoming@patchwork.ozlabs.org; Sun, 05 Jul 2015 17:09:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZBr9t-0003Dq-OQ for qemu-devel@nongnu.org; Sun, 05 Jul 2015 17:09:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZBr9o-0008Lk-6W for qemu-devel@nongnu.org; Sun, 05 Jul 2015 17:09:05 -0400 Received: from mail-pd0-x231.google.com ([2607:f8b0:400e:c02::231]:36745) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZBr9n-0008Le-Vq for qemu-devel@nongnu.org; Sun, 05 Jul 2015 17:09:00 -0400 Received: by pddu5 with SMTP id u5so6029015pdd.3 for ; Sun, 05 Jul 2015 14:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Hxz10kzujKrwhwYEs8Mzg9i2b0H371CN5ZFD2iy95K0=; b=1J37FPFn9SlvmHG/poHxtFbPwK+wBy1ZLQzNNqvJx/S5TjfloOhrcASrsZOLBZZtyd eCHdv2AxyrYedQ9E5rOhnLnTBKXgi3xdzMAUJg0fJnYjnlo1LayMXiiRU+BQi73zI0Mk Gae4Vid9cRoR1OX83WavQdTVDE5GBc/2rB/kEiTwv0UWiPSXpJqTOG7fsJETsB5PKWuv 9bteWrbatic5/wVs113eoQfEIagkzv43hg0Xc6eFE6WLlFsRV/d9g1T4Pu5mSh/In7bY UfojhCf5AAmt1V2EcAkQadqmUmhz6nu/GAzzCtDg7dG+amQhLDkx94fBYI1Hitfb/LNT Eluw== X-Received: by 10.68.190.41 with SMTP id gn9mr96554076pbc.113.1436130539439; Sun, 05 Jul 2015 14:08:59 -0700 (PDT) Received: from pcrost-laptop.hsd1.ca.comcast.net (c-73-15-58-35.hsd1.ca.comcast.net. [73.15.58.35]) by mx.google.com with ESMTPSA id km11sm15771804pbd.61.2015.07.05.14.08.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 05 Jul 2015 14:08:58 -0700 (PDT) From: Peter Crosthwaite X-Google-Original-From: Peter Crosthwaite To: qemu-devel@nongnu.org Date: Sun, 5 Jul 2015 14:08:53 -0700 Message-Id: <1436130533-18565-1-git-send-email-crosthwaite.peter@gmail.com> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c02::231 Cc: Peter Crosthwaite , rth@twiddle.net Subject: [Qemu-devel] [PATCH] cpu_defs: Simplify CPUTLB padding logic 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 was a complicated subtractive arithmetic for determining the padding on the CPUTLBEntry structure. Simplify this with a union. Signed-off-by: Peter Crosthwaite --- include/exec/cpu-defs.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index 98b9cff..5093be2 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -105,17 +105,18 @@ typedef struct CPUTLBEntry { bit 3 : indicates that the entry is invalid bit 2..0 : zero */ - target_ulong addr_read; - target_ulong addr_write; - target_ulong addr_code; - /* Addend to virtual address to get host address. IO accesses - use the corresponding iotlb value. */ - uintptr_t addend; - /* padding to get a power of two size */ - uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) - - (sizeof(target_ulong) * 3 + - ((-sizeof(target_ulong) * 3) & (sizeof(uintptr_t) - 1)) + - sizeof(uintptr_t))]; + union { + struct { + target_ulong addr_read; + target_ulong addr_write; + target_ulong addr_code; + /* Addend to virtual address to get host address. IO accesses + use the corresponding iotlb value. */ + uintptr_t addend; + }; + /* padding to get a power of two size */ + uint8_t dummy[1 << CPU_TLB_ENTRY_BITS]; + }; } CPUTLBEntry; QEMU_BUILD_BUG_ON(sizeof(CPUTLBEntry) != (1 << CPU_TLB_ENTRY_BITS));