mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
x86/mm: add speculation barriers to open coded locks
Add a speculation barrier to the clearly identified open-coded lock taking
functions.
Note that the memory sharing page_lock() replacement (_page_lock()) is left
as-is, as the code is experimental and not security supported.
This is part of XSA-453 / CVE-2024-2193
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
(cherry picked from commit 42a572a38e)
This commit is contained in:
1 parent
2ad38e116e
commit
9c7cdd55dc
2 files changed
+7
-3
No files matched your search
+4
-2
@@ -2004,7 +2004,7 @@ static inline bool current_locked_page_ne_check(struct page_info *page) {
|
||||
#define current_locked_page_ne_check(x) true
|
||||
#endif
|
||||
|
||||
int page_lock(struct page_info *page)
|
||||
int page_lock_unsafe(struct page_info *page)
|
||||
{
|
||||
unsigned long x, nx;
|
||||
|
||||
@@ -2065,7 +2065,7 @@ void page_unlock(struct page_info *page)
|
||||
* l3t_lock(), so to avoid deadlock we must avoid grabbing them in
|
||||
* reverse order.
|
||||
*/
|
||||
static void l3t_lock(struct page_info *page)
|
||||
static always_inline void l3t_lock(struct page_info *page)
|
||||
{
|
||||
unsigned long x, nx;
|
||||
|
||||
@@ -2074,6 +2074,8 @@ static void l3t_lock(struct page_info *page)
|
||||
cpu_relax();
|
||||
nx = x | PGT_locked;
|
||||
} while ( cmpxchg(&page->u.inuse.type_info, x, nx) != x );
|
||||
|
||||
block_lock_speculation();
|
||||
}
|
||||
|
||||
static void l3t_unlock(struct page_info *page)
|
||||
|
||||
@@ -393,7 +393,9 @@ const struct platform_bad_page *get_platform_badpages(unsigned int *array_size);
|
||||
* The use of PGT_locked in mem_sharing does not collide, since mem_sharing is
|
||||
* only supported for hvm guests, which do not have PV PTEs updated.
|
||||
*/
|
||||
int page_lock(struct page_info *page);
|
||||
int page_lock_unsafe(struct page_info *page);
|
||||
#define page_lock(pg) lock_evaluate_nospec(page_lock_unsafe(pg))
|
||||
|
||||
void page_unlock(struct page_info *page);
|
||||
|
||||
void put_page_type(struct page_info *page);
|
||||
|
||||