pvh dom0 patches...
v15 cover pvh dom0 patches...
Hi,
Attached please find v15 of dom0 pvh patch series.
Changes from V14:
- In ept_set_entry, check for rc after call to atomic_write_ept_entry and clear old_entry if error.
Tim, would like to get your ack/nack/comments on this please...
thanks,
Mukesh
PATCH v15 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 | 104 +++++++++++++++++++++++++++++------- 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, 233 insertions(+), 26 deletions(-)
xen/arch/x86/mm.c +3 -1
@@ -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
@@ -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 +86 -18
212 lines not on this page · raw message
xen/arch/x86/mm/p2m-pt.c +7 -0
@@ -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
@@ -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
Re: [V15 PATCH 1/2] pvh dom0: Add and remove foreign pages
xen/arch/x86/mm/p2m-ept.c ept_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, · line 758
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 23.05.14 at 01:30, <[email protected]> wrote:
xen/arch/x86/mm/p2m-ept.c +2
-1@@ -688,10 +754,12 @@ 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); +if ( rc )
This should have unlikely() ...
xen/arch/x86/mm/p2m-ept.c ept_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, · line 762
Quoted 5 lines
xen/arch/x86/mm/p2m-ept.c +2
-1+ old_entry.epte =0 ;/* Track the highest gfn for which we have ever had a valid mapping */ - if ( p2mt != p2m_invalid && + if ( rc == 0 && p2mt != p2m_invalid &&
... and this would then better be "else if()". Both of which could be adjusted while committing. Beyond that all that's left is to have Tim's approval.
Jan
Re: [V15 PATCH 1/2] pvh dom0: Add and remove foreign pages
In reply to Mukesh RathorQuoted 13 lines · Mukesh Rathor
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 typedp2m_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 functionatomic_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.
Quoted 1 line
Also, we change
get_pg_ownerso it allows foreign mappings for pvh.
But you no longer actually call get_pg_owner() for PVH domains, right? So that hunk should go away. With that done,
Cheers,
Tim.
Re: [V15 PATCH 1/2] pvh dom0: Add and remove foreign pages
Quoted 14 lines · On Fri, 23 May 2014 21:05:34 +0200 Tim Deegan <[email protected]> wrote:
Quoted 13 lines · Mukesh Rathor
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 typedp2m_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 functionatomic_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.
Quoted 4 lines
Quoted 1 line
Also, we change
get_pg_ownerso it allows foreign mappings for pvh.But you no longer actually call
get_pg_owner()for PVH domains, right? So that hunk should go away. With that done,
Hi Tim,
We actually need get_pg_owner for the mmuext call by the toolstack when building a PV domain, doing pinning operations on the guest table.
Alternates would be to call rcu directly in do_mmuext_op:
if ( pvh )
if ( DOMID_SELF )
rcu_lock_current_domain
else if ( DOMID_IO || DOMID_XEN )
error
else
rcu_lock_domain_by_id
else
get_pg_owner
OR, if you prefer in get_pg_owner():
..
case DOMID_IO:
if ( !is_pvh_domain(curr) )
pg_owner = rcu_lock_domain(dom_io);
break; ...
Please lmk asap: leave as is, first suggestion above, or second suggestion above.
thanks a lot,
mukesh
Re: [V15 PATCH 1/2] pvh dom0: Add and remove foreign pages
Quoted 19 lines · Mukesh Rathor
Quoted 16 lines · On Fri, 23 May 2014 21:05:34 +0200 Tim Deegan <[email protected]> wrote:
Quoted 14 lines · Mukesh Rathor
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 typedp2m_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 functionatomic_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_ownerso it allows foreign mappings for pvh.
Quoted 7 lines
Quoted 2 lines
But you no longer actually call
get_pg_owner()for PVH domains, right? So that hunk should go away. With that done,Hi Tim,
We actually need
get_pg_ownerfor the mmuext call by the toolstack when building a PV domain, doing pinning operations on the guest table.
Ah, I see. Let's handle that in a separate patch then, since it's now unrelated to foreign mappings in PVH any more.
Having the change where it is seems fine, but I think the correct test is (is_pv() && paging_mode_translate()) rather than (!is_pvh() && paging_mode_translate()) -- it's a weakness of the PV pagetable ops that's being avoided here, rather than any special treatment for PVH.
Cheers,
Tim.
Re: [V15 PATCH 1/2] pvh dom0: Add and remove foreign pages
Quoted 31 lines · On Sat, 24 May 2014 01:08:49 +0200 Tim Deegan <[email protected]> wrote:
Quoted 21 lines · Mukesh Rathor
Quoted 18 lines · On Fri, 23 May 2014 21:05:34 +0200 Tim Deegan <[email protected]> wrote:
Quoted 16 lines · Mukesh Rathor
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 typedp2m_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 functionatomic_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_ownerso it allows foreign mappings for pvh.Quoted 8 lines
Quoted 2 lines
But you no longer actually call
get_pg_owner()for PVH domains, right? So that hunk should go away. With that done,Hi Tim,
We actually need
get_pg_ownerfor the mmuext call by the toolstack when building a PV domain, doing pinning operations on the guest table.
Quoted 7 lines
Ah, I see. Let's handle that in a separate patch then, since it's now unrelated to foreign mappings in PVH any more.
Having the change where it is seems fine, but I think the correct test is (
is_pv()&&paging_mode_translate()) rather than (!is_pvh() &&paging_mode_translate()) -- it's a weakness of the PV pagetable ops that's being avoided here, rather than any special treatment for PVH.
Good point, but Jan had a concern on that when I had dropped the if statement completely, that it would allow HVM guests to go thru. Hence !is_pvh to let hvm guest continue to fail.
thanks,
mukesh
Re: [V15 PATCH 1/2] pvh dom0: Add and remove foreign pages
Quoted 38 lines
Quoted 1 line
Quoted 1 line · On 24.05.14 at 01:50, <[email protected]> wrote:
Quoted 34 lines · On Sat, 24 May 2014 01:08:49 +0200 Tim Deegan <[email protected]> wrote:
Quoted 21 lines · Mukesh Rathor
Quoted 18 lines · On Fri, 23 May 2014 21:05:34 +0200 Tim Deegan <[email protected]> wrote:
Quoted 16 lines · Mukesh Rathor
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 typedp2m_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 functionatomic_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_ownerso it allows foreign mappings for pvh.Quoted 8 lines
Quoted 2 lines
But you no longer actually call
get_pg_owner()for PVH domains, right? So that hunk should go away. With that done,Hi Tim,
We actually need
get_pg_ownerfor the mmuext call by the toolstack when building a PV domain, doing pinning operations on the guest table.Ah, I see. Let's handle that in a separate patch then, since it's now unrelated to foreign mappings in PVH any more.
Quoted 8 lines
Quoted 4 lines
Having the change where it is seems fine, but I think the correct test is (
is_pv()&&paging_mode_translate()) rather than (!is_pvh() &&paging_mode_translate()) -- it's a weakness of the PV pagetable ops that's being avoided here, rather than any special treatment for PVH.Good point, but Jan had a concern on that when I had dropped the if statement completely, that it would allow HVM guests to go thru. Hence !is_pvh to let hvm guest continue to fail.
The same would be achieved by using is_pv as Tim suggested.
Jan
Re: [V15 PATCH 1/2] pvh dom0: Add and remove foreign pages
Quoted 44 lines · On Mon, 26 May 2014 10:24:01 +0100 "Jan Beulich" <[email protected]> wrote:
Quoted 44 lines
Quoted 1 line
Quoted 1 line · On 24.05.14 at 01:50, <[email protected]> wrote:
Quoted 39 lines · On Sat, 24 May 2014 01:08:49 +0200 Tim Deegan <[email protected]> wrote:
Quoted 21 lines · Mukesh Rathor
Quoted 18 lines · On Fri, 23 May 2014 21:05:34 +0200 Tim Deegan <[email protected]> wrote:
Quoted 16 lines · Mukesh Rathor
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 typedp2m_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 functionatomic_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_ownerso it allows foreign mappings for pvh.Quoted 8 lines
Quoted 2 lines
But you no longer actually call
get_pg_owner()for PVH domains, right? So that hunk should go away. With that done,Hi Tim,
We actually need
get_pg_ownerfor the mmuext call by the toolstack when building a PV domain, doing pinning operations on the guest table.Ah, I see. Let's handle that in a separate patch then, since it's now unrelated to foreign mappings in PVH any more.
Having the change where it is seems fine, but I think the correct test is (
is_pv()&&paging_mode_translate()) rather than (!is_pvh() &&paging_mode_translate()) -- it's a weakness of the PV pagetable ops that's being avoided here, rather than any special treatment for PVH.
Quoted 5 lines
Quoted 3 lines
Good point, but Jan had a concern on that when I had dropped the if statement completely, that it would allow HVM guests to go thru. Hence !is_pvh to let hvm guest continue to fail.
The same would be achieved by using
is_pvas Tim suggested.
So sorry, but I don't understand how:
if ( is_pv_domain(curr) && unlikely(paging_mode_translate(curr)) )
{
MEM_LOG("Cannot mix foreign mappings with translated domains");
goto out;
}will cause this error for hvm, which is what happens now without my change, or will continue to with my proposed change:
if ( !is_pvh_domain(curr) && unlikely(paging_mode_translate(curr)) )
{
MEM_LOG("Cannot mix foreign mappings with translated domains");..
I understand your suggestion earlier was that hvm should continue to fail.
Also, my understanding is that pv domains are never translated?
thanks
mukesh
Re: [V15 PATCH 1/2] pvh dom0: Add and remove foreign pages
Quoted 32 lines
Quoted 1 line
Quoted 1 line · On 28.05.14 at 02:51, <[email protected]> wrote:
Quoted 9 lines · On Mon, 26 May 2014 10:24:01 +0100 "Jan Beulich" <[email protected]> wrote:
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 24.05.14 at 01:50, <[email protected]> wrote:
Quoted 5 lines · On Sat, 24 May 2014 01:08:49 +0200 Tim Deegan <[email protected]> wrote:
Having the change where it is seems fine, but I think the correct test is (
is_pv()&&paging_mode_translate()) rather than (!is_pvh() &&paging_mode_translate()) -- it's a weakness of the PV pagetable ops that's being avoided here, rather than any special treatment for PVH.Quoted 5 lines
Quoted 3 lines
Good point, but Jan had a concern on that when I had dropped the if statement completely, that it would allow HVM guests to go thru. Hence !is_pvh to let hvm guest continue to fail.
The same would be achieved by using
is_pvas Tim suggested.So sorry, but I don't understand how:
if ( is_pv_domain(curr) && unlikely(paging_mode_translate(curr)) ) { MEM_LOG("Cannot mix foreign mappings with translated domains"); goto out; }will cause this error for hvm, which is what happens now without my change, or will continue to with my proposed change:
if ( !is_pvh_domain(curr) && unlikely(paging_mode_translate(curr)) ) { MEM_LOG("Cannot mix foreign mappings with translated domains");
Quoted 6 lines
..
I understand your suggestion earlier was that hvm should continue to fail.
Also, my understanding is that pv domains are never translated?
Hmm, indeed, good point. I wonder whether the whole condition shouldn't simply become !is_hvm() then (and perhaps the log message adjusted accordingly). Tim?
Jan
Re: [V15 PATCH 1/2] pvh dom0: Add and remove foreign pages
Quoted 35 lines · Jan Beulich
Quoted 35 lines
Quoted 1 line
Quoted 1 line · On 28.05.14 at 02:51, <[email protected]> wrote:
Quoted 9 lines · On Mon, 26 May 2014 10:24:01 +0100 "Jan Beulich" <[email protected]> wrote:
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 24.05.14 at 01:50, <[email protected]> wrote:
Quoted 5 lines · On Sat, 24 May 2014 01:08:49 +0200 Tim Deegan <[email protected]> wrote:
Having the change where it is seems fine, but I think the correct test is (
is_pv()&&paging_mode_translate()) rather than (!is_pvh() &&paging_mode_translate()) -- it's a weakness of the PV pagetable ops that's being avoided here, rather than any special treatment for PVH.Quoted 5 lines
Quoted 3 lines
Good point, but Jan had a concern on that when I had dropped the if statement completely, that it would allow HVM guests to go thru. Hence !is_pvh to let hvm guest continue to fail.
The same would be achieved by using
is_pvas Tim suggested.So sorry, but I don't understand how:
if ( is_pv_domain(curr) && unlikely(paging_mode_translate(curr)) ) { MEM_LOG("Cannot mix foreign mappings with translated domains"); goto out; }will cause this error for hvm, which is what happens now without my change, or will continue to with my proposed change:
if ( !is_pvh_domain(curr) && unlikely(paging_mode_translate(curr)) ) { MEM_LOG("Cannot mix foreign mappings with translated domains");..
Quoted 7 lines
Quoted 3 lines
I understand your suggestion earlier was that hvm should continue to fail.
Also, my understanding is that pv domains are never translated?
Hmm, indeed, good point. I wonder whether the whole condition shouldn't simply become !is_hvm() then (and perhaps the log message adjusted accordingly). Tim?
I'll have to trawl the history to see where this came from, but AFAIK the worry is for old-style PV+translate, where if we let a guest put foreign mappings directly in its pagetables they would fail p2m lookups in the shadow code when trying to translate them.
So we could:
- check (is_pv && paging_mode_translate), as I suggested before; or
- check (paging_mode_translate && !paging_mode_refcounts), which is a bit more idiomatic and more closely describes the problem; or
- not check at all, since PVH has entirely replaced even the partial support for PV+translate that was there before.
In any case, I don't think we should be using is_pvh or is_hvm here, since they've got effectively the same memory management. But I could live with it as an intermediate measure to defer checking e.g. shadow pagetable support...
For further confusion, get_pg_owner is really for foreign mappings but is reused on the mmuext op path, where the caller is adjusting the foreign domain's pagetables and not its own. There this test is pointless since the state of the _caller's_ pagetables doesn't matter. And _that's_ the case that Mukesh needs to relax for PVH dom0. So it would also be OK (if a bit ugly) to move this check into the other two callers of the function and just not have it for mmuext_op.
Tim.
Re: [V15 PATCH 1/2] pvh dom0: Add and remove foreign pages
In reply to Mukesh RathorQuoted 37 lines · Mukesh Rathor
Quoted 34 lines · On Sat, 24 May 2014 01:08:49 +0200 Tim Deegan <[email protected]> wrote:
Quoted 21 lines · Mukesh Rathor
Quoted 18 lines · On Fri, 23 May 2014 21:05:34 +0200 Tim Deegan <[email protected]> wrote:
Quoted 16 lines · Mukesh Rathor
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 typedp2m_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 functionatomic_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_ownerso it allows foreign mappings for pvh.Quoted 8 lines
Quoted 2 lines
But you no longer actually call
get_pg_owner()for PVH domains, right? So that hunk should go away. With that done,Hi Tim,
We actually need
get_pg_ownerfor the mmuext call by the toolstack when building a PV domain, doing pinning operations on the guest table.Ah, I see. Let's handle that in a separate patch then, since it's now unrelated to foreign mappings in PVH any more.
Quoted 8 lines
Quoted 4 lines
Having the change where it is seems fine, but I think the correct test is (
is_pv()&&paging_mode_translate()) rather than (!is_pvh() &&paging_mode_translate()) -- it's a weakness of the PV pagetable ops that's being avoided here, rather than any special treatment for PVH.Good point, but Jan had a concern on that when I had dropped the if statement completely, that it would allow HVM guests to go thru. Hence !is_pvh to let hvm guest continue to fail.
Well, in that case I don't insist on it. I'll look at it again as part of the PVH->HVM merge.
Tim.
Re: [V15 PATCH 1/2] pvh dom0: Add and remove foreign pages
Quoted 45 lines · On Wed, 28 May 2014 12:06:35 +0200 Tim Deegan <[email protected]> wrote:
Quoted 44 lines · Mukesh Rathor
Quoted 40 lines · On Sat, 24 May 2014 01:08:49 +0200 Tim Deegan <[email protected]> wrote:
Quoted 22 lines · Mukesh Rathor
Quoted 19 lines · On Fri, 23 May 2014 21:05:34 +0200 Tim Deegan <[email protected]> wrote:
Quoted 17 lines · Mukesh Rathor
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 typedp2m_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 functionatomic_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_ownerso it allows foreign mappings for pvh.Quoted 8 lines
Quoted 2 lines
But you no longer actually call
get_pg_owner()for PVH domains, right? So that hunk should go away. With that done,Hi Tim,
We actually need
get_pg_ownerfor the mmuext call by the toolstack when building a PV domain, doing pinning operations on the guest table.Ah, I see. Let's handle that in a separate patch then, since it's now unrelated to foreign mappings in PVH any more.
Having the change where it is seems fine, but I think the correct test is (
is_pv()&&paging_mode_translate()) rather than (!is_pvh() &&paging_mode_translate()) -- it's a weakness of the PV pagetable ops that's being avoided here, rather than any special treatment for PVH.
Quoted 6 lines
Quoted 3 lines
Good point, but Jan had a concern on that when I had dropped the if statement completely, that it would allow HVM guests to go thru. Hence !is_pvh to let hvm guest continue to fail.
Well, in that case I don't insist on it. I'll look at it again as part of the
PVH->HVMmerge.
I think that would be better, as there are several options you mentioned in the other email, and some of it is cleanup not pvh related. For now I'll just add the !is_pvh check, so that hvm guests will continue to be restricted. Please ack the patch in V16 on its way. If you prefer ( is_pv && paging) instead, I don't mind you just changing it during commit either, if hvm going thru is not an issue.
thanks
Mukesh
PATCH v15 2/2 dom0: add opt_dom0pvh to setup.c
In reply to Mukesh RathorFinally 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
@@ -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
@@ -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
@@ -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. */
@@ -539,7 +543,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;
@@ -1345,8 +1349,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