Skip to content

Commit b57feed

Browse files
mdrothsuryasaimadhu
authored andcommitted
x86/compressed/64: Add identity mappings for setup_data entries
The decompressed kernel initially relies on the identity map set up by the boot/compressed kernel for accessing things like boot_params. With the recent introduction of SEV-SNP support, the decompressed kernel also needs to access the setup_data entries pointed to by boot_params->hdr.setup_data. This can lead to a crash in the kexec kernel during early boot due to these entries not currently being included in the initial identity map, see thread at Link below. Include mappings for the setup_data entries in the initial identity map. [ bp: Massage commit message and use a helper var for better readability. ] Fixes: b190a04 ("x86/sev: Add SEV-SNP feature detection/setup") Reported-by: Jun'ichi Nomura <junichi.nomura@nec.com> Signed-off-by: Michael Roth <michael.roth@amd.com> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lore.kernel.org/r/TYCPR01MB694815CD815E98945F63C99183B49@TYCPR01MB6948.jpnprd01.prod.outlook.com
1 parent 7e09ac2 commit b57feed

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
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. */

0 commit comments

Comments
 (0)