From: "Jan Beulich" <JBeulich@suse.com>
To: xen-devel <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Subject: [PATCH 2/6] x86: make CPU state flush requests explicit
Date: Fri, 19 Jan 2018 09:03:49 -0700 [thread overview]
Message-ID: <5A6224F502000078001A078B@prv-mh.provo.novell.com> (raw)
In-Reply-To: <5A62238B02000078001A0768@prv-mh.provo.novell.com>
Having this be an implied side effect of a TLB flush is not very nice:
It could (at least in theory) lead to unintended state flushes (see e.g.
https://lists.xenproject.org/archives/html/xen-devel/2017-11/msg00187.html
for context). Introduce a flag to be used in the two places actually
wanting the state flushed, and conditionalize the
__sync_local_execstate() invocation in the IPI handler accordingly.
At the same time also conditionalize the flush_area_local() invocations,
to short-circuit the function ending up as a no-op anyway.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -1697,7 +1697,7 @@ void context_switch(struct vcpu *prev, s
!cpumask_empty(&dirty_mask)) )
{
/* Other cpus call __sync_local_execstate from flush ipi handler. */
- flush_tlb_mask(&dirty_mask);
+ flush_mask(&dirty_mask, FLUSH_TLB | FLUSH_STATE);
}
if ( prev != next )
@@ -1806,7 +1806,7 @@ void sync_vcpu_execstate(struct vcpu *v)
sync_local_execstate();
/* Other cpus call __sync_local_execstate from flush ipi handler. */
- flush_tlb_mask(v->vcpu_dirty_cpumask);
+ flush_mask(v->vcpu_dirty_cpumask, FLUSH_TLB | FLUSH_STATE);
}
static int relinquish_memory(
--- a/xen/arch/x86/smp.c
+++ b/xen/arch/x86/smp.c
@@ -207,9 +207,10 @@ void invalidate_interrupt(struct cpu_use
unsigned int flags = flush_flags;
ack_APIC_irq();
perfc_incr(ipis);
- if ( __sync_local_execstate() )
+ if ( (flags & FLUSH_STATE) && __sync_local_execstate() )
flags &= ~(FLUSH_TLB | FLUSH_TLB_GLOBAL);
- flush_area_local(flush_va, flags);
+ if ( flags & ~(FLUSH_STATE | FLUSH_ORDER_MASK) )
+ flush_area_local(flush_va, flags);
cpumask_clear_cpu(smp_processor_id(), &flush_cpumask);
}
@@ -219,7 +220,8 @@ void flush_area_mask(const cpumask_t *ma
ASSERT(local_irq_is_enabled());
- if ( cpumask_test_cpu(cpu, mask) )
+ if ( (flags & ~(FLUSH_STATE | FLUSH_ORDER_MASK)) &&
+ cpumask_test_cpu(cpu, mask) )
flags = flush_area_local(va, flags);
if ( (flags & ~FLUSH_ORDER_MASK) &&
--- a/xen/include/asm-x86/flushtlb.h
+++ b/xen/include/asm-x86/flushtlb.h
@@ -101,6 +101,8 @@ void write_cr3(unsigned long cr3);
#define FLUSH_CACHE 0x400
/* VA for the flush has a valid mapping */
#define FLUSH_VA_VALID 0x800
+ /* Flush CPU state */
+#define FLUSH_STATE 0x1000
/* Flush local TLBs/caches. */
unsigned int flush_area_local(const void *va, unsigned int flags);
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-01-19 16:03 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-19 15:57 [PATCH 0/6] misc flush and dirty-mask related adjustments Jan Beulich
2018-01-19 16:02 ` [PATCH 1/6] x86: move invocations of hvm_flush_guest_tlbs() Jan Beulich
2018-01-19 17:00 ` Andrew Cooper
2018-01-19 17:29 ` George Dunlap
2018-01-22 9:30 ` Jan Beulich
2018-01-19 16:03 ` Jan Beulich [this message]
2018-01-19 17:40 ` [PATCH 2/6] x86: make CPU state flush requests explicit Andrew Cooper
2018-01-22 9:31 ` Jan Beulich
2018-01-22 9:32 ` Andrew Cooper
2018-01-19 16:04 ` [PATCH 3/6] add check to cpumask_of() Jan Beulich
2018-01-19 16:59 ` Wei Liu
2018-01-19 17:43 ` Andrew Cooper
2018-01-22 9:35 ` Jan Beulich
2018-01-19 16:06 ` [PATCH 4/6] replace vCPU's dirty CPU mask by numeric ID Jan Beulich
2018-01-19 17:41 ` George Dunlap
2018-01-19 17:48 ` Andrew Cooper
2018-01-22 9:39 ` Jan Beulich
2018-01-22 9:44 ` Andrew Cooper
2018-01-19 16:06 ` [PATCH 5/6] x86: avoid explicit TLB flush when saving exec state Jan Beulich
2018-01-19 17:59 ` George Dunlap
2018-01-19 18:23 ` George Dunlap
2018-01-22 9:56 ` Jan Beulich
2018-01-19 18:12 ` Andrew Cooper
2018-01-22 10:00 ` Jan Beulich
2018-01-19 16:07 ` [PATCH 6/6] drop "domain_" prefix from struct domain's dirty CPU mask Jan Beulich
2018-01-19 16:15 ` Wei Liu
2018-01-19 17:56 ` Andrew Cooper
2018-01-22 10:06 ` Jan Beulich
2018-01-19 18:01 ` George Dunlap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5A6224F502000078001A078B@prv-mh.provo.novell.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.