: Fixup error codes in some p2m paths.
cover : Fixup error codes in some p2m paths.
Hi,
In reference to our discussion on propogating error codes here
http://osdir.com/ml/general/2014-04/msg13083.html
please find the patches. Built on c/s: ac0f56a.
thanks
Mukesh
PATCH 1/3 Rename public functions in p2m-pt.c
This patch renames "public" functions in p2m-pt.c. In addition to making them more descriptive, it also frees up "p2m_set_entry" name to be used later. This patch doesn't change any functionality.
--- xen/arch/x86/mm/p2m-pt.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
xen/arch/x86/mm/p2m-pt.c +10 -10
@@ -277,8 +277,8 @@ p2m_next_level(struct p2m_domain *p2m, mfn_t *table_mfn, void **table,// Returns 0 on error (out of memory) static int -p2m_set_entry (struct p2m_domain *p2m,unsigned long gfn,mfn_t mfn, -unsigned int page_order,p2m_type_t p2mt,p2m_access_t p2ma) +p2m_pt_set_entry (struct p2m_domain *p2m,unsigned long gfn,mfn_t mfn, +unsigned int page_order,p2m_type_t p2mt,p2m_access_t p2ma) {// XXX -- this might be able to be faster iff current->domain == d mfn_t table_mfn =pagetable_get_mfn (p2m_get_pagetable (p2m));
@@ -461,9 +461,9 @@ out: }static mfn_t -p2m_gfn_to_mfn (struct p2m_domain *p2m,unsigned long gfn, -p2m_type_t *t,p2m_access_t *a,p2m_query_t q, -unsigned int *page_order) +p2m_pt_gfn_to_mfn (struct p2m_domain *p2m,unsigned long gfn, +p2m_type_t *t,p2m_access_t *a,p2m_query_t q, +unsigned int *page_order) {mfn_t mfn;paddr_t addr = ((paddr_t )gfn) <<PAGE_SHIFT ;
@@ -604,8 +604,8 @@ pod_retry_l1:/* Walk the whole p2m table, changing any entries of the old type * to the new type. This is used in hardware-assisted paging to * quickly enable or diable log-dirty tracking */ -static void p2m_change_type_global (struct p2m_domain *p2m, -p2m_type_t ot,p2m_type_t nt) +static void p2m_pt_change_type_global (struct p2m_domain *p2m, +p2m_type_t ot,p2m_type_t nt) {unsigned long mfn, gfn, flags;l1_pgentry_t l1e_content;
@@ -870,9 +870,9 @@ long p2m_pt_audit_p2m(struct p2m_domain *p2m)/* Set up the p2m function pointers for pagetable format */ void p2m_pt_init (struct p2m_domain *p2m) { - p2m->set_entry = p2m_set_entry; - p2m->get_entry = p2m_gfn_to_mfn; - p2m->change_entry_type_global = p2m_change_type_global; + p2m->set_entry = p2m_pt_set_entry; + p2m->get_entry = p2m_pt_gfn_to_mfn; + p2m->change_entry_type_global = p2m_pt_change_type_global; p2m->write_p2m_entry = paging_write_p2m_entry;#if P2M_AUDIT p2m->audit_p2m = p2m_pt_audit_p2m;
Signature · 1 line
1.8.3.1
Re: [V1 PATCH 1/3] Rename public functions in p2m-pt.c
xen/arch/x86/mm/p2m-pt.c long p2m_pt_audit_p2m(struct p2m_domain *p2m) · line 874
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 09.04.14 at 03:47, <[email protected]> wrote:
xen/arch/x86/mm/p2m-pt.c +2
-3@@ -870,9 +870,9 @@ long p2m_pt_audit_p2m(struct p2m_domain *p2m)/* Set up the p2m function pointers for pagetable format */ void p2m_pt_init (struct p2m_domain *p2m) { - p2m->set_entry = p2m_set_entry; - p2m->get_entry = p2m_gfn_to_mfn; - p2m->change_entry_type_global = p2m_change_type_global; + p2m->set_entry = p2m_pt_set_entry; + p2m->get_entry = p2m_pt_gfn_to_mfn;
Considering the left side of this, I'd prefer the function to be named p2m_pt_get_entry, allowing all variants to be found with e.g. a suitable expression passed to grep.
Jan
PATCH 2/3 Rename "set_p2m_entry" to "p2m_set_entry"
In reply to Mukesh RathorThis patch renames set_p2m_entry defined in arch/x86/mm/p2m.c to p2m_set_entry which makes it consistent with other functions from that file. It also facilitates changing the function signature to return approriate errno for failure cases. This patch doesn't change any functionality.
--- xen/arch/x86/mm/hap/nested_hap.c | 2 +- xen/arch/x86/mm/mem_sharing.c | 2 +- xen/arch/x86/mm/p2m-pod.c | 32 +++++++++++++++------------ xen/arch/x86/mm/p2m.c | 47 ++++++++++++++++++++++------------------ xen/include/asm-x86/p2m.h | 2 +- 5 files changed, 47 insertions(+), 38 deletions(-)
xen/arch/x86/mm/hap/nested_hap.c +1 -1
@@ -124,7 +124,7 @@ nestedhap_fix_p2m(struct vcpu *v, struct p2m_domain *p2m, gfn = (L2_gpa >>PAGE_SHIFT ) & mask; mfn =_mfn ((L0_gpa >>PAGE_SHIFT ) & mask); - rv =set_p2m_entry (p2m, gfn, mfn, page_order, p2mt, p2ma); + rv =p2m_set_entry (p2m, gfn, mfn, page_order, p2mt, p2ma); }p2m_unlock (p2m);
xen/arch/x86/mm/mem_sharing.c +1 -1
@@ -1092,7 +1092,7 @@ int mem_sharing_add_to_physmap(struct domain *sd, unsigned long sgfn, shr_handle goto err_unlock; } - ret =set_p2m_entry (p2m, cgfn, smfn,PAGE_ORDER_4K , p2m_ram_shared, a); + ret =p2m_set_entry (p2m, cgfn, smfn,PAGE_ORDER_4K , p2m_ram_shared, a);/* Tempted to turn this into an assert */ if ( !ret )
xen/arch/x86/mm/p2m-pod.c +18 -14
@@ -556,7 +556,8 @@ recount: {/* All PoD: Mark the whole region invalid and tell caller * we're done. */ -set_p2m_entry (p2m, gpfn,_mfn (INVALID_MFN ), order, p2m_invalid, p2m->default_access); +p2m_set_entry (p2m, gpfn,_mfn (INVALID_MFN ), order, p2m_invalid, + p2m->default_access); p2m->pod.entry_count-=(1 <<order);BUG_ON (p2m->pod.entry_count <0 ); ret =1 ;
@@ -589,7 +590,8 @@ recount: mfn = p2m->get_entry (p2m, gpfn + i, &t, &a,0 ,NULL );if ( t == p2m_populate_on_demand ) { -set_p2m_entry (p2m, gpfn + i,_mfn (INVALID_MFN ),0 , p2m_invalid, p2m->default_access); +p2m_set_entry (p2m, gpfn + i,_mfn (INVALID_MFN ),0 , p2m_invalid, + p2m->default_access); p2m->pod.entry_count--;BUG_ON (p2m->pod.entry_count <0 ); pod--;
@@ -602,7 +604,8 @@ recount: page =mfn_to_page (mfn); -set_p2m_entry (p2m, gpfn + i,_mfn (INVALID_MFN ),0 , p2m_invalid, p2m->default_access); +p2m_set_entry (p2m, gpfn + i,_mfn (INVALID_MFN ),0 , p2m_invalid, + p2m->default_access);set_gpfn_from_mfn (mfn_x (mfn),INVALID_M2P_ENTRY );p2m_pod_cache_add (p2m, page,0 );
@@ -721,7 +724,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) }/* Try to remove the page, restoring old mapping if it fails. */ -set_p2m_entry (p2m, gfn,_mfn (0 ),PAGE_ORDER_2M , +p2m_set_entry (p2m, gfn,_mfn (0 ),PAGE_ORDER_2M , p2m_populate_on_demand, p2m->default_access);/* Make none of the MFNs are used elsewhere... for example, mapped
@@ -779,7 +782,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) out_reset:if ( reset ) -set_p2m_entry (p2m, gfn, mfn0,9 , type0, p2m->default_access); +p2m_set_entry (p2m, gfn, mfn0,9 , type0, p2m->default_access); out:gfn_unlock (p2m, gfn,SUPERPAGE_ORDER );
@@ -837,7 +840,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) }/* Try to remove the page, restoring old mapping if it fails. */ -set_p2m_entry (p2m, gfns[i],_mfn (0 ),PAGE_ORDER_4K , +p2m_set_entry (p2m, gfns[i],_mfn (0 ),PAGE_ORDER_4K , p2m_populate_on_demand, p2m->default_access);/* See if the page was successfully unmapped. (Allow one refcount
@@ -847,7 +850,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count)unmap_domain_page (map[i]); map[i] =NULL ; -set_p2m_entry (p2m, gfns[i], mfns[i],PAGE_ORDER_4K , +p2m_set_entry (p2m, gfns[i], mfns[i],PAGE_ORDER_4K , types[i], p2m->default_access);continue ;
@@ -870,7 +873,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count)* check timing. */ if ( j <PAGE_SIZE /sizeof (*map[i]) ) { -set_p2m_entry (p2m, gfns[i], mfns[i],PAGE_ORDER_4K , +p2m_set_entry (p2m, gfns[i], mfns[i],PAGE_ORDER_4K , types[i], p2m->default_access); }else
@@ -1000,15 +1003,15 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, {pod_unlock (p2m); gfn_aligned = (gfn >> order) << order; -/* Note that we are supposed to call set_p2m_entry() 512 times to +/* Note that we are supposed to call p2m_set_entry() 512 times to * split 1GB into 512 2MB pages here. But We only do once here because -* set_p2m_entry() should automatically shatter the 1GB page into +* p2m_set_entry() should automatically shatter the 1GB page into * 512 2MB pages. The rest of 511 calls are unnecessary. * * NOTE: In a fine-grained p2m locking scenario this operation * may need to promote its locking from gfn->1g superpage */ -set_p2m_entry (p2m, gfn_aligned,_mfn (0 ),PAGE_ORDER_2M , +p2m_set_entry (p2m, gfn_aligned,_mfn (0 ),PAGE_ORDER_2M , p2m_populate_on_demand, p2m->default_access);return 0 ; }
@@ -1037,7 +1040,8 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, gfn_aligned = (gfn >> order) << order; -set_p2m_entry (p2m, gfn_aligned, mfn, order, p2m_ram_rw, p2m->default_access); +p2m_set_entry (p2m, gfn_aligned, mfn, order, p2m_ram_rw, + p2m->default_access);for ( i =0 ; i < (1UL << order); i++ ) {
@@ -1091,7 +1095,7 @@ remap_and_retry:* need promoting the gfn lock from gfn->2M superpage */ gfn_aligned = (gfn>>order)<<order;for (i=0 ; i<(1 <<order); i++) -set_p2m_entry (p2m, gfn_aligned+i,_mfn (0 ),PAGE_ORDER_4K , +p2m_set_entry (p2m, gfn_aligned+i,_mfn (0 ),PAGE_ORDER_4K , p2m_populate_on_demand, p2m->default_access);if ( tb_init_done ) {
@@ -1146,7 +1150,7 @@ guest_physmap_mark_populate_on_demand(struct domain *d, unsigned long gfn, }/* Now, actually do the two-way mapping */ -if ( !set_p2m_entry (p2m, gfn,_mfn (0 ), order, +if ( !p2m_set_entry (p2m, gfn,_mfn (0 ), order, p2m_populate_on_demand, p2m->default_access) ) rc = -EINVAL ;else
xen/arch/x86/mm/p2m.c +26 -21
143 lines not on this page · raw message
xen/include/asm-x86/p2m.h +1 -1
@@ -593,7 +593,7 @@ void p2m_free_ptp(struct p2m_domain *p2m, struct page_info *pg);/* Directly set a p2m entry: only for use by p2m code. Does not need * a call to put_gfn afterwards/ */ -int set_p2m_entry (struct p2m_domain *p2m,unsigned long gfn,mfn_t mfn, +int p2m_set_entry (struct p2m_domain *p2m,unsigned long gfn,mfn_t mfn,unsigned int page_order,p2m_type_t p2mt,p2m_access_t p2ma);/* Set up function pointers for PT implementation: only for use by p2m code */
Signature · 1 line
1.8.3.1
PATCH 3/3 P2M error code propogation
In reply to Mukesh RathorBecause some of the leaf p2m functions return 0 for failure and TRUE for success, the real errno is lost. We change some of those functions to return proper -errno. Also, any code in the immediate vicinity that is in coding style violation is fixed up.
This patch doesn't change any functionality.
--- xen/arch/x86/domctl.c | 19 ++++---- xen/arch/x86/mm/hap/nested_hap.c | 11 ++--- xen/arch/x86/mm/mem_sharing.c | 10 ++--- xen/arch/x86/mm/p2m-ept.c | 17 ++++--- xen/arch/x86/mm/p2m-pod.c | 7 ++- xen/arch/x86/mm/p2m-pt.c | 48 ++++++++++---------- xen/arch/x86/mm/p2m.c | 96 +++++++++++++++++++--------------------- 7 files changed, 102 insertions(+), 106 deletions(-)
xen/arch/x86/domctl.c +10 -9
@@ -671,13 +671,12 @@ long arch_do_domctl(if ( !ret &&paging_mode_translate (d) ) {for ( i =0 ; !ret && i < nr_mfns; i++ ) -if ( !set_mmio_p2m_entry (d, gfn + i,_mfn (mfn + i)) ) - ret = -EIO ; + ret =set_mmio_p2m_entry (d, gfn + i,_mfn (mfn + i));if ( ret ) {printk (XENLOG_G_WARNING -"memory_map:fail: dom%d gfn=%lx mfn=%lx\n" , - d->domain_id, gfn + i, mfn + i); +"memory_map:fail: dom%d gfn=%lx mfn=%lx ret:%ld\n" , + d->domain_id, gfn + i, mfn + i, ret);while ( i-- )clear_mmio_p2m_entry (d, gfn + i); if ( iomem_deny_access(d, mfn, mfn + nr_mfns - 1) &&
@@ -690,20 +689,22 @@ long arch_do_domctl( }else { +int tmp_rc;printk (XENLOG_G_INFO "memory_map:remove: dom%d gfn=%lx mfn=%lx nr=%lx\n" , d->domain_id, gfn, mfn, nr_mfns);if (paging_mode_translate (d) )for ( i =0 ; i < nr_mfns; i++ ) - add |= !clear_mmio_p2m_entry (d, gfn + i); - ret =iomem_deny_access (d, mfn, mfn + nr_mfns -1 ); -if ( !ret && add ) - ret = -EIO ; +if ( (tmp_rc =clear_mmio_p2m_entry (d, gfn + i)) ) + ret = tmp_rc; + tmp_rc =iomem_deny_access (d, mfn, mfn + nr_mfns -1 ); +if ( !ret && tmp_rc ) + ret = tmp_rc;if ( ret &&is_hardware_domain (current->domain) )printk (XENLOG_ERR "memory_map: error %ld %s dom%d access to [%lx,%lx]\n" , - ret, add ?"removing" :"denying" , d->domain_id, + ret, tmp_rc ?"denying" :"removing" , d->domain_id, mfn, mfn + nr_mfns -1 ); } }
xen/arch/x86/mm/hap/nested_hap.c +6 -5
@@ -103,7 +103,7 @@ nestedhap_fix_p2m(struct vcpu *v, struct p2m_domain *p2m, paddr_t L2_gpa, paddr_t L0_gpa, unsigned int page_order, p2m_type_t p2mt, p2m_access_t p2ma) { - int rv = 1; + int rc = 0;ASSERT (p2m);ASSERT (p2m->set_entry);
@@ -124,15 +124,16 @@ nestedhap_fix_p2m(struct vcpu *v, struct p2m_domain *p2m, gfn = (L2_gpa >>PAGE_SHIFT ) & mask; mfn =_mfn ((L0_gpa >>PAGE_SHIFT ) & mask); - rv =p2m_set_entry (p2m, gfn, mfn, page_order, p2mt, p2ma); + rc =p2m_set_entry (p2m, gfn, mfn, page_order, p2mt, p2ma); }p2m_unlock (p2m); -if (rv ==0 ) { +if ( rc ) + {gdprintk (XENLOG_ERR , -"failed to set entry for %#" PRIx64" -> %#" PRIx64"\n" , - L2_gpa, L0_gpa); +"failed to set entry for %#" PRIx64" -> %#" PRIx64" rc:%d\n" , + L2_gpa, L0_gpa, rc);BUG (); } }
xen/arch/x86/mm/mem_sharing.c +4 -6
@@ -1021,7 +1021,7 @@ int mem_sharing_share_pages(struct domain *sd, unsigned long sgfn, shr_handle_tput_page_and_type (cpage); d =get_domain_by_id (gfn->domain);BUG_ON (!d); -BUG_ON (set_shared_p2m_entry (d, gfn->gfn, smfn) ==0 ); +BUG_ON (set_shared_p2m_entry (d, gfn->gfn, smfn));put_domain (d); }ASSERT (list_empty (&cpage->sharing->gfns));
@@ -1095,13 +1095,11 @@ int mem_sharing_add_to_physmap(struct domain *sd, unsigned long sgfn, shr_handle ret =p2m_set_entry (p2m, cgfn, smfn,PAGE_ORDER_4K , p2m_ram_shared, a);/* Tempted to turn this into an assert */ -if ( !ret ) +if ( ret ) { - ret = -ENOENT ;mem_sharing_gfn_destroy (spage, cd, gfn_info);put_page_and_type (spage); }else { - ret =0 ;/* There is a chance we're plugging a hole where a paged out page was */ if (p2m_is_paging (cmfn_type) && (cmfn_type != p2m_ram_paging_out) ) {
@@ -1232,7 +1230,7 @@ int __mem_sharing_unshare_page(struct domain *d,unmap_domain_page (s);unmap_domain_page (t); -BUG_ON (set_shared_p2m_entry (d, gfn,page_to_mfn (page)) ==0 ); +BUG_ON (set_shared_p2m_entry (d, gfn,page_to_mfn (page)));mem_sharing_gfn_destroy (old_page, d, gfn_info);mem_sharing_page_unlock (old_page);put_page_and_type (old_page);
@@ -1288,7 +1286,7 @@ int relinquish_shared_pages(struct domain *d)* we hold the p2m lock. */ set_rc = p2m->set_entry (p2m, gfn,_mfn (0 ),PAGE_ORDER_4K , p2m_invalid, p2m_access_rwx); -ASSERT (set_rc !=0 ); +ASSERT (set_rc ==0 ); count +=0x10 ; }else
xen/arch/x86/mm/p2m-ept.c +10 -7
@@ -273,6 +273,8 @@ static int ept_next_level(struct p2m_domain *p2m, bool_t read_only,/* * ept_set_entry() computes 'need_modify_vtd_table' for itself, * by observing whether any gfn->mfn translations are modified. +* +* Returns: 0 for success, -errno for failure */ static int ept_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn,
@@ -281,7 +283,7 @@ ept_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn,ept_entry_t *table, *ept_entry =NULL ;unsigned long gfn_remainder = gfn;int i, target = order /EPT_TABLE_ORDER ; -int rv =0 ; +int rc =0 ;int ret =0 ;bool_t direct_mmio = (p2mt == p2m_mmio_direct);uint8_t ipat =0 ;
@@ -302,7 +304,7 @@ ept_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn,if ( ((gfn |mfn_x (mfn)) & ((1UL << order) -1 )) || ((u64 )gfn >> ((ept_get_wl (ept) +1 ) *EPT_TABLE_ORDER )) || (order %EPT_TABLE_ORDER ) ) -return 0 ; +return -EINVAL ; ASSERT((target == 2 && hvm_hap_has_1gb()) || (target == 1 && hvm_hap_has_2mb()) ||
@@ -314,7 +316,10 @@ ept_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, { ret =ept_next_level (p2m,0 , &table, &gfn_remainder, i);if ( !ret ) + { + rc = -ENOENT ; goto out; + }else if ( ret !=GUEST_TABLE_NORMAL_PAGE )break ; }
@@ -386,6 +391,7 @@ ept_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn,if ( !ept_split_super_page (p2m, &split_ept_entry, i, target) ) {ept_free_entry (p2m, &split_ept_entry, i); + rc = -ENOMEM ; goto out; }
@@ -426,9 +432,6 @@ ept_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, (gfn + (1UL << order) - 1 > p2m->max_mapped_pfn) ) p2m->max_mapped_pfn = gfn + (1UL << order) - 1; -/* Success */ - rv =1 ; - out:unmap_domain_page (table);
@@ -436,7 +439,7 @@ out:ept_sync_domain (p2m);/* For non-nested p2m, may need to change VT-d page table.*/ -if ( rv && !p2m_is_nestedp2m (p2m) &&need_iommu (d) && +if ( rc ==0 && !p2m_is_nestedp2m (p2m) &&need_iommu (d) && need_modify_vtd_table ) {if ( iommu_hap_pt_share )
@@ -460,7 +463,7 @@ out:if (is_epte_present (&old_entry) )ept_free_entry (p2m, &old_entry, target); -return rv; +return rc; }/* Read ept p2m entries */
xen/arch/x86/mm/p2m-pod.c +3 -4
@@ -1150,10 +1150,9 @@ guest_physmap_mark_populate_on_demand(struct domain *d, unsigned long gfn, }/* Now, actually do the two-way mapping */ -if ( !p2m_set_entry (p2m, gfn,_mfn (0 ), order, - p2m_populate_on_demand, p2m->default_access) ) - rc = -EINVAL ; -else + rc =p2m_set_entry (p2m, gfn,_mfn (0 ), order, p2m_populate_on_demand, + p2m->default_access); +if ( rc ==0 ) {pod_lock (p2m); p2m->pod.entry_count +=1 << order;
xen/arch/x86/mm/p2m-pt.c +24 -24
119 lines not on this page · raw message
xen/arch/x86/mm/p2m.c +45 -51
239 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [V1 PATCH 3/3] P2M error code propogation
xen/arch/x86/domctl.c long arch_do_domctl( · line 692
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 09.04.14 at 03:47, <[email protected]> wrote:
xen/arch/x86/domctl.c +1
-0@@ -690,20 +689,22 @@ long arch_do_domctl( }else { +int tmp_rc;
Blank line after declarations please.
Quoted 10 lines
xen/arch/x86/domctl.c +0
-4printk (XENLOG_G_INFO "memory_map:remove: dom%d gfn=%lx mfn=%lx nr=%lx\n" , d->domain_id, gfn, mfn, nr_mfns);if (paging_mode_translate (d) )for ( i =0 ; i < nr_mfns; i++ ) - add |= !clear_mmio_p2m_entry (d, gfn + i); - ret =iomem_deny_access (d, mfn, mfn + nr_mfns -1 ); -if ( !ret && add ) - ret = -EIO ;
xen/arch/x86/domctl.c long arch_do_domctl( · line 707
Quoted 10 lines
xen/arch/x86/domctl.c +6
-1+if ( (tmp_rc =clear_mmio_p2m_entry (d, gfn + i)) ) + ret = tmp_rc; + tmp_rc =iomem_deny_access (d, mfn, mfn + nr_mfns -1 ); +if ( !ret && tmp_rc ) + ret = tmp_rc;if ( ret &&is_hardware_domain (current->domain) ) printk(XENLOG_ERR "memory_map: error %ld %s dom%d access to [%lx,%lx]\n", - ret, add ? "removing" : "denying", d->domain_id, + ret, tmp_rc ? "denying" : "removing", d->domain_id,
This isn't functionally identical to the old code.
xen/arch/x86/mm/p2m.c set_mmio_p2m_entry(struct domain *d, unsigned long gfn, · line 754
Quoted 7 lines
xen/arch/x86/mm/p2m.c +1
-1@@ -753,7 +750,7 @@ set_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn)struct p2m_domain *p2m =p2m_get_hostp2m (d);if ( !paging_mode_translate (d) ) -return 0 ; +return -EPERM ;
I think EPERM isn't quite right here, the (elsewhere) previously resulting EIO would seem more appropriate. Same further down obviously.
xen/arch/x86/mm/p2m.c long p2m_set_mem_access(struct domain *d, unsigned long pfn, uint32_t nr, · line 1402
Quoted 9 lines
xen/arch/x86/mm/p2m.c +1
-3@@ -1401,11 +1398,8 @@ long p2m_set_mem_access(struct domain *d, unsigned long pfn, uint32_t nr,for ( pfn += start; nr > start; ++pfn ) { mfn = p2m->get_entry (p2m, pfn, &t, &_a,0 ,NULL ); -if ( p2m->set_entry (p2m, pfn, mfn,PAGE_ORDER_4K , t, a) ==0 ) - { - rc = -ENOMEM ; +if ( (rc = p2m->set_entry (p2m, pfn, mfn,PAGE_ORDER_4K , t, a)) )break ;
I think constructs like this, namely to the somewhat odd "requirement" of needing to add an extra pair of parentheses around the assignment to avoid a compiler warning, would benefit from being split into assignment and separate if().
Jan
Quoted 10 lines · On Tue, 8 Apr 2014 18:47:35 -0700 Mukesh Rathor <[email protected]>…
Hi,
In reference to our discussion on propogating error codes here
http://osdir.com/ml/general/2014-04/msg13083.htmlplease find the patches. Built on c/s: ac0f56a.
thanks
Mukesh
Uh-oh, looks like there's an issue with the way things are right now causing xen to panic. That makes this patch immediately eligible for backporting. See email to security list.
Coming out with V2.
thanks
mukesh