On 1/30/23 03:12, fa...@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~