Skip to contentSkip to conversation

PVH: libxl expertise...

DISCUSSION Mukesh Rathor 3 participants 11 messages Nov 13, 2012 – Nov 15, 2012

lore
Share & tools
lore
#0 lore raw

Hi,

I am wondering if there's libxl expert who can help me make some PVH related changes to libxl, pref in the US time zone. I could consult on irc or the phone. I find the libxl code hard to read, and don't want to spend lot of time figuring it out if someone can just help quickly.

thanks,
Mukesh

#1 lore raw
Quoted 5 lines · Mukesh Rathor

Hi,

I am wondering if there's libxl expert who can help me make some PVH related changes to libxl, pref in the US time zone. I could consult on irc or the phone.

I think most of the libxl experts are in European time zones. Probably the best bet is to just ask your questions either here or on IRC.

Quoted 3 lines

I find the libxl code hard to read, and don't
want to spend lot of time figuring it out if someone can just help quickly.

Can you elaborate on this? We'd like to improve things if we can.

Ian.

#2 lore raw
Quoted 9 lines · On Tue, 13 Nov 2012 10:00:53 +0000 Ian Campbell <[email protected]> wrote:
Quoted 5 lines · Mukesh Rathor

Hi,

I am wondering if there's libxl expert who can help me make some PVH related changes to libxl, pref in the US time zone. I could consult on irc or the phone.

I think most of the libxl experts are in European time zones. Probably the best bet is to just ask your questions either here or on IRC.

Ian C/Roger: what are your handles on the #xen IRC? Mine: mrathor.

thanks,
Mukesh

#3 lore raw
In reply to Ian Campbell
Quoted 9 lines · On Tue, 13 Nov 2012 10:00:53 +0000 Ian Campbell <[email protected]> wrote:
Quoted 5 lines · Mukesh Rathor

Hi,

I am wondering if there's libxl expert who can help me make some PVH related changes to libxl, pref in the US time zone. I could consult on irc or the phone.

I think most of the libxl experts are in European time zones. Probably the best bet is to just ask your questions either here or on IRC.

For PVH, xc_dom_feature_translated is not returning true, looks like its not finding XENFEAT_auto_translated_physmap set in the elf???

I've modified the arch/x86/xen/xen-head.S file to include the PVH:

ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz "!writable_page_tables|pae_pgdir_above_4gb"FEATURES_PVH)

where

#define FEATURES_PVH "|writable_descriptor_tables" \
                    "|auto_translated_physmap" \
                    "|supervisor_mode_kernel" \
                    "|hvm_callback_vector"

So, not sure why it's failing. In xc_dom_parse_image(), I see dom->parms.f_required is 0. I assume this is what the kernel is built with and should be filled with the values above? Presumably, dom->f_requested is what the library expects the kernel to have. I set it as:

libxl__build_pv():

    if (is_pvh) {
        printf("info..features:%s\n", info->u.pv.features);
        info->u.pv.features = strdup("auto_translated_physmap");
    }

which is temporary hack, and I wanna consult with libxl expert for the proper way to to this. I don't see any thing similar being done.

I can't tell why f_active is there. I also see supported, may be thats the string of what the kernel supports. It is set to 0x11 ???

Hmm... Using readelf and hexeditor, I see the feature string properly set in vmlinux (assume its in bzImage too). So, not sure whats going on.

thanks
Mukesh

#4 lore raw
Quoted 4 lines · On Tue, 13 Nov 2012 17:21:38 -0800 Mukesh Rathor <[email protected]>…

I can't tell why f_active is there. I also see supported, may be thats the string of what the kernel supports. It is set to 0x11 ???

Debugging further, I see in xc_dom_parse_elf_kernel() after elf_parse_binary(), the strings are set as:

      type = XEN_ENT_STR, name = 0x3cadc2e116 "PAE_MODE", data = {
        str = 0x7ffff61e14b0 "yes", num = 0x7ffff61e14b0}}, {
      type = XEN_ENT_STR, name = 0x3cadc2dd2d "FEATURES", data = {
        str = 0x7ffff61e1414 "!writable_page_tables|pae_pgdir_above_4gb", 
        num = 0x7ffff61e1414}}, {type = XEN_ENT_NONE, name = 0x0, data = {
        str = 0x0, num = 0x0}}, {type = XEN_ENT_LONG, 

So, may be it's not properly set in bzImage and something else needs to be done to get the correct strings there???

thanks
Mukesh

#5 lore raw
Quoted 18 lines · Mukesh Rathor
Quoted 4 lines · On Tue, 13 Nov 2012 17:21:38 -0800 Mukesh Rathor <[email protected]>…

I can't tell why f_active is there. I also see supported, may be thats the string of what the kernel supports. It is set to 0x11 ???

Debugging further, I see in xc_dom_parse_elf_kernel() after elf_parse_binary(), the strings are set as:

      type = XEN_ENT_STR, name = 0x3cadc2e116 "PAE_MODE", data = {
        str = 0x7ffff61e14b0 "yes", num = 0x7ffff61e14b0}}, {
      type = XEN_ENT_STR, name = 0x3cadc2dd2d "FEATURES", data = {
        str = 0x7ffff61e1414 "!writable_page_tables|pae_pgdir_above_4gb", 
        num = 0x7ffff61e1414}}, {type = XEN_ENT_NONE, name = 0x0, data = {
        str = 0x0, num = 0x0}}, {type = XEN_ENT_LONG, 
Quoted 2 lines

So, may be it's not properly set in bzImage and something else needs to be done to get the correct strings there???

bzImage is a container for the ELF file, possibly things don't get parsed early enough by xc_dom in this case?

Did you say that if you use the raw ELF file it works?

I think in the default case you don't need to touch libxl here (yet), you need libxc to do the correct thing.

Do you need to know if this is a PV vs PVH domain at XEN_DOMCTL_createdomain (aka xc_domain_create) time or can it be set later? My suspicion is that when the domain is created the kernel hasn't been parsed yet so the feature flags are not available. This would be easier to deal with if the PVH selection could be moved later on to the point where you are actually building the domain -- but I don't know how hard that would be.

When I prototyped this stuff years ago I added XEN_DOMCTL_setfeatures which was called from xc_dom_parse_image:
@@ -668,8 +669,26 @@ int xc_dom_parse_image(struct xc_dom_ima
/* check features */
for ( i = 0; i < XENFEAT_NR_SUBMAPS; i++ )
{
- dom->f_active[i] |= dom->f_requested[i]; /* cmd line */
- dom->f_active[i] |= dom->parms.f_required[i]; /* kernel */
+ domctl.cmd = XEN_DOMCTL_setfeatures;
+ domctl.domain = dom->guest_domid;
+
+ domctl.u.setfeatures.submap_idx = i;
+ domctl.u.setfeatures.submap = 0;
+
+ domctl.u.setfeatures.submap |= dom->f_requested[i]; /* cmd line */
+ domctl.u.setfeatures.submap |= dom->parms.f_required[i]; /* kernel */
+
+ xc_dom_printf(dom->xch, "requesting features[%d] = %#x", domctl.u.setfeatures.submap_idx, domctl.u.setfeatures.submap);
+ if (do_domctl(dom->xch, &domctl))
+ {
+ xc_dom_panic(dom->xch, XC_INVALID_PARAM,
+ "%s: unable to set requested features\n", __FUNCTION__);
+ goto err;
+ }
+
+ xc_dom_printf(dom->xch, "received features[%d] = %#x", domctl.u.setfeatures.submap_idx, domctl.u.setfeatures.submap);
+ dom->f_active[i] = domctl.u.setfeatures.submap;
+
if ( (dom->f_active[i] & dom->parms.f_supported[i]) !=
dom->f_active[i] )
{

On the hypervisor side setting the features would enable "PVH" mode as appropriate.

You only need to worry about libxl integration to allow the user to override these defaults, but shall we worry about that later once we have libxc sorted?

BTW for the purposes of parallelising things up you could post the hypervisor side part of the series stuff + a patch to force enable PVH in libxc (obviously the last not to be applied) first then we can be reviewing the h/v side things while simultaneously figuring out how the tools side fits together.

Ian.

#6 lore raw
Quoted 6 lines · On Wed, 14 Nov 2012 09:58:30 +0000 Ian Campbell <[email protected]> wrote:
Quoted 4 lines · Mukesh Rathor
Quoted 1 line · On Tue, 13 Nov 2012 17:21:38 -0800 Mukesh Rathor <[email protected]>…

Did you say that if you use the raw ELF file it works?

You mean vmlinux? I couldn't its 133M and my boot partition is only 99M.

Quoted 5 lines

BTW for the purposes of parallelising things up you could post the hypervisor side part of the series stuff + a patch to force enable PVH in libxc (obviously the last not to be applied) first then we can be reviewing the h/v side things while simultaneously figuring out how the tools side fits together.

Ok. I've been procrastinating as the patch is full of debug code, is rather big, and would take lot of time to split up in different patches. If you don't mind a very raw/debug version, all in one, here it is (built on c/s: 26124 + my KDB patch):

tools/debugger/gdbsx/xg/xg_main.c +3 -1
diff -r 8b0762504037 tools/debugger/gdbsx/xg/xg_main.c
@@ -80,6 +80,7 @@ int xgtrc_on = 0;
 struct xen_domctl domctl;         /* just use a global domctl */
 
 static int     _hvm_guest;        /* hvm guest? 32bit HVMs have 64bit context */
+static int     _pvh_guest;        /* PV guest in HVM container */
 static domid_t _dom_id;           /* guest domid */
 static int     _max_vcpu_id;      /* thus max_vcpu_id+1 VCPUs */
 static int     _dom0_fd;          /* fd of /dev/privcmd */
@@ -308,6 +309,7 @@ xg_attach(int domid, int guest_bitness)
 
     _max_vcpu_id = domctl.u.getdomaininfo.max_vcpu_id;
     _hvm_guest = (domctl.u.getdomaininfo.flags & XEN_DOMINF_hvm_guest);
+    _pvh_guest = (domctl.u.getdomaininfo.flags & XEN_DOMINF_pvh_guest);
     return _max_vcpu_id;
 }
 
@@ -368,7 +370,7 @@ _change_TF(vcpuid_t which_vcpu, int gues
     int sz = sizeof(anyc);
 
     /* first try the MTF for hvm guest. otherwise do manually */
-    if (_hvm_guest) {
+    if (_hvm_guest || _pvh_guest) {
         domctl.u.debug_op.vcpu = which_vcpu;
         domctl.u.debug_op.op = setit ? XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON :
                                        XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF;
tools/libxc/Makefile +1 -1
diff -r 8b0762504037 tools/libxc/Makefile
@@ -73,7 +73,7 @@ OSDEP_SRCS-y                 += xenctrl_
 -include $(XEN_TARGET_ARCH)/Makefile
 
 CFLAGS   += -Werror -Wmissing-prototypes
-CFLAGS   += -I. $(CFLAGS_xeninclude)
+CFLAGS   += -I. $(CFLAGS_xeninclude) -g -O0
 
 # Needed for posix_fadvise64() in xc_linux.c
 CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE
tools/libxc/xc_dom_x86.c +4 -3
diff -r 8b0762504037 tools/libxc/xc_dom_x86.c
@@ -386,7 +386,8 @@ static int setup_pgtables_x86_64(struct 
         pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86;
         l1tab[l1off] =
             pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT;
-        if ( (addr >= dom->pgtables_seg.vstart) && 
+        if ( !(dom->flags & SIF_IS_PVH)      &&
+             (addr >= dom->pgtables_seg.vstart) && 
              (addr < dom->pgtables_seg.vend) )
             l1tab[l1off] &= ~_PAGE_RW; /* page tables are r/o */
         if ( l1off == (L1_PAGETABLE_ENTRIES_X86_64 - 1) )
@@ -716,7 +717,7 @@ int arch_setup_meminit(struct xc_dom_ima
     rc = x86_compat(dom->xch, dom->guest_domid, dom->guest_type);
     if ( rc )
         return rc;
-    if ( xc_dom_feature_translated(dom) )
+    if ( xc_dom_feature_translated(dom) && !(dom->flags & SIF_IS_PVH) )
     {
         dom->shadow_enabled = 1;
         rc = x86_shadow(dom->xch, dom->guest_domid);
@@ -830,7 +831,7 @@ int arch_setup_bootlate(struct xc_dom_im
         }
 
         /* Map grant table frames into guest physmap. */
-        for ( i = 0; ; i++ )
+        for ( i = 0; !(dom->flags & SIF_IS_PVH); i++ )
         {
             rc = xc_domain_add_to_physmap(dom->xch, dom->guest_domid,
                                           XENMAPSPACE_grant_table,
tools/libxc/xc_domain_restore.c +4 -4
diff -r 8b0762504037 tools/libxc/xc_domain_restore.c
@@ -1933,15 +1933,15 @@ int xc_domain_restore(xc_interface *xch,
             munmap(start_info, PAGE_SIZE);
         }
         /* Uncanonicalise each GDT frame number. */
-        if ( GET_FIELD(ctxt, gdt_ents) > 8192 )
+        if ( GET_FIELD(ctxt, u.pv.gdt_ents) > 8192 )
         {
             ERROR("GDT entry count out of range");
             goto out;
         }
 
-        for ( j = 0; (512*j) < GET_FIELD(ctxt, gdt_ents); j++ )
+        for ( j = 0; (512*j) < GET_FIELD(ctxt, u.pv.gdt_ents); j++ )
         {
-            pfn = GET_FIELD(ctxt, gdt_frames[j]);
+            pfn = GET_FIELD(ctxt, u.pv.gdt_frames[j]);
             if ( (pfn >= dinfo->p2m_size) ||
                  (pfn_type[pfn] != XEN_DOMCTL_PFINFO_NOTAB) )
             {
@@ -1949,7 +1949,7 @@ int xc_domain_restore(xc_interface *xch,
                       j, (unsigned long)pfn);
                 goto out;
             }
-            SET_FIELD(ctxt, gdt_frames[j], ctx->p2m[pfn]);
+            SET_FIELD(ctxt, u.pv.gdt_frames[j], ctx->p2m[pfn]);
         }
         /* Uncanonicalise the page table base pointer. */
         pfn = UNFOLD_CR3(GET_FIELD(ctxt, ctrlreg[3]));
tools/libxc/xc_domain_save.c +3 -3
diff -r 8b0762504037 tools/libxc/xc_domain_save.c
@@ -1889,15 +1889,15 @@ int xc_domain_save(xc_interface *xch, in
         }
 
         /* Canonicalise each GDT frame number. */
-        for ( j = 0; (512*j) < GET_FIELD(&ctxt, gdt_ents); j++ )
+        for ( j = 0; (512*j) < GET_FIELD(&ctxt, u.pv.gdt_ents); j++ )
         {
-            mfn = GET_FIELD(&ctxt, gdt_frames[j]);
+            mfn = GET_FIELD(&ctxt, u.pv.gdt_frames[j]);
             if ( !MFN_IS_IN_PSEUDOPHYS_MAP(mfn) )
             {
                 ERROR("GDT frame is not in range of pseudophys map");
                 goto out;
             }
-            SET_FIELD(&ctxt, gdt_frames[j], mfn_to_pfn(mfn));
+            SET_FIELD(&ctxt, u.pv.gdt_frames[j], mfn_to_pfn(mfn));
         }
 
         /* Canonicalise the page table base pointer. */
tools/libxl/Makefile +1 -1
diff -r 8b0762504037 tools/libxl/Makefile
@@ -13,7 +13,7 @@ XLUMINOR = 1
 
 CFLAGS += -Werror -Wno-format-zero-length -Wmissing-declarations \
 	-Wno-declaration-after-statement -Wformat-nonliteral
-CFLAGS += -I. -fPIC
+CFLAGS += -I. -fPIC -O0
 
 ifeq ($(CONFIG_Linux),y)
 LIBUUID_LIBS += -luuid
tools/libxl/libxl_create.c +2 -0
diff -r 8b0762504037 tools/libxl/libxl_create.c
@@ -409,6 +409,8 @@ int libxl__domain_make(libxl__gc *gc, li
         flags |= XEN_DOMCTL_CDF_hvm_guest;
         flags |= libxl_defbool_val(info->hap) ? XEN_DOMCTL_CDF_hap : 0;
         flags |= libxl_defbool_val(info->oos) ? 0 : XEN_DOMCTL_CDF_oos_off;
+    } else if ( libxl_defbool_val(info->ci_pvh) ) {
+        flags |= (XEN_DOMCTL_CDF_pvh_guest | XEN_DOMCTL_CDF_hap);
     }
     *domid = -1;
 
tools/libxl/libxl_dom.c +11 -2
diff -r 8b0762504037 tools/libxl/libxl_dom.c
@@ -270,7 +270,8 @@ int libxl__build_pre(libxl__gc *gc, uint
     if (rtc_timeoffset)
         xc_domain_set_time_offset(ctx->xch, domid, rtc_timeoffset);
 
-    if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
+    if (info->type == LIBXL_DOMAIN_TYPE_HVM ||
+        libxl_defbool_val(info->bi_pvh) ) {
         unsigned long shadow;
         shadow = (info->shadow_memkb + 1023) / 1024;
         xc_shadow_control(ctx->xch, domid, XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION, NULL, 0, &shadow, 0, NULL);
@@ -368,9 +369,15 @@ int libxl__build_pv(libxl__gc *gc, uint3
     struct xc_dom_image *dom;
     int ret;
     int flags = 0;
+    int is_pvh = libxl_defbool_val(info->bi_pvh);
 
     xc_dom_loginit(ctx->xch);
 
+    if (is_pvh) {
+        printf("info..features:%s\n", info->u.pv.features);
+        info->u.pv.features = strdup("auto_translated_physmap");
+    }
+
     dom = xc_dom_allocate(ctx->xch, state->pv_cmdline, info->u.pv.features);
     if (!dom) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_allocate failed");
@@ -408,6 +415,7 @@ int libxl__build_pv(libxl__gc *gc, uint3
         }
     }
 
+    flags |= is_pvh ? SIF_IS_PVH : 0;
     dom->flags = flags;
     dom->console_evtchn = state->console_port;
     dom->console_domid = state->console_domid;
@@ -438,7 +446,8 @@ int libxl__build_pv(libxl__gc *gc, uint3
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_boot_image failed");
         goto out;
     }
-    if ( (ret = xc_dom_gnttab_init(dom)) != 0 ) {
+    /* PVH sets up its own grant during boot via hvm mechanisms */
+    if ( !is_pvh && (ret = xc_dom_gnttab_init(dom)) != 0 ) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_dom_gnttab_init failed");
         goto out;
     }
tools/libxl/libxl_types.idl +2 -0
diff -r 8b0762504037 tools/libxl/libxl_types.idl
@@ -243,6 +243,7 @@ libxl_domain_create_info = Struct("domai
     ("platformdata", libxl_key_value_list),
     ("poolid",       uint32),
     ("run_hotplug_scripts",libxl_defbool),
+    ("ci_pvh",       libxl_defbool),
     ], dir=DIR_IN)
 
 MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT")
@@ -339,6 +340,7 @@ libxl_domain_build_info = Struct("domain
                                       ])),
                  ("invalid", Struct(None, [])),
                  ], keyvar_init_val = "LIBXL_DOMAIN_TYPE_INVALID")),
+    ("bi_pvh",       libxl_defbool),
     ], dir=DIR_IN
 )
 
tools/libxl/xl_cmdimpl.c +11 -0
diff -r 8b0762504037 tools/libxl/xl_cmdimpl.c
@@ -615,8 +615,18 @@ static void parse_config_data(const char
         !strncmp(buf, "hvm", strlen(buf)))
         c_info->type = LIBXL_DOMAIN_TYPE_HVM;
 
+    libxl_defbool_setdefault(&c_info->ci_pvh, false);
+    libxl_defbool_setdefault(&c_info->hap, false);
+    xlu_cfg_get_defbool(config, "pvh", &c_info->ci_pvh, 0);
     xlu_cfg_get_defbool(config, "hap", &c_info->hap, 0);
 
+    if (libxl_defbool_val(c_info->ci_pvh) &&
+        !libxl_defbool_val(c_info->hap)) {
+
+        fprintf(stderr, "hap is required for PVH domain\n");
+        exit(1);
+    }
+
     if (xlu_cfg_replace_string (config, "name", &c_info->name, 0)) {
         fprintf(stderr, "Domain name must be specified.\n");
         exit(1);
@@ -916,6 +926,7 @@ static void parse_config_data(const char
 
         b_info->u.pv.cmdline = cmdline;
         xlu_cfg_replace_string (config, "ramdisk", &b_info->u.pv.ramdisk, 0);
+        libxl_defbool_set(&b_info->bi_pvh, libxl_defbool_val(c_info->ci_pvh));
         break;
     }
     default:
tools/xenstore/xenstored_domain.c +5 -1
diff -r 8b0762504037 tools/xenstore/xenstored_domain.c
@@ -578,11 +578,13 @@ static int close_xc_handle(void *_handle
 	return 0;
 }
 
+#if 0
 static int close_xcg_handle(void *_handle)
 {
 	xc_gnttab_close(*(xc_gnttab **)_handle);
 	return 0;
 }
+#endif
 
 /* Returns the implicit path of a connection (only domains have this) */
 const char *get_implicit_path(const struct connection *conn)
@@ -639,12 +641,14 @@ void domain_init(void)
 	if (!xcg_handle)
 		barf_perror("Failed to allocate domain gnttab handle");
 
+*xcg_handle = NULL;
+#if 0
 	*xcg_handle = xc_gnttab_open(NULL, 0);
 	if (*xcg_handle < 0)
 		xprintf("WARNING: Failed to open connection to gnttab\n");
 	else
 		talloc_set_destructor(xcg_handle, close_xcg_handle);
-
+#endif
 	xce_handle = xc_evtchn_open(NULL, 0);
 
 	if (xce_handle == NULL)
xen/arch/x86/debug.c +2 -4
diff -r 8b0762504037 xen/arch/x86/debug.c
@@ -59,7 +59,7 @@ dbg_hvm_va2mfn(dbgva_t vaddr, struct dom
         return INVALID_MFN;
     }
 
-    mfn = mfn_x(get_gfn(dp, *gfn, &gfntype)); 
+    mfn = mfn_x(get_gfn_query_unlocked(dp, *gfn, &gfntype)); 
     if ( p2m_is_readonly(gfntype) && toaddr )
     {
         DBGP2("kdb:p2m_is_readonly: gfntype:%x\n", gfntype);
@@ -153,7 +153,7 @@ dbg_rw_guest_mem(dbgva_t addr, dbgbyte_t
 
         pagecnt = min_t(long, PAGE_SIZE - (addr & ~PAGE_MASK), len);
 
-        mfn = (dp->is_hvm
+        mfn = (is_hvm_or_pvh_domain(dp)
                ? dbg_hvm_va2mfn(addr, dp, toaddr, &gfn)
                : dbg_pv_va2mfn(addr, dp, pgd3));
         if ( mfn == INVALID_MFN ) 
@@ -173,8 +173,6 @@ dbg_rw_guest_mem(dbgva_t addr, dbgbyte_t
         }
 
         unmap_domain_page(va);
-        if ( gfn != INVALID_GFN )
-            put_gfn(dp, gfn);
 
         addr += pagecnt;
         buf += pagecnt;
xen/arch/x86/domain.c +77 -41

327 lines not on this page · raw message

xen/arch/x86/domain_build.c +136 -59

335 lines not on this page · raw message

xen/arch/x86/domctl.c +82 -69

180 lines not on this page · raw message

xen/arch/x86/hvm/hvm.c +76 -2

133 lines not on this page · raw message

xen/arch/x86/hvm/irq.c +3 -0
diff -r 8b0762504037 xen/arch/x86/hvm/irq.c
@@ -405,6 +405,9 @@ struct hvm_intack hvm_vcpu_has_pending_i
          && vcpu_info(v, evtchn_upcall_pending) )
         return hvm_intack_vector(plat->irq.callback_via.vector);
 
+    if ( is_pvh_vcpu(v) )
+        return hvm_intack_none;
+
     if ( vlapic_accept_pic_intr(v) && plat->vpic[0].int_output )
         return hvm_intack_pic(0);
 
xen/arch/x86/hvm/mtrr.c +27 -0
diff -r 8b0762504037 xen/arch/x86/hvm/mtrr.c
@@ -553,6 +553,10 @@ int32_t hvm_get_mem_pinned_cacheattr(
 
     *type = 0;
 
+    if ( is_pvh_domain(d) ) {
+        printk("PVH: fixme: hvm_get_mem_pinned_cacheattr(). \n");
+        return 0;
+    }
     if ( !is_hvm_domain(d) )
         return 0;
 
@@ -578,6 +582,11 @@ int32_t hvm_set_mem_pinned_cacheattr(
 {
     struct hvm_mem_pinned_cacheattr_range *range;
 
+    if ( is_pvh_domain(d) ) {
+        printk("PVH: fixme: hvm_set_mem_pinned_cacheattr()\n");
+        return 0;
+    }
+
     if ( !((type == PAT_TYPE_UNCACHABLE) ||
            (type == PAT_TYPE_WRCOMB) ||
            (type == PAT_TYPE_WRTHROUGH) ||
@@ -606,6 +615,12 @@ static int hvm_save_mtrr_msr(struct doma
     struct vcpu *v;
     struct hvm_hw_mtrr hw_mtrr;
     struct mtrr_state *mtrr_state;
+
+    if ( is_pvh_domain(d) ) {
+        printk("PVH: fixme: hvm_save_mtrr_msr()\n");
+        return 0;
+    }
+
     /* save mtrr&pat */
     for_each_vcpu(d, v)
     {
@@ -644,6 +659,10 @@ static int hvm_load_mtrr_msr(struct doma
     struct mtrr_state *mtrr_state;
     struct hvm_hw_mtrr hw_mtrr;
 
+    if ( is_pvh_domain(d) ) {
+        printk("PVH: fixme: hvm_load_mtrr_msr()\n");
+        return 0;
+    }
     vcpuid = hvm_load_instance(h);
     if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
     {
@@ -693,6 +712,14 @@ uint8_t epte_get_entry_emt(struct domain
          ((d->vcpu == NULL) || ((v = d->vcpu[0]) == NULL)) )
         return MTRR_TYPE_WRBACK;
 
+    /* PVH TBD: FIXME: this needs to be studied, figure what need to be done
+     * for PVH */
+    if ( is_pvh_domain(d) ) {
+        if (direct_mmio)
+            return MTRR_TYPE_UNCACHABLE;
+        return MTRR_TYPE_WRBACK;
+    }
+
     if ( !v->domain->arch.hvm_domain.params[HVM_PARAM_IDENT_PT] )
         return MTRR_TYPE_WRBACK;
 
xen/arch/x86/hvm/svm/vmcb.c +1 -1
diff -r 8b0762504037 xen/arch/x86/hvm/svm/vmcb.c
@@ -326,7 +326,7 @@ void kdb_dump_vmcb(domid_t did, int vid)
 
     rcu_read_lock(&domlist_read_lock);
     for_each_domain (dp) {
-        if (!is_hvm_or_hyb_domain(dp) || dp->is_dying)
+        if (!is_hvm_or_pvh_domain(dp) || dp->is_dying)
             continue;
         if (did != 0 && did != dp->domain_id)
             continue;
xen/arch/x86/hvm/vmx/Makefile +1 -0
diff -r 8b0762504037 xen/arch/x86/hvm/vmx/Makefile
@@ -5,3 +5,4 @@ obj-y += vmcs.o
 obj-y += vmx.o
 obj-y += vpmu_core2.o
 obj-y += vvmx.o
+obj-y += vmx_pvh.o
xen/arch/x86/hvm/vmx/intr.c +4 -3
diff -r 8b0762504037 xen/arch/x86/hvm/vmx/intr.c
@@ -216,15 +216,16 @@ void vmx_intr_assist(void)
         return;
     }
 
-    /* Crank the handle on interrupt state. */
-    pt_vector = pt_update_irq(v);
+    if ( !is_pvh_vcpu(v) )
+        /* Crank the handle on interrupt state. */
+        pt_vector = pt_update_irq(v);
 
     do {
         intack = hvm_vcpu_has_pending_irq(v);
         if ( likely(intack.source == hvm_intsrc_none) )
             goto out;
 
-        if ( unlikely(nvmx_intr_intercept(v, intack)) )
+        if ( !is_pvh_vcpu(v) && unlikely(nvmx_intr_intercept(v, intack)) )
             goto out;
 
         intblk = hvm_interrupt_blocked(v, intack);
xen/arch/x86/hvm/vmx/vmcs.c +316 -15

389 lines not on this page · raw message

xen/arch/x86/hvm/vmx/vmx.c +56 -19

153 lines not on this page · raw message

xen/arch/x86/hvm/vmx/vmx_pvh.c new file +1109 -0

1,109 lines not on this page · raw message

xen/arch/x86/mm.c +221 -27

31 lines not on this page · raw message

xen/arch/x86/mm/hap/hap.c +16 -1
diff -r 8b0762504037 xen/arch/x86/mm/hap/hap.c

Lines of this file are not shown. View the raw message.

xen/arch/x86/mm/p2m-ept.c +6 -2
diff -r 8b0762504037 xen/arch/x86/mm/p2m-ept.c

Lines of this file are not shown. View the raw message.

xen/arch/x86/mm/p2m-pt.c +2 -1
diff -r 8b0762504037 xen/arch/x86/mm/p2m-pt.c

Lines of this file are not shown. View the raw message.

xen/arch/x86/mm/p2m.c +32 -1
diff -r 8b0762504037 xen/arch/x86/mm/p2m.c

Lines of this file are not shown. View the raw message.

xen/arch/x86/msi.c +4 -0
diff -r 8b0762504037 xen/arch/x86/msi.c

Lines of this file are not shown. View the raw message.

xen/arch/x86/physdev.c +19 -0
diff -r 8b0762504037 xen/arch/x86/physdev.c

Lines of this file are not shown. View the raw message.

xen/arch/x86/setup.c +7 -2
diff -r 8b0762504037 xen/arch/x86/setup.c

Lines of this file are not shown. View the raw message.

xen/arch/x86/time.c +1 -1
diff -r 8b0762504037 xen/arch/x86/time.c

Lines of this file are not shown. View the raw message.

xen/arch/x86/traps.c +32 -17

49 lines not on this page · raw message

xen/arch/x86/x86_64/traps.c +5 -5
diff -r 8b0762504037 xen/arch/x86/x86_64/traps.c

Lines of this file are not shown. View the raw message.

xen/common/domain.c +8 -0
diff -r 8b0762504037 xen/common/domain.c

Lines of this file are not shown. View the raw message.

xen/common/domctl.c +5 -0
diff -r 8b0762504037 xen/common/domctl.c

Lines of this file are not shown. View the raw message.

xen/common/grant_table.c +3 -3
diff -r 8b0762504037 xen/common/grant_table.c

Lines of this file are not shown. View the raw message.

xen/common/kernel.c +5 -1
diff -r 8b0762504037 xen/common/kernel.c

Lines of this file are not shown. View the raw message.

xen/common/libelf/libelf-loader.c +48 -4

52 lines not on this page · raw message

xen/common/memory.c +15 -5
diff -r 8b0762504037 xen/common/memory.c

Lines of this file are not shown. View the raw message.

xen/drivers/passthrough/iommu.c +15 -2
diff -r 8b0762504037 xen/drivers/passthrough/iommu.c

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/desc.h +2 -1
diff -r 8b0762504037 xen/include/asm-x86/desc.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/domain.h +9 -5
diff -r 8b0762504037 xen/include/asm-x86/domain.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/event.h +1 -1
diff -r 8b0762504037 xen/include/asm-x86/event.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/guest_access.h +6 -6
diff -r 8b0762504037 xen/include/asm-x86/guest_access.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/hap.h +1 -0
diff -r 8b0762504037 xen/include/asm-x86/hap.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/hvm/hvm.h +25 -0
diff -r 8b0762504037 xen/include/asm-x86/hvm/hvm.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/hvm/vcpu.h +13 -0
diff -r 8b0762504037 xen/include/asm-x86/hvm/vcpu.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/hvm/vmx/pvh.h new file +11 -0
diff -r 8b0762504037 xen/include/asm-x86/hvm/vmx/pvh.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/hvm/vmx/vmcs.h +1 -0
diff -r 8b0762504037 xen/include/asm-x86/hvm/vmx/vmcs.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/hvm/vmx/vmx.h +42 -0

42 lines not on this page · raw message

xen/include/asm-x86/p2m.h +4 -0
diff -r 8b0762504037 xen/include/asm-x86/p2m.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/processor.h +2 -0
diff -r 8b0762504037 xen/include/asm-x86/processor.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/system.h +8 -2
diff -r 8b0762504037 xen/include/asm-x86/system.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/traps.h +1 -0
diff -r 8b0762504037 xen/include/asm-x86/traps.h

Lines of this file are not shown. View the raw message.

xen/include/asm-x86/x86_64/regs.h +2 -1
diff -r 8b0762504037 xen/include/asm-x86/x86_64/regs.h

Lines of this file are not shown. View the raw message.

xen/include/public/arch-x86/xen.h +10 -1
diff -r 8b0762504037 xen/include/public/arch-x86/xen.h

Lines of this file are not shown. View the raw message.

xen/include/public/domctl.h +8 -0
diff -r 8b0762504037 xen/include/public/domctl.h

Lines of this file are not shown. View the raw message.

xen/include/public/physdev.h +13 -0
diff -r 8b0762504037 xen/include/public/physdev.h

Lines of this file are not shown. View the raw message.

xen/include/public/xen.h +1 -0
diff -r 8b0762504037 xen/include/public/xen.h

Lines of this file are not shown. View the raw message.

xen/include/xen/domain.h +3 -0
diff -r 8b0762504037 xen/include/xen/domain.h

Lines of this file are not shown. View the raw message.

xen/include/xen/lib.h +4 -0
diff -r 8b0762504037 xen/include/xen/lib.h

Lines of this file are not shown. View the raw message.

xen/include/xen/libelf.h +2 -1
diff -r 8b0762504037 xen/include/xen/libelf.h

Lines of this file are not shown. View the raw message.

xen/include/xen/sched.h +12 -0
diff -r 8b0762504037 xen/include/xen/sched.h

Lines of this file are not shown. View the raw message.

xen/kdb/include/kdb_extern.h +0 -3
diff -r 8b0762504037 xen/kdb/include/kdb_extern.h

Lines of this file are not shown. View the raw message.

xen/kdb/kdb_cmds.c +109 -72

181 lines not on this page · raw message

xen/kdb/kdbmain.c +10 -23
diff -r 8b0762504037 xen/kdb/kdbmain.c

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#7 lore raw
In reply to Ian Campbell
Quoted 21 lines · On Wed, 14 Nov 2012 09:58:30 +0000 Ian Campbell <[email protected]> wrote:
Quoted 12 lines · Mukesh Rathor
Quoted 5 lines · On Tue, 13 Nov 2012 17:21:38 -0800 Mukesh Rathor <[email protected]>…

I can't tell why f_active is there. I also see supported, may be thats the string of what the kernel supports. It is set to 0x11 ???

Debugging further, I see in xc_dom_parse_elf_kernel() after elf_parse_binary(), the strings are set as:

Quoted 7 lines
      type = XEN_ENT_STR, name = 0x3cadc2e116 "PAE_MODE", data = {
        str = 0x7ffff61e14b0 "yes", num = 0x7ffff61e14b0}}, {
      type = XEN_ENT_STR, name = 0x3cadc2dd2d "FEATURES", data = {
        str = 0x7ffff61e1414

"!writable_page_tables|pae_pgdir_above_4gb", num = 0x7ffff61e1414}}, {type = XEN_ENT_NONE, name = 0x0, data = { str = 0x0, num = 0x0}}, {type = XEN_ENT_LONG,

Quoted 2 lines

later? My suspicion is that when the domain is created the kernel hasn't been parsed yet so the feature flags are not available. This would be

Well, it found "!writable_page_tables|pae_pgdir_above_4gb", but not the addition ones I added:

#define FEATURES_PVH "|writable_descriptor_tables" \
                    "|auto_translated_physmap" \
                    "|supervisor_mode_kernel" \
                    "|hvm_callback_vector"

However, I see the new ones in vmlinux. So, something either in bzImage or parser.

thanks for your help.
Mukesh

#8 lore raw
In reply to Ian Campbell

On Wed, 14 Nov 2012 09:58:30 +0000
Ian Campbell <[email protected]> wrote:

Duuude!!! You owe me a beer next time we meet (was your code ;)), and I ain't making it a cheap one :).

The problem is :

#define FEATURES_PVH "|writable_descriptor_tables" \
                    "|auto_translated_physmap" \
                    "|supervisor_mode_kernel" \
                    "|hvm_callback_vector"

ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz
"!writable_page_tables|pae_pgdir_above_4gb"FEATURES_PVH)

This is a .S file and not C, and it puts null char after _4gb. Fixed it and now xc_dom_feature_translated() is returnig true. Whew! I'll send konrad a patch.

On to the next one .............

thanks again,
Mukesh

#9 lore raw
Quoted 5 lines · Mukesh Rathor

On Wed, 14 Nov 2012 09:58:30 +0000
Ian Campbell <[email protected]> wrote:

Duuude!!! You owe me a beer next time we meet (was your code ;)), and I ain't making it a cheap one :).

:-)

Quoted 4 lines

[...]
This is a .S file and not C, and it puts null char after _4gb. Fixed it and now xc_dom_feature_translated() is returnig true. Whew! I'll send konrad a patch.

Wow, good catch! I had no idea that gas didn't concatenate strings!

Ian.

#10 lore raw
In reply to Mukesh Rathor
Quoted 5 lines · Mukesh Rathor

Hi,

I am wondering if there's libxl expert who can help me make some PVH related changes to libxl, pref in the US time zone. I could consult on irc or the phone.

I wouldn't consider myself a libxl expert, but I've been working with it for some time (specially in the devices section) so if you need help I would like to give you a hand, (I'm in the EU timezone, GMT+1).

Quoted 12 lines

I find the libxl code hard to read, and don't
want to spend lot of time figuring it out if someone can just help quickly.

thanks,
Mukesh

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel