qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] target/i386: Fix #GP error code for INT instructions
@ 2025-03-12  0:06 Andrew Cooper
  2025-05-20 16:32 ` Andrew Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cooper @ 2025-03-12  0:06 UTC (permalink / raw)
  To: qemu-devel
  Cc: Andrew Cooper, Paolo Bonzini, Richard Henderson, Eduardo Habkost

While the (intno << shift) expression is correct for indexing the IDT based on
whether Long Mode is active, the error code itself was unchanged with AMD64,
and is still the index with 3 bits of metadata in the bottom.

Found when running a Xen unit test, all under QEMU.  The unit test objected to
being told there was an error with IDT index 256 when INT $0x80 (128) was the
problem instruction:

  ...
  Error: Unexpected fault 0x800d0802, #GP[IDT[256]]
  ...

Fixes: d2fd1af76777 ("x86_64 linux user emulation")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Richard Henderson <richard.henderson@linaro.org>
CC: Eduardo Habkost <eduardo@habkost.net>
---
 target/i386/tcg/user/seg_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/i386/tcg/user/seg_helper.c b/target/i386/tcg/user/seg_helper.c
index c45f2ac2ba68..ff328b2a9522 100644
--- a/target/i386/tcg/user/seg_helper.c
+++ b/target/i386/tcg/user/seg_helper.c
@@ -64,7 +64,7 @@ static void do_interrupt_user(CPUX86State *env, int intno, int is_int,
         cpl = env->hflags & HF_CPL_MASK;
         /* check privilege if software int */
         if (dpl < cpl) {
-            raise_exception_err(env, EXCP0D_GPF, (intno << shift) + 2);
+            raise_exception_err(env, EXCP0D_GPF, intno * 8 + 2);
         }
     }
 

base-commit: 825b96dbcee23d134b691fc75618b59c5f53da32
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] target/i386: Fix #GP error code for INT instructions
  2025-03-12  0:06 [PATCH] target/i386: Fix #GP error code for INT instructions Andrew Cooper
@ 2025-05-20 16:32 ` Andrew Cooper
  2025-07-25 12:01   ` [PING] " Andrew Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cooper @ 2025-05-20 16:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Richard Henderson, Eduardo Habkost

Ping?

On 12/03/2025 12:06 am, Andrew Cooper wrote:
> While the (intno << shift) expression is correct for indexing the IDT based on
> whether Long Mode is active, the error code itself was unchanged with AMD64,
> and is still the index with 3 bits of metadata in the bottom.
>
> Found when running a Xen unit test, all under QEMU.  The unit test objected to
> being told there was an error with IDT index 256 when INT $0x80 (128) was the
> problem instruction:
>
>   ...
>   Error: Unexpected fault 0x800d0802, #GP[IDT[256]]
>   ...
>
> Fixes: d2fd1af76777 ("x86_64 linux user emulation")
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Richard Henderson <richard.henderson@linaro.org>
> CC: Eduardo Habkost <eduardo@habkost.net>
> ---
>  target/i386/tcg/user/seg_helper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/i386/tcg/user/seg_helper.c b/target/i386/tcg/user/seg_helper.c
> index c45f2ac2ba68..ff328b2a9522 100644
> --- a/target/i386/tcg/user/seg_helper.c
> +++ b/target/i386/tcg/user/seg_helper.c
> @@ -64,7 +64,7 @@ static void do_interrupt_user(CPUX86State *env, int intno, int is_int,
>          cpl = env->hflags & HF_CPL_MASK;
>          /* check privilege if software int */
>          if (dpl < cpl) {
> -            raise_exception_err(env, EXCP0D_GPF, (intno << shift) + 2);
> +            raise_exception_err(env, EXCP0D_GPF, intno * 8 + 2);
>          }
>      }
>  
>
> base-commit: 825b96dbcee23d134b691fc75618b59c5f53da32



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PING] Re: [PATCH] target/i386: Fix #GP error code for INT instructions
  2025-05-20 16:32 ` Andrew Cooper
@ 2025-07-25 12:01   ` Andrew Cooper
  2025-08-29 10:06     ` [PING ^ 2] " Andrew Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cooper @ 2025-07-25 12:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Richard Henderson, Eduardo Habkost

Ping again?

~Andrew

On 20/05/2025 5:32 pm, Andrew Cooper wrote:
> Ping?
>
> On 12/03/2025 12:06 am, Andrew Cooper wrote:
>> While the (intno << shift) expression is correct for indexing the IDT based on
>> whether Long Mode is active, the error code itself was unchanged with AMD64,
>> and is still the index with 3 bits of metadata in the bottom.
>>
>> Found when running a Xen unit test, all under QEMU.  The unit test objected to
>> being told there was an error with IDT index 256 when INT $0x80 (128) was the
>> problem instruction:
>>
>>   ...
>>   Error: Unexpected fault 0x800d0802, #GP[IDT[256]]
>>   ...
>>
>> Fixes: d2fd1af76777 ("x86_64 linux user emulation")
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>> ---
>> CC: Paolo Bonzini <pbonzini@redhat.com>
>> CC: Richard Henderson <richard.henderson@linaro.org>
>> CC: Eduardo Habkost <eduardo@habkost.net>
>> ---
>>  target/i386/tcg/user/seg_helper.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/target/i386/tcg/user/seg_helper.c b/target/i386/tcg/user/seg_helper.c
>> index c45f2ac2ba68..ff328b2a9522 100644
>> --- a/target/i386/tcg/user/seg_helper.c
>> +++ b/target/i386/tcg/user/seg_helper.c
>> @@ -64,7 +64,7 @@ static void do_interrupt_user(CPUX86State *env, int intno, int is_int,
>>          cpl = env->hflags & HF_CPL_MASK;
>>          /* check privilege if software int */
>>          if (dpl < cpl) {
>> -            raise_exception_err(env, EXCP0D_GPF, (intno << shift) + 2);
>> +            raise_exception_err(env, EXCP0D_GPF, intno * 8 + 2);
>>          }
>>      }
>>  
>>
>> base-commit: 825b96dbcee23d134b691fc75618b59c5f53da32



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PING ^ 2] Re: [PATCH] target/i386: Fix #GP error code for INT instructions
  2025-07-25 12:01   ` [PING] " Andrew Cooper
@ 2025-08-29 10:06     ` Andrew Cooper
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Cooper @ 2025-08-29 10:06 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Richard Henderson, Eduardo Habkost, Zhao Liu,
	Marcelo Tosatti, Cameron Esfahani, Roman Bolshakov,
	Phil Dennis-Jordan, Wei Liu

Trying some other x86 maintainers this time...

~Andrew

On 25/07/2025 1:01 pm, Andrew Cooper wrote:
> Ping again?
>
> ~Andrew
>
> On 20/05/2025 5:32 pm, Andrew Cooper wrote:
>> Ping?
>>
>> On 12/03/2025 12:06 am, Andrew Cooper wrote:
>>> While the (intno << shift) expression is correct for indexing the IDT based on
>>> whether Long Mode is active, the error code itself was unchanged with AMD64,
>>> and is still the index with 3 bits of metadata in the bottom.
>>>
>>> Found when running a Xen unit test, all under QEMU.  The unit test objected to
>>> being told there was an error with IDT index 256 when INT $0x80 (128) was the
>>> problem instruction:
>>>
>>>   ...
>>>   Error: Unexpected fault 0x800d0802, #GP[IDT[256]]
>>>   ...
>>>
>>> Fixes: d2fd1af76777 ("x86_64 linux user emulation")
>>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>>> ---
>>> CC: Paolo Bonzini <pbonzini@redhat.com>
>>> CC: Richard Henderson <richard.henderson@linaro.org>
>>> CC: Eduardo Habkost <eduardo@habkost.net>
>>> ---
>>>  target/i386/tcg/user/seg_helper.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/target/i386/tcg/user/seg_helper.c b/target/i386/tcg/user/seg_helper.c
>>> index c45f2ac2ba68..ff328b2a9522 100644
>>> --- a/target/i386/tcg/user/seg_helper.c
>>> +++ b/target/i386/tcg/user/seg_helper.c
>>> @@ -64,7 +64,7 @@ static void do_interrupt_user(CPUX86State *env, int intno, int is_int,
>>>          cpl = env->hflags & HF_CPL_MASK;
>>>          /* check privilege if software int */
>>>          if (dpl < cpl) {
>>> -            raise_exception_err(env, EXCP0D_GPF, (intno << shift) + 2);
>>> +            raise_exception_err(env, EXCP0D_GPF, intno * 8 + 2);
>>>          }
>>>      }
>>>  
>>>
>>> base-commit: 825b96dbcee23d134b691fc75618b59c5f53da32



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-08-30 16:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-12  0:06 [PATCH] target/i386: Fix #GP error code for INT instructions Andrew Cooper
2025-05-20 16:32 ` Andrew Cooper
2025-07-25 12:01   ` [PING] " Andrew Cooper
2025-08-29 10:06     ` [PING ^ 2] " Andrew Cooper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).