* Re: [PATCH] Make sure fetch_instruction exist before calling it
2025-11-14 8:29 [PATCH] Make sure fetch_instruction exist before calling it phind.uet
@ 2025-11-14 11:24 ` Paolo Bonzini
2025-11-14 12:36 ` Philippe Mathieu-Daudé
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2025-11-14 11:24 UTC (permalink / raw)
To: phind.uet, Cameron Esfahani, Roman Bolshakov, Phil Dennis-Jordan,
Wei Liu
Cc: qemu-devel
On 11/14/25 09:29, phind.uet@gmail.com wrote:
> From: Nguyen Dinh Phi <phind.uet@gmail.com>
>
> Currently, this function is only available in MSHV. If a different accelerator
> is used, and the code jumps to this section, a segfault will occur.
> (I ran into this with HVF)
>
> Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
Applied, thanks.
Paolo
> ---
> target/i386/emulate/x86_decode.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/target/i386/emulate/x86_decode.c b/target/i386/emulate/x86_decode.c
> index 97bd6f1a3b..d037ed1142 100644
> --- a/target/i386/emulate/x86_decode.c
> +++ b/target/i386/emulate/x86_decode.c
> @@ -77,7 +77,11 @@ static inline uint64_t decode_bytes(CPUX86State *env, struct x86_decode *decode,
> memcpy(&val, decode->stream->bytes + decode->len, size);
> } else {
> target_ulong va = linear_rip(env_cpu(env), env->eip) + decode->len;
> - emul_ops->fetch_instruction(env_cpu(env), &val, va, size);
> + if (emul_ops->fetch_instruction) {
> + emul_ops->fetch_instruction(env_cpu(env), &val, va, size);
> + } else {
> + emul_ops->read_mem(env_cpu(env), &val, va, size);
> + }
> }
> decode->len += size;
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Make sure fetch_instruction exist before calling it
2025-11-14 8:29 [PATCH] Make sure fetch_instruction exist before calling it phind.uet
2025-11-14 11:24 ` Paolo Bonzini
@ 2025-11-14 12:36 ` Philippe Mathieu-Daudé
2025-11-14 16:10 ` Richard Henderson
2025-11-21 5:54 ` Michael Tokarev
3 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-11-14 12:36 UTC (permalink / raw)
To: phind.uet, Cameron Esfahani, Roman Bolshakov, Phil Dennis-Jordan,
Wei Liu
Cc: qemu-devel
On 14/11/25 09:29, phind.uet@gmail.com wrote:
> From: Nguyen Dinh Phi <phind.uet@gmail.com>
>
> Currently, this function is only available in MSHV. If a different accelerator
> is used, and the code jumps to this section, a segfault will occur.
> (I ran into this with HVF)
>
Fixes: 1e25327b244 ("x86/emulate: Allow instruction decoding from stream")
> Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
> ---
> target/i386/emulate/x86_decode.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/target/i386/emulate/x86_decode.c b/target/i386/emulate/x86_decode.c
> index 97bd6f1a3b..d037ed1142 100644
> --- a/target/i386/emulate/x86_decode.c
> +++ b/target/i386/emulate/x86_decode.c
> @@ -77,7 +77,11 @@ static inline uint64_t decode_bytes(CPUX86State *env, struct x86_decode *decode,
> memcpy(&val, decode->stream->bytes + decode->len, size);
> } else {
> target_ulong va = linear_rip(env_cpu(env), env->eip) + decode->len;
> - emul_ops->fetch_instruction(env_cpu(env), &val, va, size);
> + if (emul_ops->fetch_instruction) {
> + emul_ops->fetch_instruction(env_cpu(env), &val, va, size);
> + } else {
> + emul_ops->read_mem(env_cpu(env), &val, va, size);
> + }
> }
> decode->len += size;
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Make sure fetch_instruction exist before calling it
2025-11-14 8:29 [PATCH] Make sure fetch_instruction exist before calling it phind.uet
2025-11-14 11:24 ` Paolo Bonzini
2025-11-14 12:36 ` Philippe Mathieu-Daudé
@ 2025-11-14 16:10 ` Richard Henderson
2025-11-21 5:54 ` Michael Tokarev
3 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2025-11-14 16:10 UTC (permalink / raw)
To: phind.uet, Cameron Esfahani, Roman Bolshakov, Phil Dennis-Jordan,
Wei Liu
Cc: qemu-devel
On 11/14/25 09:29, phind.uet@gmail.com wrote:
> From: Nguyen Dinh Phi <phind.uet@gmail.com>
>
> Currently, this function is only available in MSHV. If a different accelerator
> is used, and the code jumps to this section, a segfault will occur.
> (I ran into this with HVF)
>
> Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
> ---
> target/i386/emulate/x86_decode.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/target/i386/emulate/x86_decode.c b/target/i386/emulate/x86_decode.c
> index 97bd6f1a3b..d037ed1142 100644
> --- a/target/i386/emulate/x86_decode.c
> +++ b/target/i386/emulate/x86_decode.c
> @@ -77,7 +77,11 @@ static inline uint64_t decode_bytes(CPUX86State *env, struct x86_decode *decode,
> memcpy(&val, decode->stream->bytes + decode->len, size);
> } else {
> target_ulong va = linear_rip(env_cpu(env), env->eip) + decode->len;
> - emul_ops->fetch_instruction(env_cpu(env), &val, va, size);
> + if (emul_ops->fetch_instruction) {
> + emul_ops->fetch_instruction(env_cpu(env), &val, va, size);
> + } else {
> + emul_ops->read_mem(env_cpu(env), &val, va, size);
> + }
> }
> decode->len += size;
>
We should instead have fetch_instruction == read_mem for the cases that do not require a
specialized version.
r~
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Make sure fetch_instruction exist before calling it
2025-11-14 8:29 [PATCH] Make sure fetch_instruction exist before calling it phind.uet
` (2 preceding siblings ...)
2025-11-14 16:10 ` Richard Henderson
@ 2025-11-21 5:54 ` Michael Tokarev
2025-11-21 5:59 ` Michael Tokarev
3 siblings, 1 reply; 6+ messages in thread
From: Michael Tokarev @ 2025-11-21 5:54 UTC (permalink / raw)
To: phind.uet, Cameron Esfahani, Roman Bolshakov, Phil Dennis-Jordan,
Wei Liu
Cc: qemu-devel, qemu-stable, Paolo Bonzini
On 11/14/25 11:29, phind.uet@gmail.com wrote:
> From: Nguyen Dinh Phi <phind.uet@gmail.com>
>
> Currently, this function is only available in MSHV. If a different accelerator
> is used, and the code jumps to this section, a segfault will occur.
> (I ran into this with HVF)
Is it a qemu-stable material? It looks like it is.
Please let me know if it isn't.
Thanks,
/mjt
> Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
> ---
> target/i386/emulate/x86_decode.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/target/i386/emulate/x86_decode.c b/target/i386/emulate/x86_decode.c
> index 97bd6f1a3b..d037ed1142 100644
> --- a/target/i386/emulate/x86_decode.c
> +++ b/target/i386/emulate/x86_decode.c
> @@ -77,7 +77,11 @@ static inline uint64_t decode_bytes(CPUX86State *env, struct x86_decode *decode,
> memcpy(&val, decode->stream->bytes + decode->len, size);
> } else {
> target_ulong va = linear_rip(env_cpu(env), env->eip) + decode->len;
> - emul_ops->fetch_instruction(env_cpu(env), &val, va, size);
> + if (emul_ops->fetch_instruction) {
> + emul_ops->fetch_instruction(env_cpu(env), &val, va, size);
> + } else {
> + emul_ops->read_mem(env_cpu(env), &val, va, size);
> + }
> }
> decode->len += size;
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Make sure fetch_instruction exist before calling it
2025-11-21 5:54 ` Michael Tokarev
@ 2025-11-21 5:59 ` Michael Tokarev
0 siblings, 0 replies; 6+ messages in thread
From: Michael Tokarev @ 2025-11-21 5:59 UTC (permalink / raw)
To: phind.uet, Cameron Esfahani, Roman Bolshakov, Phil Dennis-Jordan,
Wei Liu
Cc: qemu-devel, qemu-stable, Paolo Bonzini
On 11/21/25 08:54, Michael Tokarev wrote:
> On 11/14/25 11:29, phind.uet@gmail.com wrote:
>> From: Nguyen Dinh Phi <phind.uet@gmail.com>
>>
>> Currently, this function is only available in MSHV. If a different
>> accelerator
>> is used, and the code jumps to this section, a segfault will occur.
>> (I ran into this with HVF)
>
> Is it a qemu-stable material? It looks like it is.
> Please let me know if it isn't.
Ah, n/m. This one fixes a commit which were added after 10.1
(so not in any stable release), --
1e25327b24 target/i386/emulate: Allow instruction decoding from stream
Sorry for the noise.
/mjt
^ permalink raw reply [flat|nested] 6+ messages in thread