From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 5778C3858D37 for ; Wed, 28 Dec 2022 00:12:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5778C3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 7E3B9340FB0; Wed, 28 Dec 2022 00:12:35 +0000 (UTC) Date: Tue, 27 Dec 2022 19:12:33 -0500 From: Mike Frysinger To: Dragan Mladjenovic Cc: gdb-patches@sourceware.org, "Maciej W . Rozycki" , Chao-ying Fu , Faraz Shahbazker Subject: Re: [PATCH v5 4/4] sim: mips: Add simulator support for mips32r6/mips64r6 Message-ID: References: <20220202101725.23671-1-Dragan.Mladjenovic@syrmia.com> <20220202101725.23671-5-Dragan.Mladjenovic@syrmia.com> <5c3f02e8-737d-c992-f321-abbe7a60e249@syrmia.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="asWm2poSGWS1AlJF" Content-Disposition: inline In-Reply-To: <5c3f02e8-737d-c992-f321-abbe7a60e249@syrmia.com> X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,KAM_NUMSUBJECT,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --asWm2poSGWS1AlJF Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 27 Dec 2022 20:35, Dragan Mladjenovic wrote: > On 25-Dec-22 01:26, Mike Frysinger wrote: > > On 02 Feb 2022 11:17, Dragan Mladjenovic wrote: > >> --- a/sim/mips/configure.ac > >> +++ b/sim/mips/configure.ac > >> @@ -216,6 +227,7 @@ if test ${sim_gen} =3D MULTI; then > >> #include "sim-main.h" > >> #include "multi-include.h" > >> #include "elf-bfd.h" > >> +#include "elfxx-mips.h" > >> #include "elf/mips.h" > >> =20 > >> #define SD sd > >> @@ -235,7 +247,11 @@ sim_engine_run (SIM_DESC sd, > >> & EF_MIPS_ARCH_ASE_MICROMIPS) > >> mach =3D bfd_mach_mips_micromips; > >> else > >> - mach =3D STATE_ARCHITECTURE (SD)->mach; > >> + { > >> + mach =3D _bfd_elf_mips_mach (elf_elfheader (STATE_PROG_BFD (sd))= ->e_flags); > >> + if (!mach) > >> + mach =3D STATE_ARCHITECTURE (SD)->mach; > >> + } > >=20 > > why do you need this logic in the main engine run routine ? why isn't = the > > STATE_ARCHITECTURE value already set to the correct value ? if it isn'= t set > > correctly all the time, this can lead to incorrect behavior elsewhere w= hen > > code checks it. > >=20 > > when the sim is opened, the bfd_mach is either explicitly passed in (wh= ich > > gdb does), or initialized with a call to the bfd library APIs. see the > > sim/common/sim-utils.c:sim_analyze_program code. >=20 > Sorry but the exact reason for doing so eludes me. It is done on=20 > internal jump for gdb 8 to gdb 10, permissibly to allow running > binary even whet set arch forces older mips isa, but I see little > use of that outside of testsuite maybe. i'd argue that if you load a binary for one ISA, then force the runtime to use a different one, and the result crashes, then the sim is WAI. it should behave as real hardware does, and if you load a binary that needs a newer ISA than a CPU provides, it won't work. do you know if there's a testsuite, sim or gdb, that exercises this ? -mike --asWm2poSGWS1AlJF Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEuQK1JxMl+JKsJRrUQWM7n+g39YEFAmOrifEACgkQQWM7n+g3 9YE6Ng/8C1L/cOAgaiXmokauwbZ5Ha4WPeuWbO7wuBx3m6GUjkoo3FTLDS86h4AJ 6fV46gKLCg0i9tb/YX2uFh9Z/K64YYIprFC9BKSSrOw5nhYTdZgjS3T5O67d881q q37pLx2AALUNnVnNh525JgKdcWCQImQpEq0SW7p7eA+XP4/TxAam6ATPfVnHS0hC ZYooLvGRVfNPldZhHGQJesYt0fI/sZCz81LcDWdECzbA62KlNwpdoPpPseTyU57V lQCFPUKwKVPWkGU/fRnPrcULvhgM6HJjzGXf00UsF5xvlKw1wkxwOsqJbofZFEyK KpN2FoR865g1MDNo32ikV9CQQ3a7hjwiErH+MU1SNlz0fNVwa/ulCQ9shK4MbphC fmd9rHiVjMADzOmVURHWXcmyyabKN5Ya2y9VPC96CpA18VRtcKeEYk8aPpIi1DEv HIWTfG1qBPzs2/HFlGTemXS5p6fF4vAJwKtqfjiTRWHZT3Gh3Md+y+mTwg/4B8ha nSQ0XzKIQQunQ0iNfxUIEYaiZalQuPzS6aG78Z0LChDVZFCa/oxST4evIMaPZ89J SBXF/AwpNK/hliFvUGHMzGBs1L5imCqkhEFYX/q/JfTXoDHyzlsZuLV4LHAdXg0l VcaRS2Gz3J38RQiFMrmHoMSxMaiwETcdgct8afimH+hs271Szwc= =4N04 -----END PGP SIGNATURE----- --asWm2poSGWS1AlJF--