grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v4 4/6] i386/memory: Rename PAGE_SHIFT to GRUB_PAGE_SHIFT


From: Sergii Dmytruk
Subject: [PATCH v4 4/6] i386/memory: Rename PAGE_SHIFT to GRUB_PAGE_SHIFT
Date: Sun, 6 Oct 2024 17:14:45 +0300

From: Daniel Kiper <daniel.kiper@oracle.com>

This fixes naming inconsistency that goes against coding style as well
as helps to avoid potential conflicts and confusion as this constant is
used in multiple places.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 grub-core/lib/i386/xen/relocator.S   |  6 +++---
 grub-core/lib/x86_64/xen/relocator.S |  4 ++--
 grub-core/loader/i386/xen.c          | 28 ++++++++++++++--------------
 include/grub/i386/memory.h           |  2 +-
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/grub-core/lib/i386/xen/relocator.S 
b/grub-core/lib/i386/xen/relocator.S
index 96e51b59a..dab4d8ace 100644
--- a/grub-core/lib/i386/xen/relocator.S
+++ b/grub-core/lib/i386/xen/relocator.S
@@ -75,10 +75,10 @@ VARIABLE(grub_relocator_xen_mfn_list)
        .long   0
        movl    0(%eax, %ebp, 4), %ecx  /* mfn */
        movl    %ebp, %ebx
-       shll    $PAGE_SHIFT, %ebx       /* virtual address (1:1 mapping) */
+       shll    $GRUB_PAGE_SHIFT, %ebx  /* virtual address (1:1 mapping) */
        movl    %ecx, %edx
-       shll    $PAGE_SHIFT,  %ecx      /* prepare pte low part */
-       shrl    $(32 - PAGE_SHIFT),  %edx       /* pte high part */
+       shll    $GRUB_PAGE_SHIFT,  %ecx /* prepare pte low part */
+       shrl    $(32 - GRUB_PAGE_SHIFT),  %edx  /* pte high part */
        orl     $(GRUB_PAGE_PRESENT | GRUB_PAGE_USER), %ecx     /* pte low */
        movl    $UVMF_INVLPG, %esi
        movl    $__HYPERVISOR_update_va_mapping, %eax
diff --git a/grub-core/lib/x86_64/xen/relocator.S 
b/grub-core/lib/x86_64/xen/relocator.S
index f5364ed0f..852cd40aa 100644
--- a/grub-core/lib/x86_64/xen/relocator.S
+++ b/grub-core/lib/x86_64/xen/relocator.S
@@ -60,9 +60,9 @@ LOCAL(cont):
        jz      3f
 2:
        movq    %r12, %rdi
-       shlq    $PAGE_SHIFT, %rdi       /* virtual address (1:1 mapping) */
+       shlq    $GRUB_PAGE_SHIFT, %rdi  /* virtual address (1:1 mapping) */
        movq    (%rbx, %r12, 8), %rsi   /* mfn */
-       shlq    $PAGE_SHIFT,  %rsi
+       shlq    $GRUB_PAGE_SHIFT,  %rsi
        orq     $(GRUB_PAGE_PRESENT | GRUB_PAGE_USER), %rsi     /* Build pte */
        movq    $UVMF_INVLPG, %rdx
        movq    %rcx, %r9       /* %rcx clobbered by hypercall */
diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c
index 3b856e842..520367732 100644
--- a/grub-core/loader/i386/xen.c
+++ b/grub-core/loader/i386/xen.c
@@ -92,7 +92,7 @@ static struct xen_loader_state xen_state;
 
 static grub_dl_t my_mod;
 
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
+#define PAGE_SIZE (1UL << GRUB_PAGE_SHIFT)
 #define MAX_MODULES (PAGE_SIZE / sizeof (struct xen_multiboot_mod_list))
 #define STACK_SIZE 1048576
 #define ADDITIONAL_SIZE (1 << 19)
@@ -103,7 +103,7 @@ static grub_dl_t my_mod;
 static grub_uint64_t
 page2offset (grub_uint64_t page)
 {
-  return page << PAGE_SHIFT;
+  return page << GRUB_PAGE_SHIFT;
 }
 
 static grub_err_t
@@ -142,7 +142,7 @@ get_pgtable_size (grub_uint64_t from, grub_uint64_t to, 
grub_uint64_t pfn)
          continue;
        }
 
-      bits = PAGE_SHIFT + (i + 1) * LOG_POINTERS_PER_PAGE;
+      bits = GRUB_PAGE_SHIFT + (i + 1) * LOG_POINTERS_PER_PAGE;
       mask = (1ULL << bits) - 1;
       map->lvls[i].virt_start = map->area.virt_start & ~mask;
       map->lvls[i].virt_end = map->area.virt_end | mask;
@@ -247,11 +247,11 @@ generate_page_table (grub_xen_mfn_t *mfn_list)
              if (lvl->virt_start >= end || lvl->virt_end <= start)
                continue;
              p_s = (grub_max (start, lvl->virt_start) - start) >>
-                   (PAGE_SHIFT + l * LOG_POINTERS_PER_PAGE);
+                   (GRUB_PAGE_SHIFT + l * LOG_POINTERS_PER_PAGE);
              p_e = (grub_min (end, lvl->virt_end) - start) >>
-                   (PAGE_SHIFT + l * LOG_POINTERS_PER_PAGE);
+                   (GRUB_PAGE_SHIFT + l * LOG_POINTERS_PER_PAGE);
              pfn = ((grub_max (start, lvl->virt_start) - lvl->virt_start) >>
-                    (PAGE_SHIFT + l * LOG_POINTERS_PER_PAGE)) + lvl->pfn_start;
+                    (GRUB_PAGE_SHIFT + l * LOG_POINTERS_PER_PAGE)) + 
lvl->pfn_start;
              grub_dprintf ("xen", "write page table entries level %d pg %p "
                            "mapping %d/%d index %lx-%lx pfn %llx\n",
                            l, pg, m1, m2, p_s, p_e, (unsigned long long) pfn);
@@ -329,16 +329,16 @@ grub_xen_p2m_alloc (void)
     {
       err = get_pgtable_size (xen_state.xen_inf.p2m_base,
                              xen_state.xen_inf.p2m_base + p2msize,
-                             (xen_state.max_addr + p2msize) >> PAGE_SHIFT);
+                             (xen_state.max_addr + p2msize) >> 
GRUB_PAGE_SHIFT);
       if (err)
        return err;
 
-      map->area.pfn_start = xen_state.max_addr >> PAGE_SHIFT;
+      map->area.pfn_start = xen_state.max_addr >> GRUB_PAGE_SHIFT;
       p2malloc = p2msize + page2offset (map->area.n_pt_pages);
       xen_state.n_mappings++;
       xen_state.next_start.mfn_list = xen_state.xen_inf.p2m_base;
       xen_state.next_start.first_p2m_pfn = map->area.pfn_start;
-      xen_state.next_start.nr_p2m_frames = p2malloc >> PAGE_SHIFT;
+      xen_state.next_start.nr_p2m_frames = p2malloc >> GRUB_PAGE_SHIFT;
     }
   else
     {
@@ -381,7 +381,7 @@ grub_xen_special_alloc (void)
   xen_state.virt_start_info = get_virtual_current_address (ch);
   xen_state.max_addr =
     ALIGN_UP (xen_state.max_addr + sizeof (xen_state.next_start), PAGE_SIZE);
-  xen_state.console_pfn = xen_state.max_addr >> PAGE_SHIFT;
+  xen_state.console_pfn = xen_state.max_addr >> GRUB_PAGE_SHIFT;
   xen_state.max_addr += 2 * PAGE_SIZE;
 
   xen_state.next_start.nr_pages = grub_xen_start_page_addr->nr_pages;
@@ -413,7 +413,7 @@ grub_xen_pt_alloc (void)
 
   xen_state.next_start.pt_base =
     xen_state.max_addr + xen_state.xen_inf.virt_base;
-  nr_info_pages = xen_state.max_addr >> PAGE_SHIFT;
+  nr_info_pages = xen_state.max_addr >> GRUB_PAGE_SHIFT;
   nr_need_pages = nr_info_pages;
 
   while (1)
@@ -461,7 +461,7 @@ grub_xen_pt_alloc (void)
     xen_state.max_addr + STACK_SIZE + xen_state.xen_inf.virt_base;
   xen_state.next_start.nr_pt_frames = nr_need_pages;
   xen_state.max_addr = try_virt_end - xen_state.xen_inf.virt_base;
-  xen_state.pgtbl_end = xen_state.max_addr >> PAGE_SHIFT;
+  xen_state.pgtbl_end = xen_state.max_addr >> GRUB_PAGE_SHIFT;
   xen_state.map_reloc->where = (grub_uint64_t *) ((char *) map->where +
                                        page2offset (map->area.n_pt_pages));
 
@@ -515,7 +515,7 @@ grub_xen_boot (void)
   if (err)
     return err;
 
-  nr_pages = xen_state.max_addr >> PAGE_SHIFT;
+  nr_pages = xen_state.max_addr >> GRUB_PAGE_SHIFT;
 
   grub_dprintf ("xen", "bootstrap domain %llx+%llx\n",
                (unsigned long long) xen_state.xen_inf.virt_base,
@@ -818,7 +818,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ 
((unused)),
   if (xen_state.xen_inf.unmapped_initrd)
     {
       xen_state.next_start.flags |= SIF_MOD_START_PFN;
-      xen_state.next_start.mod_start = xen_state.max_addr >> PAGE_SHIFT;
+      xen_state.next_start.mod_start = xen_state.max_addr >> GRUB_PAGE_SHIFT;
     }
   else
     xen_state.next_start.mod_start =
diff --git a/include/grub/i386/memory.h b/include/grub/i386/memory.h
index 5cb607fb4..7be57d6d7 100644
--- a/include/grub/i386/memory.h
+++ b/include/grub/i386/memory.h
@@ -20,7 +20,7 @@
 #ifndef GRUB_MEMORY_CPU_HEADER
 #define GRUB_MEMORY_CPU_HEADER 1
 
-#define PAGE_SHIFT             12
+#define GRUB_PAGE_SHIFT                12
 
 /* The flag for protected mode.  */
 #define GRUB_MEMORY_CPU_CR0_PE_ON              0x1
-- 
2.46.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]