From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: root@wjsota.com, qemu-discuss@nongnu.org
Cc: QEMU Developers <qemu-devel@nongnu.org>, qemu-arm <qemu-arm@nongnu.org>
Subject: Re: QEMU emulating ARM Neoverse N1 unexpectectly emulates `retaa`
Date: Mon, 16 Jun 2025 07:09:12 +0200 [thread overview]
Message-ID: <7d1ddf7e-b16c-4820-958c-0d03bf8479d1@linaro.org> (raw)
In-Reply-To: <1235E663-AD2F-499E-8CF9-16E54A1C01DD@wjsota.com>
Hi Solomon,
Cc'ing the qemu-arm@ list.
On 14/6/25 06:51, root@wjsota.com wrote:
> Hi!
>
> Is `qemu-aarch64 -cpu neoverse-n1` supposed to emulate the `retaa` instruction?
>
> I have a binary called `main_pac` compiled from https://learn.arm.com/learning-paths/servers-and-cloud-computing/pac/example/ .
>
> The compiling command is `aarch64-linux-gnu-gcc -march=armv8.5-a -fPIC -pedantic -Wall -Wextra -ggdb3 -O0 -mbranch-protection=standard -fno-stack-protector -fPIE -static main.c -o main_pac`. The binary includes the `paciasp` and `retaa` instructions associated with ARM PAC.
>
> ```
> (gdb) disas main
> Dump of assembler code for function main:
> 0x0000000000400858 <+0>: paciasp
> 0x000000000040085c <+4>: stp x29, x30, [sp, #-32]!
> […]
> 0x0000000000400898 <+64>: ldp x29, x30, [sp], #32
> 0x000000000040089c <+68>: retaa
> End of assembler dump.
> (gdb) quit
> ```
>
> When emulated using `qemu-aarch64 -cpu neoverse-n1` , the program completes without issues.
> ```
> user@dell-op7020:~/learning/arm_learning_path_pac$ qemu-aarch64 -cpu neoverse-n1 main_pac test
> Hello World!
> user@dell-op7020:~/learning/arm_learning_path_pac$
> ```
>
> This is the case for two versions I tested:
> - v9.2.1 (Debian 1:9.2.1+ds-1ubuntu5)
> - v10.0.50 (v10.0.0-1610-gd9ce74873a)
>
>
> The expected behavior is for an Illegal Instruction exception to occur. Citing the Arm A-profile A64 Instruction Set Architect Version 2025-03, the `retaa` instruction should return an Undefined Instruction error when the PAC feature is not implemented.
> ```
> if !IsFeatureImplemented(FEAT_PAuth) then EndOfDecode(Decode_UNDEF);
> ```
>
> The same binary was run on AWS’s t4g.nano running Neoverse N1. It got the illegal instruction exception, as expected
> ```
> Core was generated by `./main_pac test'.
> Program terminated with signal SIGILL, Illegal instruction.
> #0 0x00000000004007d4 in func1 (s=0xffffe2446636 "test") at main.c:9
> 9 }
> (gdb) x/i $pc
> => 0x4007d4 <func1+36>: retaa
> (gdb) quit
> ```
>
> Is the emulation of Neoverse N1 behavior correct?
>
> Thank you
> Cheers,
> Solomon
next parent reply other threads:[~2025-06-16 5:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1235E663-AD2F-499E-8CF9-16E54A1C01DD@wjsota.com>
2025-06-16 5:09 ` Philippe Mathieu-Daudé [this message]
2025-06-18 1:44 ` QEMU emulating ARM Neoverse N1 unexpectectly emulates `retaa` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7d1ddf7e-b16c-4820-958c-0d03bf8479d1@linaro.org \
--to=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-discuss@nongnu.org \
--cc=root@wjsota.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).