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

[Xen-devel] [PATCH] cleanup domain builder declarations and related users



There are several unused function and structure declarations in the
hypervisor related to domain building. Remove them.

Use an enum for elf_dom_parms.pae instead of just hard coding the
values when setting the information and adjust the code to use those
instead of own macros (hypervisor and tools).

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
This is the merge of patches 1-3 of my former series "various cleanups"
as requested by Jan. It contains additional cleanups as further
suggested by Jan.

Patch 4 of this series has already been applied and patch 5 will be
done on it's own as Jan's comment suggests it will no longer be a
pure cleanup topic.
---
 tools/libxc/xc_dom_binloader.c     |  2 +-
 tools/libxc/xc_dom_elfloader.c     |  8 ++++----
 tools/libxc/xc_dom_x86.c           |  6 +++---
 tools/libxc/xg_private.h           |  6 ------
 xen/arch/x86/domain_build.c        |  6 +++---
 xen/common/libelf/libelf-dominfo.c |  8 ++++----
 xen/include/xen/elf.h              | 21 ---------------------
 xen/include/xen/libelf.h           |  9 ++++++++-
 xen/include/xen/sched.h            | 23 -----------------------
 9 files changed, 23 insertions(+), 66 deletions(-)

diff --git a/tools/libxc/xc_dom_binloader.c b/tools/libxc/xc_dom_binloader.c
index 740601a..d6f7f2a 100644
--- a/tools/libxc/xc_dom_binloader.c
+++ b/tools/libxc/xc_dom_binloader.c
@@ -238,7 +238,7 @@ static int xc_dom_parse_bin_kernel(struct xc_dom_image *dom)
         {
             DOMPRINTF("%s: PAE fixup", __FUNCTION__);
             dom->guest_type = "xen-3.0-x86_32p";
-            dom->parms.pae  = 2;
+            dom->parms.pae  = XEN_PAE_EXTCR3;
         }
         break;
     }
diff --git a/tools/libxc/xc_dom_elfloader.c b/tools/libxc/xc_dom_elfloader.c
index 66ea9d6..82524c9 100644
--- a/tools/libxc/xc_dom_elfloader.c
+++ b/tools/libxc/xc_dom_elfloader.c
@@ -61,14 +61,14 @@ static char *xc_dom_guest_type(struct xc_dom_image *dom,
     case EM_386:
         switch ( dom->parms.pae )
         {
-        case 3 /* PAEKERN_bimodal */:
+        case XEN_PAE_BIMODAL:
             if ( strstr(dom->xen_caps, "xen-3.0-x86_32p") )
                 return "xen-3.0-x86_32p";
             return "xen-3.0-x86_32";
-        case PAEKERN_extended_cr3:
-        case PAEKERN_yes:
+        case XEN_PAE_EXTCR3:
+        case XEN_PAE_YES:
             return "xen-3.0-x86_32p";
-        case PAEKERN_no:
+        case XEN_PAE_NO:
         default:
             return "xen-3.0-x86_32";
         }
diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
index 05fb0ce..e2f3792 100644
--- a/tools/libxc/xc_dom_x86.c
+++ b/tools/libxc/xc_dom_x86.c
@@ -249,7 +249,7 @@ static int setup_pgtables_x86_32_pae(struct xc_dom_image 
*dom)
     xen_pfn_t pgpfn;
     xen_pfn_t l3mfn = xc_dom_p2m_guest(dom, l3pfn);
 
-    if ( dom->parms.pae == 1 )
+    if ( dom->parms.pae == XEN_PAE_YES )
     {
         if ( l3mfn >= 0x100000 )
             l3mfn = move_l3_below_4G(dom, l3pfn, l3mfn);
@@ -602,8 +602,8 @@ static int vcpu_x86_32(struct xc_dom_image *dom, void *ptr)
     ctxt->user_regs.eflags = 1 << 9; /* Interrupt Enable */
 
     ctxt->flags = VGCF_in_kernel_X86_32 | VGCF_online_X86_32;
-    if ( dom->parms.pae == 2 /* extended_cr3 */ ||
-         dom->parms.pae == 3 /* bimodal */ )
+    if ( dom->parms.pae == XEN_PAE_EXTCR3 ||
+         dom->parms.pae == XEN_PAE_BIMODAL )
         ctxt->vm_assist |= (1UL << VMASST_TYPE_pae_extended_cr3);
 
     cr3_pfn = xc_dom_p2m_guest(dom, dom->pgtables_seg.pfn);
diff --git a/tools/libxc/xg_private.h b/tools/libxc/xg_private.h
index 07eeb67..5544897 100644
--- a/tools/libxc/xg_private.h
+++ b/tools/libxc/xg_private.h
@@ -165,12 +165,6 @@ static inline xen_pfn_t xc_pfn_to_mfn(xen_pfn_t pfn, 
xen_pfn_t *p2m,
 #define MFN_MASK_X86    ((1ULL << (MADDR_BITS_X86 - PAGE_SHIFT_X86)) - 1)
 #define MADDR_MASK_X86  (MFN_MASK_X86 << PAGE_SHIFT_X86)
 
-
-#define PAEKERN_no           0
-#define PAEKERN_yes          1
-#define PAEKERN_extended_cr3 2
-#define PAEKERN_bimodal      3
-
 int pin_table(xc_interface *xch, unsigned int type, unsigned long mfn,
               domid_t dom);
 
diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c
index 18cf6aa..cd27864 100644
--- a/xen/arch/x86/domain_build.c
+++ b/xen/arch/x86/domain_build.c
@@ -953,8 +953,8 @@ int __init construct_dom0(
     compat32   = 0;
     machine = elf_uval(&elf, elf.ehdr, e_machine);
     printk(" Xen  kernel: 64-bit, lsb, compat32\n");
-    if (elf_32bit(&elf) && parms.pae == PAEKERN_bimodal)
-        parms.pae = PAEKERN_extended_cr3;
+    if (elf_32bit(&elf) && parms.pae == XEN_PAE_BIMODAL)
+        parms.pae = XEN_PAE_EXTCR3;
     if (elf_32bit(&elf) && parms.pae && machine == EM_386)
     {
         compat32 = 1;
@@ -1005,7 +1005,7 @@ int __init construct_dom0(
 
     nr_pages = compute_dom0_nr_pages(d, &parms, initrd_len);
 
-    if ( parms.pae == PAEKERN_extended_cr3 )
+    if ( parms.pae == XEN_PAE_EXTCR3 )
             set_bit(VMASST_TYPE_pae_extended_cr3, &d->vm_assist);
 
     if ( (parms.virt_hv_start_low != UNSET_ADDR) && elf_32bit(&elf) )
diff --git a/xen/common/libelf/libelf-dominfo.c 
b/xen/common/libelf/libelf-dominfo.c
index f929968..3de1c23 100644
--- a/xen/common/libelf/libelf-dominfo.c
+++ b/xen/common/libelf/libelf-dominfo.c
@@ -172,9 +172,9 @@ elf_errorstatus elf_xen_parse_note(struct elf_binary *elf,
         break;
     case XEN_ELFNOTE_PAE_MODE:
         if ( !strcmp(str, "yes") )
-            parms->pae = 2 /* extended_cr3 */;
+            parms->pae = XEN_PAE_EXTCR3;
         if ( strstr(str, "bimodal") )
-            parms->pae = 3 /* bimodal */;
+            parms->pae = XEN_PAE_BIMODAL;
         break;
     case XEN_ELFNOTE_BSD_SYMTAB:
         if ( !strcmp(str, "yes") )
@@ -317,9 +317,9 @@ elf_errorstatus elf_xen_parse_guest_info(struct elf_binary 
*elf,
         if ( !strcmp(name, "PAE") )
         {
             if ( !strcmp(value, "yes[extended-cr3]") )
-                parms->pae = 2 /* extended_cr3 */;
+                parms->pae = XEN_PAE_EXTCR3;
             else if ( !strncmp(value, "yes", 3) )
-                parms->pae = 1 /* yes */;
+                parms->pae = XEN_PAE_YES;
         }
         if ( !strcmp(name, "BSD_SYMTAB") )
             parms->bsd_symtab = 1;
diff --git a/xen/include/xen/elf.h b/xen/include/xen/elf.h
index 03faac7..4199b4d 100644
--- a/xen/include/xen/elf.h
+++ b/xen/include/xen/elf.h
@@ -34,25 +34,4 @@
 #define ELFNOTE_DESC(_n_) (ELFNOTE_NAME(_n_) + ELFNOTE_ALIGN((_n_)->namesz))
 #define ELFNOTE_NEXT(_n_) ((Elf_Note *)(ELFNOTE_DESC(_n_) + 
ELFNOTE_ALIGN((_n_)->descsz)))
 
-struct domain_setup_info;
-extern int loadelfimage(struct domain_setup_info *);
-extern int parseelfimage(struct domain_setup_info *);
-
-extern unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi,
-                                             int type, int *defined);
-extern const char *xen_elfnote_string(struct domain_setup_info *dsi, int type);
-
-#ifdef CONFIG_COMPAT
-extern int elf32_sanity_check(const Elf32_Ehdr *ehdr);
-extern int loadelf32image(struct domain_setup_info *);
-extern int parseelf32image(struct domain_setup_info *);
-extern unsigned long long xen_elf32note_numeric(struct domain_setup_info *,
-                                               int type, int *defined);
-extern const char *xen_elf32note_string(struct domain_setup_info *, int type);
-#endif
-
-#ifdef Elf_Ehdr
-extern int elf_sanity_check(const Elf_Ehdr *ehdr);
-#endif
-
 #endif /* __XEN_ELF_H__ */
diff --git a/xen/include/xen/libelf.h b/xen/include/xen/libelf.h
index 6393040..d7045f6 100644
--- a/xen/include/xen/libelf.h
+++ b/xen/include/xen/libelf.h
@@ -393,6 +393,13 @@ enum xen_elfnote_type {
     XEN_ENT_STR  = 2
 };
 
+enum xen_pae_type {
+    XEN_PAE_NO      = 0,
+    XEN_PAE_YES     = 1,
+    XEN_PAE_EXTCR3  = 2,
+    XEN_PAE_BIMODAL = 3
+};
+
 struct xen_elfnote {
     enum xen_elfnote_type type;
     const char *name;
@@ -414,7 +421,7 @@ struct elf_dom_parms {
     char guest_ver[16];
     char xen_ver[16];
     char loader[16];
-    int pae; /* some kind of enum apparently */
+    enum xen_pae_type pae;
     bool bsd_symtab;
     uint64_t virt_base;
     uint64_t virt_entry;
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 68819f8..3729b0f 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -463,29 +463,6 @@ struct domain
     struct vnuma_info *vnuma;
 };
 
-struct domain_setup_info
-{
-    /* Initialised by caller. */
-    unsigned long image_addr;
-    unsigned long image_len;
-    /* Initialised by loader: Public. */
-    unsigned long v_start;
-    unsigned long v_end;
-    unsigned long v_kernstart;
-    unsigned long v_kernend;
-    unsigned long v_kernentry;
-#define PAEKERN_no           0
-#define PAEKERN_yes          1
-#define PAEKERN_extended_cr3 2
-#define PAEKERN_bimodal      3
-    unsigned int  pae_kernel;
-    /* Initialised by loader: Private. */
-    unsigned long elf_paddr_offset;
-    unsigned int  load_symtab;
-    unsigned long symtab_addr;
-    unsigned long symtab_len;
-};
-
 /* Protect updates/reads (resp.) of domain_list and domain_hash. */
 extern spinlock_t domlist_update_lock;
 extern rcu_read_lock_t domlist_read_lock;
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.