From: Richard Henderson <richard.henderson@linaro.org>
To: gaosong <gaosong@loongson.cn>, qemu-devel@nongnu.org
Cc: laurent@vivier.eu, Xiaojuan Yang <yangxiaojuan@loongson.cn>
Subject: Re: [PATCH v15 8/9] target/loongarch: Adjust functions and structure to support user-mode
Date: Fri, 10 Jun 2022 15:45:18 -0700 [thread overview]
Message-ID: <20b38d22-0c59-ec11-88e1-af0f1f604984@linaro.org> (raw)
In-Reply-To: <e6e9c111-ca44-0126-b7a5-dcffe33385a5@loongson.cn>
On 6/9/22 23:53, gaosong wrote:
> Hi Richard,
>
> On 2022/6/10 上午2:42, Richard Henderson wrote:
>>> void helper_asrtle_d(CPULoongArchState *env, target_ulong rj, target_ulong rk)
>>> {
>>> if (rj > rk) {
>>> +#ifdef CONFIG_USER_ONLY
>>> + cpu_loop_exit_sigsegv(env_cpu(env), GETPC(),
>>> + MMU_DATA_LOAD, true, GETPC());
>>> +#else
>>> do_raise_exception(env, EXCCODE_ADEM, GETPC());
>>> +#endif
>>
>> This change is wrong. First, the kernel's do_ade raises SIGBUS. Second, GETPC() is a
>> host address, not a guest address. Third, this highlights the fact that the existing
>> system code is wrong, and should be setting badvaddr.
>>
>> You need to
>> (1) set badvaddr here, and then
>> (2) handle EXCCODE_ADEM in linux-user/loongarch/cpu_loop.c to
>> force_fix_fault(TARGET_SIGBUS, TARGET_BUS_ADRERR, env->badvaddr).
>
> badvaddr is env->pc or base->pc_next?
I don't know. The documentation for the ASRT{LE,GD}.D instructions is incomplete.
However, from the kernel code,
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/kernel/traps.c#n360
I can see that the kernel expects *some* value to be set there. Given that this is the
same trap used by the bound check memory accesses, I presume that badvaddr is related to
the memory access not the PC. So I would expect badvaddr to be RJ.
But that is a guess. Please check with your hardware engineers.
r~
next prev parent reply other threads:[~2022-06-10 22:47 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 2:42 [PATCH v15 0/9] Add LoongArch linux-user emulation support Song Gao
2022-06-09 2:42 ` [PATCH v15 1/9] linux-user: Add LoongArch generic header files Song Gao
2022-06-09 9:54 ` WANG Xuerui
2022-06-09 2:42 ` [PATCH v15 2/9] linux-user: Add LoongArch signal support Song Gao
2022-06-09 18:00 ` Richard Henderson
2022-06-09 2:42 ` [PATCH v15 3/9] linux-user: Add LoongArch elf support Song Gao
2022-06-09 2:42 ` [PATCH v15 4/9] linux-user: Add LoongArch syscall support Song Gao
2022-06-09 10:04 ` WANG Xuerui
2022-06-10 1:15 ` gaosong
2022-06-09 2:42 ` [PATCH v15 5/9] linux-user: Add LoongArch cpu_loop support Song Gao
2022-06-09 2:42 ` [PATCH v15 6/9] default-configs: Add loongarch linux-user support Song Gao
2022-06-09 10:11 ` WANG Xuerui
2022-06-09 18:14 ` Richard Henderson
2022-06-09 2:42 ` [PATCH v15 7/9] scripts: add loongarch64 binfmt config Song Gao
2022-06-09 2:42 ` [PATCH v15 8/9] target/loongarch: Adjust functions and structure to support user-mode Song Gao
2022-06-09 10:18 ` WANG Xuerui
2022-06-09 18:42 ` Richard Henderson
2022-06-10 6:53 ` gaosong
2022-06-10 22:45 ` Richard Henderson [this message]
2022-06-11 3:10 ` gaosong
2022-06-11 16:06 ` Richard Henderson
2022-06-13 3:50 ` gaosong
2022-06-13 16:05 ` Richard Henderson
2022-06-09 2:42 ` [PATCH v15 9/9] target/loongarch: Update README Song Gao
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=20b38d22-0c59-ec11-88e1-af0f1f604984@linaro.org \
--to=richard.henderson@linaro.org \
--cc=gaosong@loongson.cn \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=yangxiaojuan@loongson.cn \
/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).