pvh dom0 patches...
v14 cover pvh dom0 patches...
Hi,
Attached please find v14 of dom0 pvh patch series.
Changes from V13:
- In atomic_write_ept_entry, prohibit addition of foreign types if entry is not present.
thanks,
Mukesh
PATCH v14 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, 232 insertions(+), 27 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 +85 -19
218 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
PATCH v14 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