From: Andres Lagar-Cavilla <andres@lagarcavilla.org>
To: xen-devel@lists.xen.org
Cc: olaf@aepfle.de, keir@xen.org, andres@gridcentric.ca, tim@xen.org,
wei.wang2@amd.com, hongkaixing@huawei.com, adin@gridcentric.ca
Subject: [PATCH 3 of 3] x86/mm: Teach paging to page table-based p2m
Date: Wed, 21 Mar 2012 15:23:00 -0400 [thread overview]
Message-ID: <7704c9e0f5ffdf37a290.1332357780@xdev.gridcentric.ca> (raw)
In-Reply-To: <patchbomb.1332357777@xdev.gridcentric.ca>
xen/arch/x86/mm/p2m-pt.c | 30 +++++++++++++++++++-----------
1 files changed, 19 insertions(+), 11 deletions(-)
The p2m-pt.c code, used by both shadow and AMD NPT modes, was not aware of
paging types, and the implications those types have on p2m entries. Add support
to the page table-based p2m to understand the paging types. This is a necessary
step towards enabling memory paging on AMD NPT mode, but not yet the full
solution.
Tested not to break neither shadow mode nor "normal" (i.e. no paging) AMD NPT
mode.
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
diff -r e325da663345 -r 7704c9e0f5ff xen/arch/x86/mm/p2m-pt.c
--- a/xen/arch/x86/mm/p2m-pt.c
+++ b/xen/arch/x86/mm/p2m-pt.c
@@ -77,6 +77,9 @@ static unsigned long p2m_type_to_flags(p
case p2m_invalid:
case p2m_mmio_dm:
case p2m_populate_on_demand:
+ case p2m_ram_paging_out:
+ case p2m_ram_paged:
+ case p2m_ram_paging_in:
default:
return flags;
case p2m_ram_ro:
@@ -168,7 +171,7 @@ p2m_next_level(struct p2m_domain *p2m, m
shift, max)) )
return 0;
- /* PoD: Not present doesn't imply empty. */
+ /* PoD/paging: Not present doesn't imply empty. */
if ( !l1e_get_flags(*p2m_entry) )
{
struct page_info *pg;
@@ -384,7 +387,7 @@ p2m_set_entry(struct p2m_domain *p2m, un
0, L1_PAGETABLE_ENTRIES);
ASSERT(p2m_entry);
- if ( mfn_valid(mfn) || (p2mt == p2m_mmio_direct) )
+ if ( mfn_valid(mfn) || (p2mt == p2m_mmio_direct) || p2m_is_paging(p2mt) )
entry_content = l1e_from_pfn(mfn_x(mfn),
p2m_type_to_flags(p2mt, mfn));
else
@@ -615,11 +618,12 @@ pod_retry_l1:
sizeof(l1e));
if ( ret == 0 ) {
+ unsigned long l1e_mfn = l1e_get_pfn(l1e);
p2mt = p2m_flags_to_type(l1e_get_flags(l1e));
- ASSERT(l1e_get_pfn(l1e) != INVALID_MFN || !p2m_is_ram(p2mt));
+ ASSERT( (l1e_mfn != INVALID_MFN || !p2m_is_ram(p2mt)) ||
+ (l1e_mfn == INVALID_MFN && p2m_is_paging(p2mt)) );
- if ( p2m_flags_to_type(l1e_get_flags(l1e))
- == p2m_populate_on_demand )
+ if ( p2mt == p2m_populate_on_demand )
{
/* The read has succeeded, so we know that the mapping
* exits at this point. */
@@ -641,7 +645,7 @@ pod_retry_l1:
}
if ( p2m_is_valid(p2mt) || p2m_is_grant(p2mt) )
- mfn = _mfn(l1e_get_pfn(l1e));
+ mfn = _mfn(l1e_mfn);
else
/* XXX see above */
p2mt = p2m_mmio_dm;
@@ -663,6 +667,8 @@ p2m_gfn_to_mfn(struct p2m_domain *p2m, u
paddr_t addr = ((paddr_t)gfn) << PAGE_SHIFT;
l2_pgentry_t *l2e;
l1_pgentry_t *l1e;
+ unsigned long l1e_flags;
+ p2m_type_t l1t;
ASSERT(paging_mode_translate(p2m->domain));
@@ -781,10 +787,12 @@ pod_retry_l2:
l1e = map_domain_page(mfn_x(mfn));
l1e += l1_table_offset(addr);
pod_retry_l1:
- if ( (l1e_get_flags(*l1e) & _PAGE_PRESENT) == 0 )
+ l1e_flags = l1e_get_flags(*l1e);
+ l1t = p2m_flags_to_type(l1e_flags);
+ if ( ((l1e_flags & _PAGE_PRESENT) == 0) && (!p2m_is_paging(l1t)) )
{
/* PoD: Try to populate */
- if ( p2m_flags_to_type(l1e_get_flags(*l1e)) == p2m_populate_on_demand )
+ if ( l1t == p2m_populate_on_demand )
{
if ( q & P2M_ALLOC ) {
if ( !p2m_pod_demand_populate(p2m, gfn, PAGE_ORDER_4K, q) )
@@ -792,15 +800,15 @@ pod_retry_l1:
} else
*t = p2m_populate_on_demand;
}
-
+
unmap_domain_page(l1e);
return _mfn(INVALID_MFN);
}
mfn = _mfn(l1e_get_pfn(*l1e));
- *t = p2m_flags_to_type(l1e_get_flags(*l1e));
+ *t = l1t;
unmap_domain_page(l1e);
- ASSERT(mfn_valid(mfn) || !p2m_is_ram(*t));
+ ASSERT(mfn_valid(mfn) || !p2m_is_ram(*t) || p2m_is_paging(*t));
if ( page_order )
*page_order = PAGE_ORDER_4K;
return (p2m_is_valid(*t) || p2m_is_grant(*t)) ? mfn : _mfn(INVALID_MFN);
next prev parent reply other threads:[~2012-03-21 19:23 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-21 19:22 [PATCH 0 of 3] Fixes for paging/sharing with AMD processors Andres Lagar-Cavilla
2012-03-21 19:22 ` [PATCH 1 of 3] IOMMU: Add command line param to disable sharing of IOMMU and hap tables Andres Lagar-Cavilla
2012-03-22 9:17 ` Jan Beulich
2012-03-22 10:44 ` Tim Deegan
2012-03-22 10:57 ` Jan Beulich
2012-03-22 11:03 ` Tim Deegan
2012-03-27 15:19 ` Andres Lagar-Cavilla
2012-03-29 10:27 ` Tim Deegan
2012-03-29 10:57 ` Keir Fraser
2012-03-29 11:09 ` Tim Deegan
2012-03-29 15:05 ` Jan Beulich
2012-03-21 19:22 ` [PATCH 2 of 3] Clip mfn to allowable width when building a PTE Andres Lagar-Cavilla
2012-03-22 9:18 ` Jan Beulich
2012-03-22 10:50 ` Tim Deegan
2012-03-22 11:02 ` Jan Beulich
2012-03-22 14:54 ` Andres Lagar-Cavilla
2012-03-22 15:31 ` Jan Beulich
2012-03-27 15:21 ` Andres Lagar-Cavilla
2012-03-21 19:23 ` Andres Lagar-Cavilla [this message]
2012-03-22 10:55 ` [PATCH 3 of 3] x86/mm: Teach paging to page table-based p2m Tim Deegan
2012-03-22 14:47 ` Andres Lagar-Cavilla
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=7704c9e0f5ffdf37a290.1332357780@xdev.gridcentric.ca \
--to=andres@lagarcavilla.org \
--cc=adin@gridcentric.ca \
--cc=andres@gridcentric.ca \
--cc=hongkaixing@huawei.com \
--cc=keir@xen.org \
--cc=olaf@aepfle.de \
--cc=tim@xen.org \
--cc=wei.wang2@amd.com \
--cc=xen-devel@lists.xen.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).