From patchwork Sat May 4 00:05:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 794554 Delivered-To: patch@linaro.org Received: by 2002:adf:a153:0:b0:34d:5089:5a9e with SMTP id r19csp985806wrr; Fri, 3 May 2024 17:06:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXq5No1JxjPYxLv4UPyp0TzKMXr5e463rPgouWtAmYWVPhgRyJks91dJU3i7Zr7ZO2zho6V2346pbikVQYmaQOj X-Google-Smtp-Source: AGHT+IFpuvNKgdofFeL4r6JalfjXKvxJhosEDPxY0Z2HWK6DLjQ1BG3AnCnx3uqWpUQjC6B7r7PB X-Received: by 2002:a05:6871:5897:b0:23d:9821:2b90 with SMTP id ok23-20020a056871589700b0023d98212b90mr4889468oac.23.1714781174179; Fri, 03 May 2024 17:06:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714781174; cv=pass; d=google.com; s=arc-20160816; b=UtsedBxnKibjKwbXHjJ0Xxn++GXGm/2pKSD3Pn97CUfFbEU6VO0LRFxf/Mnli1ZKXs JH37j6/6luaPGq/goEwls0ocrItxUdMdMvtc/JfOKXamRUMC6n4RmhT+MY1Hk+2MLyzY MgUOROfFO1THVmsbP3jxn3EZ6WSkL1nOnSJdoGowmd77eOKPJgFGPNqbn7+lM+k0nXfP Qx3n38OIq6B3kwn/RicjiDWqv3Is14pntFPXR1YCE3479jaameJJWaxL+mekuj3hoUz5 xhXduknRFoRRT33fbeNDK4gfrdmdLmJaeRi+cW3qcPmScF8jUVplUHxRAgzByPOZpuUn heIQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=GvPssLg+IXk2QnJ4msRdqgy9CGdgocoBSD9nbquhNyI=; fh=72kqq0iQhigvR9Vv/oqX5ebs3Yyyw7XhzWxOOEPdupI=; b=ssTsU8OdAqmoQIuZyCQd/ZOVi+HHmVYdqLiYAIwpD3/gRMTiLaKf3D9yxn/3S2kE9Z PodE5WgtROz/ahEhxiU/l7CxLcuaDV68W/1HJoGvsfG6hqHfYOrfF/Ip+Lu5QsKE6rUW Mf6qgv2WePn7T0BMYB8kjYaBavbyi0fkbeWIo6V9Nn6M4q3IkXp7MomyGH4P0OkTeBqf lxn1omfIA/oE0gxl2W8Pxt/eTaz9iI+Ka1eocKY8NtaCJVUnI3Gl6qFixPjJCye6mKWd IJGdDMzSOrjLaR0SoabXZkdl/tj+YuKi5DQv9SHJ9iQ8fuF5wyjKxBeY4DolBRLqiWYr ZR9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N99IaHk3; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gdb-patches-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id b9-20020a05620a04e900b00790f06f5071si4193581qkh.571.2024.05.03.17.06.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 17:06:14 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N99IaHk3; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gdb-patches-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C35B8386F41E for ; Sat, 4 May 2024 00:06:13 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id A31633844750 for ; Sat, 4 May 2024 00:05:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A31633844750 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A31633844750 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::629 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714781140; cv=none; b=BEfwAda0ZDdfxf3VV6tcFZqpMErp5j0EAEB9H1KtFJ46lj6119LchRi15S2gv/CFVxj7RGzf3TAZi913NqE0ttPw1Vf/kPoap67toIh/RdVCRuIN7abDB2uCzWdSCvJgvP5jz6UenYkezZkoCw3bv8jzb/LYYAckWLE3joTopJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714781140; c=relaxed/simple; bh=GdOvo9+lnPXC/34Ga/Z0aIgEb0MIIpjGYPU3zk74/P4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=X3/+n+X/vydHyYPAwmHT6v0K2tpMYahyXkQ3LBERft9i6aphWmBDbENAUpHgEdxkVGj2TISm0zMTzJUk2USNNLTUszLpNMN6XHrBRM1170C7j53YOf4TABtTjvwunpckznRozP/e4t9lLU9UrGuo8pYZ2cOCEdtpXlpYPdt0CLI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1ed835f3c3cso1909225ad.3 for ; Fri, 03 May 2024 17:05:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714781132; x=1715385932; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=GvPssLg+IXk2QnJ4msRdqgy9CGdgocoBSD9nbquhNyI=; b=N99IaHk3Iq2WS+5QIQeCKJv/ClZZjDGvyEhXisqf92pFlB+MxdjggtEt85BpVhVFHt C28yhLlKqY6l3NK6+NfHXDuEaf9ZUnZ5pl9hh8tHXdmGPfl6dtnqERydzkljHEyrrqSz qTC53HQueVIDsAoAuY4dFqF0UC2yxL5eTWRbXQPOug/jROsARTjewHIbcFOU1BdMJUnt K/z0fNTUgEsi0k6lstO0BTcSD35B2a1ZkYQ0pehgpELblpta3+DnNxbItLyz4weGI9ce Ldz9Ig+kHdqg4EI/ZV0dBw7nnx8dicVjWZ+mGnxnk5YNQKmwBW12Axg9r8WrHzFhhQey UOQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714781132; x=1715385932; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GvPssLg+IXk2QnJ4msRdqgy9CGdgocoBSD9nbquhNyI=; b=q6EjeULT0CsF7cQ99EL57HL4o2NGxfGsMG/PJt80h2ZMtPTBaUvtIImRKiczUIsLR7 PFxYmPACL4zAQFmnnVPPvq35Q+sdRaQhGOkqm+HmyQT/7NzN/hXvuqkHo8aav410XqqU Se3L2rgRvCYZlDrHZxiQNAya8P8uemC+MYaSCw4LsPtdwM2vlfuhxgPKE/c/oB+TVPbx n9OEkhGOMWCc7DDfRgeiNIn0tiox1h23f+o3QFf5JHBXx1e9mHwLqlYeu9mY91SF6cE3 noMOkxMVw9JawE0GlAL59tfs3NzIwAN9PAqvu9BX+SexADnxq5ljnff+xkkqhkoRpL4L c9eg== X-Gm-Message-State: AOJu0YyWpFl6Etk+eJNc7WOrttTmkIIKv+K+LzJ0KeVgQtTxI3BB7X3E RipOBGSkROnTjvsaAqJ4Es+dQYGTI+ITVpjPwkggYTtLKvufQ3E2o/Cf1kg/4eeuY3qm7M4eo0g C X-Received: by 2002:a17:902:e54d:b0:1e6:7731:80 with SMTP id n13-20020a170902e54d00b001e677310080mr5708011plf.11.1714781132478; Fri, 03 May 2024 17:05:32 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:50e3:94e0:79b0:c9f9]) by smtp.gmail.com with ESMTPSA id jb13-20020a170903258d00b001ec4ed47ddesm3869387plb.86.2024.05.03.17.05.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 17:05:32 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Subject: [PATCH 2/5] gdb/aarch64: Add record support for MOPS instructions. Date: Fri, 3 May 2024 21:05:18 -0300 Message-ID: <20240504000521.314531-3-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240504000521.314531-1-thiago.bauermann@linaro.org> References: <20240504000521.314531-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patch=linaro.org@sourceware.org There are two kinds of MOPS instructions: set instructions and copy instructions. Within each group there are variants with minor differences in how they read or write to memory — e.g., non-temporal read and/or write, unprivileged read and/or write and permutations of those — but they work in the same way in terms of the registers and regions of memory that they modify. PR tdep/31666 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31666 --- gdb/aarch64-tdep.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index e920cea49066..c60c5d6e0ec2 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -5289,6 +5289,86 @@ aarch64_record_asimd_load_store (aarch64_insn_decode_record *aarch64_insn_r) return AARCH64_RECORD_SUCCESS; } +/* Record handler for Memory Copy and Memory Set instructions. */ + +static unsigned int +aarch64_record_memcopy_memset (aarch64_insn_decode_record *aarch64_insn_r) +{ + if (record_debug) + debug_printf ("Process record: memory copy and memory set\n"); + + uint8_t op1 = bits (aarch64_insn_r->aarch64_insn, 22, 23); + uint8_t op2 = bits (aarch64_insn_r->aarch64_insn, 12, 15); + uint32_t reg_rd = bits (aarch64_insn_r->aarch64_insn, 0, 4); + uint32_t reg_rn = bits (aarch64_insn_r->aarch64_insn, 5, 9); + uint32_t record_buf[3]; + uint64_t record_buf_mem[4]; + + if (op1 != 3) + { + /* Copy instructions. */ + uint32_t reg_rs = bits (aarch64_insn_r->aarch64_insn, 16, 20); + + record_buf[0] = reg_rd; + record_buf[1] = reg_rn; + record_buf[2] = reg_rs; + aarch64_insn_r->reg_rec_count = 3; + + ULONGEST dest_addr; + regcache_raw_read_unsigned (aarch64_insn_r->regcache, reg_rd, + &dest_addr); + ULONGEST source_addr; + regcache_raw_read_unsigned (aarch64_insn_r->regcache, reg_rs, + &source_addr); + LONGEST length; + regcache_raw_read_signed (aarch64_insn_r->regcache, reg_rn, + &length); + + /* In a processor using algorithm option A, the length in Rn has an + inverted sign. */ + if (length < 0) + length *= -1; + + record_buf_mem[0] = length; + record_buf_mem[1] = dest_addr; + record_buf_mem[2] = length; + record_buf_mem[3] = source_addr; + aarch64_insn_r->mem_rec_count = 2; + } + else if ((op1 == 3 && op2 < 12) || (op1 == 3 && op2 < 12)) + { + /* Set instructions. */ + record_buf[0] = reg_rd; + record_buf[1] = reg_rn; + aarch64_insn_r->reg_rec_count = 2; + + ULONGEST address; + regcache_raw_read_unsigned (aarch64_insn_r->regcache, reg_rd, + &address); + + LONGEST length; + regcache_raw_read_signed (aarch64_insn_r->regcache, reg_rn, + &length); + + /* In a processor using algorithm option B, the length in Rn has an + inverted sign. */ + if (length < 0) + length *= -1; + + record_buf_mem[0] = length; + record_buf_mem[1] = address; + aarch64_insn_r->mem_rec_count = 1; + } + else + return AARCH64_RECORD_UNKNOWN; + + MEM_ALLOC (aarch64_insn_r->aarch64_mems, aarch64_insn_r->mem_rec_count, + record_buf_mem); + REG_ALLOC (aarch64_insn_r->aarch64_regs, aarch64_insn_r->reg_rec_count, + record_buf); + return AARCH64_RECORD_SUCCESS; +} + /* Record handler for load and store instructions. */ static unsigned int @@ -5566,6 +5646,10 @@ aarch64_record_load_store (aarch64_insn_decode_record *aarch64_insn_r) if (insn_bits10_11 == 0x01 || insn_bits10_11 == 0x03) record_buf[aarch64_insn_r->reg_rec_count++] = reg_rn; } + /* Memory Copy and Memory Set instructions. */ + else if ((insn_bits24_27 & 1) == 1 && insn_bits28_29 == 1 + && insn_bits10_11 == 1 && !insn_bit21) + return aarch64_record_memcopy_memset (aarch64_insn_r); /* Advanced SIMD load/store instructions. */ else return aarch64_record_asimd_load_store (aarch64_insn_r);