Skip to contentSkip to conversation

pvh dom0 patches...

PATCH Superseded Mukesh Rathor 3 participants 14 messages May 19, 2014 – May 23, 2014

Subsystems (2)

v13 of 16 Superseded Latest is v16 →

lore
Share & tools
lore
#0 lore raw

v13 cover pvh dom0 patches...

Hi,

Attached please find v13 of dom0 pvh patch series based on c/s: 11dba84.

git tree: git://oss.oracle.com/git/mrathor/xen.git branch: dom0pvh-v13

Changes from v12:
patch 1:
- don't allow paging/sharing if dom0 is pvh.
- don't ignore rc from atomic_write_ept_entry even in paths that don't set foreign types.
- use is_epte_superpage() instead of new.sp bit check in atomic_write_ept_entry

patch 2: none

thanks,
Mukesh

#1 lore raw

PATCH v13 1/2 pvh dom0: Add and remove foreign pages

In this patch, a new function, p2m_add_foreign(), is added to map pages from a foreign guest into dom0 for various purposes like domU creation, running xentrace, etc... Such pages are typed p2m_map_foreign. Note, it is the nature of such pages that a refcnt is held during their stay in the p2m. The refcnt is added and released in the low level ept function atomic_write_ept_entry. That macro is converted to a function to allow for such refcounting, which only applies to leaf entries in the ept. Furthermore, please note that paging/sharing is disabled if the controlling or hardware domain is pvh. Any enabling of those features would need to ensure refcnt are properly maintained for foreign types, or paging/sharing is skipped for foreign types.

Also, we change get_pg_owner so it allows foreign mappings for pvh.

---
 xen/arch/x86/mm.c           |   4 +-
 xen/arch/x86/mm/mem_event.c |  11 ++++
 xen/arch/x86/mm/p2m-ept.c   |  98 +++++++++++++++++++++++++++-------
 xen/arch/x86/mm/p2m-pt.c    |   7 +++
 xen/arch/x86/mm/p2m.c       | 126 +++++++++++++++++++++++++++++++++++++++++---
 xen/include/asm-x86/p2m.h   |   7 +++
 6 files changed, 226 insertions(+), 27 deletions(-)
xen/arch/x86/mm.c +3 -1
index 1a8a5e0..d005c34 100644
@@ -2811,7 +2811,7 @@ static struct domain *get_pg_owner(domid_t domid)
         goto out;
     }
 
-    if ( unlikely(paging_mode_translate(curr)) )
+    if ( !is_pvh_domain(curr) && unlikely(paging_mode_translate(curr)) )
     {
         MEM_LOG("Cannot mix foreign mappings with translated domains");
         goto out;
@@ -4584,6 +4584,8 @@ int xenmem_add_to_physmap_one(
             page = mfn_to_page(mfn);
             break;
         }
+        case XENMAPSPACE_gmfn_foreign:
+            return p2m_add_foreign(d, idx, gpfn, foreign_domid);
         default:
             break;
     }
xen/arch/x86/mm/mem_event.c +11 -0
index 36b9dba..7722dcb 100644
@@ -538,6 +538,12 @@ int mem_event_domctl(struct domain *d, xen_domctl_mem_event_op_t *mec,
         case XEN_DOMCTL_MEM_EVENT_OP_PAGING_ENABLE:
         {
             struct p2m_domain *p2m = p2m_get_hostp2m(d);
+
+            rc = -EOPNOTSUPP;
+            /* pvh fixme: p2m_is_foreign types need addressing */
+            if ( is_pvh_vcpu(current) || is_pvh_domain(hardware_domain) )
+                break;
+
             rc = -ENODEV;
             /* Only HAP is supported */
             if ( !hap_enabled(d) )
@@ -620,6 +626,11 @@ int mem_event_domctl(struct domain *d, xen_domctl_mem_event_op_t *mec,
         {
         case XEN_DOMCTL_MEM_EVENT_OP_SHARING_ENABLE:
         {
+            rc = -EOPNOTSUPP;
+            /* pvh fixme: p2m_is_foreign types need addressing */
+            if ( is_pvh_vcpu(current) || is_pvh_domain(hardware_domain) )
+                break;
+
             rc = -ENODEV;
             /* Only HAP is supported */
             if ( !hap_enabled(d) )
xen/arch/x86/mm/p2m-ept.c +79 -19

212 lines not on this page · raw message

xen/arch/x86/mm/p2m-pt.c +7 -0
index cd9867a..a1794d0 100644
@@ -513,6 +513,13 @@ p2m_pt_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn,
         __trace_var(TRC_MEM_SET_P2M_ENTRY, 0, sizeof(t), &t);
     }
 
+    if ( unlikely(p2m_is_foreign(p2mt)) )
+    {
+        /* pvh fixme: foreign types are only supported on ept at present */
+        gdprintk(XENLOG_WARNING, "Unimplemented foreign p2m type.\n");
+        return -EINVAL;
+    }
+
     /* Carry out any eventually pending earlier changes first. */
     rc = do_recalc(p2m, gfn);
     if ( rc < 0 )
xen/arch/x86/mm/p2m.c +119 -7

159 lines not on this page · raw message

xen/include/asm-x86/p2m.h +7 -0
index 027f011..d0cfdac 100644
@@ -188,6 +188,10 @@ typedef unsigned int p2m_query_t;
 #define p2m_is_broken(_t)   (p2m_to_mask(_t) & P2M_BROKEN_TYPES)
 #define p2m_is_foreign(_t)  (p2m_to_mask(_t) & p2m_to_mask(p2m_map_foreign))
 
+#define p2m_is_any_ram(_t)  (p2m_to_mask(_t) &                   \
+                             (P2M_RAM_TYPES | P2M_GRANT_TYPES |  \
+                              p2m_to_mask(p2m_map_foreign)))
+
 /* Per-p2m-table state */
 struct p2m_domain {
     /* Lock that protects updates to the p2m */
@@ -532,6 +536,9 @@ int p2m_is_logdirty_range(struct p2m_domain *, unsigned long start,
 int set_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn);
 int clear_mmio_p2m_entry(struct domain *d, unsigned long gfn);
 
+/* Add foreign mapping to the guest's p2m table. */
+int p2m_add_foreign(struct domain *tdom, unsigned long fgfn,
+                    unsigned long gpfn, domid_t foreign_domid);
 
 /* 
  * Populate-on-demand
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [V13 PATCH 1/2] pvh dom0: Add and remove foreign pages

Quoted 41 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 01:51, <[email protected]> wrote:
xen/arch/x86/mm/p2m-ept.c +40 -0
+static int atomic_write_ept_entry(ept_entry_t *entryptr, ept_entry_t new,
+                                  int level)
+{
+    int rc = 0;
+    unsigned long oldmfn = INVALID_MFN;
+    bool_t skip_foreign = (new.mfn == entryptr->mfn &&
+                           new.sa_p2mt == entryptr->sa_p2mt);
+
+    if ( level )
+    {
+        ASSERT(!is_epte_superpage(&new) || !p2m_is_foreign(new.sa_p2mt));
+        write_atomic(&entryptr->epte, new.epte);
+        goto out;
+    }
+
+    if ( unlikely(p2m_is_foreign(new.sa_p2mt)) && !skip_foreign )
+    {
+        struct domain *fdom;
+
+        rc = -EINVAL;
+        if ( !mfn_valid(new.mfn) )
+            goto out;
+
+        rc = -ESRCH;
+        fdom = page_get_owner(mfn_to_page(new.mfn));
+        if ( fdom == NULL )
+            goto out;
+
+        /* get refcount on the page */
+        rc = -EBUSY;
+        if ( !get_page(mfn_to_page(new.mfn), fdom) )
+            goto out;
+    }
+
+    if ( unlikely(p2m_is_foreign(entryptr->sa_p2mt)) && !skip_foreign )
+        oldmfn = entryptr->mfn;
+
+    write_atomic(&entryptr->epte, new.epte);
+
+    if ( unlikely(oldmfn != INVALID_MFN) )

xen/arch/x86/mm/p2m-ept.c static inline bool_t is_epte_valid(ept_entry_t *e) · line 97

Quoted 10 lines
xen/arch/x86/mm/p2m-ept.c +10 -0
+        put_page(mfn_to_page(oldmfn));
+
+    rc = 0;
+
+ out:
+    if ( rc )
+        gdprintk(XENLOG_ERR, "epte o:%"PRIx64" n:%"PRIx64" rc:%d\n",
+                 entryptr->epte, new.epte, rc);
+    return rc;
+}

There's still no sign of any use of is_epte_present() here, and also no mention anywhere that taking refcounts even for inaccessible entries is correct. I think this is actually okay, but the policy (refcount taken even for inaccessible pages) should be spelled out somewhere.

xen/arch/x86/mm/p2m-ept.c ept_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, · line 751

Quoted 6 lines
xen/arch/x86/mm/p2m-ept.c +1 -1
@@ -688,10 +748,10 @@ ept_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn,
         ept_p2m_type_to_flags(&new_entry, p2mt, p2ma);
     }
 
-    atomic_write_ept_entry(ept_entry, new_entry);
+    rc = atomic_write_ept_entry(ept_entry, new_entry, target);

To me it would seem cleaner to clear old_entry here right away, so there's no confusion about it needing freeing on eventual new error paths getting added in the future.

Jan

#3 lore raw

Re: [V13 PATCH 1/2] pvh dom0: Add and remove foreign pages

Quoted 51 lines · On Tue, 20 May 2014 11:33:11 +0100 "Jan Beulich" <[email protected]> wrote:
Quoted 51 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 01:51, <[email protected]> wrote:

+static int atomic_write_ept_entry(ept_entry_t *entryptr, ept_entry_t new,

xen/arch/x86/mm/p2m-ept.c +10 -0
+                                  int level)
+{
+    int rc = 0;
+    unsigned long oldmfn = INVALID_MFN;
+    bool_t skip_foreign = (new.mfn == entryptr->mfn &&
+                           new.sa_p2mt == entryptr->sa_p2mt);
+
+    if ( level )
+    {
+        ASSERT(!is_epte_superpage(&new)

|| !p2m_is_foreign(new.sa_p2mt));

xen/arch/x86/mm/p2m-ept.c +24 -0
+        write_atomic(&entryptr->epte, new.epte);
+        goto out;
+    }
+
+    if ( unlikely(p2m_is_foreign(new.sa_p2mt)) && !skip_foreign )
+    {
+        struct domain *fdom;
+
+        rc = -EINVAL;
+        if ( !mfn_valid(new.mfn) )
+            goto out;
+
+        rc = -ESRCH;
+        fdom = page_get_owner(mfn_to_page(new.mfn));
+        if ( fdom == NULL )
+            goto out;
+
+        /* get refcount on the page */
+        rc = -EBUSY;
+        if ( !get_page(mfn_to_page(new.mfn), fdom) )
+            goto out;
+    }
+
+    if ( unlikely(p2m_is_foreign(entryptr->sa_p2mt))

&& !skip_foreign )

xen/arch/x86/mm/p2m-ept.c +12 -0
+        oldmfn = entryptr->mfn;
+
+    write_atomic(&entryptr->epte, new.epte);
+
+    if ( unlikely(oldmfn != INVALID_MFN) )
+        put_page(mfn_to_page(oldmfn));
+
+    rc = 0;
+
+ out:
+    if ( rc )
+        gdprintk(XENLOG_ERR, "epte o:%"PRIx64" n:%"PRIx64"
Quoted 8 lines

xen/arch/x86/mm/p2m-ept.c static inline bool_t is_epte_valid(ept_entry_t *e) · line 97

Quoted 4 lines

rc:%d\n",

xen/arch/x86/mm/p2m-ept.c +3 -0
+                 entryptr->epte, new.epte, rc);
+    return rc;
+}

There's still no sign of any use of is_epte_present() here, and also no mention anywhere that taking refcounts even for inaccessible entries is correct. I think this is actually okay, but the policy

I thought we now have no paths leading to that! Can you please point me to a path that this would happen for foreign type?

In the interest of saving time, are you looking-for/ok-with something like:

    unsigned int operm = entryptr->epte & 0x7, nperm = new.epte & 0x7;
    bool_t skip_foreign = (new.mfn == entryptr->mfn &&
                           new.sa_p2mt == entryptr->sa_p2mt &&
                           operm == nperm);
...
    if ( level )
    {
        ASSERT(!is_epte_superpage(&new) || !p2m_is_foreign(new.sa_p2mt));
        write_atomic(&entryptr->epte, new.epte);
        goto out;
    }

    if ( unlikely(p2m_is_foreign(new.sa_p2mt)) && !skip_foreign )
    {
        struct domain *fdom;

        rc = -EINVAL;
        if ( !mfn_valid(new.mfn) ||  !is_epte_present(&new) ) <====
            goto out;

..

thereby just rejecting non-present for foreign types.

Quoted 3 lines

entries is correct. I think this is actually okay, but the policy (refcount taken even for inaccessible pages) should be spelled out somewhere.

Can you please point to where this is spelled out for grant types? They are very similar to foreign types.

Quoted 10 lines

xen/arch/x86/mm/p2m-ept.c ept_set_entry(struct p2m_domain *p2m, · line 751

Quoted 6 lines
xen/arch/x86/mm/p2m-ept.c +1 -1
@@ -688,10 +748,10 @@ ept_set_entry(struct p2m_domain *p2m,
 unsigned long gfn, mfn_t mfn, ept_p2m_type_to_flags(&new_entry,
 p2mt, p2ma); }
 
-    atomic_write_ept_entry(ept_entry, new_entry);
+    rc = atomic_write_ept_entry(ept_entry, new_entry, target);

To me it would seem cleaner to clear old_entry here right away, so there's no confusion about it needing freeing on eventual new error paths getting added in the future.

Not sure I understand why. If the error happens only before the entry is ever written, leaving the old entry seems reasonable. IOW, if going from A to B, if there's an error, nothing is changed, A is still around. Clearing the old entry may make things worse, specially if clearing the entry needs any special handling, like clearing old refcnt etc.. Having an api change state from A to C when failing to set to B seems odd to me.

thanks
mukesh

#4 lore raw

Re: [V13 PATCH 1/2] pvh dom0: Add and remove foreign pages

Quoted 64 lines
Quoted 1 line
Quoted 1 line · On 21.05.14 at 01:46, <[email protected]> wrote:
Quoted 51 lines · On Tue, 20 May 2014 11:33:11 +0100 "Jan Beulich" <[email protected]> wrote:
Quoted 51 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 01:51, <[email protected]> wrote:

+static int atomic_write_ept_entry(ept_entry_t *entryptr, ept_entry_t new,

xen/arch/x86/mm/p2m-ept.c +10 -0
+                                  int level)
+{
+    int rc = 0;
+    unsigned long oldmfn = INVALID_MFN;
+    bool_t skip_foreign = (new.mfn == entryptr->mfn &&
+                           new.sa_p2mt == entryptr->sa_p2mt);
+
+    if ( level )
+    {
+        ASSERT(!is_epte_superpage(&new)

|| !p2m_is_foreign(new.sa_p2mt));

xen/arch/x86/mm/p2m-ept.c +24 -0
+        write_atomic(&entryptr->epte, new.epte);
+        goto out;
+    }
+
+    if ( unlikely(p2m_is_foreign(new.sa_p2mt)) && !skip_foreign )
+    {
+        struct domain *fdom;
+
+        rc = -EINVAL;
+        if ( !mfn_valid(new.mfn) )
+            goto out;
+
+        rc = -ESRCH;
+        fdom = page_get_owner(mfn_to_page(new.mfn));
+        if ( fdom == NULL )
+            goto out;
+
+        /* get refcount on the page */
+        rc = -EBUSY;
+        if ( !get_page(mfn_to_page(new.mfn), fdom) )
+            goto out;
+    }
+
+    if ( unlikely(p2m_is_foreign(entryptr->sa_p2mt))

&& !skip_foreign )

xen/arch/x86/mm/p2m-ept.c +12 -0
+        oldmfn = entryptr->mfn;
+
+    write_atomic(&entryptr->epte, new.epte);
+
+    if ( unlikely(oldmfn != INVALID_MFN) )
+        put_page(mfn_to_page(oldmfn));
+
+    rc = 0;
+
+ out:
+    if ( rc )
+        gdprintk(XENLOG_ERR, "epte o:%"PRIx64" n:%"PRIx64"
Quoted 8 lines

xen/arch/x86/mm/p2m-ept.c static inline bool_t is_epte_valid(ept_entry_t *e) · line 97

Quoted 4 lines

rc:%d\n",

xen/arch/x86/mm/p2m-ept.c +3 -0
+                 entryptr->epte, new.epte, rc);
+    return rc;
+}

There's still no sign of any use of is_epte_present() here, and also no mention anywhere that taking refcounts even for inaccessible entries is correct. I think this is actually okay, but the policy

Quoted 2 lines

I thought we now have no paths leading to that! Can you please point me to a path that this would happen for foreign type?

No I can't - as implied by the rest of the response seen below. _If_ indeed there are no such paths, a respective ASSERT() might be the way to go.

Quoted 6 lines
Quoted 3 lines

entries is correct. I think this is actually okay, but the policy (refcount taken even for inaccessible pages) should be spelled out somewhere.

Can you please point to where this is spelled out for grant types? They are very similar to foreign types.

Can you please stop using examples of bad situations as justification for adding further badness? But then again, it's Tim to decide whether he's fine with all sorts of things being implicit rather than explicit here.

Apart from that the question would need to be raised to those not having spelled out properly what the rules for grants are - considering that it's the second switch() in ept_p2m_type_to_flags() that can actually lead to non-present entries associated with a valid MFN, it's likely the addition of mem_access to blame here.

Quoted 11 lines
Quoted 10 lines

xen/arch/x86/mm/p2m-ept.c ept_set_entry(struct p2m_domain *p2m, · line 751

Quoted 6 lines
xen/arch/x86/mm/p2m-ept.c +1 -1
@@ -688,10 +748,10 @@ ept_set_entry(struct p2m_domain *p2m,
 unsigned long gfn, mfn_t mfn, ept_p2m_type_to_flags(&new_entry,
 p2mt, p2ma); }
 
-    atomic_write_ept_entry(ept_entry, new_entry);
+    rc = atomic_write_ept_entry(ept_entry, new_entry, target);

To me it would seem cleaner to clear old_entry here right away, so there's no confusion about it needing freeing on eventual new error paths getting added in the future.

Quoted 6 lines

Not sure I understand why. If the error happens only before the entry is ever written, leaving the old entry seems reasonable. IOW, if going from A to B, if there's an error, nothing is changed, A is still around. Clearing the old entry may make things worse, specially if clearing the entry needs any special handling, like clearing old refcnt etc.. Having an api change state from A to C when failing to set to B seems odd to me.

You're right with what you state, yet you apparently didn't spot that I talked about "old_entry", since all your response refers to "old entry". I.e. I was asking for the local variable to be cleared right away, not an entry in the active table.

Jan

#5 lore raw

Re: [V13 PATCH 1/2] pvh dom0: Add and remove foreign pages

Quoted 6 lines · On Wed, 21 May 2014 08:59:27 +0100 "Jan Beulich" <[email protected]> wrote:
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 21.05.14 at 01:46, <[email protected]> wrote:
Quoted 2 lines · On Tue, 20 May 2014 11:33:11 +0100 "Jan Beulich" <[email protected]> wrote:
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 01:51, <[email protected]> wrote:

+static int atomic_write_ept_entry(ept_entry_t *entryptr,

..

Quoted 24 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

+ out:

(quoted diff) +2 -0
+    if ( rc )
+        gdprintk(XENLOG_ERR, "epte o:%"PRIx64" n:%"PRIx64"

rc:%d\n",

xen/arch/x86/mm/p2m-ept.c +3 -0
+                 entryptr->epte, new.epte, rc);
+    return rc;
+}
Quoted 7 lines
Quoted 4 lines

There's still no sign of any use of is_epte_present() here, and also no mention anywhere that taking refcounts even for inaccessible entries is correct. I think this is actually okay, but the policy

I thought we now have no paths leading to that! Can you please point me to a path that this would happen for foreign type?

No I can't - as implied by the rest of the response seen below. _If_ indeed there are no such paths, a respective ASSERT() might be the way to go.

Quoted 4 lines
Quoted 3 lines

entries is correct. I think this is actually okay, but the policy (refcount taken even for inaccessible pages) should be spelled out somewhere.

Quoted 7 lines
Quoted 2 lines

Can you please point to where this is spelled out for grant types? They are very similar to foreign types.

Can you please stop using examples of bad situations as justification for adding further badness? But then again, it's Tim to decide whether he's fine with all sorts of things being implicit rather than explicit here.

I feel by just failing atomic_write_ept_entry for non-present entries we don't need to add any more is_pvh_* checks/asserts which in the past have been frowned upon.

Quoted 5 lines

Apart from that the question would need to be raised to those not having spelled out properly what the rules for grants are - considering that it's the second switch() in ept_p2m_type_to_flags() that can actually lead to non-present entries associated with a valid MFN, it's likely the addition of mem_access to blame here.

That would be denied for pvh as mem_event_enable() would fail for pvh because only param allowed to be set for pvh is HVM_PARAM_CALLBACK_IRQ.

Quoted 19 lines
Quoted 11 lines
Quoted 10 lines

xen/arch/x86/mm/p2m-ept.c ept_set_entry(struct p2m_domain *p2m, · line 751

Quoted 6 lines
xen/arch/x86/mm/p2m-ept.c +1 -1
@@ -688,10 +748,10 @@ ept_set_entry(struct p2m_domain *p2m,
 unsigned long gfn, mfn_t mfn, ept_p2m_type_to_flags(&new_entry,
 p2mt, p2ma); }
 
-    atomic_write_ept_entry(ept_entry, new_entry);
+    rc = atomic_write_ept_entry(ept_entry, new_entry, target);

To me it would seem cleaner to clear old_entry here right away, so there's no confusion about it needing freeing on eventual new error paths getting added in the future.

Quoted 7 lines

Not sure I understand why. If the error happens only before the entry is ever written, leaving the old entry seems reasonable. IOW, if going from A to B, if there's an error, nothing is changed, A is still around. Clearing the old entry may make things worse, specially if clearing the entry needs any special handling, like clearing old refcnt etc.. Having an api change state from A to C when failing to set to B seems odd to me.

Quoted 4 lines

You're right with what you state, yet you apparently didn't spot that I talked about "old_entry", since all your response refers to "old entry". I.e. I was asking for the local variable to be cleared right away, not an entry in the active table.

Sorry, my eyes missed the underscore between old and entry... According to the comment, it needs to be done after sync domain... I'd rather just leave it as is for now, I'm unable to anticipate how the function might change in future.

Sendig V14, please take a look.

thanks,
Mukesh

#6 lore raw

Re: [V13 PATCH 1/2] pvh dom0: Add and remove foreign pages

Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 22.05.14 at 03:15, <[email protected]> wrote:
Quoted 23 lines · On Wed, 21 May 2014 08:59:27 +0100 "Jan Beulich" <[email protected]> wrote:
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 21.05.14 at 01:46, <[email protected]> wrote:
Quoted 11 lines · On Tue, 20 May 2014 11:33:11 +0100 "Jan Beulich" <[email protected]> wrote:

xen/arch/x86/mm/p2m-ept.c ept_set_entry(struct p2m_domain *p2m, · line 751

Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 01:51, <[email protected]> wrote:
xen/arch/x86/mm/p2m-ept.c +1 -1
@@ -688,10 +748,10 @@ ept_set_entry(struct p2m_domain *p2m,
 unsigned long gfn, mfn_t mfn, ept_p2m_type_to_flags(&new_entry,
 p2mt, p2ma); }
 
-    atomic_write_ept_entry(ept_entry, new_entry);
+    rc = atomic_write_ept_entry(ept_entry, new_entry, target);

To me it would seem cleaner to clear old_entry here right away, so there's no confusion about it needing freeing on eventual new error paths getting added in the future.

Quoted 7 lines

Not sure I understand why. If the error happens only before the entry is ever written, leaving the old entry seems reasonable. IOW, if going from A to B, if there's an error, nothing is changed, A is still around. Clearing the old entry may make things worse, specially if clearing the entry needs any special handling, like clearing old refcnt etc.. Having an api change state from A to C when failing to set to B seems odd to me.

Quoted 4 lines

You're right with what you state, yet you apparently didn't spot that I talked about "old_entry", since all your response refers to "old entry". I.e. I was asking for the local variable to be cleared right away, not an entry in the active table.

Quoted 4 lines

Sorry, my eyes missed the underscore between old and entry... According to the comment, it needs to be done after sync domain... I'd rather just leave it as is for now, I'm unable to anticipate how the function might change in future.

I think you still didn't understand what I would like to be done:
Rather than adding an rc check to where old_entry is being checked for presence (to determine whether to call ept_free_entry() - that check is pointless anyway) I'd like you to zap old_entry (read: old_entry.epte = 0) right away when the above atomic_write_ept_entry() fails.

Jan

#7 lore raw

Re: [V13 PATCH 1/2] pvh dom0: Add and remove foreign pages

Quoted 37 lines · On Thu, 22 May 2014 08:33:47 +0100 "Jan Beulich" <[email protected]> wrote:
Quoted 32 lines
Quoted 1 line
Quoted 1 line · On 22.05.14 at 03:15, <[email protected]> wrote:
Quoted 24 lines · On Wed, 21 May 2014 08:59:27 +0100 "Jan Beulich" <[email protected]> wrote:
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 21.05.14 at 01:46, <[email protected]> wrote:
Quoted 5 lines · On Tue, 20 May 2014 11:33:11 +0100 "Jan Beulich" <[email protected]> wrote:
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 01:51, <[email protected]> wrote:
(quoted diff) +0 -0
@@ -688,10 +748,10 @@ ept_set_entry(struct p2m_domain *p2m,
 unsigned long gfn, mfn_t mfn,
 ept_p2m_type_to_flags(&new_entry, p2mt, p2ma); }
 
Quoted 7 lines

Review ept_set_entry(struct p2m_domain *p2m, · line 752

Quoted 3 lines
(quoted diff) +1 -1
-    atomic_write_ept_entry(ept_entry, new_entry);
+    rc = atomic_write_ept_entry(ept_entry, new_entry,
 target);

To me it would seem cleaner to clear old_entry here right away, so there's no confusion about it needing freeing on eventual new error paths getting added in the future.

Quoted 7 lines

Not sure I understand why. If the error happens only before the entry is ever written, leaving the old entry seems reasonable. IOW, if going from A to B, if there's an error, nothing is changed, A is still around. Clearing the old entry may make things worse, specially if clearing the entry needs any special handling, like clearing old refcnt etc.. Having an api change state from A to C when failing to set to B seems odd to me.

Quoted 4 lines

You're right with what you state, yet you apparently didn't spot that I talked about "old_entry", since all your response refers to "old entry". I.e. I was asking for the local variable to be cleared right away, not an entry in the active table.

Quoted 4 lines

Sorry, my eyes missed the underscore between old and entry... According to the comment, it needs to be done after sync domain... I'd rather just leave it as is for now, I'm unable to anticipate how the function might change in future.

Quoted 9 lines

I think you still didn't understand what I would like to be done:
Rather than adding an rc check to where old_entry is being checked for presence (to determine whether to call ept_free_entry() - that check is pointless anyway) I'd like you to zap old_entry (read: old_entry.epte = 0) right away when the above atomic_write_ept_entry() fails.

Jan

Got it. V15 with that change.

thanks,
mukesh

#8 lore raw

PATCH v13 2/2 dom0: add opt_dom0pvh to setup.c

In reply to Mukesh Rathor

Finally last patch in the series to enable creation of pvh dom0. A pvh dom0 is created by adding dom0pvh to grub xen command line.

---
 docs/misc/pvh-readme.txt            |  2 ++
 docs/misc/xen-command-line.markdown |  7 +++++++
 xen/arch/x86/setup.c                | 11 +++++++++--
 3 files changed, 18 insertions(+), 2 deletions(-)
docs/misc/pvh-readme.txt +2 -0
index 9fea137..c5b3de4 100644
@@ -37,6 +37,8 @@ supported. Phase I patches are broken into three parts:
    - tools changes for creating a PVH guest
    - boot of 64bit dom0 in PVH mode.
 
+To boot 64bit dom0 in PVH mode, add dom0pvh to grub xen command line.
+
 Following fixme's exist in the code:
   - arch/x86/time.c: support more tsc modes.
 
docs/misc/xen-command-line.markdown +7 -0
index a7ac53d..b45ba7e 100644
@@ -494,6 +494,13 @@ Practices](http://wiki.xen.org/wiki/Xen_Best_Practices#Xen_dom0_dedicated_memory
 
 Pin dom0 vcpus to their respective pcpus
 
+### dom0pvh
+> `= <boolean>`
+
+> Default: `false`
+
+Flag that makes a 64bit dom0 boot in PVH mode. No 32bit support at present.
+
 ### e820-mtrr-clip
 > `= <boolean>`
 
xen/arch/x86/setup.c +9 -2
index d8598a3..8e9db9e 100644
@@ -65,6 +65,10 @@ invbool_param("smep", disable_smep);
 static bool_t __initdata disable_smap;
 invbool_param("smap", disable_smap);
 
+/* Boot dom0 in pvh mode */
+static bool_t __initdata opt_dom0pvh;
+boolean_param("dom0pvh", opt_dom0pvh);
+
 /* **** Linux config option: propagated to domain0. */
 /* "acpi=off":    Sisables both ACPI table parsing and interpreter. */
 /* "acpi=force":  Override the disable blacklist.                   */
@@ -545,7 +549,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
 {
     char *memmap_type = NULL;
     char *cmdline, *kextra, *loader;
-    unsigned int initrdidx;
+    unsigned int initrdidx, domcr_flags = DOMCRF_s3_integrity;
     multiboot_info_t *mbi = __va(mbi_p);
     module_t *mod = (module_t *)__va(mbi->mods_addr);
     unsigned long nr_pages, raw_max_page, modules_headroom, *module_map;
@@ -1347,8 +1351,11 @@ void __init noreturn __start_xen(unsigned long mbi_p)
     if ( !tboot_protect_mem_regions() )
         panic("Could not protect TXT memory regions");
 
+    if ( opt_dom0pvh )
+        domcr_flags |= DOMCRF_pvh | DOMCRF_hap;
+
     /* Create initial domain 0. */
-    dom0 = domain_create(0, DOMCRF_s3_integrity, 0);
+    dom0 = domain_create(0, domcr_flags, 0);
     if ( IS_ERR(dom0) || (alloc_dom0_vcpu0(dom0) == NULL) )
         panic("Error creating domain 0");
 
Signature · 1 line
1.8.3.1
#9 lore raw
In reply to Mukesh Rathor
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 20.05.14 at 01:51, <[email protected]> wrote:

Attached please find v13 of dom0 pvh patch series based on c/s: 11dba84.

I continue to be confused by these statements: Saying that a series is based on a week old c/s may mean two things - either it is not meant to be applied even if otherwise considered good (in which case I would think it should be marked RFC), or it is meant to be applied and you leave it to the eventual committer to find out if it actually applies (which isn't really the way things ought to work, i.e. it should be you to make sure that it still applies fine to the tip of the tree at the time of submission and no other conflicting changes went in). Please clarify.

Jan

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

Hi,

Attached please find v13 of dom0 pvh patch series based on c/s: 11dba84.

git tree: git://oss.oracle.com/git/mrathor/xen.git branch: dom0pvh-v13

I think you forgot to push the series to the git repo (or at least I'm not able to see branch dom0pvh-v13).

Thanks, Roger.

#11 lore raw
Quoted 10 lines · Roger Pau Monné
Quoted 6 lines · Mukesh Rathor

Hi,

Attached please find v13 of dom0 pvh patch series based on c/s: 11dba84.

git tree: git://oss.oracle.com/git/mrathor/xen.git branch: dom0pvh-v13

I think you forgot to push the series to the git repo (or at least I'm not able to see branch dom0pvh-v13).

Also a Linux branch that works as PVH Dom0 would be interesting to me, since I've been hitting the vioapic crash when creating HVM guests with Linux 3.14 plus your patch to map foreign memory.

Roger.

#12 lore raw
Quoted 7 lines · On Thu, 22 May 2014 20:19:54 +0200 Roger Pau Monné <[email protected]> wrote:
Quoted 6 lines · Roger Pau Monné
Quoted 5 lines · Mukesh Rathor

Hi,

Attached please find v13 of dom0 pvh patch series based on c/s: 11dba84.

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

git tree: git://oss.oracle.com/git/mrathor/xen.git branch:
dom0pvh-v13

I think you forgot to push the series to the git repo (or at least I'm not able to see branch dom0pvh-v13).

Also a Linux branch that works as PVH Dom0 would be interesting to me,

Hey Roger,

git://oss.oracle.com/git/mrathor/xen.git branch: dom0pvh-v15
git://oss.oracle.com/git/mrathor/linux.git branch: dom0pvh-1

Quoted 1 line

since I've been hitting the vioapic crash when creating HVM guests

Just apply following patch to get around vioapic crash so you can debug your real ept issue:

xen/arch/x86/hvm/hvm.c +5 -0
index b69f164..c687d18 100644
@@ -2079,6 +2079,11 @@ int hvm_hap_nested_page_fault(paddr_t gpa,
          (access_w && (p2mt == p2m_ram_ro)) )
     {
         put_gfn(p2m->domain, gfn);
+
+        rc = 0;
+        if ( unlikely(is_pvh_vcpu(v)) )
+            goto out;
+
         if ( !handle_mmio() )
             hvm_inject_hw_exception(TRAP_gp_fault, 0);
         rc = 1;

thanks,
Mukesh

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

#13 lore raw
Quoted 19 lines · Mukesh Rathor
Quoted 7 lines · On Thu, 22 May 2014 20:19:54 +0200 Roger Pau Monné <[email protected]> wrote:
Quoted 6 lines · Roger Pau Monné
Quoted 5 lines · Mukesh Rathor

Hi,

Attached please find v13 of dom0 pvh patch series based on c/s: 11dba84.

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

git tree: git://oss.oracle.com/git/mrathor/xen.git branch:
dom0pvh-v13

I think you forgot to push the series to the git repo (or at least I'm not able to see branch dom0pvh-v13).

Also a Linux branch that works as PVH Dom0 would be interesting to me,

Hey Roger,

Quoted 7 lines

git://oss.oracle.com/git/mrathor/xen.git branch: dom0pvh-v15
git://oss.oracle.com/git/mrathor/linux.git branch: dom0pvh-1

Quoted 1 line

since I've been hitting the vioapic crash when creating HVM guests

Just apply following patch to get around vioapic crash so you can debug your real ept issue:

Thanks, I think your Linux side patch is missing something like:

arch/x86/xen/mmu.c +0 -0
index 8efc066..690b289 100644
@@ -2533,7 +2533,7 @@ static int xlate_add_to_p2m(unsigned long lpfn,

unsigned long fgmfn,

        set_xen_guest_handle(xatp.errs, &err);

        rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap_range, &xatp);

- return rc;
+ return rc ? : err;
}

Or else the error value is lost and Linux thinks this page is actually mapped when it is not, trigger the vioapic crash when trying to access it. Without this fix I cannot boot HVM domains, with the fix it seems to be quite stable AFAICT.

Roger.

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