From patchwork Tue May 7 02:22:46 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: 795195 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:34e:ceec:bfcd with SMTP id k28csp88501wrc; Mon, 6 May 2024 19:23:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUD/KbfFOHfWiYzvbGrfEteMq0dm0uv3MYW6MdZ9OFUtuX0IwQZsUE7SbK7c+sr1OJS8s5El1hH0/fchVmXxgdj X-Google-Smtp-Source: AGHT+IH6VJOFLLCvdGMwNI0BA49vN5lL0ku03EHOWWLdh/kUePbRCdSez5O1OUKI+qklm8N4yJg7 X-Received: by 2002:a05:6214:29e7:b0:69b:3c90:400f with SMTP id jv7-20020a05621429e700b0069b3c90400fmr14910482qvb.32.1715048607479; Mon, 06 May 2024 19:23:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715048607; cv=pass; d=google.com; s=arc-20160816; b=fE6RAPPqpAKiVgboBFLgb4H5cZnFQ6DyWFwTfsbrRIEac+Q1xYyX7fNznV5oWjCoFf i9vcr3KhU4E1np9P4pR09Md4972kcdpwCgEo1eCtMM3WYJY9XO68UTN247mw9QBZ9SRJ xTwSXi+b4GoSk7E/gWR73ph0oJyPWPt9ceroD8iY6ulwwR4HGQxZhf9DBoCidO2oTHkg 5krHjwhjXA8aT+0IlxKn+CHToelUmNLZV43QLOXio2mp+apC8zwLRkvlLYfl3gq7V/+k 1SsSGJSHafSOBC2nA6VGVUCVCrfAWV6n+EdsLbF2vPE1vnfNSOhj2gcs9RH+V+ieq+Dq Yy+g== 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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=90Fsq7okzcCDkvzCp6Zi3BzS3iryMRyff9fFSoWGAbo=; fh=AA1/l1kx9p7hoPrYVWA5ku4B9TvBXTIEFDQu7s+joq4=; b=bN7wfcnhtbMTqIWFJRlVPljDrLzrddOlCfpaAJh3Anjtn5VQ0SuhpDl3ppMHrFE0EY YPgjNapnmba4Kab6K59uU603iCOCbnyDlcnVL1ak8y9uwrourB4zu5rP7NkGkZ7Ap/KV zFckg9A0O4Pv9NQ+OEQvVpxm2KMLxpn0LPKxvt1qX2TdymEVcYZYDPS7PQ4/a7900McQ Eo5LhO/Byz09bx0Igh6Y2cFJ1FX3R5NilYQ2w18nsd4nn7aj8gFPMhIV1JpG727c9tml cpvCowBWA2pySIGRIZTqJ5xieF///sekUqebnGl/MaDG0ga0T+elyWgJts8vZgqs6uLH wrtg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vBkCaCEp; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id hf12-20020a0562140e8c00b006a0d5480cd7si10738396qvb.300.2024.05.06.19.23.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 19:23:27 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vBkCaCEp; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 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 1CEEB385B50A for ; Tue, 7 May 2024 02:23:27 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-oo1-xc33.google.com (mail-oo1-xc33.google.com [IPv6:2607:f8b0:4864:20::c33]) by sourceware.org (Postfix) with ESMTPS id 914423858D35 for ; Tue, 7 May 2024 02:22:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 914423858D35 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 914423858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715048581; cv=none; b=PKxo3F7T1QZmfUJ6ASLdKlMqGEeVzhQ+hb4ABZaQMFCYwMssUxkQBuGDPI4J0vQkYJVeJMk929yQiYcEzItGyNQ12Tc4l3N9+87o3HhNLKxmulSto+6HZGI3zEflu02qFTZQy97ko3hxb6/rD0SCFRpDOY3vhY+bY6fsp//pHkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715048581; c=relaxed/simple; bh=Hek0cIl608E4Cs0r5V0jtRr6oqV8KdumpYSNx965vQg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=o7DhsBoBS6JFRvFcP3jra/hqJbQTC5ndhb7fP775WR0qeWaz2HnA0TdS7yUna2cU1K1ISUf5XWoPfsryU7Ce4zUjKkTC0DPYkt4RsoJAwxNOMgA4MQuEnw8/LqA+3GRy03GSUQ0a0TVab4xLPILO6eVXuodKtpAejB1pmlKvk3M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc33.google.com with SMTP id 006d021491bc7-5b2180a5330so747511eaf.0 for ; Mon, 06 May 2024 19:22:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715048579; x=1715653379; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=90Fsq7okzcCDkvzCp6Zi3BzS3iryMRyff9fFSoWGAbo=; b=vBkCaCEpqi/ZyV20BEZZy9/79WxHJdrKABOMCcrU9tJbiQwwR9yhYc/jdtA9hgJqtM QbEXQlrDqQ1CV3zkXZz3wYegR2oXIeHdJdxHjQsAvFHGGUWmsIL0ZezfrM3fhMVxUJf/ QfSvUGZCp7HWr7QpEY8kRCnKhxdrFQEKeT5BN7VoMZmyHc53u/GIZTpZOSa6wB1h0CBx rPfpGw5U8TNiyFgMcMR/Xur/vxUBUS/n6Nkgq7zbtCsvDWa+chb46cVpEwMtlbreCFWT Z7JOsAAfZrRi7CRzIw7/BIcWRp3//xbv7KAEKRaQ5IEJwz7/LsjqXv9CIBw2ONb6DqsW ukQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715048579; x=1715653379; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=90Fsq7okzcCDkvzCp6Zi3BzS3iryMRyff9fFSoWGAbo=; b=GlEaaq9Qp+jrekzMohcucAN6E4NkwBJ3OYdJO8Wg86JrLpzoWaoTJePknpd96bW4+g w557T/NBy+M1e4aLyzjUt0uUrIFW+ZcSRk4CPQsi6FosKLba2oNd7ZnUsbgzuVMVi08W jzaXW2wCsf0/f+RgnekNbM5AlXPA/Jic+eL7Doodsjix3CAx+f1+9XOKbgrFj/IeqkX4 AVtilJ009Ze99Uaw4GbRbi9+TQmboeRJeZjD+1sniPYnwugVmlVh3gjCZjNr9R7gPsAL NWyk3JLXUT4fwmdN6/EFIrJP84CUshkoq1RYf+q4mSaYE6IqzjrfbYINLDa85FFm3eGL uvRA== X-Gm-Message-State: AOJu0YzQOWfo0ms//wtZK6QVVU2XfovdR0TpQQfacys+/DCcITSIX3oR 9ftBD/f7N6Lkw7qfArL3Xfn5bWzAlqfkKxdphS4+xMJddQlgWcnzFpGStBRJQUo+0DV768gNs/V F X-Received: by 2002:a05:6358:5398:b0:186:c06f:435c with SMTP id z24-20020a056358539800b00186c06f435cmr15474990rwe.24.1715048578668; Mon, 06 May 2024 19:22:58 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:38ad:4156:59df:8141]) by smtp.gmail.com with ESMTPSA id s127-20020a637785000000b0061d3b3c4708sm6953431pgc.88.2024.05.06.19.22.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 19:22:58 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Christophe Lyon Subject: [PATCH v2 2/5] gdb/aarch64: Add record support for MOPS instructions. Date: Mon, 6 May 2024 23:22:46 -0300 Message-ID: <20240507022249.554831-3-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240507022249.554831-1-thiago.bauermann@linaro.org> References: <20240507022249.554831-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 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(+) No change in v2. 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);