diff mbox series

[v2,01/14] arm64/efi: move EFI_PAGE definitions to efi/memory.h

Message ID 20170803100432.29913-2-leif.lindholm@linaro.org
State New
Headers show
Series efi: improved correctness, arm unification, and cleanup | expand

Commit Message

Leif Lindholm Aug. 3, 2017, 10:04 a.m. UTC
The EFI page definitions and macros are generic and should not be confined
to atm64 headers - so move to efi/memory.h.
Also add EFI_PAGE_SIZE macro.

Update loader sources to reflect new header location.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

---
 grub-core/loader/arm64/fdt.c      | 1 +
 grub-core/loader/arm64/linux.c    | 1 +
 grub-core/loader/arm64/xen_boot.c | 1 +
 include/grub/arm64/fdtload.h      | 3 ---
 include/grub/efi/memory.h         | 4 ++++
 5 files changed, 7 insertions(+), 3 deletions(-)

-- 
2.11.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Comments

Vladimir 'phcoder' Serbinenko Aug. 3, 2017, 3:18 p.m. UTC | #1
This assumes that all CPUs supporting EFI have 4K pages. What if some of
CPUs have other page sizes?

Le Thu, Aug 3, 2017 à 12:07 PM, Leif Lindholm <leif.lindholm@linaro.org> a
écrit :

> The EFI page definitions and macros are generic and should not be confined

> to atm64 headers - so move to efi/memory.h.

> Also add EFI_PAGE_SIZE macro.

>

> Update loader sources to reflect new header location.

>

> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

> ---

>  grub-core/loader/arm64/fdt.c      | 1 +

>  grub-core/loader/arm64/linux.c    | 1 +

>  grub-core/loader/arm64/xen_boot.c | 1 +

>  include/grub/arm64/fdtload.h      | 3 ---

>  include/grub/efi/memory.h         | 4 ++++

>  5 files changed, 7 insertions(+), 3 deletions(-)

>

> diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/arm64/fdt.c

> index db49cf649..bdc3a0c1f 100644

> --- a/grub-core/loader/arm64/fdt.c

> +++ b/grub-core/loader/arm64/fdt.c

> @@ -24,6 +24,7 @@

>  #include <grub/command.h>

>  #include <grub/file.h>

>  #include <grub/efi/efi.h>

> +#include <grub/efi/memory.h>

>

>  static void *loaded_fdt;

>  static void *fdt;

> diff --git a/grub-core/loader/arm64/linux.c

> b/grub-core/loader/arm64/linux.c

> index 9519d2e4d..1960d18b5 100644

> --- a/grub-core/loader/arm64/linux.c

> +++ b/grub-core/loader/arm64/linux.c

> @@ -28,6 +28,7 @@

>  #include <grub/cpu/linux.h>

>  #include <grub/cpu/fdtload.h>

>  #include <grub/efi/efi.h>

> +#include <grub/efi/memory.h>

>  #include <grub/efi/pe32.h>

>  #include <grub/i18n.h>

>  #include <grub/lib/cmdline.h>

> diff --git a/grub-core/loader/arm64/xen_boot.c

> b/grub-core/loader/arm64/xen_boot.c

> index 27ede46ca..b7a5b17c9 100644

> --- a/grub-core/loader/arm64/xen_boot.c

> +++ b/grub-core/loader/arm64/xen_boot.c

> @@ -30,6 +30,7 @@

>  #include <grub/cpu/fdtload.h>

>  #include <grub/cpu/linux.h>

>  #include <grub/efi/efi.h>

> +#include <grub/efi/memory.h>

>  #include <grub/efi/pe32.h>     /* required by struct

> xen_hypervisor_header */

>  #include <grub/i18n.h>

>  #include <grub/lib/cmdline.h>

> diff --git a/include/grub/arm64/fdtload.h b/include/grub/arm64/fdtload.h

> index 7b9ddba91..713c9424d 100644

> --- a/include/grub/arm64/fdtload.h

> +++ b/include/grub/arm64/fdtload.h

> @@ -29,7 +29,4 @@ grub_fdt_unload (void);

>  grub_err_t

>  grub_fdt_install (void);

>

> -#define GRUB_EFI_PAGE_SHIFT    12

> -#define GRUB_EFI_BYTES_TO_PAGES(bytes)   (((bytes) + 0xfff) >>

> GRUB_EFI_PAGE_SHIFT)

> -

>  #endif

> diff --git a/include/grub/efi/memory.h b/include/grub/efi/memory.h

> index 20526b146..a113348ca 100644

> --- a/include/grub/efi/memory.h

> +++ b/include/grub/efi/memory.h

> @@ -22,6 +22,10 @@

>  #include <grub/err.h>

>  #include <grub/types.h>

>

> +#define GRUB_EFI_PAGE_SHIFT             12

> +#define GRUB_EFI_PAGE_SIZE              (1 << GRUB_EFI_PAGE_SHIFT)

> +#define GRUB_EFI_BYTES_TO_PAGES(bytes)  (((bytes) + 0xfff) >>

> GRUB_EFI_PAGE_SHIFT)

> +

>  #define GRUB_MMAP_REGISTER_BY_FIRMWARE  1

>

>  grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t

> size,

> --

> 2.11.0

>

>

> _______________________________________________

> Grub-devel mailing list

> Grub-devel@gnu.org

> https://lists.gnu.org/mailman/listinfo/grub-devel

>
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
Leif Lindholm Aug. 4, 2017, 9:11 a.m. UTC | #2
On Thu, Aug 03, 2017 at 03:18:00PM +0000, Vladimir 'phcoder' Serbinenko wrote:
> This assumes that all CPUs supporting EFI have 4K pages. What if some of

> CPUs have other page sizes?


No, but now you mention it, that used to confuse me too (which is why
I put it in an architecture-specific header originally).

UEFI does not take translation mechanisms into account; a page is
simply an allocation unit - 4kB in size and aligned to 4kB.

I should add a comment explaining this to efi/memory.h.

/
    Leif

> Le Thu, Aug 3, 2017 à 12:07 PM, Leif Lindholm <leif.lindholm@linaro.org> a

> écrit :

> 

> > The EFI page definitions and macros are generic and should not be confined

> > to atm64 headers - so move to efi/memory.h.

> > Also add EFI_PAGE_SIZE macro.

> >

> > Update loader sources to reflect new header location.

> >

> > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

> > ---

> >  grub-core/loader/arm64/fdt.c      | 1 +

> >  grub-core/loader/arm64/linux.c    | 1 +

> >  grub-core/loader/arm64/xen_boot.c | 1 +

> >  include/grub/arm64/fdtload.h      | 3 ---

> >  include/grub/efi/memory.h         | 4 ++++

> >  5 files changed, 7 insertions(+), 3 deletions(-)

> >

> > diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/arm64/fdt.c

> > index db49cf649..bdc3a0c1f 100644

> > --- a/grub-core/loader/arm64/fdt.c

> > +++ b/grub-core/loader/arm64/fdt.c

> > @@ -24,6 +24,7 @@

> >  #include <grub/command.h>

> >  #include <grub/file.h>

> >  #include <grub/efi/efi.h>

> > +#include <grub/efi/memory.h>

> >

> >  static void *loaded_fdt;

> >  static void *fdt;

> > diff --git a/grub-core/loader/arm64/linux.c

> > b/grub-core/loader/arm64/linux.c

> > index 9519d2e4d..1960d18b5 100644

> > --- a/grub-core/loader/arm64/linux.c

> > +++ b/grub-core/loader/arm64/linux.c

> > @@ -28,6 +28,7 @@

> >  #include <grub/cpu/linux.h>

> >  #include <grub/cpu/fdtload.h>

> >  #include <grub/efi/efi.h>

> > +#include <grub/efi/memory.h>

> >  #include <grub/efi/pe32.h>

> >  #include <grub/i18n.h>

> >  #include <grub/lib/cmdline.h>

> > diff --git a/grub-core/loader/arm64/xen_boot.c

> > b/grub-core/loader/arm64/xen_boot.c

> > index 27ede46ca..b7a5b17c9 100644

> > --- a/grub-core/loader/arm64/xen_boot.c

> > +++ b/grub-core/loader/arm64/xen_boot.c

> > @@ -30,6 +30,7 @@

> >  #include <grub/cpu/fdtload.h>

> >  #include <grub/cpu/linux.h>

> >  #include <grub/efi/efi.h>

> > +#include <grub/efi/memory.h>

> >  #include <grub/efi/pe32.h>     /* required by struct

> > xen_hypervisor_header */

> >  #include <grub/i18n.h>

> >  #include <grub/lib/cmdline.h>

> > diff --git a/include/grub/arm64/fdtload.h b/include/grub/arm64/fdtload.h

> > index 7b9ddba91..713c9424d 100644

> > --- a/include/grub/arm64/fdtload.h

> > +++ b/include/grub/arm64/fdtload.h

> > @@ -29,7 +29,4 @@ grub_fdt_unload (void);

> >  grub_err_t

> >  grub_fdt_install (void);

> >

> > -#define GRUB_EFI_PAGE_SHIFT    12

> > -#define GRUB_EFI_BYTES_TO_PAGES(bytes)   (((bytes) + 0xfff) >>

> > GRUB_EFI_PAGE_SHIFT)

> > -

> >  #endif

> > diff --git a/include/grub/efi/memory.h b/include/grub/efi/memory.h

> > index 20526b146..a113348ca 100644

> > --- a/include/grub/efi/memory.h

> > +++ b/include/grub/efi/memory.h

> > @@ -22,6 +22,10 @@

> >  #include <grub/err.h>

> >  #include <grub/types.h>

> >

> > +#define GRUB_EFI_PAGE_SHIFT             12

> > +#define GRUB_EFI_PAGE_SIZE              (1 << GRUB_EFI_PAGE_SHIFT)

> > +#define GRUB_EFI_BYTES_TO_PAGES(bytes)  (((bytes) + 0xfff) >>

> > GRUB_EFI_PAGE_SHIFT)

> > +

> >  #define GRUB_MMAP_REGISTER_BY_FIRMWARE  1

> >

> >  grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t

> > size,

> > --

> > 2.11.0

> >

> >

> > _______________________________________________

> > Grub-devel mailing list

> > Grub-devel@gnu.org

> > https://lists.gnu.org/mailman/listinfo/grub-devel

> >


> _______________________________________________

> Grub-devel mailing list

> Grub-devel@gnu.org

> https://lists.gnu.org/mailman/listinfo/grub-devel



_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
diff mbox series

Patch

diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/arm64/fdt.c
index db49cf649..bdc3a0c1f 100644
--- a/grub-core/loader/arm64/fdt.c
+++ b/grub-core/loader/arm64/fdt.c
@@ -24,6 +24,7 @@ 
 #include <grub/command.h>
 #include <grub/file.h>
 #include <grub/efi/efi.h>
+#include <grub/efi/memory.h>
 
 static void *loaded_fdt;
 static void *fdt;
diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
index 9519d2e4d..1960d18b5 100644
--- a/grub-core/loader/arm64/linux.c
+++ b/grub-core/loader/arm64/linux.c
@@ -28,6 +28,7 @@ 
 #include <grub/cpu/linux.h>
 #include <grub/cpu/fdtload.h>
 #include <grub/efi/efi.h>
+#include <grub/efi/memory.h>
 #include <grub/efi/pe32.h>
 #include <grub/i18n.h>
 #include <grub/lib/cmdline.h>
diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c
index 27ede46ca..b7a5b17c9 100644
--- a/grub-core/loader/arm64/xen_boot.c
+++ b/grub-core/loader/arm64/xen_boot.c
@@ -30,6 +30,7 @@ 
 #include <grub/cpu/fdtload.h>
 #include <grub/cpu/linux.h>
 #include <grub/efi/efi.h>
+#include <grub/efi/memory.h>
 #include <grub/efi/pe32.h>	/* required by struct xen_hypervisor_header */
 #include <grub/i18n.h>
 #include <grub/lib/cmdline.h>
diff --git a/include/grub/arm64/fdtload.h b/include/grub/arm64/fdtload.h
index 7b9ddba91..713c9424d 100644
--- a/include/grub/arm64/fdtload.h
+++ b/include/grub/arm64/fdtload.h
@@ -29,7 +29,4 @@  grub_fdt_unload (void);
 grub_err_t
 grub_fdt_install (void);
 
-#define GRUB_EFI_PAGE_SHIFT	12
-#define GRUB_EFI_BYTES_TO_PAGES(bytes)   (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT)
-
 #endif
diff --git a/include/grub/efi/memory.h b/include/grub/efi/memory.h
index 20526b146..a113348ca 100644
--- a/include/grub/efi/memory.h
+++ b/include/grub/efi/memory.h
@@ -22,6 +22,10 @@ 
 #include <grub/err.h>
 #include <grub/types.h>
 
+#define GRUB_EFI_PAGE_SHIFT             12
+#define GRUB_EFI_PAGE_SIZE              (1 << GRUB_EFI_PAGE_SHIFT)
+#define GRUB_EFI_BYTES_TO_PAGES(bytes)  (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT)
+
 #define GRUB_MMAP_REGISTER_BY_FIRMWARE  1
 
 grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size,