Revision abb02a824555c160dccc316971cbb802b3ebf4f7 authored by Linus Torvalds on 17 March 2023, 17:57:09 UTC, committed by Linus Torvalds on 17 March 2023, 17:57:09 UTC
Pull ACPI fixes from Rafael Wysocki:
 "These add some new quirks, fix PPTT handling, fix an ACPI utility and
  correct a mistake in the ACPI documentation.

  Specifics:

   - Fix ACPI PPTT handling to avoid sleep in the atomic context when it
     is not present (Sudeep Holla)

   - Add 'backlight=native' DMI quirk for Dell Vostro 15 3535 to the
     ACPI video driver (Chia-Lin Kao)

   - Add ACPI quirks for I2C device enumeration on Lenovo Yoga Book X90
     and Acer Iconia One 7 B1-750 (Hans de Goede)

   - Fix handling of invalid command line option values in the ACPI
     pfrut utility (Chen Yu)

   - Fix references to I2C device data type in the ACPI documentation
     for device enumeration (Andy Shevchenko)"

* tag 'acpi-6.3-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  ACPI: tools: pfrut: Check if the input of level and type is in the right numeric range
  ACPI: PPTT: Fix to avoid sleep in the atomic context when PPTT is absent
  ACPI: x86: Add skip i2c clients quirk for Lenovo Yoga Book X90
  ACPI: x86: Add skip i2c clients quirk for Acer Iconia One 7 B1-750
  ACPI: x86: Introduce an acpi_quirk_skip_gpio_event_handlers() helper
  ACPI: video: Add backlight=native DMI quirk for Dell Vostro 15 3535
  ACPI: docs: enumeration: Correct reference to the I²C device data type
2 parent s ba9c779 + f36cc6c
Raw File
binfmt_elf_test.c
// SPDX-License-Identifier: GPL-2.0-only
#include <kunit/test.h>

static void total_mapping_size_test(struct kunit *test)
{
	struct elf_phdr empty[] = {
		{ .p_type = PT_LOAD, .p_vaddr = 0, .p_memsz = 0, },
		{ .p_type = PT_INTERP, .p_vaddr = 10, .p_memsz = 999999, },
	};
	/*
	 * readelf -lW /bin/mount | grep '^  .*0x0' | awk '{print "\t\t{ .p_type = PT_" \
	 *				$1 ", .p_vaddr = " $3 ", .p_memsz = " $6 ", },"}'
	 */
	struct elf_phdr mount[] = {
		{ .p_type = PT_PHDR, .p_vaddr = 0x00000040, .p_memsz = 0x0002d8, },
		{ .p_type = PT_INTERP, .p_vaddr = 0x00000318, .p_memsz = 0x00001c, },
		{ .p_type = PT_LOAD, .p_vaddr = 0x00000000, .p_memsz = 0x0033a8, },
		{ .p_type = PT_LOAD, .p_vaddr = 0x00004000, .p_memsz = 0x005c91, },
		{ .p_type = PT_LOAD, .p_vaddr = 0x0000a000, .p_memsz = 0x0022f8, },
		{ .p_type = PT_LOAD, .p_vaddr = 0x0000d330, .p_memsz = 0x000d40, },
		{ .p_type = PT_DYNAMIC, .p_vaddr = 0x0000d928, .p_memsz = 0x000200, },
		{ .p_type = PT_NOTE, .p_vaddr = 0x00000338, .p_memsz = 0x000030, },
		{ .p_type = PT_NOTE, .p_vaddr = 0x00000368, .p_memsz = 0x000044, },
		{ .p_type = PT_GNU_PROPERTY, .p_vaddr = 0x00000338, .p_memsz = 0x000030, },
		{ .p_type = PT_GNU_EH_FRAME, .p_vaddr = 0x0000b490, .p_memsz = 0x0001ec, },
		{ .p_type = PT_GNU_STACK, .p_vaddr = 0x00000000, .p_memsz = 0x000000, },
		{ .p_type = PT_GNU_RELRO, .p_vaddr = 0x0000d330, .p_memsz = 0x000cd0, },
	};
	size_t mount_size = 0xE070;
	/* https://lore.kernel.org/linux-fsdevel/YfF18Dy85mCntXrx@fractal.localdomain */
	struct elf_phdr unordered[] = {
		{ .p_type = PT_LOAD, .p_vaddr = 0x00000000, .p_memsz = 0x0033a8, },
		{ .p_type = PT_LOAD, .p_vaddr = 0x0000d330, .p_memsz = 0x000d40, },
		{ .p_type = PT_LOAD, .p_vaddr = 0x00004000, .p_memsz = 0x005c91, },
		{ .p_type = PT_LOAD, .p_vaddr = 0x0000a000, .p_memsz = 0x0022f8, },
	};

	/* No headers, no size. */
	KUNIT_EXPECT_EQ(test, total_mapping_size(NULL, 0), 0);
	KUNIT_EXPECT_EQ(test, total_mapping_size(empty, 0), 0);
	/* Empty headers, no size. */
	KUNIT_EXPECT_EQ(test, total_mapping_size(empty, 1), 0);
	/* No PT_LOAD headers, no size. */
	KUNIT_EXPECT_EQ(test, total_mapping_size(&empty[1], 1), 0);
	/* Empty PT_LOAD and non-PT_LOAD headers, no size. */
	KUNIT_EXPECT_EQ(test, total_mapping_size(empty, 2), 0);

	/* Normal set of PT_LOADS, and expected size. */
	KUNIT_EXPECT_EQ(test, total_mapping_size(mount, ARRAY_SIZE(mount)), mount_size);
	/* Unordered PT_LOADs result in same size. */
	KUNIT_EXPECT_EQ(test, total_mapping_size(unordered, ARRAY_SIZE(unordered)), mount_size);
}

static struct kunit_case binfmt_elf_test_cases[] = {
	KUNIT_CASE(total_mapping_size_test),
	{},
};

static struct kunit_suite binfmt_elf_test_suite = {
	.name = KBUILD_MODNAME,
	.test_cases = binfmt_elf_test_cases,
};

kunit_test_suite(binfmt_elf_test_suite);
back to top