xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Keir Fraser <keir@xen.org>, Jan Beulich <JBeulich@suse.com>
Subject: [PATCH] x86/traps: do not inline do_trap() into 10 different handlers
Date: Mon, 12 May 2014 11:52:31 +0100	[thread overview]
Message-ID: <1399891951-17455-1-git-send-email-andrew.cooper3@citrix.com> (raw)

Furthermore, trapnr can be pulled from regs->entry_vector to avoid a risk of
mismatching the trap number with the underlying exception state.

This nets 2K of code reduction.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Keir Fraser <keir@xen.org>
CC: Jan Beulich <JBeulich@suse.com>
---
 xen/arch/x86/traps.c |   40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 5d27581..48e2bb2 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -534,10 +534,10 @@ int set_guest_nmi_trapbounce(void)
     return !null_trap_bounce(v, tb);
 }
 
-static inline void do_trap(
-    int trapnr, struct cpu_user_regs *regs, int use_error_code)
+static void do_trap(struct cpu_user_regs *regs, int use_error_code)
 {
     struct vcpu *curr = current;
+    unsigned int trapnr = regs->entry_vector;
     unsigned long fixup;
 
     DEBUGGER_trap_entry(trapnr, regs);
@@ -573,28 +573,28 @@ static inline void do_trap(
           trapnr, trapstr(trapnr), regs->error_code);
 }
 
-#define DO_ERROR_NOCODE(trapnr, name)                   \
-void do_##name(struct cpu_user_regs *regs)   \
+#define DO_ERROR_NOCODE(name)                           \
+void do_##name(struct cpu_user_regs *regs)              \
 {                                                       \
-    do_trap(trapnr, regs, 0);                           \
+    do_trap(regs, 0);                                   \
 }
 
-#define DO_ERROR(trapnr, name)                          \
-void do_##name(struct cpu_user_regs *regs)   \
+#define DO_ERROR(name)                                  \
+void do_##name(struct cpu_user_regs *regs)              \
 {                                                       \
-    do_trap(trapnr, regs, 1);                           \
-}
-
-DO_ERROR_NOCODE(TRAP_divide_error,    divide_error)
-DO_ERROR_NOCODE(TRAP_overflow,        overflow)
-DO_ERROR_NOCODE(TRAP_bounds,          bounds)
-DO_ERROR_NOCODE(TRAP_copro_seg,       coprocessor_segment_overrun)
-DO_ERROR(       TRAP_invalid_tss,     invalid_TSS)
-DO_ERROR(       TRAP_no_segment,      segment_not_present)
-DO_ERROR(       TRAP_stack_error,     stack_segment)
-DO_ERROR_NOCODE(TRAP_copro_error,     coprocessor_error)
-DO_ERROR(       TRAP_alignment_check, alignment_check)
-DO_ERROR_NOCODE(TRAP_simd_error,      simd_coprocessor_error)
+    do_trap(regs, 1);                                   \
+}
+
+DO_ERROR_NOCODE(divide_error)
+DO_ERROR_NOCODE(overflow)
+DO_ERROR_NOCODE(bounds)
+DO_ERROR_NOCODE(coprocessor_segment_overrun)
+DO_ERROR(       invalid_TSS)
+DO_ERROR(       segment_not_present)
+DO_ERROR(       stack_segment)
+DO_ERROR_NOCODE(coprocessor_error)
+DO_ERROR(       alignment_check)
+DO_ERROR_NOCODE(simd_coprocessor_error)
 
 /* Returns 0 if not handled, and non-0 for success. */
 int rdmsr_hypervisor_regs(uint32_t idx, uint64_t *val)
-- 
1.7.10.4

                 reply	other threads:[~2014-05-12 10:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1399891951-17455-1-git-send-email-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=keir@xen.org \
    --cc=xen-devel@lists.xen.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).