Skip to content

Commit 7fa0da5

Browse files
committed
x86/xen: remove hypercall page
The hypercall page is no longer needed. It can be removed, as from the Xen perspective it is optional. But, from Linux's perspective, it removes naked RET instructions that escape the speculative protections that Call Depth Tracking and/or Untrain Ret are trying to achieve. This is part of XSA-466 / CVE-2024-53241. Reported-by: Andrew Cooper <[email protected]> Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Andrew Cooper <[email protected]> Reviewed-by: Jan Beulich <[email protected]>
1 parent b1c2cb8 commit 7fa0da5

File tree

7 files changed

+1
-52
lines changed

7 files changed

+1
-52
lines changed

arch/x86/include/asm/xen/hypercall.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ struct xen_dm_op_buf;
8888
* there aren't more than 5 arguments...)
8989
*/
9090

91-
extern struct { char _entry[32]; } hypercall_page[];
92-
9391
void xen_hypercall_func(void);
9492
DECLARE_STATIC_CALL(xen_hypercall, xen_hypercall_func);
9593

arch/x86/kernel/callthunks.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,6 @@ static bool skip_addr(void *dest)
142142
if (dest >= (void *)relocate_kernel &&
143143
dest < (void*)relocate_kernel + KEXEC_CONTROL_CODE_MAX_SIZE)
144144
return true;
145-
#endif
146-
#ifdef CONFIG_XEN
147-
if (dest >= (void *)hypercall_page &&
148-
dest < (void*)hypercall_page + PAGE_SIZE)
149-
return true;
150145
#endif
151146
return false;
152147
}

arch/x86/kernel/vmlinux.lds.S

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,14 +519,10 @@ INIT_PER_CPU(irq_stack_backing_store);
519519
* linker will never mark as relocatable. (Using just ABSOLUTE() is not
520520
* sufficient for that).
521521
*/
522-
#ifdef CONFIG_XEN
523522
#ifdef CONFIG_XEN_PV
524523
xen_elfnote_entry_value =
525524
ABSOLUTE(xen_elfnote_entry) + ABSOLUTE(startup_xen);
526525
#endif
527-
xen_elfnote_hypercall_page_value =
528-
ABSOLUTE(xen_elfnote_hypercall_page) + ABSOLUTE(hypercall_page);
529-
#endif
530526
#ifdef CONFIG_PVH
531527
xen_elfnote_phys32_entry_value =
532528
ABSOLUTE(xen_elfnote_phys32_entry) + ABSOLUTE(pvh_start_xen - LOAD_OFFSET);

arch/x86/xen/enlighten.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
#include "xen-ops.h"
2424

25-
EXPORT_SYMBOL_GPL(hypercall_page);
26-
2725
DEFINE_STATIC_CALL(xen_hypercall, xen_hypercall_hvm);
2826
EXPORT_STATIC_CALL_TRAMP(xen_hypercall);
2927

arch/x86/xen/enlighten_hvm.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,8 @@ static void __init init_hvm_pv_info(void)
106106
/* PVH set up hypercall page in xen_prepare_pvh(). */
107107
if (xen_pvh_domain())
108108
pv_info.name = "Xen PVH";
109-
else {
110-
u64 pfn;
111-
uint32_t msr;
112-
109+
else
113110
pv_info.name = "Xen HVM";
114-
msr = cpuid_ebx(base + 2);
115-
pfn = __pa(hypercall_page);
116-
wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32));
117-
}
118111

119112
xen_setup_features();
120113

arch/x86/xen/enlighten_pvh.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,10 @@ static void __init pvh_arch_setup(void)
129129

130130
void __init xen_pvh_init(struct boot_params *boot_params)
131131
{
132-
u32 msr;
133-
u64 pfn;
134-
135132
xen_pvh = 1;
136133
xen_domain_type = XEN_HVM_DOMAIN;
137134
xen_start_flags = pvh_start_info.flags;
138135

139-
msr = cpuid_ebx(xen_cpuid_base() + 2);
140-
pfn = __pa(hypercall_page);
141-
wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32));
142-
143136
x86_init.oem.arch_setup = pvh_arch_setup;
144137
x86_init.oem.banner = xen_banner;
145138

arch/x86/xen/xen-head.S

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,6 @@
2222
#include <xen/interface/xen-mca.h>
2323
#include <asm/xen/interface.h>
2424

25-
.pushsection .noinstr.text, "ax"
26-
.balign PAGE_SIZE
27-
SYM_CODE_START(hypercall_page)
28-
.rept (PAGE_SIZE / 32)
29-
UNWIND_HINT_FUNC
30-
ANNOTATE_NOENDBR
31-
ANNOTATE_UNRET_SAFE
32-
ret
33-
/*
34-
* Xen will write the hypercall page, and sort out ENDBR.
35-
*/
36-
.skip 31, 0xcc
37-
.endr
38-
39-
#define HYPERCALL(n) \
40-
.equ xen_hypercall_##n, hypercall_page + __HYPERVISOR_##n * 32; \
41-
.type xen_hypercall_##n, @function; .size xen_hypercall_##n, 32
42-
#include <asm/xen-hypercalls.h>
43-
#undef HYPERCALL
44-
SYM_CODE_END(hypercall_page)
45-
.popsection
46-
4725
#ifdef CONFIG_XEN_PV
4826
__INIT
4927
SYM_CODE_START(startup_xen)
@@ -199,8 +177,6 @@ SYM_FUNC_END(xen_hypercall_intel)
199177
#else
200178
# define FEATURES_DOM0 0
201179
#endif
202-
ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .globl xen_elfnote_hypercall_page;
203-
xen_elfnote_hypercall_page: _ASM_PTR xen_elfnote_hypercall_page_value - .)
204180
ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES,
205181
.long FEATURES_PV | FEATURES_PVH | FEATURES_DOM0)
206182
ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic")

0 commit comments

Comments
 (0)