From: "Jan Beulich" <JBeulich@suse.com>
To: xen-devel <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Subject: [PATCH] x86/mm: drop further relics of translated PV domains
Date: Thu, 08 Jun 2017 09:30:20 -0600 [thread overview]
Message-ID: <593989AC0200007800160F2E@prv-mh.provo.novell.com> (raw)
In-Reply-To: 593989AC0200007800160F2E@prv-mh.provo.novell.com
[-- Attachment #1: Type: text/plain, Size: 5923 bytes --]
For PV domains paging_mode_{refcounts,translate}() are always false as
of commits 4045953527 ("x86/paging: Enforce PG_external == PG_translate
== PG_refcounts") and 92942fd3d4 ("x86/mm: drop
guest_{map,get_eff}_l1e() hooks").
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- 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)] =
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)] = l4e_empty();
}
@@ -1902,12 +1902,7 @@ static int mod_l1_entry(l1_pgentry_t *pl
if ( unlikely(__copy_from_user(&ol1e, pl1e, sizeof(ol1e)) != 0) )
return -EFAULT;
- 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));
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)));
- if ( shadow_mode_refcounts(owner) )
- return 0;
+ ASSERT(!shadow_mode_refcounts(owner));
gmfn = 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 = pagetable_get_pfn(curr->arch.guest_table);
l4_pgentry_t *pl4e = map_domain_page(_mfn(gt_mfn));
- rc = 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 = 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;
}
- 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(
if ( op.arg1.mfn != 0 )
{
- if ( paging_mode_refcounts(d) )
- rc = get_page_from_pagenr(op.arg1.mfn, d) ? 0 : -EINVAL;
- else
- rc = get_page_and_type_from_pagenr(
- op.arg1.mfn, PGT_root_page_table, d, 0, 1);
+ rc = get_page_and_type_from_pagenr(op.arg1.mfn,
+ PGT_root_page_table,
+ d, 0, 1);
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);
}
@@ -3410,21 +3392,18 @@ long do_mmuext_op(
{
page = mfn_to_page(old_mfn);
- if ( paging_mode_refcounts(d) )
- put_page(page);
- else
- switch ( rc = put_page_and_type_preemptible(page) )
- {
- case -EINTR:
- rc = -ERESTART;
- /* fallthrough */
- case -ERESTART:
- curr->arch.old_guest_table = page;
- break;
- default:
- BUG_ON(rc);
- break;
- }
+ switch ( rc = put_page_and_type_preemptible(page) )
+ {
+ case -EINTR:
+ rc = -ERESTART;
+ /* fallthrough */
+ case -ERESTART:
+ curr->arch.old_guest_table = page;
+ break;
+ default:
+ BUG_ON(rc);
+ break;
+ }
}
break;
@@ -4035,8 +4014,7 @@ static int create_grant_pte_mapping(
page_unlock(page);
- if ( !paging_mode_refcounts(d) )
- put_page_from_l1e(ol1e, d);
+ put_page_from_l1e(ol1e, d);
failed:
unmap_domain_page(va);
@@ -4162,7 +4140,7 @@ static int create_grant_va_mapping(
put_page(l1pg);
guest_unmap_l1e(pl1e);
- if ( okay && !paging_mode_refcounts(d) )
+ if ( okay )
put_page_from_l1e(ol1e, d);
return okay ? GNTST_okay : GNTST_general_error;
@@ -4387,7 +4365,7 @@ int replace_grant_host_mapping(
guest_unmap_l1e(pl1e);
rc = replace_grant_va_mapping(addr, frame, ol1e, curr);
- if ( rc && !paging_mode_refcounts(curr->domain) )
+ if ( rc )
put_page_from_l1e(ol1e, curr->domain);
return rc;
[-- Attachment #2: x86-drop-paging-mode-checks.patch --]
[-- Type: text/plain, Size: 5975 bytes --]
x86/mm: drop further relics of translated PV domains
For PV domains paging_mode_{refcounts,translate}() are always false as
of commits 4045953527 ("x86/paging: Enforce PG_external == PG_translate
== PG_refcounts") and 92942fd3d4 ("x86/mm: drop
guest_{map,get_eff}_l1e() hooks").
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- 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)] =
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)] = l4e_empty();
}
@@ -1902,12 +1902,7 @@ static int mod_l1_entry(l1_pgentry_t *pl
if ( unlikely(__copy_from_user(&ol1e, pl1e, sizeof(ol1e)) != 0) )
return -EFAULT;
- 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));
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)));
- if ( shadow_mode_refcounts(owner) )
- return 0;
+ ASSERT(!shadow_mode_refcounts(owner));
gmfn = 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 = pagetable_get_pfn(curr->arch.guest_table);
l4_pgentry_t *pl4e = map_domain_page(_mfn(gt_mfn));
- rc = 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 = 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;
}
- 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(
if ( op.arg1.mfn != 0 )
{
- if ( paging_mode_refcounts(d) )
- rc = get_page_from_pagenr(op.arg1.mfn, d) ? 0 : -EINVAL;
- else
- rc = get_page_and_type_from_pagenr(
- op.arg1.mfn, PGT_root_page_table, d, 0, 1);
+ rc = get_page_and_type_from_pagenr(op.arg1.mfn,
+ PGT_root_page_table,
+ d, 0, 1);
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);
}
@@ -3410,21 +3392,18 @@ long do_mmuext_op(
{
page = mfn_to_page(old_mfn);
- if ( paging_mode_refcounts(d) )
- put_page(page);
- else
- switch ( rc = put_page_and_type_preemptible(page) )
- {
- case -EINTR:
- rc = -ERESTART;
- /* fallthrough */
- case -ERESTART:
- curr->arch.old_guest_table = page;
- break;
- default:
- BUG_ON(rc);
- break;
- }
+ switch ( rc = put_page_and_type_preemptible(page) )
+ {
+ case -EINTR:
+ rc = -ERESTART;
+ /* fallthrough */
+ case -ERESTART:
+ curr->arch.old_guest_table = page;
+ break;
+ default:
+ BUG_ON(rc);
+ break;
+ }
}
break;
@@ -4035,8 +4014,7 @@ static int create_grant_pte_mapping(
page_unlock(page);
- if ( !paging_mode_refcounts(d) )
- put_page_from_l1e(ol1e, d);
+ put_page_from_l1e(ol1e, d);
failed:
unmap_domain_page(va);
@@ -4162,7 +4140,7 @@ static int create_grant_va_mapping(
put_page(l1pg);
guest_unmap_l1e(pl1e);
- if ( okay && !paging_mode_refcounts(d) )
+ if ( okay )
put_page_from_l1e(ol1e, d);
return okay ? GNTST_okay : GNTST_general_error;
@@ -4387,7 +4365,7 @@ int replace_grant_host_mapping(
guest_unmap_l1e(pl1e);
rc = replace_grant_va_mapping(addr, frame, ol1e, curr);
- if ( rc && !paging_mode_refcounts(curr->domain) )
+ if ( rc )
put_page_from_l1e(ol1e, curr->domain);
return rc;
[-- Attachment #3: Type: text/plain, Size: 127 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next parent reply other threads:[~2017-06-08 15:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-08 15:30 Jan Beulich [this message]
2017-06-09 17:38 ` [PATCH] x86/mm: drop further relics of translated PV domains Andrew Cooper
2017-06-12 6:28 ` Jan Beulich
2017-06-12 10:37 ` Andrew Cooper
2017-06-12 10:44 ` Jan Beulich
2017-06-12 10:52 ` Andrew Cooper
2017-06-12 11:19 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=593989AC0200007800160F2E@prv-mh.provo.novell.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).