From: Andrii Anisov <andrii.anisov@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
Julien Grall <julien.grall@arm.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Andrii Anisov <andrii_anisov@epam.com>
Subject: [Xen-devel] [RFC 5/6] arm64: call enter_hypervisor_head only when it is needed
Date: Fri, 26 Jul 2019 13:37:39 +0300 [thread overview]
Message-ID: <1564137460-25629-7-git-send-email-andrii.anisov@gmail.com> (raw)
In-Reply-To: <1564137460-25629-1-git-send-email-andrii.anisov@gmail.com>
From: Andrii Anisov <andrii_anisov@epam.com>
On ARM64 we know exactly if trap happened from hypervisor or guest, so
we do not need to take that decision. This reduces a condition for
all enter_hypervisor_head calls and the function call for traps from
the hypervisor mode.
Currently, it is implemented for ARM64 only. Integrating the stuff
with ARM32 requires moving ` if ( guest_mode(regs) )` condition
into ARM32 specific traps.c
Signed-off-by: Andrii Anisov <andrii_anisov@epam.com>
---
xen/arch/arm/arm64/entry.S | 6 ++--
xen/arch/arm/traps.c | 75 ++++++++++++++++++++++++----------------------
2 files changed, 43 insertions(+), 38 deletions(-)
diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S
index 8f28789..21c710d 100644
--- a/xen/arch/arm/arm64/entry.S
+++ b/xen/arch/arm/arm64/entry.S
@@ -211,7 +211,7 @@ hyp_irq:
entry hyp=1
msr daifclr, #4
mov x0, sp
- bl do_trap_irq
+ bl do_trap_hyp_irq
exit hyp=1
guest_sync:
@@ -321,7 +321,7 @@ guest_irq:
SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT)
msr daifclr, #4
mov x0, sp
- bl do_trap_irq
+ bl do_trap_guest_irq
1:
exit hyp=0, compat=0
@@ -364,7 +364,7 @@ guest_irq_compat:
SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT)
msr daifclr, #4
mov x0, sp
- bl do_trap_irq
+ bl do_trap_guest_irq
1:
exit hyp=0, compat=1
diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 5a9dc66..13726db 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -2011,48 +2011,45 @@ static inline bool needs_ssbd_flip(struct vcpu *v)
cpu_require_ssbd_mitigation();
}
-static void enter_hypervisor_head(struct cpu_user_regs *regs)
+static void enter_hypervisor_head(void)
{
- if ( guest_mode(regs) )
- {
- struct vcpu *v = current;
+ struct vcpu *v = current;
- ASSERT(!local_irq_is_enabled());
+ ASSERT(!local_irq_is_enabled());
- /* If the guest has disabled the workaround, bring it back on. */
- if ( needs_ssbd_flip(v) )
- arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2_FID, 1, NULL);
+ /* If the guest has disabled the workaround, bring it back on. */
+ if ( needs_ssbd_flip(v) )
+ arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2_FID, 1, NULL);
- /*
- * If we pended a virtual abort, preserve it until it gets cleared.
- * See ARM ARM DDI 0487A.j D1.14.3 (Virtual Interrupts) for details,
- * but the crucial bit is "On taking a vSError interrupt, HCR_EL2.VSE
- * (alias of HCR.VA) is cleared to 0."
- */
- if ( v->arch.hcr_el2 & HCR_VA )
- v->arch.hcr_el2 = READ_SYSREG(HCR_EL2);
+ /*
+ * If we pended a virtual abort, preserve it until it gets cleared.
+ * See ARM ARM DDI 0487A.j D1.14.3 (Virtual Interrupts) for details,
+ * but the crucial bit is "On taking a vSError interrupt, HCR_EL2.VSE
+ * (alias of HCR.VA) is cleared to 0."
+ */
+ if ( v->arch.hcr_el2 & HCR_VA )
+ v->arch.hcr_el2 = READ_SYSREG(HCR_EL2);
#ifdef CONFIG_NEW_VGIC
- /*
- * We need to update the state of our emulated devices using level
- * triggered interrupts before syncing back the VGIC state.
- *
- * TODO: Investigate whether this is necessary to do on every
- * trap and how it can be optimised.
- */
- vtimer_update_irqs(v);
- vcpu_update_evtchn_irq(v);
+ /*
+ * We need to update the state of our emulated devices using level
+ * triggered interrupts before syncing back the VGIC state.
+ *
+ * TODO: Investigate whether this is necessary to do on every
+ * trap and how it can be optimised.
+ */
+ vtimer_update_irqs(v);
+ vcpu_update_evtchn_irq(v);
#endif
- vgic_sync_from_lrs(v);
- }
+ vgic_sync_from_lrs(v);
}
void do_trap_guest_sync(struct cpu_user_regs *regs)
{
const union hsr hsr = { .bits = regs->hsr };
- enter_hypervisor_head(regs);
+ enter_hypervisor_head();
local_irq_enable();
switch ( hsr.ec )
@@ -2188,7 +2185,6 @@ void do_trap_hyp_sync(struct cpu_user_regs *regs)
{
const union hsr hsr = { .bits = regs->hsr };
- enter_hypervisor_head(regs);
local_irq_enable();
switch ( hsr.ec )
@@ -2227,7 +2223,6 @@ void do_trap_hyp_sync(struct cpu_user_regs *regs)
void do_trap_hyp_serror(struct cpu_user_regs *regs)
{
- enter_hypervisor_head(regs);
local_irq_enable();
__do_trap_serror(regs, VABORT_GEN_BY_GUEST(regs));
@@ -2235,21 +2230,31 @@ void do_trap_hyp_serror(struct cpu_user_regs *regs)
void do_trap_guest_serror(struct cpu_user_regs *regs)
{
- enter_hypervisor_head(regs);
+ enter_hypervisor_head();
local_irq_enable();
__do_trap_serror(regs, true);
}
-void do_trap_irq(struct cpu_user_regs *regs)
+void do_trap_guest_irq(struct cpu_user_regs *regs)
+{
+ enter_hypervisor_head();
+ gic_interrupt(regs, 0);
+}
+
+void do_trap_guest_fiq(struct cpu_user_regs *regs)
+{
+ enter_hypervisor_head();
+ gic_interrupt(regs, 1);
+}
+
+void do_trap_hyp_irq(struct cpu_user_regs *regs)
{
- enter_hypervisor_head(regs);
gic_interrupt(regs, 0);
}
-void do_trap_fiq(struct cpu_user_regs *regs)
+void do_trap_hyp_fiq(struct cpu_user_regs *regs)
{
- enter_hypervisor_head(regs);
gic_interrupt(regs, 1);
}
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-07-26 10:38 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-26 10:37 [Xen-devel] [RFC 0/6] XEN scheduling hardening Andrii Anisov
2019-07-26 10:37 ` [Xen-devel] [RFC 1/6] xen/arm: Re-enable interrupt later in the trap path Andrii Anisov
2019-07-26 10:48 ` Julien Grall
2019-07-30 17:35 ` Andrii Anisov
2019-07-30 20:10 ` Julien Grall
2019-08-01 6:45 ` Andrii Anisov
2019-08-01 9:37 ` Julien Grall
2019-08-02 8:28 ` Andrii Anisov
2019-08-02 9:03 ` Julien Grall
2019-08-02 12:24 ` Andrii Anisov
2019-08-02 13:22 ` Julien Grall
2019-08-01 11:19 ` Dario Faggioli
2019-08-02 7:50 ` Andrii Anisov
2019-08-02 9:15 ` Julien Grall
2019-08-02 13:07 ` Andrii Anisov
2019-08-02 13:49 ` Julien Grall
2019-08-03 1:39 ` Dario Faggioli
2019-08-03 0:55 ` Dario Faggioli
2019-08-06 13:09 ` Andrii Anisov
2019-08-08 14:07 ` Andrii Anisov
2019-08-13 14:45 ` Dario Faggioli
2019-08-15 18:25 ` Andrii Anisov
2019-07-26 10:37 ` [Xen-devel] [RFC 2/6] schedule: account true system idle time Andrii Anisov
2019-07-26 12:00 ` Dario Faggioli
2019-07-26 12:42 ` Andrii Anisov
2019-07-29 11:40 ` Dario Faggioli
2019-08-01 8:23 ` Andrii Anisov
2019-07-26 10:37 ` [Xen-devel] [RFC 3/6] sysctl: extend XEN_SYSCTL_getcpuinfo interface Andrii Anisov
2019-07-26 12:15 ` Dario Faggioli
2019-07-26 13:06 ` Andrii Anisov
2019-07-26 10:37 ` [Xen-devel] [RFC 4/6] xentop: show CPU load information Andrii Anisov
2019-07-26 10:37 ` [Xen-devel] [RFC 5/6] arm64: сall enter_hypervisor_head only when it is needed Andrii Anisov
2019-07-26 10:44 ` Andrii Anisov
2019-07-26 10:37 ` Andrii Anisov [this message]
2019-07-26 10:59 ` [Xen-devel] [RFC 5/6] arm64: call " Julien Grall
2019-07-30 17:35 ` Andrii Anisov
2019-07-31 11:02 ` Julien Grall
2019-07-31 11:33 ` Andre Przywara
2019-08-01 7:33 ` Andrii Anisov
2019-08-01 10:17 ` Julien Grall
2019-08-02 13:50 ` Andrii Anisov
2019-07-26 10:37 ` [Xen-devel] [RFC 6/6] schedule: account all the hypervisor time to the idle vcpu Andrii Anisov
2019-07-26 11:56 ` [Xen-devel] [RFC 0/6] XEN scheduling hardening Dario Faggioli
2019-07-26 12:14 ` Juergen Gross
2019-07-29 11:53 ` Dario Faggioli
2019-07-29 12:13 ` Juergen Gross
2019-07-29 14:47 ` Andrii Anisov
2019-07-29 18:46 ` Dario Faggioli
2019-07-29 14:28 ` Andrii Anisov
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=1564137460-25629-7-git-send-email-andrii.anisov@gmail.com \
--to=andrii.anisov@gmail.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=andrii_anisov@epam.com \
--cc=julien.grall@arm.com \
--cc=sstabellini@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).