diff --git a/xen/arch/x86/include/asm/mm.h b/xen/arch/x86/include/asm/mm.h index 05dfe35502..d1b1fee99b 100644 --- a/xen/arch/x86/include/asm/mm.h +++ b/xen/arch/x86/include/asm/mm.h @@ -399,7 +399,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); diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index ab0acbfea6..000fd0fb55 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -2017,7 +2017,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; @@ -2078,7 +2078,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; @@ -2087,6 +2087,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)