efi/unaccepted: Fix off-by-one when checking for overlapping ranges
authorMichael Roth <michael.roth@amd.com>
Fri, 3 Nov 2023 15:13:54 +0000 (10:13 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Dec 2023 07:52:23 +0000 (08:52 +0100)
commit589959bf46e46f9d056782ea4601a546d163cba6
treea3fe5e8117368491d9b5c6a2f838d1217b29ebb9
parent9e23c7f75b32b6286f1706efaff50837de3c6cc2
efi/unaccepted: Fix off-by-one when checking for overlapping ranges

[ Upstream commit 01b1e3ca0e5ce47bbae8217d47376ad01b331b07 ]

When a task needs to accept memory it will scan the accepting_list
to see if any ranges already being processed by other tasks overlap
with its range. Due to an off-by-one in the range comparisons, a task
might falsely determine that an overlapping range is being accepted,
leading to an unnecessary delay before it begins processing the range.

Fix the off-by-one in the range comparison to prevent this and slightly
improve performance.

Fixes: 50e782a86c98 ("efi/unaccepted: Fix soft lockups caused by parallel memory acceptance")
Link: https://lore.kernel.org/linux-mm/20231101004523.vseyi5bezgfaht5i@amd.com/T/#me2eceb9906fcae5fe958b3fe88e41f920f8335b6
Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/efi/unaccepted_memory.c