From patchwork Fri Feb 12 14:34:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 8292391 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 1E5E8C1F0D for ; Fri, 12 Feb 2016 14:39:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 54425203C1 for ; Fri, 12 Feb 2016 14:39:18 +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 9ADE12039E for ; Fri, 12 Feb 2016 14:39:17 +0000 (UTC) Received: from localhost ([::1]:33151 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUEsP-0004PO-0X for patchwork-qemu-devel@patchwork.kernel.org; Fri, 12 Feb 2016 09:39:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUEqI-0000iQ-1u for qemu-devel@nongnu.org; Fri, 12 Feb 2016 09:37:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aUEqG-0002lO-V7 for qemu-devel@nongnu.org; Fri, 12 Feb 2016 09:37:05 -0500 Received: from mail-pa0-x243.google.com ([2607:f8b0:400e:c03::243]:34012) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUEqG-0002kg-KR; Fri, 12 Feb 2016 09:37:04 -0500 Received: by mail-pa0-x243.google.com with SMTP id yy13so3897841pab.1; Fri, 12 Feb 2016 06:37:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gt6zuhY8go46uhbD6TiaaU4q+HV5eQo4Df2V8hqEju4=; b=O0d3kU1pNL9K6Tllk8dIcw9dl6GRIU/mKYoFNXvbnaOPJArM4AVrVuF2mGNboud/Ii eGFWGJj/OfMHZVBArx9eFmWE+dDPxVX5JRQKTt7uvZcm0y1so2mc/xsoJ6aUwNlm12// /VG+qgwPKgP1Tdw8DRBjhC+PLkLiw52K9zB9MED/+qh2965Sy4DPYaTcTKOoy1au2MSZ bS0v2br6wABaN3AZtwMJkYja0HJxRSy/1HdT/fY68Pn9jSJYrMwz7auT3knx86uoG1x8 lLtWirkJtbLlNXs/ATU7JiTzqLx6Vum8DpvruTAgphqFxdtLrSRg3J3zixhbRZk1ryL4 /3dw== 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; bh=gt6zuhY8go46uhbD6TiaaU4q+HV5eQo4Df2V8hqEju4=; b=KUn/7eAOSY+7EG2hdruLRtZk4WcfFcMzHOjZ2QlXVXU80v5uoCL0maHATef085pyGO ivjkLUbRklAfdAcs0BKoGV4WQdw0Eltr3p+qyRZzDbg/IPUmXshT8sKdl860mgTdjEep w8AK/vX81+esgWZRmfrOQeNOqj0AAOeHnOWZvRzrpa/W3Ys2zQruubzOTQkIjS/ZU75j yPswcYY3Kv5VipuMXZHiRlZXtFqhg4YU+RjT5Hjq+DGZTdVrdXNaVW738J99PSppXNjZ lDv9g1/39O6I5tWmfpVg5mG34zK0IsbFUYFzLRQZeUgVqD53B4MuILAlAV+zqDD0pmxo LouQ== X-Gm-Message-State: AG10YOSWeuEVEXISzxE2tSUZrmXpFbkz2g/DNaeR8HvN+fECHpxgzkT8T8qVyn69ytIiUA== X-Received: by 10.66.250.199 with SMTP id ze7mr2527936pac.103.1455287823977; Fri, 12 Feb 2016 06:37:03 -0800 (PST) Received: from localhost (ec2-52-8-89-49.us-west-1.compute.amazonaws.com. [52.8.89.49]) by smtp.gmail.com with ESMTPSA id f12sm19976759pfd.87.2016.02.12.06.37.02 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 12 Feb 2016 06:37:03 -0800 (PST) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Fri, 12 Feb 2016 15:34:00 +0100 Message-Id: <1455287642-28166-8-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455287642-28166-1-git-send-email-edgar.iglesias@gmail.com> References: <1455287642-28166-1-git-send-email-edgar.iglesias@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c03::243 Cc: edgar.iglesias@xilinx.com, serge.fdrv@gmail.com, qemu-arm@nongnu.org, alex.bennee@linaro.org, rth@twiddle.net Subject: [Qemu-devel] [PATCH v1 7/9] target-arm: Add the ARMInsnSyndrome type 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 From: "Edgar E. Iglesias" Add the ARMInsnSyndrome type including helper functions to encode and decode it into an u32. This is in preparation for Instruction Syndrome generation for Data Aborts. No functional change. Signed-off-by: Edgar E. Iglesias --- target-arm/cpu.h | 22 +++++++++++++++++++ target-arm/translate.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 5137632..a00a121 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -123,6 +123,28 @@ typedef struct { uint32_t base_mask; } TCR; +/* Holds the state needed to create an instruction syndrome. */ +typedef struct ARMInsnSyndrome { + /* Data Abort section. */ + struct { + bool valid; + unsigned int sas; + bool sse; + unsigned int srt; + bool sf; + bool ar; + } dabt; + + /* SWStep section. */ + struct { + /* True if the insn just emitted was a load-exclusive instruction + * (necessary for syndrome information for single step exceptions), + * ie A64 LDX*, LDAX*, A32/T32 LDREX*, LDAEX*. + */ + bool ex; + } swstep; +} ARMInsnSyndrome; + typedef struct CPUARMState { /* Regs for current mode. */ uint32_t regs[16]; diff --git a/target-arm/translate.h b/target-arm/translate.h index 53ef971..a94e17e 100644 --- a/target-arm/translate.h +++ b/target-arm/translate.h @@ -151,4 +151,61 @@ void arm_free_cc(DisasCompare *cmp); void arm_jump_cc(DisasCompare *cmp, TCGLabel *label); void arm_gen_test_cc(int cc, TCGLabel *label); + +/* The following describes the packing and unpacking of the Data Abort + * section of an ARMInsnSyndrome from/into an u32. + */ + +/* Field widths. */ +#define ISYN_WIDTH_valid 1 +#define ISYN_WIDTH_sas 2 +#define ISYN_WIDTH_sse 1 +#define ISYN_WIDTH_srt 5 +#define ISYN_WIDTH_sf 1 +#define ISYN_WIDTH_ar 1 + +/* We use 64bit deposit to allow for overflow checking. */ +#define ISYN_SHIFT_IN(val, isyn, field) \ + { \ + unsigned int width = xglue(ISYN_WIDTH_, field); \ + val <<= width; \ + val = deposit64(val, 0, width, (isyn).field); \ + } while (0) + +#define ISYN_SHIFT_OUT(val, isyn, field) \ + { \ + unsigned int width = xglue(ISYN_WIDTH_, field); \ + (isyn).field = extract32(val, 0, width); \ + val >>= width; \ + } while (0) + +static inline uint32_t arm_encode_dabt_isyn_u32(ARMInsnSyndrome *isyn) +{ + uint64_t v = 0; + uint32_t v32; + + ISYN_SHIFT_IN(v, isyn->dabt, valid); + ISYN_SHIFT_IN(v, isyn->dabt, sas); + ISYN_SHIFT_IN(v, isyn->dabt, sse); + ISYN_SHIFT_IN(v, isyn->dabt, srt); + ISYN_SHIFT_IN(v, isyn->dabt, sf); + ISYN_SHIFT_IN(v, isyn->dabt, ar); + /* Check for overflows. */ + v32 = v; + assert(v32 == v); + return v32; +} + +static inline void arm_decode_dabt_isyn_u32(ARMInsnSyndrome *isyn, uint32_t v) +{ + /* The fields must be shifted out in reverse order. */ + ISYN_SHIFT_OUT(v, isyn->dabt, ar); + ISYN_SHIFT_OUT(v, isyn->dabt, sf); + ISYN_SHIFT_OUT(v, isyn->dabt, srt); + ISYN_SHIFT_OUT(v, isyn->dabt, sse); + ISYN_SHIFT_OUT(v, isyn->dabt, sas); + ISYN_SHIFT_OUT(v, isyn->dabt, valid); + assert(v == 0); +} + #endif /* TARGET_ARM_TRANSLATE_H */