]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[riscv] Use 1GB pages for I/O device mappings
authorMichael Brown <mcb30@ipxe.org>
Fri, 11 Jul 2025 10:30:57 +0000 (11:30 +0100)
committerMichael Brown <mcb30@ipxe.org>
Fri, 11 Jul 2025 11:05:52 +0000 (12:05 +0100)
All 64-bit paging schemes support at least 1GB "gigapages".  Use these
to map I/O devices instead of 2MB "megapages".  This reduces the
number of consumed page table entries, increases the visual similarity
of I/O remapped addresses to the underlying physical addresses, and
opens up the possibility of reusing the code to create the coherent
DMA map of the 32-bit address space.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/riscv/core/svpage.c

index 380f3df8b374ab076fae230ff1caee3a2aa0485d..2240b3736440d3d65aea7f7549e6742436228ff1 100644 (file)
@@ -35,10 +35,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  * With the 64-bit paging schemes (Sv39, Sv48, and Sv57) we choose to
  * identity-map as much as possible of the physical address space via
  * PTEs 0-255, and place a recursive page table entry in PTE 511 which
- * allows PTEs 256-510 to be used to map 2MB "megapages" within the
- * top 512MB of the 64-bit address space.  At least one of these 2MB
- * PTEs will already be in use to map iPXE itself.  The remaining PTEs
- * may be used to map I/O devices.
+ * allows PTEs 256-510 to be used to map 1GB "gigapages" within the
+ * top 256GB of the 64-bit address space.  At least one of these PTEs
+ * will already be in use to map iPXE itself.  The remaining PTEs may
+ * be used to map I/O devices.
  */
 
 /** A page table */
@@ -75,17 +75,17 @@ extern struct page_table page_table;
 
 /** I/O page size
  *
- * We choose to use 2MB "megapages", since these are supported by all
+ * We choose to use 1GB "gigapages", since these are supported by all
  * paging levels.
  */
-#define IO_PAGE_SIZE 0x200000UL
+#define IO_PAGE_SIZE 0x40000000UL
 
 /** I/O page base address
  *
- * The recursive page table entry maps the high 1024MB of the 64-bit
- * address space as 2MB "megapages".
+ * The recursive page table entry maps the high 512GB of the 64-bit
+ * address space as 1GB "gigapages".
  */
-#define IO_BASE ( ( void * ) ( intptr_t ) ( -1024 * 1024 * 1024 ) )
+#define IO_BASE ( ( void * ) ( intptr_t ) ( -1ULL << 39 ) )
 
 /**
  * Map pages for I/O