From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id DB0063858D20 for ; Mon, 11 Mar 2024 11:31:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB0063858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DB0063858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::631 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710156700; cv=none; b=RUsMJ2xzy3ybB0CBQ7s2qcHiUUYt33ZnFSGI7j19zFt8NOdUjjiG6Og6dZDx192YIB4+HAxQZzSslf1rahG8EHOXTkDOARC8dobkjhxP2ZTzMfYAHePxjzY3GnGp+yx810Zr7IeoavTEEfBpR5lPBS665YK9fU/sRcPtBKoCd58= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710156700; c=relaxed/simple; bh=jUCNNYTslYOdqptcTY+KaCo8KMoCardt00y/js8fCbY=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=tICfBYYjCchqni8crjJayqLsyHdVV69IFfF5+ppgj+m3gw22khnPq5n2rA+mU6BDHuUsiOHEXRg1gOc2fOhtFTKLI39r9DRyeA69a9MphImNcn7Pvg9L235yV81n0gdULGylQGp68e2zDR/vP5QZlvD5HAKHJD2kQfsMKOaNstc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a4429c556efso321818966b.0 for ; Mon, 11 Mar 2024 04:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710156695; x=1710761495; darn=sourceware.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Ws5PtqDo76G2H5/1J8uoQ4Ci6F4rN/nZDhXr3TsSmAk=; b=iQSKmIc+PQNXdF0ZuAuvS8rhNu7WuMnAM4mLOSqwX3+osda6uzFXOhkBedqRISG+Ek jMT1ga+mr8o7zNR5XVXRHj+FDYbIJZLfYzJiYGpbq9hS69DrprXcR2BIMVAg3ZkmTFkw LKdve0E4HQgeJPznwTdEAoqsL9B6P0/qBfRyZnSQs8Xl/Pq/jNf1muOUctXd7pKeA8cL Ij015Aw4wZZW/yXNQdmwBK6kmmEhu3lwVnwgLXYNrFHVaOyU9LDtESYuhZ7PFdwUkoSw VYFWTgp/Kh66YB7Dxgs0N545jR+XUxAkyopphGUOrdvh2ti8c77DEOLtSErS77ovRQHr LPuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710156695; x=1710761495; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ws5PtqDo76G2H5/1J8uoQ4Ci6F4rN/nZDhXr3TsSmAk=; b=gQm07JQ4j0xJNiDf6Fu5RtIL+9PbSig3q5gQsDD98BDmY1gUHdzJykGyXRHrmmM+nK qNRSxmhok5Gn74GVlL53lVhumGytK5lwPtC1G9zwuaxhD3iOTP+9LJZ6Iv0+fl5w+oDT 1hREubxc+L8tObmIvTL7mWUy5ph6PJbH8PcuCkx/zstiCkiA/DD+bpFecax5+iuXBe4l ufPZGk6caPLOXE5KhUpmPEHuTCJdT4qhQBVXew0jyDPWa6vwbCRHUCUGf2CtLBFpQnNL Wjo0+hosBfmfbuofDRtefsOoTMXups7H7sJBLQyoaeBsJuqW1q57v9do3I6gaZTWAp0o iy3w== X-Gm-Message-State: AOJu0Yz//wQ/5WYK6MTVKo3KP8Y0X2GaMPj+qY83GKRLzF1Pn6wfkEam HyZ/wLdyWpOZaEMQueP0uzJOdI7C0JBhH0a7RinyO4S14APB+rgYMa2b+ZBGnNdE0eDmz5DNfwS HvuwYjbAtrku4auApZaonRpxLzt9vnASaYm5Hpd+9 X-Google-Smtp-Source: AGHT+IGgZw8deXkfQeIeRZjULkkWg3zsi9CSY3hGZSFQzZSwc8efy1AJ4GTypjlCMbBkYE693fuEi+9oMWbK2gi4VBs= X-Received: by 2002:a17:907:8906:b0:a46:2760:3c9b with SMTP id rs6-20020a170907890600b00a4627603c9bmr1306299ejc.34.1710156695123; Mon, 11 Mar 2024 04:31:35 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Shiro B Date: Mon, 11 Mar 2024 19:31:23 +0800 Message-ID: Subject: Re: Inquiry on AArch64 Simulator in GDB To: Andrew Dinn Cc: gdb@sourceware.org Content-Type: multipart/alternative; boundary="00000000000052bc49061360e210" X-Spam-Status: No, score=0.9 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --00000000000052bc49061360e210 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Andrew Binn, Thank you very much for your comprehensive response regarding the AArch64 simulator. A userspace simulator is all I need, and this seems will be very helpful to my project. During my exploration and testing, I believe I may have stumbled upon a bug related to the UMINV instruction, as detailed in the ARM documentation ( https://developer.arm.com/documentation/ddi0596/2020-12/SIMD-FP-Instruction= s/UMINV--Unsigned-Minimum-across-Vector-?lang=3Den). According to ARM's specifications, it appears that after comparing and identifying the minimum value in a vector, the result should be stored in a floating-point/vector register, rather than a general-purpose register. The relevant code can be found here: https://sourceware.org/git/?p=3Dbinutils-gdb.git;a=3Dblob;f=3Dsim/aarch64/s= imulator.c;h=3D1dde0b478c3d1bc9b88a63dd703225c9a2bb3703;hb=3DHEAD#l4482 Admittedly, my familiarity with ARM64, especially SIMD instructions, is not very extensive. However, through testing, I've noticed that the simulation's outcome for this instruction indeed differs from that of an actual CPU. Could you please take a look at this observation and provide your insights? I'm keen to understand whether this discrepancy could be attributed to my limited understanding or if it indeed points to a potential oversight in the simulator's implementation of the UMINV instruction (and also UMAXV, SMINV, SMAXV). Thank you once again for your invaluable feedback and for considering my query. I look forward to your expert opinion on this matter. Best regards Andrew Dinn =E4=BA=8E2024=E5=B9=B43=E6=9C=8811=E6=97=A5= =E5=91=A8=E4=B8=80 18:41=E5=86=99=E9=81=93=EF=BC=9A > Hi Shiro B, > > I believe a lot of the simulator code is based on work that was > originally done by me when we used the simulator to port OpenJDK to run > on AArch64. It was adapted by Phil Muldoon for use in gdb but a lot of > the code still looks recognisable to me. I cannot properly answer all > your questions but I can provide some background that might help. > > The original simulator was built to allow execution of AArch64 code > generated by the OpenJDK JIT compiler before any hardware was available. > So, it was based on a pre-release copy of the ARM ARM (ARM Architecture > Reference Manual) and it only catered for the subset of the original > instruction set that might be used during operation of conventional > userspace application. > > It did cover all the standard GPR- and FPR-based instructions. I think > it may also have supported a small subset of Neon vector instructions. > It did not cater for instructions, and associated registers, that would > only be needed during system bootstrap (e.g. only a few move to/from > system register options are supported). It also does not correctly > implement the AArch64 memory model - the original sim provided a > per-thread memory cache to simulate a local memory buffer but it was > nothing like the real thing. So, memory reads and writes operate using > host memory semantics (e.g. TSO on x86). > > I am not certain but I think the version currently in the gdb tree has > been updated to allow for extra Neon vector instructions that were not > in the original decode/execute tree. I don't think it has been updated > to cater for the few recent additions to the instruction set, nor to > allow for SVE. I cannot say exactly what is implemented now. It looks > like it still only really addresses userspace programs. > > I can tell you how to find out fairly quickly and easily what parts of > the instruction set are implemented. Start by looking at routine > *aarch64_decode_and_execute* in file simulator.c. It gets called from > *aarch64_step/run* to decode and execute a single instruction. The > decode does a recursive descent through groups and subgroups of > instructions, based on a hierarchy of discriminant bits. > > So, the top level dispatch is on bits [28..25]. Within each top level > group different bit patterns are used to do the next dispatch and so on. > For example, instructions in top level groups GROUP_DPIMM_1000 and > GROUP_DPIMM_1001 are discriminated by looking at bits [25..23] (n.b. it > may be obvious but just to spell it out -- the numbers in those top > level enum tags indicate what value bits [28..25] have). > > The logic of this recursive dispatch is implemented by the functions in > simulator.c with names in the format dexAAAAAA (A is an Alphabetic > character). The corresponding top level and nested bit patterns they > rely on are defined by enums with names in the format DispatchAAAA in > file decode.h. The function and enum names should match up. > > So, if you follow through each of these functions and associated nested > bit patterns you can find all the instructions in a given family and > subfamily that are implemented by the sim. Likewise if you want to see > if an instruction is implemented then you need to read off the bit > patterns from the top level on downwards to place it in a family and > subfamilies. When you reach the bottom of the dexAAAA tree you will find > out whether it is catered for or treated as an unknown instruction. > > Sorry that does not answer all your questions. Hopefully the comments in > the code will still help you identify what is supported and how. If they > are not enough then I may be able to answer specific queries. However, > since I wrote the original code 12 years ago I'm not sure I will be able > to remember all the details. > > regards, > > > Andrew Dinn > ----------- > Red Hat Distinguished Engineer > Red Hat UK Ltd > Registered in England and Wales under Company Registration No. 03798903 > Directors: Michael Cunningham, Michael ("Mike") O'Neill > > > On 11/03/2024 03:34, Shiro B via Gdb wrote: > > Dear GDB Mailing List, > > > > I hope this message finds you well. I am reaching out to express my keen > > interest in the AArch64 simulator included within GDB. (the one in > > [binutils-gdb.git]/sim/aarch64/) > > > > Despite my efforts, I have encountered difficulty in locating detailed > > documentation or introductions that shed light on several aspects of th= is > > simulator. > > > > My inquiries primarily revolve around its capabilities and limitations > with > > regard to the ARM64 instruction set. > > > > Specifically, I am eager to understand: > > > > 1. Which ARM64 instructions are supported by the AArch64 simulator? > > 2. Which version of the ARM standard does it adhere to? like v8 v8.1...? > > 3. Are there any extensions to the instruction set that the simulator > > supports? like pauth, crypto, neon, etc > > 3. Could you provide details on any instructions that are explicitly not > > supported? > > 4. Is the simulator limited to user-mode instructions, or does it offer > > broader functionality? > > 5. Lastly, I would appreciate insights into any known issues, > limitations, > > or scenarios where the AArch64 simulator may not be suitable for use. > > > > I believe understanding these aspects will greatly enhance my ability to > > utilize the AArch64 simulator effectively within GDB for development and > > testing purposes. Your guidance and any available documentation or > > resources on this topic would be immensely valuable. > > > > Thank you for your time and assistance. I look forward to your response > and > > any information you can share. > > > > Best regards > > > > --00000000000052bc49061360e210--