Re: access guest address from within instruction

2022-10-02 Thread Richard Henderson
On 10/2/22 07:52, BitFriends wrote: my bad, then I was mislead by "Which is, in general, what you want for implementing a custom instruction". Also the code around me is full of gen instructions, so I thought that's what I should use. So, when reading the doc I found out about the cpu_{ld,st}*

Re: access guest address from within instruction

2022-10-02 Thread BitFriends
thanks for the clarification, I will look at those insns. My instruction is for some more advanced logging between guest and host, that should be done quickly. Regards BitFriends Peter Maydell schrieb am So., 2. Okt. 2022, 16:45: > On Sun, 2 Oct 2022 at 10:22, BitFriends wrote: > > I now came

Re: access guest address from within instruction

2022-10-02 Thread BitFriends
my bad, then I was mislead by "Which is, in general, what you want for implementing a custom instruction". Also the code around me is full of gen instructions, so I thought that's what I should use. So, when reading the doc I found out about the cpu_{ld,st}*_mmu functions. That sounds more what I

Re: access guest address from within instruction

2022-10-02 Thread Peter Maydell
On Sun, 2 Oct 2022 at 10:22, BitFriends wrote: > I now came up with this code: > > TCGv_i64 res = 0; > TCGv_i64 addr = (TCGv_i64)(env->regs[R_EDI]); > > tcg_gen_qemu_ld_i64(res, addr, 0, MO_LEUQ); > > env->regs[R_EAX] = (target_ulong)res; This is wrong, because you cannot read or write env->regs[

Re: access guest address from within instruction

2022-10-02 Thread Richard Henderson
On 10/2/22 02:20, BitFriends wrote: I now came up with this code: TCGv_i64 res = 0; TCGv_i64 addr = (TCGv_i64)(env->regs[R_EDI]); tcg_gen_qemu_ld_i64(res, addr, 0, MO_LEUQ); env->regs[R_EAX] = (target_ulong)res; However this crashes afterwards in test_bit. Maybe this is caused by an invalid a

Re: access guest address from within instruction

2022-10-02 Thread Alex Bennée
BitFriends writes: > Hello, > > I am trying to create a custom instruction that accesses guest memory > specified by an address in a register. I specifically > want to read from that address. So I tried to do that using > "tcg_gen_qemu_ld_i64(&res, env->regs[R_EDI], 0, > MO_LEUQ);", but that

Re: access guest address from within instruction

2022-10-02 Thread BitFriends
I now came up with this code: TCGv_i64 res = 0; TCGv_i64 addr = (TCGv_i64)(env->regs[R_EDI]); tcg_gen_qemu_ld_i64(res, addr, 0, MO_LEUQ); env->regs[R_EAX] = (target_ulong)res; However this crashes afterwards in test_bit. Maybe this is caused by an invalid access? Anything wrong about the code?

Re: access guest address from within instruction

2022-10-01 Thread BitFriends
well, it doesn't give errors, but warnings because of unsigned longs being converted to TCGv_i64, which exact definiton I cannot find in the qemu repo. Where is it located? When stepping through the instructions' code, the value that should be read isn't read. Maybe that'll work when fixing the war

Re: access guest address from within instruction

2022-10-01 Thread Richard Henderson
On 10/1/22 13:10, BitFriends wrote: Hello, I am trying to create a custom instruction that accesses guest memory specified by an address in a register. I specifically want to read from that address. So I tried to do that using "tcg_gen_qemu_ld_i64(&res, env->regs[R_EDI], 0, MO_LEUQ);", but tha

access guest address from within instruction

2022-10-01 Thread BitFriends
Hello, I am trying to create a custom instruction that accesses guest memory specified by an address in a register. I specifically want to read from that address. So I tried to do that using "tcg_gen_qemu_ld_i64(&res, env->regs[R_EDI], 0, MO_LEUQ);", but that doesn't save any result in res. So eit