Skip to contentSkip to conversation

x86: dovetail: Drop bogus local_irq_disable_full from __bad_area_nosemaphore

PATCH Superseded Jan Kiszka 2 participants 5 messages Nov 12

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 x86: dovetail: Drop bogus local_irq_disable_full from __bad_area_nosemaphore

From: Jan Kiszka <[email protected]>

There is no technical reason to disable IRQs here again, neither when the IRQ pipeline is enable nor when it is off, which this change also causes. We are never passing this point from OOB because of the !running_inband check and jump earlier in function. The inband case is identical to the !IRQ_PIPELINE case, and that one does not need any additional IRQ disabling as well (upstream code path).

The addition was most likely a mismerged during the forward-port from 6.18 to 6.19. Remove it.

---
 arch/x86/mm/fault.c | 2 --
 1 file changed, 2 deletions(-)
arch/x86/mm/fault.c +0 -2
index e41ed2092730c..e9a08a5d26e60 100644
@@ -886,8 +886,6 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
 		force_sig_pkuerr((void __user *)address, pkey);
 	else
 		force_sig_fault(SIGSEGV, si_code, (void __user *)address);
-
-	local_irq_disable_full();
 out:
 	oob_trap_unwind(X86_TRAP_PF, regs);
 }
Signature · 1 line
2.47.3
#1 lore raw
Quoted 22 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

There is no technical reason to disable IRQs here again, neither when the IRQ pipeline is enable nor when it is off, which this change also causes. We are never passing this point from OOB because of the !running_inband check and jump earlier in function. The inband case is identical to the !IRQ_PIPELINE case, and that one does not need any additional IRQ disabling as well (upstream code path).

The addition was most likely a mismerged during the forward-port from 6.18 to 6.19. Remove it.

---
 arch/x86/mm/fault.c | 2 --
 1 file changed, 2 deletions(-)
arch/x86/mm/fault.c +0 -0
index e41ed2092730c..e9a08a5d26e60 100644

arch/x86/mm/fault.c __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, · line 891

Quoted 8 lines
arch/x86/mm/fault.c +0 -2
@@ -886,8 +886,6 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
 		force_sig_pkuerr((void __user *)address, pkey);
 	else
 		force_sig_fault(SIGSEGV, si_code, (void __user *)address);
-
-	local_irq_disable_full();
 out:
 	oob_trap_unwind(X86_TRAP_PF, regs);
 }

When removing such code, replacing it by an assertion like WARN_ON_ONCE(irqs_pipelined() && !irqs_disabled()) would catch wrong moves.

Signature · 1 line
Philippe.
author
#2 lore raw
Quoted 28 lines · Philippe Gerum
Quoted 26 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

There is no technical reason to disable IRQs here again, neither when the IRQ pipeline is enable nor when it is off, which this change also causes. We are never passing this point from OOB because of the !running_inband check and jump earlier in function. The inband case is identical to the !IRQ_PIPELINE case, and that one does not need any additional IRQ disabling as well (upstream code path).

The addition was most likely a mismerged during the forward-port from 6.18 to 6.19. Remove it.

---
 arch/x86/mm/fault.c | 2 --
 1 file changed, 2 deletions(-)
arch/x86/mm/fault.c +0 -1
index e41ed2092730c..e9a08a5d26e60 100644
@@ -886,8 +886,6 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
 		force_sig_pkuerr((void __user *)address, pkey);
 	else
 		force_sig_fault(SIGSEGV, si_code, (void __user *)address);
-
Quoted 9 lines

arch/x86/mm/fault.c __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, · line 891

Quoted 4 lines
arch/x86/mm/fault.c +0 -1
-	local_irq_disable_full();
 out:
 	oob_trap_unwind(X86_TRAP_PF, regs);
 }

When removing such code, replacing it by an assertion like WARN_ON_ONCE(irqs_pipelined() && !irqs_disabled()) would catch wrong moves.

IRQs are enabled at the point where local_irq_disable_full was located (-> cond_reenable_irqs_user / local_irq_enable), so this warning would always trigger.

Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center
#3 lore raw
Quoted 39 lines · Jan Kiszka
Quoted 28 lines · Philippe Gerum
Quoted 26 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

There is no technical reason to disable IRQs here again, neither when the IRQ pipeline is enable nor when it is off, which this change also causes. We are never passing this point from OOB because of the !running_inband check and jump earlier in function. The inband case is identical to the !IRQ_PIPELINE case, and that one does not need any additional IRQ disabling as well (upstream code path).

The addition was most likely a mismerged during the forward-port from 6.18 to 6.19. Remove it.

---
 arch/x86/mm/fault.c | 2 --
 1 file changed, 2 deletions(-)
arch/x86/mm/fault.c +0 -1
index e41ed2092730c..e9a08a5d26e60 100644
@@ -886,8 +886,6 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
 		force_sig_pkuerr((void __user *)address, pkey);
 	else
 		force_sig_fault(SIGSEGV, si_code, (void __user *)address);
-
Quoted 9 lines

arch/x86/mm/fault.c __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, · line 891

Quoted 4 lines
arch/x86/mm/fault.c +0 -1
-	local_irq_disable_full();
 out:
 	oob_trap_unwind(X86_TRAP_PF, regs);
 }

When removing such code, replacing it by an assertion like WARN_ON_ONCE(irqs_pipelined() && !irqs_disabled()) would catch wrong moves.

Quoted 4 lines

IRQs are enabled at the point where local_irq_disable_full was located (-> cond_reenable_irqs_user / local_irq_enable), so this warning would always trigger.

See my previous answer.

Signature · 1 line
Philippe.
author
#4 lore raw
Quoted 41 lines · Philippe Gerum
Quoted 39 lines · Jan Kiszka
Quoted 37 lines · Philippe Gerum
Quoted 22 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

There is no technical reason to disable IRQs here again, neither when the IRQ pipeline is enable nor when it is off, which this change also causes. We are never passing this point from OOB because of the !running_inband check and jump earlier in function. The inband case is identical to the !IRQ_PIPELINE case, and that one does not need any additional IRQ disabling as well (upstream code path).

The addition was most likely a mismerged during the forward-port from 6.18 to 6.19. Remove it.

---
 arch/x86/mm/fault.c | 2 --
 1 file changed, 2 deletions(-)
arch/x86/mm/fault.c +0 -0
index e41ed2092730c..e9a08a5d26e60 100644

arch/x86/mm/fault.c __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, · line 891

Quoted 8 lines
arch/x86/mm/fault.c +0 -2
@@ -886,8 +886,6 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
 		force_sig_pkuerr((void __user *)address, pkey);
 	else
 		force_sig_fault(SIGSEGV, si_code, (void __user *)address);
-
-	local_irq_disable_full();
 out:
 	oob_trap_unwind(X86_TRAP_PF, regs);
 }

When removing such code, replacing it by an assertion like WARN_ON_ONCE(irqs_pipelined() && !irqs_disabled()) would catch wrong moves.

Quoted 7 lines
Quoted 4 lines

IRQs are enabled at the point where local_irq_disable_full was located (-> cond_reenable_irqs_user / local_irq_enable), so this warning would always trigger.

See my previous answer.

OK, LLM may again help us out of this confusion, it likely found the source of it:

Before 614da1d3d4cdbd6e41aea06bc97ec15aacff6daf (late in 6.19), there was indeed a local_irq_disable() at the end of __bad_area_nosemaphore. But that commit moved it to handle_page_fault() where we also convert it to cond_disable_irqs(). And that commit was also backported to stable versions.

So, the current local_irq_disable_full() in 6.19+ became misplaced AND checking for irqs_disabled() at that point would be premature before they are actually disabled again in handle_page_fault().

I can try to rephrase the commit message accordingly.

Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center