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

[xen master] x86/mm: avoid inadvertently degrading a TLB flush to local only



commit 78e072bc375043e81691a59454e09f0b38241ddd
Author:     David Vrabel <dvrabel@xxxxxxxxxxxx>
AuthorDate: Wed Apr 20 10:55:01 2022 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Apr 20 10:55:01 2022 +0200

    x86/mm: avoid inadvertently degrading a TLB flush to local only
    
    If the direct map is incorrectly modified with interrupts disabled,
    the required TLB flushes are degraded to flushing the local CPU only.
    
    This could lead to very hard to diagnose problems as different CPUs will
    end up with different views of memory. Although, no such issues have yet
    been identified.
    
    Change the check in the flush_area() macro to look at system_state
    instead. This defers the switch from local to all later in the boot
    (see xen/arch/x86/setup.c:__start_xen()). This is fine because
    additional PCPUs are not brought up until after the system state is
    SYS_STATE_smp_boot.
    
    Signed-off-by: David Vrabel <dvrabel@xxxxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/mm.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index c271e383b5..72dbce43b1 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -5071,11 +5071,10 @@ l1_pgentry_t *virt_to_xen_l1e(unsigned long v)
 #define lNf_to_l1f(f) (((f) & _PAGE_PRESENT) ? ((f) & ~_PAGE_PSE) : (f))
 
 /*
- * map_pages_to_xen() can be called with interrupts disabled during
- * early bootstrap. In this case it is safe to use flush_area_local()
- * and avoid locking because only the local CPU is online.
+ * map_pages_to_xen() can be called early in boot before any other
+ * CPUs are online. Use flush_area_local() in this case.
  */
-#define flush_area(v,f) (!local_irq_is_enabled() ?              \
+#define flush_area(v,f) (system_state < SYS_STATE_smp_boot ?    \
                          flush_area_local((const void *)v, f) : \
                          flush_area_all((const void *)v, f))
 
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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