From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH] x86/mm: drop further relics of translated PV domains Date: Thu, 08 Jun 2017 09:30:20 -0600 Message-ID: <593989AC0200007800160F2E@prv-mh.provo.novell.com> References: <593989AC0200007800160F2E@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartF9C1949C.1__=" Return-path: Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIzOD-0004hr-GZ for xen-devel@lists.xenproject.org; Thu, 08 Jun 2017 15:30:25 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: xen-devel Cc: Andrew Cooper List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartF9C1949C.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline For PV domains paging_mode_{refcounts,translate}() are always false as of commits 4045953527 ("x86/paging: Enforce PG_external =3D=3D PG_translate= =3D=3D PG_refcounts") and 92942fd3d4 ("x86/mm: drop guest_{map,get_eff}_l1e() hooks"). Signed-off-by: Jan Beulich --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1591,7 +1591,7 @@ void init_guest_l4_table(l4_pgentry_t l4 l4e_from_pfn(domain_page_map_to_mfn(l4tab), __PAGE_HYPERVISOR_RW);= l4tab[l4_table_offset(PERDOMAIN_VIRT_START)] =3D l4e_from_page(d->arch.perdomain_l3_pg, __PAGE_HYPERVISOR_RW); - if ( zap_ro_mpt || is_pv_32bit_domain(d) || paging_mode_refcounts(d) = ) + if ( zap_ro_mpt || is_pv_32bit_domain(d) ) l4tab[l4_table_offset(RO_MPT_VIRT_START)] =3D l4e_empty(); } =20 @@ -1902,12 +1902,7 @@ static int mod_l1_entry(l1_pgentry_t *pl if ( unlikely(__copy_from_user(&ol1e, pl1e, sizeof(ol1e)) !=3D 0) ) return -EFAULT; =20 - if ( unlikely(paging_mode_refcounts(pt_dom)) ) - { - if ( UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu, = preserve_ad) ) - return 0; - return -EBUSY; - } + ASSERT(!paging_mode_refcounts(pt_dom)); =20 if ( l1e_get_flags(nl1e) & _PAGE_PRESENT ) { @@ -2359,8 +2354,7 @@ int free_page_type(struct page_info *pag /* A page table is dirtied when its type count becomes zero. */ paging_mark_dirty(owner, _mfn(page_to_mfn(page))); =20 - if ( shadow_mode_refcounts(owner) ) - return 0; + ASSERT(!shadow_mode_refcounts(owner)); =20 gmfn =3D mfn_to_gmfn(owner, page_to_mfn(page)); ASSERT(VALID_M2P(gmfn)); @@ -2960,14 +2954,11 @@ int new_guest_cr3(unsigned long mfn) unsigned long gt_mfn =3D pagetable_get_pfn(curr->arch.guest_table)= ; l4_pgentry_t *pl4e =3D map_domain_page(_mfn(gt_mfn)); =20 - rc =3D paging_mode_refcounts(d) - ? -EINVAL /* Old code was broken, but what should it be? */ - : mod_l4_entry( - pl4e, - l4e_from_pfn( - mfn, - (_PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED)= ), - gt_mfn, 0, curr); + rc =3D mod_l4_entry(pl4e, + l4e_from_pfn(mfn, + (_PAGE_PRESENT | _PAGE_RW | + _PAGE_USER | _PAGE_ACCESSED)), + gt_mfn, 0, curr); unmap_domain_page(pl4e); switch ( rc ) { @@ -3069,13 +3060,6 @@ static struct domain *get_pg_owner(domid goto out; } =20 - if ( !is_hvm_domain(curr) && unlikely(paging_mode_translate(curr)) ) - { - gdprintk(XENLOG_WARNING, - "Cannot mix foreign mappings with translated domains\n");= - goto out; - } - switch ( domid ) { case DOMID_IO: @@ -3384,11 +3368,9 @@ long do_mmuext_op( =20 if ( op.arg1.mfn !=3D 0 ) { - if ( paging_mode_refcounts(d) ) - rc =3D get_page_from_pagenr(op.arg1.mfn, d) ? 0 : = -EINVAL; - else - rc =3D get_page_and_type_from_pagenr( - op.arg1.mfn, PGT_root_page_table, d, 0, 1); + rc =3D get_page_and_type_from_pagenr(op.arg1.mfn, + PGT_root_page_table, + d, 0, 1); =20 if ( unlikely(rc) ) { @@ -3400,7 +3382,7 @@ long do_mmuext_op( rc, op.arg1.mfn); break; } - if ( VM_ASSIST(d, m2p_strict) && !paging_mode_refcounts(d)= ) + if ( VM_ASSIST(d, m2p_strict) ) zap_ro_mpt(op.arg1.mfn); } =20 @@ -3410,21 +3392,18 @@ long do_mmuext_op( { page =3D mfn_to_page(old_mfn); =20 - if ( paging_mode_refcounts(d) ) - put_page(page); - else - switch ( rc =3D put_page_and_type_preemptible(page) ) - { - case -EINTR: - rc =3D -ERESTART; - /* fallthrough */ - case -ERESTART: - curr->arch.old_guest_table =3D page; - break; - default: - BUG_ON(rc); - break; - } + switch ( rc =3D put_page_and_type_preemptible(page) ) + { + case -EINTR: + rc =3D -ERESTART; + /* fallthrough */ + case -ERESTART: + curr->arch.old_guest_table =3D page; + break; + default: + BUG_ON(rc); + break; + } } =20 break; @@ -4035,8 +4014,7 @@ static int create_grant_pte_mapping( =20 page_unlock(page); =20 - if ( !paging_mode_refcounts(d) ) - put_page_from_l1e(ol1e, d); + put_page_from_l1e(ol1e, d); =20 failed: unmap_domain_page(va); @@ -4162,7 +4140,7 @@ static int create_grant_va_mapping( put_page(l1pg); guest_unmap_l1e(pl1e); =20 - if ( okay && !paging_mode_refcounts(d) ) + if ( okay ) put_page_from_l1e(ol1e, d); =20 return okay ? GNTST_okay : GNTST_general_error; @@ -4387,7 +4365,7 @@ int replace_grant_host_mapping( guest_unmap_l1e(pl1e); =20 rc =3D replace_grant_va_mapping(addr, frame, ol1e, curr); - if ( rc && !paging_mode_refcounts(curr->domain) ) + if ( rc ) put_page_from_l1e(ol1e, curr->domain); =20 return rc; --=__PartF9C1949C.1__= Content-Type: text/plain; name="x86-drop-paging-mode-checks.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-drop-paging-mode-checks.patch" x86/mm: drop further relics of translated PV domains=0A=0AFor PV domains = paging_mode_{refcounts,translate}() are always false as=0Aof commits = 4045953527 ("x86/paging: Enforce PG_external =3D=3D PG_translate=0A=3D=3D = PG_refcounts") and 92942fd3d4 ("x86/mm: drop=0Aguest_{map,get_eff}_l1e() = hooks").=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = a/xen/arch/x86/mm.c=0A+++ b/xen/arch/x86/mm.c=0A@@ -1591,7 +1591,7 @@ void = init_guest_l4_table(l4_pgentry_t l4=0A l4e_from_pfn(domain_page_map= _to_mfn(l4tab), __PAGE_HYPERVISOR_RW);=0A l4tab[l4_table_offset(PERDOMA= IN_VIRT_START)] =3D=0A l4e_from_page(d->arch.perdomain_l3_pg, = __PAGE_HYPERVISOR_RW);=0A- if ( zap_ro_mpt || is_pv_32bit_domain(d) || = paging_mode_refcounts(d) )=0A+ if ( zap_ro_mpt || is_pv_32bit_domain(d) = )=0A l4tab[l4_table_offset(RO_MPT_VIRT_START)] =3D l4e_empty();=0A = }=0A =0A@@ -1902,12 +1902,7 @@ static int mod_l1_entry(l1_pgentry_t *pl=0A = if ( unlikely(__copy_from_user(&ol1e, pl1e, sizeof(ol1e)) !=3D 0) )=0A = return -EFAULT;=0A =0A- if ( unlikely(paging_mode_refcounts(pt_d= om)) )=0A- {=0A- if ( UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, = pt_vcpu, preserve_ad) )=0A- return 0;=0A- return = -EBUSY;=0A- }=0A+ ASSERT(!paging_mode_refcounts(pt_dom));=0A =0A = if ( l1e_get_flags(nl1e) & _PAGE_PRESENT )=0A {=0A@@ -2359,8 +2354,7 = @@ int free_page_type(struct page_info *pag=0A /* A page table is = dirtied when its type count becomes zero. */=0A paging_mark_dirty(o= wner, _mfn(page_to_mfn(page)));=0A =0A- if ( shadow_mode_refcounts(o= wner) )=0A- return 0;=0A+ ASSERT(!shadow_mode_refcounts(o= wner));=0A =0A gmfn =3D mfn_to_gmfn(owner, page_to_mfn(page));=0A = ASSERT(VALID_M2P(gmfn));=0A@@ -2960,14 +2954,11 @@ int new_guest_cr3= (unsigned long mfn)=0A unsigned long gt_mfn =3D pagetable_get_pfn(c= urr->arch.guest_table);=0A l4_pgentry_t *pl4e =3D map_domain_page(_= mfn(gt_mfn));=0A =0A- rc =3D paging_mode_refcounts(d)=0A- = ? -EINVAL /* Old code was broken, but what should it be? */=0A- = : mod_l4_entry(=0A- pl4e,=0A- = l4e_from_pfn(=0A- mfn,=0A- = (_PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED)),=0A- = gt_mfn, 0, curr);=0A+ rc =3D mod_l4_entry(pl4e,=0A+ = l4e_from_pfn(mfn,=0A+ = (_PAGE_PRESENT | _PAGE_RW |=0A+ = _PAGE_USER | _PAGE_ACCESSED)),=0A+ gt_mfn, 0, = curr);=0A unmap_domain_page(pl4e);=0A switch ( rc )=0A = {=0A@@ -3069,13 +3060,6 @@ static struct domain *get_pg_owner(domid=0A = goto out;=0A }=0A =0A- if ( !is_hvm_domain(curr) && = unlikely(paging_mode_translate(curr)) )=0A- {=0A- gdprintk(XENLOG= _WARNING,=0A- "Cannot mix foreign mappings with translated = domains\n");=0A- goto out;=0A- }=0A-=0A switch ( domid )=0A = {=0A case DOMID_IO:=0A@@ -3384,11 +3368,9 @@ long do_mmuext_op(=0A = =0A if ( op.arg1.mfn !=3D 0 )=0A {=0A- = if ( paging_mode_refcounts(d) )=0A- rc =3D get_page_f= rom_pagenr(op.arg1.mfn, d) ? 0 : -EINVAL;=0A- else=0A- = rc =3D get_page_and_type_from_pagenr(=0A- = op.arg1.mfn, PGT_root_page_table, d, 0, 1);=0A+ rc =3D = get_page_and_type_from_pagenr(op.arg1.mfn,=0A+ = PGT_root_page_table,=0A+ = d, 0, 1);=0A =0A if ( unlikely(rc) = )=0A {=0A@@ -3400,7 +3382,7 @@ long do_mmuext_op(=0A = rc, op.arg1.mfn);=0A = break;=0A }=0A- if ( VM_ASSIST(d, m2p_strict= ) && !paging_mode_refcounts(d) )=0A+ if ( VM_ASSIST(d, = m2p_strict) )=0A zap_ro_mpt(op.arg1.mfn);=0A = }=0A =0A@@ -3410,21 +3392,18 @@ long do_mmuext_op(=0A {=0A = page =3D mfn_to_page(old_mfn);=0A =0A- if ( = paging_mode_refcounts(d) )=0A- put_page(page);=0A- = else=0A- switch ( rc =3D put_page_and_type_pre= emptible(page) )=0A- {=0A- case = -EINTR:=0A- rc =3D -ERESTART;=0A- = /* fallthrough */=0A- case -ERESTART:=0A- = curr->arch.old_guest_table =3D page;=0A- = break;=0A- default:=0A- = BUG_ON(rc);=0A- break;=0A- }=0A+ = switch ( rc =3D put_page_and_type_preemptible(page) )=0A+ = {=0A+ case -EINTR:=0A+ rc = =3D -ERESTART;=0A+ /* fallthrough */=0A+ = case -ERESTART:=0A+ curr->arch.old_guest_table =3D = page;=0A+ break;=0A+ default:=0A+ = BUG_ON(rc);=0A+ break;=0A+ = }=0A }=0A =0A break;=0A@@ -4035,8 +4014,7 @@ = static int create_grant_pte_mapping(=0A =0A page_unlock(page);=0A =0A- = if ( !paging_mode_refcounts(d) )=0A- put_page_from_l1e(ol1e, = d);=0A+ put_page_from_l1e(ol1e, d);=0A =0A failed:=0A unmap_domain_= page(va);=0A@@ -4162,7 +4140,7 @@ static int create_grant_va_mapping(=0A = put_page(l1pg);=0A guest_unmap_l1e(pl1e);=0A =0A- if ( okay && = !paging_mode_refcounts(d) )=0A+ if ( okay )=0A put_page_from_l1e= (ol1e, d);=0A =0A return okay ? GNTST_okay : GNTST_general_error;=0A@@ = -4387,7 +4365,7 @@ int replace_grant_host_mapping(=0A guest_unmap_l1e(p= l1e);=0A =0A rc =3D replace_grant_va_mapping(addr, frame, ol1e, = curr);=0A- if ( rc && !paging_mode_refcounts(curr->domain) )=0A+ if = ( rc )=0A put_page_from_l1e(ol1e, curr->domain);=0A =0A return = rc;=0A --=__PartF9C1949C.1__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --=__PartF9C1949C.1__=--