From: 邹旭 <sendtozouxu@gmail.com>
To: qemu-devel@nongnu.org
Subject: Re: [PATCH] linux-user: Handle EXCP10_COPR properly for i386
Date: Fri, 21 May 2021 11:04:07 +0800 [thread overview]
Message-ID: <CAK8YQrUHyV5FPZiRviN5amHurJ-gCP8_jb-DSB-XRit3WUfUeg@mail.gmail.com> (raw)
In-Reply-To: <CAK8YQrXoOJNwfoutvh7BkYmqfdMtZ6eAQQ+uAjL27FuOK28cvg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2917 bytes --]
ping
邹旭 <sendtozouxu@gmail.com> 于2021年5月14日周五 下午5:23写道:
> From e805b793f7d4b3e8c37d540b7d6cc0c6ac682311 Mon Sep 17 00:00:00 2001
> From: Xu Zou <sendtozouxu@gmail.com>
> Date: Fri, 14 May 2021 15:55:07 +0800
> Subject: [PATCH] linux-user: Handle EXCP10_COPR properly for i386
>
> Handle EXCP10_COPR properly for i386 in cpu loop.
>
> NE flag is set to select native mode for handling floating-point
> exceptions. FWAIT instruction can raise EXCP10_COPR exception by using
> fpu_raise_exception() function.
>
> The code is based on kernel's function fpu__exception_code() in
> arch/x86/kernel/fpu/core.c.
>
> Signed-off-by: Xu Zou <sendtozouxu@gmail.com>
> ---
> linux-user/i386/cpu_loop.c | 26 +++++++++++++++++++++++++-
> 1 file changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/linux-user/i386/cpu_loop.c b/linux-user/i386/cpu_loop.c
> index f813e87294..e1f2911554 100644
> --- a/linux-user/i386/cpu_loop.c
> +++ b/linux-user/i386/cpu_loop.c
> @@ -199,6 +199,8 @@ void cpu_loop(CPUX86State *env)
> {
> CPUState *cs = env_cpu(env);
> int trapnr;
> + int si_code;
> + uint8_t status;
> abi_ulong pc;
> abi_ulong ret;
>
> @@ -315,6 +317,28 @@ void cpu_loop(CPUX86State *env)
> case EXCP_ATOMIC:
> cpu_exec_step_atomic(cs);
> break;
> + case EXCP10_COPR:
> + si_code = 0;
> + status = env->fp_status.float_exception_flags;
> + if (status & float_flag_invalid) {
> + si_code = TARGET_FPE_FLTINV;
> + }
> + if (status & float_flag_divbyzero) {
> + si_code = TARGET_FPE_FLTDIV;
> + }
> + if (status & float_flag_overflow) {
> + si_code = TARGET_FPE_FLTOVF;
> + }
> + if ((status & float_flag_underflow) ||
> + (status & float_flag_input_denormal) ||
> + (status & float_flag_output_denormal)) {
> + si_code = TARGET_FPE_FLTUND;
> + }
> + if (status & float_flag_inexact) {
> + si_code = TARGET_FPE_FLTRES;
> + }
> + gen_signal(env, TARGET_SIGFPE, si_code, env->eip);
> + break;
> default:
> pc = env->segs[R_CS].base + env->eip;
> EXCP_DUMP(env, "qemu: 0x%08lx: unhandled CPU exception 0x%x -
> aborting\n",
> @@ -327,7 +351,7 @@ void cpu_loop(CPUX86State *env)
>
> void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
> {
> - env->cr[0] = CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK;
> + env->cr[0] = CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK | CR0_NE_MASK;
> env->hflags |= HF_PE_MASK | HF_CPL_MASK;
> if (env->features[FEAT_1_EDX] & CPUID_SSE) {
> env->cr[4] |= CR4_OSFXSR_MASK;
> --
> 2.25.1
>
>
[-- Attachment #2: Type: text/html, Size: 3645 bytes --]
next prev parent reply other threads:[~2021-05-21 3:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-14 9:23 [PATCH] linux-user: Handle EXCP10_COPR properly for i386 邹旭
2021-05-21 3:04 ` 邹旭 [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-05-24 7:44 Xu Zou
2021-05-14 8:46 Xu Zou
2021-07-12 16:56 ` Richard Henderson
2021-05-14 7:56 Xu Zou
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=CAK8YQrUHyV5FPZiRviN5amHurJ-gCP8_jb-DSB-XRit3WUfUeg@mail.gmail.com \
--to=sendtozouxu@gmail.com \
--cc=qemu-devel@nongnu.org \
/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).