diff mbox series

hvmloader: tidy pci_mem_{start,end}

Message ID 35cc5395-f88e-f08a-cbaf-5938a508ff29@suse.com (mailing list archive)
State New, archived
Headers show
Series hvmloader: tidy pci_mem_{start,end} | expand

Commit Message

Jan Beulich Dec. 14, 2021, 8:24 a.m. UTC
For one at least pci_mem_start has to be precisely 32 bits wide, so use
uint32_t for both. Otherwise expressions like "pci_mem_start <<= 1"
won't have the intended effect (in their context).

Further since its introduction pci_mem_end was never written to. Mark it
const to make this explicit.

Finally drop PCI_MEM_END: It is used just once and needlessly
disconnected from the other constant (RESERVED_MEMBASE) it needs to
match. Use RESERVED_MEMBASE as initializer of pci_mem_end instead.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Comments

Andrew Cooper Dec. 16, 2021, 11:28 a.m. UTC | #1
On 14/12/2021 08:24, Jan Beulich wrote:
> For one at least pci_mem_start has to be precisely 32 bits wide, so use
> uint32_t for both. Otherwise expressions like "pci_mem_start <<= 1"
> won't have the intended effect (in their context).
>
> Further since its introduction pci_mem_end was never written to. Mark it
> const to make this explicit.
>
> Finally drop PCI_MEM_END: It is used just once and needlessly
> disconnected from the other constant (RESERVED_MEMBASE) it needs to
> match. Use RESERVED_MEMBASE as initializer of pci_mem_end instead.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff mbox series

Patch

--- a/tools/firmware/hvmloader/config.h
+++ b/tools/firmware/hvmloader/config.h
@@ -55,12 +55,10 @@  extern uint8_t ioapic_version;
 #define PCI_ISA_DEVFN       0x08    /* dev 1, fn 0 */
 #define PCI_ISA_IRQ_MASK    0x0c20U /* ISA IRQs 5,10,11 are PCI connected */
 
-/* MMIO hole: Hardcoded defaults, which can be dynamically expanded. */
-#define PCI_MEM_END         0xfc000000
-
 #define ACPI_TIS_HDR_ADDRESS 0xFED40F00UL
 
-extern unsigned long pci_mem_start, pci_mem_end;
+extern uint32_t pci_mem_start;
+extern const uint32_t pci_mem_end;
 extern uint64_t pci_hi_mem_start, pci_hi_mem_end;
 
 extern bool acpi_enabled;
--- a/tools/firmware/hvmloader/pci.c
+++ b/tools/firmware/hvmloader/pci.c
@@ -29,8 +29,8 @@ 
 #include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/e820.h>
 
-unsigned long pci_mem_start = HVM_BELOW_4G_MMIO_START;
-unsigned long pci_mem_end = PCI_MEM_END;
+uint32_t pci_mem_start = HVM_BELOW_4G_MMIO_START;
+const uint32_t pci_mem_end = RESERVED_MEMBASE;
 uint64_t pci_hi_mem_start = 0, pci_hi_mem_end = 0;
 
 enum virtual_vga virtual_vga = VGA_none;
@@ -329,7 +329,7 @@  void pci_setup(void)
         else
         {
             pci_mem_start = max_ram_below_4g;
-            printf("pci_mem_start=0x%lx (was 0x%x) for mmio_hole_size=%lu\n",
+            printf("pci_mem_start=0x%x (was 0x%x) for mmio_hole_size=0x%lx\n",
                    pci_mem_start, HVM_BELOW_4G_MMIO_START,
                    (long)mmio_hole_size);
         }