From: "Alex Bennée" <alex.bennee@linaro.org>
To: fanwj@mail.ustc.edu.cn
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] linux-user: fix bug about incorrect base addresss of idt and gdt on i386 and x86_64
Date: Sun, 01 Jan 2023 16:46:50 +0000 [thread overview]
Message-ID: <87v8lqqjx4.fsf@linaro.org> (raw)
In-Reply-To: <75da8346.1fd34.1856e0d08ef.Coremail.fanwj@mail.ustc.edu.cn>
fanwj@mail.ustc.edu.cn writes:
> From 4601a624f40b2c89e7df2dec1adffb4f4308ba2d Mon Sep 17 00:00:00 2001
> From: fanwenjie <fanwj@mail.ustc.edu.cn>
> Date: Sun, 1 Jan 2023 23:13:34 +0800
> Subject: [PATCH] linux-user: fix bug about incorrect base addresss of idt and
> gdt on i386 and x86_64
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1405
> Signed-off-by: fanwenjie <fanwj@mail.ustc.edu.cn>
> ---
> linux-user/main.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/linux-user/main.c b/linux-user/main.c
> index a17fed045b..5d673c95b3 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -171,6 +171,12 @@ void fork_end(int child)
>
> __thread CPUState *thread_cpu;
>
> +#if defined(TARGET_I386) || defined(TARGET_X86_64)
> +#include <stdalign.h>
> +__thread alignas(TARGET_PAGE_SIZE) static uint64_t gdt_base[TARGET_GDT_ENTRIES];
> +__thread alignas(TARGET_PAGE_SIZE) static uint64_t idt_base[TARGET_PAGE_SIZE / sizeof(uint64_t)];
> +#endif
> +
> bool qemu_cpu_is_self(CPUState *cpu)
> {
> return thread_cpu == cpu;
> @@ -235,6 +241,13 @@ CPUArchState *cpu_copy(CPUArchState *env)
> new_cpu->tcg_cflags = cpu->tcg_cflags;
> memcpy(new_env, env, sizeof(CPUArchState));
>
> +#if defined(TARGET_I386) || defined(TARGET_X86_64)
> + memcpy(idt_base, (void*)new_env->idt.base, sizeof(uint64_t) * (new_env->idt.limit + 1));
> + memcpy(gdt_base, (void*)new_env->gdt.base, sizeof(uint64_t) * TARGET_GDT_ENTRIES);
> + new_env->idt.base = (target_ulong)idt_base;
> + new_env->gdt.base = (target_ulong)gdt_base;
> +#endif
> +
This is the wrong place to copy target specific bits of code. I think
this belongs with cpu_clone_regs_child and the gdt/idt structures in
linux-user/i386/cpu_loop.c I think.
> /* Clone all break/watchpoints.
> Note: Once we support ptrace with hw-debug register access, make sure
> BP_CPU break/watchpoints are handled correctly on clone. */
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2023-01-01 16:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-01 15:57 [PATCH] linux-user: fix bug about incorrect base addresss of idt and gdt on i386 and x86_64 fanwj
2023-01-01 16:11 ` Recall: " fanwj
2023-01-01 16:46 ` Alex Bennée [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-01-02 3:06 fanwj
2023-01-02 9:44 fanwj
2023-01-02 10:00 fanwenjie
2023-01-02 10:03 fanwenjie
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=87v8lqqjx4.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=fanwj@mail.ustc.edu.cn \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.