File 5a6703cb-x86-move-invocations-of-hvm_flush_guest_tlbs.patch of Package xen.8005
From 3e635d02d704e71534b6edf0202ed4170725a14a Mon Sep 17 00:00:00 2001
From: Jan Beulich <jbeulich@suse.com>
Date: Tue, 23 Jan 2018 10:43:39 +0100
Subject: [PATCH] x86: move invocations of hvm_flush_guest_tlbs()
Their need is not tied to the actual flushing of TLBs, but the ticking
of the TLB clock. Make this more obvious by folding the two invocations
into a single one in pre_flush().
Also defer the latching of CR4 in write_cr3() until after pre_flush()
(and hence implicitly until after IRQs are off), making operation
sequence the same in both cases (eliminating the theoretical risk of
pre_flush() altering CR4). This then also improves register allocation,
as the compiler doesn't need to use a callee-saved register for "cr4"
anymore.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
--- a/xen/arch/x86/flushtlb.c
+++ b/xen/arch/x86/flushtlb.c
@@ -50,6 +50,8 @@ static u32 pre_flush(void)
raise_softirq(NEW_TLBFLUSH_CLOCK_PERIOD_SOFTIRQ);
skip_clocktick:
+ hvm_flush_guest_tlbs();
+
return t2;
}
@@ -79,8 +81,6 @@ void write_cr3(unsigned long cr3)
local_irq_save(flags);
t = pre_flush();
-
- hvm_flush_guest_tlbs();
#ifdef USER_MAPPINGS_ARE_GLOBAL
{
@@ -124,8 +125,6 @@ void flush_area_local(const void *va, un
{
u32 t = pre_flush();
- hvm_flush_guest_tlbs();
-
#ifndef USER_MAPPINGS_ARE_GLOBAL
if ( !(flags & FLUSH_TLB_GLOBAL) || !(read_cr4() & X86_CR4_PGE) )
{