xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: grub-devel@gnu.org
Cc: Juergen Gross <jgross@suse.com>,
	phcoder@gmail.com, daniel.kiper@oracle.com,
	xen-devel@lists.xen.org
Subject: [PATCH 6/8] xenpvh: support building a standalone image
Date: Wed, 29 Nov 2017 14:46:48 +0100	[thread overview]
Message-ID: <20171129134650.20102-7-jgross@suse.com> (raw)
In-Reply-To: <20171129134650.20102-1-jgross@suse.com>

Suppor mkimage for xenpvh.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/grub/util/mkimage.h |  3 ++-
 util/grub-mkimage32.c       |  1 +
 util/grub-mkimage64.c       |  1 +
 util/grub-mkimagexx.c       | 44 ++++++++++++++++++++++++++++++++++++++++----
 util/mkimage.c              | 23 ++++++++++++++++++++++-
 5 files changed, 66 insertions(+), 6 deletions(-)

diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h
index b3a5ca132..3f5bc2e00 100644
--- a/include/grub/util/mkimage.h
+++ b/include/grub/util/mkimage.h
@@ -71,7 +71,8 @@ struct grub_install_image_target_desc
     IMAGE_I386_IEEE1275,
     IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH,
     IMAGE_FULOONG2F_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC,
-    IMAGE_QEMU_MIPS_FLASH, IMAGE_UBOOT, IMAGE_XEN, IMAGE_I386_PC_ELTORITO
+    IMAGE_QEMU_MIPS_FLASH, IMAGE_UBOOT, IMAGE_XEN, IMAGE_I386_PC_ELTORITO,
+    IMAGE_XENPVH
   } id;
   enum
     {
diff --git a/util/grub-mkimage32.c b/util/grub-mkimage32.c
index 9b31397bc..4253c4897 100644
--- a/util/grub-mkimage32.c
+++ b/util/grub-mkimage32.c
@@ -18,5 +18,6 @@
 # define ELF_R_TYPE(val)		ELF32_R_TYPE(val)
 # define ELF_ST_TYPE(val)		ELF32_ST_TYPE(val)
 #define XEN_NOTE_SIZE 132
+#define XENPVH_NOTE_SIZE 20
 
 #include "grub-mkimagexx.c"
diff --git a/util/grub-mkimage64.c b/util/grub-mkimage64.c
index d83345924..c862be8c0 100644
--- a/util/grub-mkimage64.c
+++ b/util/grub-mkimage64.c
@@ -18,5 +18,6 @@
 # define ELF_R_TYPE(val)		ELF64_R_TYPE(val)
 # define ELF_ST_TYPE(val)		ELF64_ST_TYPE(val)
 #define XEN_NOTE_SIZE 120
+#define XENPVH_NOTE_SIZE 24
 
 #include "grub-mkimagexx.c"
diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
index a2bb05439..a024e57b6 100644
--- a/util/grub-mkimagexx.c
+++ b/util/grub-mkimagexx.c
@@ -207,12 +207,12 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc
       phnum++;
       footer_size += sizeof (struct grub_ieee1275_note);
     }
-  if (image_target->id == IMAGE_XEN)
+  if (image_target->id == IMAGE_XEN || image_target->id == IMAGE_XENPVH)
     {
       phnum++;
       shnum++;
       string_size += sizeof (".xen");
-      footer_size += XEN_NOTE_SIZE;
+      footer_size += (image_target->id == IMAGE_XEN) ? XEN_NOTE_SIZE : XENPVH_NOTE_SIZE;
     }
   header_size = ALIGN_UP (sizeof (*ehdr) + phnum * sizeof (*phdr)
 			  + shnum * sizeof (*shdr) + string_size, layout->align);
@@ -399,6 +399,39 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc
       phdr->p_offset = grub_host_to_target32 (header_size + program_size);
     }
 
+  if (image_target->id == IMAGE_XENPVH)
+    {
+      char *note_start = (elf_img + program_size + header_size);
+      Elf_Nhdr *note_ptr;
+      char *ptr = (char *) note_start;
+
+      grub_util_info ("adding XEN NOTE segment");
+
+      /* Phys32 Entry.  */
+      note_ptr = (Elf_Nhdr *) ptr;
+      note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME));
+      note_ptr->n_descsz = grub_host_to_target32 (image_target->voidp_sizeof);
+      note_ptr->n_type = grub_host_to_target32 (18);
+      ptr += sizeof (Elf_Nhdr);
+      memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME));
+      ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4);
+      memset (ptr, 0, image_target->voidp_sizeof);
+      *(grub_uint32_t *) ptr = GRUB_KERNEL_I386_XENPVH_LINK_ADDR;
+      ptr += image_target->voidp_sizeof;
+
+      assert (XENPVH_NOTE_SIZE == (ptr - note_start));
+
+      phdr++;
+      phdr->p_type = grub_host_to_target32 (PT_NOTE);
+      phdr->p_flags = grub_host_to_target32 (PF_R);
+      phdr->p_align = grub_host_to_target32 (image_target->voidp_sizeof);
+      phdr->p_vaddr = 0;
+      phdr->p_paddr = 0;
+      phdr->p_filesz = grub_host_to_target32 (XENPVH_NOTE_SIZE);
+      phdr->p_memsz = 0;
+      phdr->p_offset = grub_host_to_target32 (header_size + program_size);
+    }
+
   if (note)
     {
       int note_size = sizeof (struct grub_ieee1275_note);
@@ -474,7 +507,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc
     shdr->sh_entsize = grub_host_to_target32 (0);
     shdr++;
 
-    if (image_target->id == IMAGE_XEN)
+    if (image_target->id == IMAGE_XEN || image_target->id == IMAGE_XENPVH)
       {
 	memcpy (ptr, ".xen", sizeof (".xen"));
 	shdr->sh_name = grub_host_to_target32 (ptr - str_start);
@@ -482,7 +515,10 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc
 	shdr->sh_type = grub_host_to_target32 (SHT_PROGBITS);
 	shdr->sh_addr = grub_host_to_target_addr (target_addr + layout->kernel_size);
 	shdr->sh_offset = grub_host_to_target_addr (program_size + header_size);
-	shdr->sh_size = grub_host_to_target32 (XEN_NOTE_SIZE);
+	if (image_target->id == IMAGE_XEN)
+	  shdr->sh_size = grub_host_to_target32 (XEN_NOTE_SIZE);
+	else
+	  shdr->sh_size = grub_host_to_target32 (XENPVH_NOTE_SIZE);
 	shdr->sh_link = grub_host_to_target32 (0);
 	shdr->sh_info = grub_host_to_target32 (0);
 	shdr->sh_addralign = grub_host_to_target32 (image_target->voidp_sizeof);
diff --git a/util/mkimage.c b/util/mkimage.c
index e22d82afa..5e071c074 100644
--- a/util/mkimage.c
+++ b/util/mkimage.c
@@ -133,6 +133,24 @@ static const struct grub_install_image_target_desc image_targets[] =
       .default_compression = GRUB_COMPRESSION_LZMA
     },
     {
+      .dirname = "i386-xenpvh",
+      .names = { "i386-xenpvh", NULL },
+      .voidp_sizeof = 4,
+      .bigendian = 0,
+      .id = IMAGE_XENPVH,
+      .flags = PLATFORM_FLAGS_NONE,
+      .total_module_size = TARGET_NO_FIELD,
+      .decompressor_compressed_size = TARGET_NO_FIELD,
+      .decompressor_uncompressed_size = TARGET_NO_FIELD,
+      .decompressor_uncompressed_addr = TARGET_NO_FIELD,
+      .elf_target = EM_386,
+      .section_align = 1,
+      .vaddr_offset = 0,
+      .link_addr = GRUB_KERNEL_I386_XENPVH_LINK_ADDR,
+      .mod_align = GRUB_KERNEL_I386_XENPVH_MOD_ALIGN,
+      .link_align = 4
+    },
+    {
       .dirname = "i386-pc",
       .names = { "i386-pc-pxe", NULL },
       .voidp_sizeof = 4,
@@ -860,7 +878,8 @@ grub_install_generate_image (const char *dir, const char *prefix,
   else
     kernel_img = grub_mkimage_load_image64 (kernel_path, total_module_size,
 					    &layout, image_target);
-  if (image_target->id == IMAGE_XEN && layout.align < 4096)
+  if ((image_target->id == IMAGE_XEN || image_target->id == IMAGE_XENPVH) &&
+      layout.align < 4096)
     layout.align = 4096;
 
   if ((image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS)
@@ -1103,6 +1122,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
     case IMAGE_MIPS_ARC:
     case IMAGE_QEMU_MIPS_FLASH:
     case IMAGE_XEN:
+    case IMAGE_XENPVH:
       break;
     case IMAGE_SPARC64_AOUT:
     case IMAGE_SPARC64_RAW:
@@ -1679,6 +1699,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
     case IMAGE_LOONGSON_ELF:
     case IMAGE_PPC:
     case IMAGE_XEN:
+    case IMAGE_XENPVH:
     case IMAGE_COREBOOT:
     case IMAGE_I386_IEEE1275:
       {
-- 
2.12.3


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2017-11-29 13:46 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20171129134650.20102-1-jgross@suse.com>
2017-11-29 13:46 ` [PATCH 1/8] xen: add some xen headers Juergen Gross
2018-02-15 11:12   ` Daniel Kiper
2017-11-29 13:46 ` [PATCH 2/8] loader/linux: support passing rsdp address via boot params Juergen Gross
2018-02-15 11:17   ` Daniel Kiper
2017-11-29 13:46 ` [PATCH 3/8] xen: carve out grant tab initialization into dedicated function Juergen Gross
2017-11-29 13:46 ` [PATCH 4/8] xen: add xen pvh guest support to grub-core Juergen Gross
2017-11-29 13:46 ` [PATCH 5/8] xenpvh: add build runes for grub-core Juergen Gross
2018-02-15 11:39   ` Daniel Kiper
2017-11-29 13:46 ` Juergen Gross [this message]
2018-02-15 11:47   ` [PATCH 6/8] xenpvh: support building a standalone image Daniel Kiper
2017-11-29 13:46 ` [PATCH 7/8] xenpvh: support grub-install for xenpvh Juergen Gross
2018-02-15 11:49   ` Daniel Kiper
2017-11-29 13:46 ` [PATCH 8/8] xenpvh: add support to configure Juergen Gross
2018-02-15 11:51   ` Daniel Kiper
2017-11-30 21:03 ` [PATCH 0/8] xen: add pvh guest support Daniel Kiper
2017-12-01  5:37   ` Juergen Gross
2017-12-01 11:12     ` Daniel Kiper
2017-12-14 11:19       ` Daniel Kiper
     [not found]       ` <20171214111952.GH4531@olila.local.net-space.pl>
2017-12-14 11:26         ` Juergen Gross
     [not found]         ` <3e5282dd-c819-5963-52a9-77bc18832ea5@suse.com>
2017-12-14 11:32           ` Daniel Kiper
     [not found]           ` <20171214113237.GJ4531@olila.local.net-space.pl>
2017-12-14 11:44             ` Juergen Gross
     [not found]             ` <f18b85e9-5bfd-8e6a-f939-46f20cf25d95@suse.com>
2018-01-29 12:15               ` Daniel Kiper
2018-01-29 13:33                 ` Juergen Gross
     [not found] ` <20171129134650.20102-4-jgross@suse.com>
2018-02-15 11:26   ` [PATCH 3/8] xen: carve out grant tab initialization into dedicated function Daniel Kiper
     [not found] ` <20171129134650.20102-5-jgross@suse.com>
2018-02-15 11:31   ` [PATCH 4/8] xen: add xen pvh guest support to grub-core Daniel Kiper
2018-02-15 12:02 ` [PATCH 0/8] xen: add pvh guest support Daniel Kiper
     [not found] ` <20180215120250.GB19041@olila.local.net-space.pl>
2018-10-09  9:35   ` Juergen Gross
     [not found]   ` <99628ba5-f300-0d0a-0484-c357b38058c7@suse.com>
2018-10-09 12:54     ` Daniel Kiper

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=20171129134650.20102-7-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=daniel.kiper@oracle.com \
    --cc=grub-devel@gnu.org \
    --cc=phcoder@gmail.com \
    --cc=xen-devel@lists.xen.org \
    /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 NNTP newsgroup(s).