x86/mm: Refactor map_pages_to_xen to have only a single exit path

We will soon need to perform clean-ups before returning.

No functional change.

This is part of XSA-345.

Reported-by: Hongyan Xia <hongyxia@amazon.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Hongyan Xia <hongyxia@amazon.com>
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Wei Liu authored and Jan Beulich committed 2020-10-20 14:19:31 +02:00
1 parent a7f0831e58
commit 08e6c6f80b
1 file changed
+12 -7
+12 -7
View File
@@ -275,7 +275,7 @@ static l4_pgentry_t __read_mostly split_l4e;
* Originally cloned from share_xen_page_with_guest(), just to avoid setting
* PGC_xen_heap on non-heap (typically) MMIO pages. Other pieces got dropped
* simply because they're not needed in this context.
*/
*/
static void __init assign_io_page(struct page_info *page)
{
set_gpfn_from_mfn(mfn_x(page_to_mfn(page)), INVALID_M2P_ENTRY);
@@ -5079,6 +5079,7 @@ int map_pages_to_xen(
l2_pgentry_t *pl2e, ol2e;
l1_pgentry_t *pl1e, ol1e;
unsigned int i;
int rc = -ENOMEM;
#define flush_flags(oldf) do { \
unsigned int o_ = (oldf); \
@@ -5099,7 +5100,8 @@ int map_pages_to_xen(
l3_pgentry_t ol3e, *pl3e = virt_to_xen_l3e(virt);
if ( !pl3e )
return -ENOMEM;
goto out;
ol3e = *pl3e;
if ( cpu_has_page1gb &&
@@ -5189,7 +5191,7 @@ int map_pages_to_xen(
l2t = alloc_xen_pagetable();
if ( l2t == NULL )
return -ENOMEM;
goto out;
for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ )
l2e_write(l2t + i,
@@ -5218,7 +5220,7 @@ int map_pages_to_xen(
pl2e = virt_to_xen_l2e(virt);
if ( !pl2e )
return -ENOMEM;
goto out;
if ( ((((virt >> PAGE_SHIFT) | mfn_x(mfn)) &
((1u << PAGETABLE_ORDER) - 1)) == 0) &&
@@ -5262,7 +5264,7 @@ int map_pages_to_xen(
{
pl1e = virt_to_xen_l1e(virt);
if ( pl1e == NULL )
return -ENOMEM;
goto out;
}
else if ( l2e_get_flags(*pl2e) & _PAGE_PSE )
{
@@ -5290,7 +5292,7 @@ int map_pages_to_xen(
l1t = alloc_xen_pagetable();
if ( l1t == NULL )
return -ENOMEM;
goto out;
for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ )
l1e_write(&l1t[i],
@@ -5436,7 +5438,10 @@ int map_pages_to_xen(
#undef flush_flags
return 0;
rc = 0;
out:
return rc;
}
int populate_pt_range(unsigned long virt, unsigned long nr_mfns)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.