2020-08-26 13:26:03

by Josh Poimboeuf

[permalink] [raw]
Subject: Re: [PATCH] x86/irq: Preserve vector in orig_ax for APIC code

On Wed, Aug 26, 2020 at 01:53:57PM +0200, Alexander Graf wrote:
> -.macro idtentry_body cfunc has_error_code:req
> +.macro idtentry_body cfunc has_error_code:req preserve_error_code:req
>
> call error_entry
> UNWIND_HINT_REGS
> @@ -328,7 +328,9 @@ SYM_CODE_END(ret_from_fork)
>
> .if \has_error_code == 1
> movq ORIG_RAX(%rsp), %rsi /* get error code into 2nd argument*/
> - movq $-1, ORIG_RAX(%rsp) /* no syscall to restart */
> + .if \preserve_error_code == 0
> + movq $-1, ORIG_RAX(%rsp) /* no syscall to restart */
> + .endif

When does this happen (has_error_code=1 && preserve_error_code=0)? I
don't see any users of this macro (or idtentry) with this combination.

--
Josh


2020-08-26 13:55:39

by Alexander Graf

[permalink] [raw]
Subject: Re: [PATCH] x86/irq: Preserve vector in orig_ax for APIC code



On 26.08.20 15:22, Josh Poimboeuf wrote:
>
> On Wed, Aug 26, 2020 at 01:53:57PM +0200, Alexander Graf wrote:
>> -.macro idtentry_body cfunc has_error_code:req
>> +.macro idtentry_body cfunc has_error_code:req preserve_error_code:req
>>
>> call error_entry
>> UNWIND_HINT_REGS
>> @@ -328,7 +328,9 @@ SYM_CODE_END(ret_from_fork)
>>
>> .if \has_error_code == 1
>> movq ORIG_RAX(%rsp), %rsi /* get error code into 2nd argument*/
>> - movq $-1, ORIG_RAX(%rsp) /* no syscall to restart */
>> + .if \preserve_error_code == 0
>> + movq $-1, ORIG_RAX(%rsp) /* no syscall to restart */
>> + .endif
>
> When does this happen (has_error_code=1 && preserve_error_code=0)? I
> don't see any users of this macro (or idtentry) with this combination.

It's well hidden in arch/x86/include/asm/idtentry.h:

#define DECLARE_IDTENTRY_ERRORCODE(vector, func) \
idtentry vector asm_##func func has_error_code=1

/* Simple exception entries with error code pushed by hardware */
DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_TS, exc_invalid_tss);
DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_NP, exc_segment_not_present);
DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_SS, exc_stack_segment);
DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_GP, exc_general_protection);
DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_AC, exc_alignment_check);
[...]
DECLARE_IDTENTRY_RAW_ERRORCODE(X86_TRAP_PF, exc_page_fault);


Alex



Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879