grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: "Vladimir 'phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Cc: Peter Jones <pjones@redhat.com>,
	Jan Setje-Eilers <jan.setjeeilers@oracle.com>,
	 Mate Kukri <mate.kukri@canonical.com>
Subject: Re: [PATCH 04/15] pe: add the DOS header struct and fix some bad naming.
Date: Fri, 24 May 2024 20:49:47 +0300	[thread overview]
Message-ID: <CAEaD8JOeK_i4VLQvFH8nfk6hwDcUipQNROZzcPTT2cioxvFcdw@mail.gmail.com> (raw)
In-Reply-To: <20240524110402.203880-5-mate.kukri@canonical.com>

>  struct grub_msdos_image_header
>  {
>    /* This is always 'MZ'. (GRUB_PE32_MAGIC)  */
Please adjust this

> @@ -171,6 +194,8 @@ struct grub_pe32_optional_header
>    struct grub_pe32_data_directory reserved_entry;
>  };
>
> +#define GRUB_PE32_NX_COMPAT 0x0100
> +
This was not mentioned in the description. Looks like 2 patches are conflated.

>  struct grub_pe64_optional_header
>  {
>    grub_uint16_t magic;
> @@ -236,7 +261,11 @@ struct grub_pe64_optional_header
>  struct grub_pe32_section_table
>  {
>    char name[8];
> -  grub_uint32_t virtual_size;
> +  union
> +    {
> +      grub_uint32_t physical_address;
> +      grub_uint32_t virtual_size;
> +    };
>    grub_uint32_t virtual_address;
>    grub_uint32_t raw_data_size;
>    grub_uint32_t raw_data_offset;
> @@ -247,12 +276,18 @@ struct grub_pe32_section_table
>    grub_uint32_t characteristics;
>  };
>
> +#define GRUB_PE32_SCN_TYPE_NO_PAD              0x00000008
>  #define GRUB_PE32_SCN_CNT_CODE                 0x00000020
>  #define GRUB_PE32_SCN_CNT_INITIALIZED_DATA     0x00000040
> -#define GRUB_PE32_SCN_MEM_DISCARDABLE          0x02000000
> -#define GRUB_PE32_SCN_MEM_EXECUTE              0x20000000
> -#define GRUB_PE32_SCN_MEM_READ                 0x40000000
> -#define GRUB_PE32_SCN_MEM_WRITE                        0x80000000
> +#define GRUB_PE32_SCN_CNT_UNINITIALIZED_DATA   0x00000080
> +#define GRUB_PE32_SCN_LNK_OTHER                        0x00000100
> +#define GRUB_PE32_SCN_LNK_INFO                 0x00000200
> +#define GRUB_PE32_SCN_LNK_REMOVE               0x00000800
> +#define GRUB_PE32_SCN_LNK_COMDAT               0x00001000
> +#define GRUB_PE32_SCN_GPREL                    0x00008000
> +#define GRUB_PE32_SCN_MEM_16BIT                        0x00020000
> +#define GRUB_PE32_SCN_MEM_LOCKED               0x00040000
> +#define GRUB_PE32_SCN_MEM_PRELOAD              0x00080000
>
Again, not mentioned

>  #define GRUB_PE32_SCN_ALIGN_1BYTES             0x00100000
>  #define GRUB_PE32_SCN_ALIGN_2BYTES             0x00200000
> @@ -261,11 +296,28 @@ struct grub_pe32_section_table
>  #define GRUB_PE32_SCN_ALIGN_16BYTES            0x00500000
>  #define GRUB_PE32_SCN_ALIGN_32BYTES            0x00600000
>  #define GRUB_PE32_SCN_ALIGN_64BYTES            0x00700000
> +#define GRUB_PE32_SCN_ALIGN_128BYTES           0x00800000
> +#define GRUB_PE32_SCN_ALIGN_256BYTES           0x00900000
> +#define GRUB_PE32_SCN_ALIGN_512BYTES           0x00A00000
> +#define GRUB_PE32_SCN_ALIGN_1024BYTES          0x00B00000
> +#define GRUB_PE32_SCN_ALIGN_2048BYTES          0x00C00000
> +#define GRUB_PE32_SCN_ALIGN_4096BYTES          0x00D00000
> +#define GRUB_PE32_SCN_ALIGN_8192BYTES          0x00E00000
>
>  #define GRUB_PE32_SCN_ALIGN_SHIFT              20
>  #define GRUB_PE32_SCN_ALIGN_MASK               7
>
> -#define GRUB_PE32_SIGNATURE_SIZE 4
> +#define GRUB_PE32_SCN_LNK_NRELOC_OVFL          0x01000000
> +#define GRUB_PE32_SCN_MEM_DISCARDABLE          0x02000000
> +#define GRUB_PE32_SCN_MEM_NOT_CACHED           0x04000000
> +#define GRUB_PE32_SCN_MEM_NOT_PAGED            0x08000000
> +#define GRUB_PE32_SCN_MEM_SHARED               0x10000000
> +#define GRUB_PE32_SCN_MEM_EXECUTE              0x20000000
> +#define GRUB_PE32_SCN_MEM_READ                 0x40000000
> +#define GRUB_PE32_SCN_MEM_WRITE                        0x80000000
> +
> +#define GRUB_PE32_SIGNATURE_SIZE               4
> +#define GRUB_PE32_SIGNATURE                    "PE\0\0"
>
>  #if GRUB_TARGET_SIZEOF_VOID_P == 8
>  #define GRUB_PE32_NATIVE_MAGIC                 GRUB_PE32_PE64_MAGIC
> @@ -290,6 +342,40 @@ struct grub_pe_image_header
>  #endif
>  };
>
> +struct grub_pe32_header
> +{
> +  /* This should be filled in with GRUB_PE32_MSDOS_STUB.  */
> +  grub_uint8_t msdos_stub[GRUB_PE32_MSDOS_STUB_SIZE];
> +
> +  /* This is always PE\0\0.  */
> +  char signature[GRUB_PE32_SIGNATURE_SIZE];
> +
> +  /* The COFF file header.  */
> +  struct grub_pe32_coff_header coff_header;
> +
> +#if GRUB_TARGET_SIZEOF_VOID_P == 8
> +  /* The Optional header.  */
> +  struct grub_pe64_optional_header optional_header;
> +#else
> +  /* The Optional header.  */
> +  struct grub_pe32_optional_header optional_header;
> +#endif
> +};
> +
> +struct grub_pe32_header_32
> +{
> +  char signature[GRUB_PE32_SIGNATURE_SIZE];
> +  struct grub_pe32_coff_header coff_header;
> +  struct grub_pe32_optional_header optional_header;
> +};
> +
> +struct grub_pe32_header_64
> +{
> +  char signature[GRUB_PE32_SIGNATURE_SIZE];
> +  struct grub_pe32_coff_header coff_header;
> +  struct grub_pe64_optional_header optional_header;
> +};
> +
>  struct grub_pe32_fixup_block
>  {
>    grub_uint32_t page_rva;
> --
> 2.39.2
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel



-- 
Regards
Vladimir 'phcoder' Serbinenko

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

  reply	other threads:[~2024-05-24 17:50 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-24 11:03 [PATCH 00/15] UEFI NX support and NX Linux loader using shim loader protocol Mate Kukri
2024-05-24 11:03 ` [PATCH 01/15] modules: make .module_license read-only Mate Kukri
2024-05-24 17:41   ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 02/15] modules: strip .llvm_addrsig sections and similar Mate Kukri
2024-05-24 17:42   ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 03/15] modules: Don't allocate space for non-allocable sections Mate Kukri
2024-05-24 17:45   ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 04/15] pe: add the DOS header struct and fix some bad naming Mate Kukri
2024-05-24 17:49   ` Vladimir 'phcoder' Serbinenko [this message]
2024-05-24 11:03 ` [PATCH 05/15] modules: load module sections at page-aligned addresses Mate Kukri
2024-05-24 17:57   ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 06/15] nx: add memory attribute get/set API Mate Kukri
2024-05-24 18:03   ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 07/15] nx: set page permissions for loaded modules Mate Kukri
2024-05-24 18:10   ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 08/15] nx: set the nx compatible flag in EFI grub images Mate Kukri
2024-05-24 18:11   ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 09/15] grub_dl_load_segments(): page-align the tramp/GOT areas too Mate Kukri
2024-05-24 18:15   ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 10/15] grub_dl_set_mem_attrs(): add self-check for the tramp/GOT sizes Mate Kukri
2024-05-24 18:16   ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 11/15] grub_dl_set_mem_attrs(): fix format string Mate Kukri
2024-05-24 11:03 ` [PATCH 12/15] mm: Fixup bogus assumptions about types sizes in format strings Mate Kukri
2024-05-24 11:04 ` [PATCH 13/15] efi: Provide wrappers for load_image, start_image, unload_image Mate Kukri
2024-05-24 18:27   ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:04 ` [PATCH 14/15] efi: Use shim's loader protocol for EFI image verification and loading Mate Kukri
2024-05-24 11:04 ` [PATCH 15/15] efi: Disallow fallback to legacy Linux loader when shim says NX is required Mate Kukri
2024-05-24 18:23 ` [PATCH 00/15] UEFI NX support and NX Linux loader using shim loader protocol Vladimir 'phcoder' Serbinenko
2024-05-24 19:07   ` Mate Kukri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEaD8JOeK_i4VLQvFH8nfk6hwDcUipQNROZzcPTT2cioxvFcdw@mail.gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    --cc=jan.setjeeilers@oracle.com \
    --cc=mate.kukri@canonical.com \
    --cc=pjones@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).