* [PATCH] x86/efi: mark racy access on efi_rts_work.efi_rts_id
@ 2024-04-27 5:25 linke li
2024-04-29 15:40 ` Ard Biesheuvel
0 siblings, 1 reply; 3+ messages in thread
From: linke li @ 2024-04-27 5:25 UTC (permalink / raw)
Cc: xujianhao01, linke li, Ard Biesheuvel, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
linux-efi, linux-kernel
In efi_crash_gracefully_on_page_fault(), efi_rts_work.efi_rts_id can by
changed by other thread from the comment. Mark possible data race on
efi_rts_work.efi_rts_id as benign using READ_ONCE.
This patch is aimed at reducing the number of benign races reported by
KCSAN in order to focus future debugging effort on harmful races.
Signed-off-by: linke li <lilinke99@qq.com>
---
arch/x86/platform/efi/quirks.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
index f0cc00032751..4acb81700caf 100644
--- a/arch/x86/platform/efi/quirks.c
+++ b/arch/x86/platform/efi/quirks.c
@@ -751,7 +751,7 @@ void efi_crash_gracefully_on_page_fault(unsigned long phys_addr)
* because this case occurs *very* rarely and hence could be improved
* on a need by basis.
*/
- if (efi_rts_work.efi_rts_id == EFI_RESET_SYSTEM) {
+ if (READ_ONCE(efi_rts_work.efi_rts_id) == EFI_RESET_SYSTEM) {
pr_info("efi_reset_system() buggy! Reboot through BIOS\n");
machine_real_restart(MRR_BIOS);
return;
--
2.39.3 (Apple Git-146)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/efi: mark racy access on efi_rts_work.efi_rts_id
2024-04-27 5:25 [PATCH] x86/efi: mark racy access on efi_rts_work.efi_rts_id linke li
@ 2024-04-29 15:40 ` Ard Biesheuvel
2024-05-01 2:59 ` linke li
0 siblings, 1 reply; 3+ messages in thread
From: Ard Biesheuvel @ 2024-04-29 15:40 UTC (permalink / raw)
To: linke li
Cc: xujianhao01, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, H. Peter Anvin, linux-efi, linux-kernel
On Sat, 27 Apr 2024 at 07:28, linke li <lilinke99@qq.com> wrote:
>
> In efi_crash_gracefully_on_page_fault(), efi_rts_work.efi_rts_id can by
> changed by other thread from the comment. Mark possible data race on
> efi_rts_work.efi_rts_id as benign using READ_ONCE.
>
> This patch is aimed at reducing the number of benign races reported by
> KCSAN in order to focus future debugging effort on harmful races.
>
> Signed-off-by: linke li <lilinke99@qq.com>
> ---
> arch/x86/platform/efi/quirks.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
> index f0cc00032751..4acb81700caf 100644
> --- a/arch/x86/platform/efi/quirks.c
> +++ b/arch/x86/platform/efi/quirks.c
> @@ -751,7 +751,7 @@ void efi_crash_gracefully_on_page_fault(unsigned long phys_addr)
> * because this case occurs *very* rarely and hence could be improved
> * on a need by basis.
> */
> - if (efi_rts_work.efi_rts_id == EFI_RESET_SYSTEM) {
> + if (READ_ONCE(efi_rts_work.efi_rts_id) == EFI_RESET_SYSTEM) {
> pr_info("efi_reset_system() buggy! Reboot through BIOS\n");
> machine_real_restart(MRR_BIOS);
> return;
Why is this the only reference that needs an annotation?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/efi: mark racy access on efi_rts_work.efi_rts_id
2024-04-29 15:40 ` Ard Biesheuvel
@ 2024-05-01 2:59 ` linke li
0 siblings, 0 replies; 3+ messages in thread
From: linke li @ 2024-05-01 2:59 UTC (permalink / raw)
To: ardb
Cc: bp, dave.hansen, hpa, lilinke99, linux-efi, linux-kernel, mingo,
tglx, x86, xujianhao01
> Why is this the only reference that needs an annotation?
In the function efi_runtime_services_init(), the if check on
efi_rts_work.efi_rts_id in line 728 uses READ_ONCE(), and the comment
explains that this is to reduce reports from KTSAN.
I propose that the check in line 754 undergoes a similar treatment for
consistency and to potentially reduce sanitizer reports.
Thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-01 2:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-27 5:25 [PATCH] x86/efi: mark racy access on efi_rts_work.efi_rts_id linke li
2024-04-29 15:40 ` Ard Biesheuvel
2024-05-01 2:59 ` linke li
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).