Commit ae1a4113 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'x86-boot-2020-06-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 boot updates from Ingo Molnar:
 "Misc updates:

   - Add the initrdmem= boot option to specify an initrd embedded in RAM
     (flash most likely)

   - Sanitize the CS value earlier during boot, which also fixes SEV-ES

   - Various fixes and smaller cleanups"

* tag 'x86-boot-2020-06-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/boot: Correct relocation destination on old linkers
  x86/boot/compressed/64: Switch to __KERNEL_CS after GDT is loaded
  x86/boot: Fix -Wint-to-pointer-cast build warning
  x86/boot: Add kstrtoul() from lib/
  x86/tboot: Mark tboot static
  x86/setup: Add an initrdmem= option to specify initrd physical address
parents d861f6e6 5214028d
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1748,6 +1748,13 @@

	initrd=		[BOOT] Specify the location of the initial ramdisk

	initrdmem=	[KNL] Specify a physical address and size from which to
			load the initrd. If an initrd is compiled in or
			specified in the bootparams, it takes priority over this
			setting.
			Format: ss[KMG],nn[KMG]
			Default is 0, 0

	init_on_alloc=	[MM] Fill newly allocated pages and heap objects with
			zeroes.
			Format: 0 | 1
+3 −4
Original line number Diff line number Diff line
@@ -280,9 +280,9 @@ acpi_physical_address get_rsdp_addr(void)
 */
#define MAX_ADDR_LEN 19

static acpi_physical_address get_cmdline_acpi_rsdp(void)
static unsigned long get_cmdline_acpi_rsdp(void)
{
	acpi_physical_address addr = 0;
	unsigned long addr = 0;

#ifdef CONFIG_KEXEC
	char val[MAX_ADDR_LEN] = { };
@@ -292,7 +292,7 @@ static acpi_physical_address get_cmdline_acpi_rsdp(void)
	if (ret < 0)
		return 0;

	if (kstrtoull(val, 16, &addr))
	if (boot_kstrtoul(val, 16, &addr))
		return 0;
#endif
	return addr;
@@ -314,7 +314,6 @@ static unsigned long get_acpi_srat_table(void)
	 * different ideas about whether to trust a command-line parameter.
	 */
	rsdp = (struct acpi_table_rsdp *)get_cmdline_acpi_rsdp();

	if (!rsdp)
		rsdp = (struct acpi_table_rsdp *)(long)
			boot_params->acpi_rsdp_addr;
+3 −2
Original line number Diff line number Diff line
@@ -49,16 +49,17 @@
 * Position Independent Executable (PIE) so that linker won't optimize
 * R_386_GOT32X relocation to its fixed symbol address.  Older
 * linkers generate R_386_32 relocations against locally defined symbols,
 * _bss, _ebss, _got and _egot, in PIE.  It isn't wrong, just less
 * _bss, _ebss, _got, _egot and _end, in PIE.  It isn't wrong, just less
 * optimal than R_386_RELATIVE.  But the x86 kernel fails to properly handle
 * R_386_32 relocations when relocating the kernel.  To generate
 * R_386_RELATIVE relocations, we mark _bss, _ebss, _got and _egot as
 * R_386_RELATIVE relocations, we mark _bss, _ebss, _got, _egot and _end as
 * hidden:
 */
	.hidden _bss
	.hidden _ebss
	.hidden _got
	.hidden _egot
	.hidden _end

	__HEAD
SYM_FUNC_START(startup_32)
+9 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@
	.hidden _ebss
	.hidden _got
	.hidden _egot
	.hidden _end

	__HEAD
	.code32
@@ -393,6 +394,14 @@ SYM_CODE_START(startup_64)
	addq	%rax, 2(%rax)
	lgdt	(%rax)

	/* Reload CS so IRET returns to a CS actually in the GDT */
	pushq	$__KERNEL_CS
	leaq	.Lon_kernel_cs(%rip), %rax
	pushq	%rax
	lretq

.Lon_kernel_cs:

	/*
	 * paging_prepare() sets up the trampoline and checks if we need to
	 * enable 5-level paging.
+42 −1
Original line number Diff line number Diff line
@@ -117,7 +117,6 @@ static unsigned int simple_guess_base(const char *cp)
 * @endp: A pointer to the end of the parsed string will be placed here
 * @base: The number base to use
 */

unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base)
{
	unsigned long long result = 0;
@@ -335,3 +334,45 @@ int kstrtoull(const char *s, unsigned int base, unsigned long long *res)
		s++;
	return _kstrtoull(s, base, res);
}

static int _kstrtoul(const char *s, unsigned int base, unsigned long *res)
{
	unsigned long long tmp;
	int rv;

	rv = kstrtoull(s, base, &tmp);
	if (rv < 0)
		return rv;
	if (tmp != (unsigned long)tmp)
		return -ERANGE;
	*res = tmp;
	return 0;
}

/**
 * kstrtoul - convert a string to an unsigned long
 * @s: The start of the string. The string must be null-terminated, and may also
 *  include a single newline before its terminating null. The first character
 *  may also be a plus sign, but not a minus sign.
 * @base: The number base to use. The maximum supported base is 16. If base is
 *  given as 0, then the base of the string is automatically detected with the
 *  conventional semantics - If it begins with 0x the number will be parsed as a
 *  hexadecimal (case insensitive), if it otherwise begins with 0, it will be
 *  parsed as an octal number. Otherwise it will be parsed as a decimal.
 * @res: Where to write the result of the conversion on success.
 *
 * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error.
 * Used as a replacement for the simple_strtoull.
 */
int boot_kstrtoul(const char *s, unsigned int base, unsigned long *res)
{
	/*
	 * We want to shortcut function call, but
	 * __builtin_types_compatible_p(unsigned long, unsigned long long) = 0.
	 */
	if (sizeof(unsigned long) == sizeof(unsigned long long) &&
	    __alignof__(unsigned long) == __alignof__(unsigned long long))
		return kstrtoull(s, base, (unsigned long long *)res);
	else
		return _kstrtoul(s, base, res);
}
Loading