lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250416101318.7313-1-ilpo.jarvinen@linux.intel.com>
Date: Wed, 16 Apr 2025 13:13:18 +0300
From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To: "Rafael J. Wysocki" <rafael@...nel.org>,
	Len Brown <lenb@...nel.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	Borislav Petkov <bp@...en8.de>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	x86@...nel.org,
	"H. Peter Anvin" <hpa@...or.com>,
	Bjorn Helgaas <bhelgaas@...gle.com>,
	Andy Shevchenko <andy@...nel.org>,
	linux-acpi@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	linux-pci@...r.kernel.org
Cc: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
Subject: [PATCH 1/1] x86: Use resource_set_{range,size}() helpers

Convert open coded resource size calculations to use
resource_set_{range,size}() helpers.

While at it, use SZ_* for size parameter which makes the intent of code
more obvious.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
---
 arch/x86/kernel/acpi/boot.c    | 4 ++--
 arch/x86/kernel/amd_nb.c       | 3 +--
 arch/x86/kernel/apic/apic.c    | 3 +--
 arch/x86/kernel/apic/io_apic.c | 3 +--
 arch/x86/kernel/probe_roms.c   | 3 +--
 arch/x86/pci/fixup.c           | 4 ++--
 arch/x86/pci/intel_mid_pci.c   | 2 +-
 7 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index dae6a73be40e..4490cbc01030 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -21,6 +21,7 @@
 #include <linux/pci.h>
 #include <linux/efi-bgrt.h>
 #include <linux/serial_core.h>
+#include <linux/sizes.h>
 #include <linux/pgtable.h>
 
 #include <asm/e820/api.h>
@@ -940,8 +941,7 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table)
 	snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
 		 hpet_tbl->sequence);
 
-	hpet_res->start = hpet_address;
-	hpet_res->end = hpet_address + (1 * 1024) - 1;
+	resource_set_range(hpet_res, hpet_address, SZ_1K);
 
 	return 0;
 }
diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c
index 6d12a9b69432..cba336dcb40d 100644
--- a/arch/x86/kernel/amd_nb.c
+++ b/arch/x86/kernel/amd_nb.c
@@ -164,8 +164,7 @@ struct resource *amd_get_mmconfig_range(struct resource *res)
 			 FAM10H_MMIO_CONF_BUSRANGE_MASK;
 
 	res->flags = IORESOURCE_MEM;
-	res->start = base;
-	res->end = base + (1ULL<<(segn_busn_bits + 20)) - 1;
+	resource_set_range(res, base, 1ULL << (segn_busn_bits + 20));
 	return res;
 }
 
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 62584a347931..efd3304ecbb3 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2640,8 +2640,7 @@ static int __init lapic_insert_resource(void)
 		return -1;
 
 	/* Put local APIC into the resource map. */
-	lapic_resource.start = apic_mmio_base;
-	lapic_resource.end = lapic_resource.start + PAGE_SIZE - 1;
+	resource_set_range(&lapic_resource, apic_mmio_base, PAGE_SIZE);
 	insert_resource(&iomem_resource, &lapic_resource);
 
 	return 0;
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index eebc360ed1bb..3069885d6421 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -2571,8 +2571,7 @@ void __init io_apic_init_mappings(void)
 				__fix_to_virt(idx) + (ioapic_phys & ~PAGE_MASK), ioapic_phys);
 		idx++;
 
-		ioapic_res->start = ioapic_phys;
-		ioapic_res->end = ioapic_phys + IO_APIC_SLOT_SIZE - 1;
+		resource_set_range(ioapic_res, ioapic_phys, IO_APIC_SLOT_SIZE);
 		ioapic_res++;
 	}
 }
diff --git a/arch/x86/kernel/probe_roms.c b/arch/x86/kernel/probe_roms.c
index cc2c34ba7228..44da85e50c44 100644
--- a/arch/x86/kernel/probe_roms.c
+++ b/arch/x86/kernel/probe_roms.c
@@ -260,8 +260,7 @@ void __init probe_roms(void)
 		if (!length || start + length > upper || !romchecksum(rom, length))
 			continue;
 
-		adapter_rom_resources[i].start = start;
-		adapter_rom_resources[i].end = start + length - 1;
+		resource_set_range(&adapter_rom_resources[i], start, length);
 		request_resource(&iomem_resource, &adapter_rom_resources[i]);
 
 		start = adapter_rom_resources[i++].end & ~2047UL;
diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c
index efefeb82ab61..94e98e3bf041 100644
--- a/arch/x86/pci/fixup.c
+++ b/arch/x86/pci/fixup.c
@@ -7,6 +7,7 @@
 #include <linux/delay.h>
 #include <linux/dmi.h>
 #include <linux/pci.h>
+#include <linux/sizes.h>
 #include <linux/suspend.h>
 #include <linux/vgaarb.h>
 #include <asm/amd_node.h>
@@ -347,8 +348,7 @@ static void pci_fixup_video(struct pci_dev *pdev)
 			if (res->parent)
 				release_resource(res);
 
-			res->start = 0xC0000;
-			res->end = res->start + 0x20000 - 1;
+			resource_set_range(res, 0xC0000, SZ_128K);
 			res->flags = IORESOURCE_MEM | IORESOURCE_ROM_SHADOW |
 				     IORESOURCE_PCI_FIXED;
 			dev_info(&pdev->dev, "Video device with shadowed ROM at %pR\n",
diff --git a/arch/x86/pci/intel_mid_pci.c b/arch/x86/pci/intel_mid_pci.c
index b433b1753016..5e047e802d5d 100644
--- a/arch/x86/pci/intel_mid_pci.c
+++ b/arch/x86/pci/intel_mid_pci.c
@@ -399,7 +399,7 @@ static void pci_fixed_bar_fixup(struct pci_dev *dev)
 
 	for (i = 0; i < PCI_STD_NUM_BARS; i++) {
 		pci_read_config_dword(dev, offset + 8 + (i * 4), &size);
-		dev->resource[i].end = dev->resource[i].start + size - 1;
+		resource_set_size(&dev->resource[i], size);
 		dev->resource[i].flags |= IORESOURCE_PCI_FIXED;
 	}
 }
-- 
2.39.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ