Skip to content

Commit 74a0032

Browse files
committed
Merge tag 'x86_urgent_for_v5.19_rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Borislav Petkov: - Prepare for and clear .brk early in order to address XenPV guests failures where the hypervisor verifies page tables and uninitialized data in that range leads to bogus failures in those checks - Add any potential setup_data entries supplied at boot to the identity pagetable mappings to prevent kexec kernel boot failures. Usually, this is not a problem for the normal kernel as those mappings are part of the initially mapped 2M pages but if kexec gets to allocate the second kernel somewhere else, those setup_data entries need to be mapped there too. - Fix objtool not to discard text references from the __tracepoints section so that ENDBR validation still works - Correct the setup_data types limit as it is user-visible, before 5.19 releases * tag 'x86_urgent_for_v5.19_rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/boot: Fix the setup data types max limit x86/ibt, objtool: Don't discard text references from tracepoint section x86/compressed/64: Add identity mappings for setup_data entries x86: Fix .brk attribute in linker script x86: Clear .brk area at early boot x86/xen: Use clear_bss() for Xen PV guests
2 parents b1c428b + cb8a4be commit 74a0032

File tree

8 files changed

+29
-16
lines changed

8 files changed

+29
-16
lines changed

arch/x86/boot/compressed/ident_map_64.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ void kernel_add_identity_map(unsigned long start, unsigned long end)
110110
void initialize_identity_maps(void *rmode)
111111
{
112112
unsigned long cmdline;
113+
struct setup_data *sd;
113114

114115
/* Exclude the encryption mask from __PHYSICAL_MASK */
115116
physical_mask &= ~sme_me_mask;
@@ -163,6 +164,18 @@ void initialize_identity_maps(void *rmode)
163164
cmdline = get_cmd_line_ptr();
164165
kernel_add_identity_map(cmdline, cmdline + COMMAND_LINE_SIZE);
165166

167+
/*
168+
* Also map the setup_data entries passed via boot_params in case they
169+
* need to be accessed by uncompressed kernel via the identity mapping.
170+
*/
171+
sd = (struct setup_data *)boot_params->hdr.setup_data;
172+
while (sd) {
173+
unsigned long sd_addr = (unsigned long)sd;
174+
175+
kernel_add_identity_map(sd_addr, sd_addr + sizeof(*sd) + sd->len);
176+
sd = (struct setup_data *)sd->next;
177+
}
178+
166179
sev_prep_identity_maps(top_level_pgt);
167180

168181
/* Load the new page-table. */

arch/x86/include/asm/setup.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ void *extend_brk(size_t size, size_t align);
120120
static char __brk_##name[size]
121121

122122
extern void probe_roms(void);
123+
124+
void clear_bss(void);
125+
123126
#ifdef __i386__
124127

125128
asmlinkage void __init i386_start_kernel(void);

arch/x86/include/uapi/asm/bootparam.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#define SETUP_INDIRECT (1<<31)
1616

1717
/* SETUP_INDIRECT | max(SETUP_*) */
18-
#define SETUP_TYPE_MAX (SETUP_INDIRECT | SETUP_JAILHOUSE)
18+
#define SETUP_TYPE_MAX (SETUP_INDIRECT | SETUP_CC_BLOB)
1919

2020
/* ram_size flags */
2121
#define RAMDISK_IMAGE_START_MASK 0x07FF

arch/x86/kernel/head64.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,12 @@ void __init do_early_exception(struct pt_regs *regs, int trapnr)
426426

427427
/* Don't add a printk in there. printk relies on the PDA which is not initialized
428428
yet. */
429-
static void __init clear_bss(void)
429+
void __init clear_bss(void)
430430
{
431431
memset(__bss_start, 0,
432432
(unsigned long) __bss_stop - (unsigned long) __bss_start);
433+
memset(__brk_base, 0,
434+
(unsigned long) __brk_limit - (unsigned long) __brk_base);
433435
}
434436

435437
static unsigned long get_cmd_line_ptr(void)

arch/x86/kernel/vmlinux.lds.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ SECTIONS
385385
__end_of_kernel_reserve = .;
386386

387387
. = ALIGN(PAGE_SIZE);
388-
.brk (NOLOAD) : AT(ADDR(.brk) - LOAD_OFFSET) {
388+
.brk : AT(ADDR(.brk) - LOAD_OFFSET) {
389389
__brk_base = .;
390390
. += 64 * 1024; /* 64k alignment slop space */
391391
*(.bss..brk) /* areas brk users have reserved */

arch/x86/xen/enlighten_pv.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,15 +1183,19 @@ static void __init xen_domu_set_legacy_features(void)
11831183
extern void early_xen_iret_patch(void);
11841184

11851185
/* First C function to be called on Xen boot */
1186-
asmlinkage __visible void __init xen_start_kernel(void)
1186+
asmlinkage __visible void __init xen_start_kernel(struct start_info *si)
11871187
{
11881188
struct physdev_set_iopl set_iopl;
11891189
unsigned long initrd_start = 0;
11901190
int rc;
11911191

1192-
if (!xen_start_info)
1192+
if (!si)
11931193
return;
11941194

1195+
clear_bss();
1196+
1197+
xen_start_info = si;
1198+
11951199
__text_gen_insn(&early_xen_iret_patch,
11961200
JMP32_INSN_OPCODE, &early_xen_iret_patch, &xen_iret,
11971201
JMP32_INSN_SIZE);

arch/x86/xen/xen-head.S

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,6 @@ SYM_CODE_START(startup_xen)
4848
ANNOTATE_NOENDBR
4949
cld
5050

51-
/* Clear .bss */
52-
xor %eax,%eax
53-
mov $__bss_start, %rdi
54-
mov $__bss_stop, %rcx
55-
sub %rdi, %rcx
56-
shr $3, %rcx
57-
rep stosq
58-
59-
mov %rsi, xen_start_info
6051
mov initial_stack(%rip), %rsp
6152

6253
/* Set up %gs.
@@ -71,6 +62,7 @@ SYM_CODE_START(startup_xen)
7162
cdq
7263
wrmsr
7364

65+
mov %rsi, %rdi
7466
call xen_start_kernel
7567
SYM_CODE_END(startup_xen)
7668
__FINIT

tools/objtool/check.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3826,8 +3826,7 @@ static int validate_ibt(struct objtool_file *file)
38263826
!strcmp(sec->name, "__bug_table") ||
38273827
!strcmp(sec->name, "__ex_table") ||
38283828
!strcmp(sec->name, "__jump_table") ||
3829-
!strcmp(sec->name, "__mcount_loc") ||
3830-
!strcmp(sec->name, "__tracepoints"))
3829+
!strcmp(sec->name, "__mcount_loc"))
38313830
continue;
38323831

38333832
list_for_each_entry(reloc, &sec->reloc->reloc_list, list)

0 commit comments

Comments
 (0)