From patchwork Tue Apr 19 13:39:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: alvise rigo X-Patchwork-Id: 8880151 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 66CD3BF440 for ; Tue, 19 Apr 2016 13:40:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A102C2010C for ; Tue, 19 Apr 2016 13:40:06 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 9F10820263 for ; Tue, 19 Apr 2016 13:40:05 +0000 (UTC) Received: from localhost ([::1]:58127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asVsq-0003Ge-SZ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Apr 2016 09:40:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asVsX-0003CL-FT for qemu-devel@nongnu.org; Tue, 19 Apr 2016 09:39:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1asVsV-0000fJ-Ui for qemu-devel@nongnu.org; Tue, 19 Apr 2016 09:39:45 -0400 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:37889) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asVsV-0000f5-L7 for qemu-devel@nongnu.org; Tue, 19 Apr 2016 09:39:43 -0400 Received: by mail-wm0-x22c.google.com with SMTP id u206so30243859wme.1 for ; Tue, 19 Apr 2016 06:39:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtualopensystems-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S3n/yB8Vdtfh3nsGlnCHXAZz3+dVkT4M4aU53SKVWSI=; b=LUOY0pv6tQTC3+MerL9KDrYpjCqo/8t/PVOmyPW+TZ1Y3aJsT8B6b8DNRlFcFHkyOe bIfaftPrD8Gvd3KDXQQlptwOzDM6fknwT5MlL9a9ij1jOEEh+dh1KndL19/DEdCJyihK JzYfKYoyyjzKu5QTbFDdY24S82+eYvlvDj6FNG89paNImDK1oJySZXOyDylTxMLJzaXR JHRzIc8MBlUgnpOmg5hu8k+/Vk/W7Gdy/o719XxjE1JmxYAb1REZCy7U2M92gB9SSglz cK+w9VL7RdHdpQnQlvgR0oMCT34XXYjDhgvoW07u3a7xyEOGOdo3SLC2OrmwuZ4xrj20 L7Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S3n/yB8Vdtfh3nsGlnCHXAZz3+dVkT4M4aU53SKVWSI=; b=bFheWmPGoS3f0ToBiruZGnHjJx3QJMTtwNFbASjlelVoIwm2qOG2qyIOOdzjSXgfMS uAzzAyEJWDTA9y/IREvz2Z72y7aGMKRe4Xzk8RVz7zwM7ZW0tTt+1gHQSTnNFdG1PMRj 7HMU1zWG4rkbTyMfjQUOIPsT4c0EdoxjciLx08ixEndgwBsejconGEyrJXriWfRAjMNS yRU5b5WOK+M67bZz7d5WrcIyS7rCwvPUm2+icQ9gY61WYod3n6XaKmpiRTr0XHhN0y2B fhmD+9WNyJ7bknb3V8BbwOaxMQox1ahoZ6ZDClDDq5XJ18s9G6KCDdmNRbTKJMnV4Bqy 5CqQ== X-Gm-Message-State: AOPr4FVwVSlPgFoSo/rhKHB272++8NdxELxG27rJQ0IoN5ZuUY9UNutCVEUX5Vp65JHSYQ== X-Received: by 10.28.18.10 with SMTP id 10mr25990918wms.0.1461073182976; Tue, 19 Apr 2016 06:39:42 -0700 (PDT) Received: from localhost.localdomain (LPuteaux-656-1-278-113.w80-15.abo.wanadoo.fr. [80.15.154.113]) by smtp.googlemail.com with ESMTPSA id c85sm2789756wmd.0.2016.04.19.06.39.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Apr 2016 06:39:42 -0700 (PDT) From: Alvise Rigo To: qemu-devel@nongnu.org, mttcg@listserver.greensocs.com Date: Tue, 19 Apr 2016 15:39:20 +0200 Message-Id: <1461073171-22953-4-git-send-email-a.rigo@virtualopensystems.com> X-Mailer: git-send-email 2.8.0 In-Reply-To: <1461073171-22953-1-git-send-email-a.rigo@virtualopensystems.com> References: <1461073171-22953-1-git-send-email-a.rigo@virtualopensystems.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22c Subject: [Qemu-devel] [RFC v8 03/14] softmmu: Simplify helper_*_st_name, wrap MMIO code 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: Peter Crosthwaite , claudio.fontana@huawei.com, Alvise Rigo , serge.fdrv@gmail.com, pbonzini@redhat.com, jani.kokkonen@huawei.com, tech@virtualopensystems.com, alex.bennee@linaro.org, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Attempting to simplify the helper_*_st_name, wrap the MMIO code into an inline function. The function covers both BE and LE cases and it is expanded twice in each helper (TODO: check this last statement). Suggested-by: Jani Kokkonen Suggested-by: Claudio Fontana CC: Alex Bennée Signed-off-by: Alvise Rigo --- softmmu_template.h | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/softmmu_template.h b/softmmu_template.h index 3eb54f8..9185486 100644 --- a/softmmu_template.h +++ b/softmmu_template.h @@ -410,6 +410,29 @@ static inline void smmu_helper(do_unl_store)(CPUArchState *env, } } +static inline void smmu_helper(do_mmio_store)(CPUArchState *env, + bool little_endian, + DATA_TYPE val, + target_ulong addr, + TCGMemOpIdx oi, unsigned mmu_idx, + int index, uintptr_t retaddr) +{ + CPUIOTLBEntry *iotlbentry = &env->iotlb[mmu_idx][index]; + + if ((addr & (DATA_SIZE - 1)) != 0) { + smmu_helper(do_unl_store)(env, little_endian, val, addr, mmu_idx, oi, + retaddr); + } + /* ??? Note that the io helpers always read data in the target + byte ordering. We should push the LE/BE request down into io. */ + if (little_endian) { + val = TGT_LE(val); + } else { + val = TGT_BE(val); + } + glue(io_write, SUFFIX)(env, iotlbentry, val, addr, retaddr); +} + void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, TCGMemOpIdx oi, uintptr_t retaddr) { @@ -437,17 +460,8 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, /* Handle an IO access. */ if (unlikely(tlb_addr & ~TARGET_PAGE_MASK)) { - CPUIOTLBEntry *iotlbentry; - if ((addr & (DATA_SIZE - 1)) != 0) { - smmu_helper(do_unl_store)(env, false, val, addr, oi, mmu_idx, retaddr); - return; - } - iotlbentry = &env->iotlb[mmu_idx][index]; - - /* ??? Note that the io helpers always read data in the target - byte ordering. We should push the LE/BE request down into io. */ - val = TGT_LE(val); - glue(io_write, SUFFIX)(env, iotlbentry, val, addr, retaddr); + smmu_helper(do_mmio_store)(env, true, val, addr, oi, mmu_idx, index, + retaddr); return; } @@ -502,17 +516,8 @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, /* Handle an IO access. */ if (unlikely(tlb_addr & ~TARGET_PAGE_MASK)) { - CPUIOTLBEntry *iotlbentry; - if ((addr & (DATA_SIZE - 1)) != 0) { - smmu_helper(do_unl_store)(env, true, val, addr, oi, mmu_idx, retaddr); - return; - } - iotlbentry = &env->iotlb[mmu_idx][index]; - - /* ??? Note that the io helpers always read data in the target - byte ordering. We should push the LE/BE request down into io. */ - val = TGT_BE(val); - glue(io_write, SUFFIX)(env, iotlbentry, val, addr, retaddr); + smmu_helper(do_mmio_store)(env, false, val, addr, oi, mmu_idx, index, + retaddr); return; }