* [PATCH] x86/idt: Simplify the idt_setup_apic_and_irq_gates()
@ 2018-04-26 5:44 Dou Liyang
2018-05-19 12:32 ` Thomas Gleixner
0 siblings, 1 reply; 4+ messages in thread
From: Dou Liyang @ 2018-04-26 5:44 UTC (permalink / raw)
To: x86, linux-kernel; +Cc: tglx, mingo, hpa, Dou Liyang
The vectors between FIRST_SYSTEM_VECTOR and NR_VECTORS are special IRQ
vectors used by the SMP architecture. But, if X86_LOCAL_APIC=n, it will
not be used, and the FIRST_SYSTEM_VECTOR is equal to NR_VECTORS.
idt_setup_apic_and_irq_gates() didn't notice that, which make the code
a little complex.
Remove the code of the X86_LOCAL_APIC=n case to simplify it.
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
---
arch/x86/kernel/idt.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c
index 2c3a1b4294eb..8b4174890706 100644
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -317,15 +317,16 @@ void __init idt_setup_apic_and_irq_gates(void)
set_intr_gate(i, entry);
}
- for_each_clear_bit_from(i, system_vectors, NR_VECTORS) {
+ /*
+ * If X86_LOCAL_APIC=n, the FIRST_SYSTEM_VECTOR is equal to NR_VECTORS
+ * Just consider the X86_LOCAL_APIC=y case
+ */
#ifdef CONFIG_X86_LOCAL_APIC
+ for_each_clear_bit_from(i, system_vectors, NR_VECTORS) {
set_bit(i, system_vectors);
set_intr_gate(i, spurious_interrupt);
-#else
- entry = irq_entries_start + 8 * (i - FIRST_EXTERNAL_VECTOR);
- set_intr_gate(i, entry);
-#endif
}
+#endif
}
/**
--
2.14.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/idt: Simplify the idt_setup_apic_and_irq_gates()
2018-04-26 5:44 [PATCH] x86/idt: Simplify the idt_setup_apic_and_irq_gates() Dou Liyang
@ 2018-05-19 12:32 ` Thomas Gleixner
2018-05-22 2:44 ` Dou Liyang
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2018-05-19 12:32 UTC (permalink / raw)
To: Dou Liyang; +Cc: x86, linux-kernel, mingo, hpa
On Thu, 26 Apr 2018, Dou Liyang wrote:
> The vectors between FIRST_SYSTEM_VECTOR and NR_VECTORS are special IRQ
> vectors used by the SMP architecture. But, if X86_LOCAL_APIC=n, it will
> not be used, and the FIRST_SYSTEM_VECTOR is equal to NR_VECTORS.
Correct, but that function has nothing to do with FIRST_SYSTEM_VECTOR.
> diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c
> index 2c3a1b4294eb..8b4174890706 100644
> --- a/arch/x86/kernel/idt.c
> +++ b/arch/x86/kernel/idt.c
> @@ -317,15 +317,16 @@ void __init idt_setup_apic_and_irq_gates(void)
> set_intr_gate(i, entry);
> }
>
> - for_each_clear_bit_from(i, system_vectors, NR_VECTORS) {
> + /*
> + * If X86_LOCAL_APIC=n, the FIRST_SYSTEM_VECTOR is equal to NR_VECTORS
> + * Just consider the X86_LOCAL_APIC=y case
> + */
> #ifdef CONFIG_X86_LOCAL_APIC
> + for_each_clear_bit_from(i, system_vectors, NR_VECTORS) {
> set_bit(i, system_vectors);
> set_intr_gate(i, spurious_interrupt);
> -#else
> - entry = irq_entries_start + 8 * (i - FIRST_EXTERNAL_VECTOR);
> - set_intr_gate(i, entry);
> -#endif
> }
> +#endif
That change breaks the LOCAL_APIC=n case in a subtle way. What the function
does is to set _ALL_ entries starting from FIRST_EXTERNAL_VECTOR up to
NR_VECTORS in the IDT to a known target, except those which are already
occupied by a system vector.
So for APIC=y this sets them to: spurious vector and for APIC=n it sets it
to the corresppnding vector entry. You remove the latter...
Thanks,
tglx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/idt: Simplify the idt_setup_apic_and_irq_gates()
2018-05-19 12:32 ` Thomas Gleixner
@ 2018-05-22 2:44 ` Dou Liyang
2018-05-22 14:17 ` Thomas Gleixner
0 siblings, 1 reply; 4+ messages in thread
From: Dou Liyang @ 2018-05-22 2:44 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: x86, linux-kernel, mingo, hpa
Hi Thomas,
At 05/19/2018 08:32 PM, Thomas Gleixner wrote:
> On Thu, 26 Apr 2018, Dou Liyang wrote:
>
>> The vectors between FIRST_SYSTEM_VECTOR and NR_VECTORS are special IRQ
>> vectors used by the SMP architecture. But, if X86_LOCAL_APIC=n, it will
>> not be used, and the FIRST_SYSTEM_VECTOR is equal to NR_VECTORS.
>
> Correct, but that function has nothing to do with FIRST_SYSTEM_VECTOR.
>
Oops, sorry, when I reread, my changelog even made me misunderstand.
the patch hided it.
void __init idt_setup_apic_and_irq_gates(void)
...
for_each_clear_bit_from(i, system_vectors, FIRST_SYSTEM_VECTOR)
^^^^^^^^^^^^^^^^^^^
...
for_each_clear_bit_from(i, system_vectors, NR_VECTORS)
What I want to say is:
In the APIC=n system, the FIRST_SYSTEM_VECTOR is equal to
NR_VECTORS, So all entries has been set by
for_each_clear_bit_from(i, system_vectors, FIRST_SYSTEM_VECTOR)
...
the following setup code for APIC=n is redundant. Just setup gates for
APIC=y.
If it is OK, I will send v2.
Thanks,
dou
>> diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c
>> index 2c3a1b4294eb..8b4174890706 100644
>> --- a/arch/x86/kernel/idt.c
>> +++ b/arch/x86/kernel/idt.c
>> @@ -317,15 +317,16 @@ void __init idt_setup_apic_and_irq_gates(void)
>> set_intr_gate(i, entry);
>> }
>>
>> - for_each_clear_bit_from(i, system_vectors, NR_VECTORS) {
>> + /*
>> + * If X86_LOCAL_APIC=n, the FIRST_SYSTEM_VECTOR is equal to NR_VECTORS
>> + * Just consider the X86_LOCAL_APIC=y case
>> + */
>> #ifdef CONFIG_X86_LOCAL_APIC
>> + for_each_clear_bit_from(i, system_vectors, NR_VECTORS) {
>> set_bit(i, system_vectors);
>> set_intr_gate(i, spurious_interrupt);
>> -#else
>> - entry = irq_entries_start + 8 * (i - FIRST_EXTERNAL_VECTOR);
>> - set_intr_gate(i, entry);
>> -#endif
>> }
>> +#endif
>
> That change breaks the LOCAL_APIC=n case in a subtle way. What the function
> does is to set _ALL_ entries starting from FIRST_EXTERNAL_VECTOR up to
> NR_VECTORS in the IDT to a known target, except those which are already
> occupied by a system vector.
>
> So for APIC=y this sets them to: spurious vector and for APIC=n it sets it
> to the corresppnding vector entry. You remove the latter...
> > Thanks,
>
> tglx
>
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/idt: Simplify the idt_setup_apic_and_irq_gates()
2018-05-22 2:44 ` Dou Liyang
@ 2018-05-22 14:17 ` Thomas Gleixner
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2018-05-22 14:17 UTC (permalink / raw)
To: Dou Liyang; +Cc: x86, linux-kernel, mingo, hpa
[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]
On Tue, 22 May 2018, Dou Liyang wrote:
> Hi Thomas,
>
> At 05/19/2018 08:32 PM, Thomas Gleixner wrote:
> > On Thu, 26 Apr 2018, Dou Liyang wrote:
> >
> > > The vectors between FIRST_SYSTEM_VECTOR and NR_VECTORS are special IRQ
> > > vectors used by the SMP architecture. But, if X86_LOCAL_APIC=n, it will
> > > not be used, and the FIRST_SYSTEM_VECTOR is equal to NR_VECTORS.
> >
> > Correct, but that function has nothing to do with FIRST_SYSTEM_VECTOR.
> >
>
> Oops, sorry, when I reread, my changelog even made me misunderstand.
> the patch hided it.
>
> void __init idt_setup_apic_and_irq_gates(void)
> ...
> for_each_clear_bit_from(i, system_vectors, FIRST_SYSTEM_VECTOR)
> ^^^^^^^^^^^^^^^^^^^
> ...
> for_each_clear_bit_from(i, system_vectors, NR_VECTORS)
>
> What I want to say is:
>
> In the APIC=n system, the FIRST_SYSTEM_VECTOR is equal to
> NR_VECTORS, So all entries has been set by
>
> for_each_clear_bit_from(i, system_vectors, FIRST_SYSTEM_VECTOR)
> ...
>
> the following setup code for APIC=n is redundant. Just setup gates for
> APIC=y.
>
> If it is OK, I will send v2.
Right you are. I got confused ....
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-05-22 14:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-26 5:44 [PATCH] x86/idt: Simplify the idt_setup_apic_and_irq_gates() Dou Liyang
2018-05-19 12:32 ` Thomas Gleixner
2018-05-22 2:44 ` Dou Liyang
2018-05-22 14:17 ` Thomas Gleixner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®