qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Please review a important patch abort fix setting of CPUX86State::gd


From: Richard Henderson
Subject: Re: Please review a important patch abort fix setting of CPUX86State::gdt::base
Date: Mon, 30 Jan 2023 09:31:17 -1000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

On 1/30/23 03:12, fanwj@mail.ustc.edu.cn wrote:

1. "The memcpy is definitely wrong, because you're casting a guest address into a 
host address, which is incorrect. You have to use g2h()."
There is no need to use g2h(), Because there are both guest address whether source or 
dest memory. refer to "linux-user/i386/cpu_loop.c" target_cpu_copy_regs 
function, Only use g2h_untagged when convert gdt::base to gdt_table. I don't use and 
modify gdt_table, Only copy gdt::base from source CPU to dest CPU. They are same type so 
no needed to convert by g2h.

This is *not* about the type, this is about the location in host memory, as input to memcpy. The g2h function is 1-to-1, but it is not the identity function.


2. "I'm actually surprised that you need this for TARGET_X86_64 at all ..."
GDT on QEMU User Mode is Pseudorandom GDT,It is NOT kernel private data 
structures. It is NOT Global Descriptor Table. It IS index table of fs and gs. 
And It is Thread local data. The Memory which gdt::base point can be modified 
by syscall SYS_set_thread_data.

Well, then you'll need to fix other assumptions in target/i386/tcg/translate.c, beginning with

#if defined(CONFIG_USER_ONLY) && defined(TARGET_X86_64)
#define VM86(S)   false
#define CODE32(S) true
#define SS32(S)   true
#define ADDSEG(S) false

which currently means that whatever you do with set_thread_data won't be recognized at translation time.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]