|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen staging] x86/setup: properly update PTEs if src/dst overlaps when relocating Xen image
commit cfc888f8cc5e0070df9c60b2cef068aef7dc3257
Author: Daniel Kiper <daniel.kiper@xxxxxxxxxx>
AuthorDate: Fri Apr 20 11:54:00 2018 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Jun 28 09:28:42 2018 +0200
x86/setup: properly update PTEs if src/dst overlaps when relocating Xen
image
Commit 0d31d16 (x86/setup: do not relocate Xen over current Xen image
placement) disallowed src/dst images overlaps when relocating Xen image.
Though it deliberately allowed destination region between __image_base__
and (__image_base__ + XEN_IMG_OFFSET) overlaps with the end of source
image. And here is the problem. If anything between __page_tables_start
and __page_tables_end in source image lands in the overlap then some or
even all page table entries may not be updated. This usually means boom
in early boot which will be difficult to the investigate. So, I think
that we have three choices to fix the issue:
- drop XEN_IMG_OFFSET from
if ( (end > s) && (end - reloc_size + XEN_IMG_OFFSET >= __pa(_end)) )
- add XEN_IMG_OFFSET to xen_phys_start in PFN_DOWN(xen_phys_start)
used in loops as one of conditions and replace ">" with ">=",
- change PFN_DOWN(xen_phys_start) to PFN_DOWN(xen_remap_end_pfn)
proposed in earlier version of this patch.
This patch implements the second option. This way we still allow source
and destination partial overlap as described above but PTEs are properly
updated now.
Signed-off-by: Daniel Kiper <daniel.kiper@xxxxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
xen/arch/x86/setup.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index a3172ca92c..39ac130a9d 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -1014,6 +1014,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
l3_pgentry_t *pl3e;
l2_pgentry_t *pl2e;
int i, j, k;
+ unsigned long pte_update_limit;
/* Select relocation address. */
e = end - reloc_size;
@@ -1021,6 +1022,14 @@ void __init noreturn __start_xen(unsigned long mbi_p)
bootsym(trampoline_xen_phys_start) = e;
/*
+ * No PTEs pointing above this address are candidates for
relocation.
+ * Due to possibility of partial overlap of the end of source image
+ * and the beginning of region for destination image some PTEs may
+ * point to addresses in range [e, e + XEN_IMG_OFFSET).
+ */
+ pte_update_limit = PFN_DOWN(e + XEN_IMG_OFFSET);
+
+ /*
* Perform relocation to new physical address.
* Before doing so we must sync static/global data with main memory
* with a barrier(). After this we must *not* modify static/global
@@ -1043,7 +1052,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
/* Not present, 1GB mapping, or already relocated? */
if ( !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) ||
(l3e_get_flags(*pl3e) & _PAGE_PSE) ||
- (l3e_get_pfn(*pl3e) > PFN_DOWN(xen_phys_start)) )
+ (l3e_get_pfn(*pl3e) >= pte_update_limit) )
continue;
*pl3e = l3e_from_intpte(l3e_get_intpte(*pl3e) +
xen_phys_start);
@@ -1053,7 +1062,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
/* Not present, PSE, or already relocated? */
if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ||
(l2e_get_flags(*pl2e) & _PAGE_PSE) ||
- (l2e_get_pfn(*pl2e) > PFN_DOWN(xen_phys_start)) )
+ (l2e_get_pfn(*pl2e) >= pte_update_limit) )
continue;
*pl2e = l2e_from_intpte(l2e_get_intpte(*pl2e) +
xen_phys_start);
@@ -1077,7 +1086,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
unsigned int flags;
if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ||
- (l2e_get_pfn(*pl2e) > PFN_DOWN(xen_phys_start)) )
+ (l2e_get_pfn(*pl2e) >= pte_update_limit) )
continue;
if ( !using_2M_mapping() )
--
generated by git-patchbot for /home/xen/git/xen.git#staging
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |