[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] xen/x86: domain: Remove specific case when allocating struct domain

commit 7608f33452ae417ee2b7406e06add7c4e12db9fa
Author:     Julien Grall <jgrall@xxxxxxxxxx>
AuthorDate: Mon Jan 20 14:10:57 2020 +0000
Commit:     Julien Grall <julien@xxxxxxx>
CommitDate: Fri Jan 31 18:50:32 2020 +0000

    xen/x86: domain: Remove specific case when allocating struct domain
    Commit 8916fcf4577 "x86/domain: compile with lock_profile=y enabled"
    allowed the struct domain to use more than a PAGE_SIZE (i.e 4096).
    However, the function free_domheap_struct() will only free the first
    We could modify the free part to free the correct number of pages, but
    the structure has been fitting in a page (even with lock profile
    enabled) since commit 428607a410 "x86: shrink 'struct domain', was
    already PAGE_SIZE" (part of Xen 4.7).
    Therefore, the specific case for lock profile is now removed.
    This is not a security issue because struct domain can only be bigger
    than a page size for lock profiling. The feature can only be selected
    in DEBUG and EXPERT mode.
    Fixes: 8916fcf4577 ("x86/domain: compile with lock_profile=y enabled")
    Reported-by: David Woodhouse <dwmw@xxxxxxxxxxxx>
    Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
 xen/arch/x86/domain.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 28fefa1f81..f53ae5ff86 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -313,7 +313,6 @@ static unsigned int __init noinline 
 struct domain *alloc_domain_struct(void)
     struct domain *d;
-    unsigned int order = get_order_from_bytes(sizeof(*d));
     const unsigned int bits = 0;
@@ -327,18 +326,10 @@ struct domain *alloc_domain_struct(void)
          bits = _domain_struct_bits();
     BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE);
-    d = alloc_xenheap_pages(order, MEMF_bits(bits));
+    d = alloc_xenheap_pages(0, MEMF_bits(bits));
     if ( d != NULL )
-    {
-        unsigned int sz;
-        for ( sz = 0; sz < (PAGE_SIZE << order); sz += PAGE_SIZE )
-            clear_page((void *)d + sz);
-    }
+        clear_page(d);
     return d;
generated by git-patchbot for /home/xen/git/xen.git#master

Xen-changelog mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.