xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v3 4/5] x86: move declaration of the exception_table to C
Date: Mon, 29 Jan 2018 12:26:42 +0000	[thread overview]
Message-ID: <20180129122643.13008-5-roger.pau@citrix.com> (raw)
In-Reply-To: <20180129122643.13008-1-roger.pau@citrix.com>

This makes the code cleaner because there's no need to declare the
exception_table in assembly, and also fixes the following error when
using clang's integrated assembler:

entry.S:834:15: error: unexpected token in '.rept' directive
        .rept 32 - ((. - exception_table) / 8)
              ^
entry.S:836:14: error: unmatched '.endr' directive
        .endr
             ^

This should be a non-functional change.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
Changes since v2:
 - Make do_trap/do_reserved_trap static.
 - Only use '...' to initialize the end of the exception_table array.

Changes since v1:
 - Cast to void *.
 - Align assignments.
 - Use ARRAY_SIZE instead of TRAP_nr.
---
 xen/arch/x86/traps.c            | 32 ++++++++++++++++++++++++++++++--
 xen/arch/x86/x86_64/entry.S     | 30 ------------------------------
 xen/include/asm-x86/processor.h |  1 -
 3 files changed, 30 insertions(+), 33 deletions(-)

diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index a3e8f0c9b9..1187fd9c25 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -119,6 +119,34 @@ boolean_param("ler", opt_ler);
 #define stack_words_per_line 4
 #define ESP_BEFORE_EXCEPTION(regs) ((unsigned long *)regs->rsp)
 
+static void do_trap(struct cpu_user_regs *regs);
+static void do_reserved_trap(struct cpu_user_regs *regs);
+
+void (* const exception_table[TRAP_nr])(struct cpu_user_regs *regs) = {
+    [TRAP_divide_error]                 = do_trap,
+    [TRAP_debug]                        = do_debug,
+    [TRAP_nmi]                          = (void *)do_nmi,
+    [TRAP_int3]                         = do_int3,
+    [TRAP_overflow]                     = do_trap,
+    [TRAP_bounds]                       = do_trap,
+    [TRAP_invalid_op]                   = do_invalid_op,
+    [TRAP_no_device]                    = do_device_not_available,
+    [TRAP_double_fault]                 = do_reserved_trap,
+    [TRAP_copro_seg]                    = do_reserved_trap,
+    [TRAP_invalid_tss]                  = do_trap,
+    [TRAP_no_segment]                   = do_trap,
+    [TRAP_stack_error]                  = do_trap,
+    [TRAP_gp_fault]                     = do_general_protection,
+    [TRAP_page_fault]                   = do_page_fault,
+    [TRAP_spurious_int]                 = do_reserved_trap,
+    [TRAP_copro_error]                  = do_trap,
+    [TRAP_alignment_check]              = do_trap,
+    [TRAP_machine_check]                = (void *)do_machine_check,
+    [TRAP_simd_error]                   = do_trap,
+    [TRAP_virtualisation ...
+     (ARRAY_SIZE(exception_table) - 1)] = do_reserved_trap,
+};
+
 static void show_code(const struct cpu_user_regs *regs)
 {
     unsigned char insns_before[8] = {}, insns_after[16] = {};
@@ -687,7 +715,7 @@ void fatal_trap(const struct cpu_user_regs *regs, bool show_remote)
           (regs->eflags & X86_EFLAGS_IF) ? "" : ", IN INTERRUPT CONTEXT");
 }
 
-void do_reserved_trap(struct cpu_user_regs *regs)
+static void do_reserved_trap(struct cpu_user_regs *regs)
 {
     unsigned int trapnr = regs->entry_vector;
 
@@ -698,7 +726,7 @@ void do_reserved_trap(struct cpu_user_regs *regs)
     panic("FATAL RESERVED TRAP %#x: %s", trapnr, trapstr(trapnr));
 }
 
-void do_trap(struct cpu_user_regs *regs)
+static void do_trap(struct cpu_user_regs *regs)
 {
     struct vcpu *curr = current;
     unsigned int trapnr = regs->entry_vector;
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index 710c0616ba..af703f6c06 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -806,36 +806,6 @@ ENTRY(enable_nmis)
 GLOBAL(trap_nop)
         iretq
 
-
-
-.section .rodata, "a", @progbits
-
-ENTRY(exception_table)
-        .quad do_trap
-        .quad do_debug
-        .quad do_nmi
-        .quad do_int3
-        .quad do_trap
-        .quad do_trap
-        .quad do_invalid_op
-        .quad do_device_not_available
-        .quad do_reserved_trap /* double_fault - has its own entry. */
-        .quad do_reserved_trap /* coproc_seg_overrun - Intel 387 only. */
-        .quad do_trap
-        .quad do_trap
-        .quad do_trap
-        .quad do_general_protection
-        .quad do_page_fault
-        .quad do_reserved_trap /* Default PIC spurious irq - architecturally reserved. */
-        .quad do_trap
-        .quad do_trap
-        .quad do_machine_check
-        .quad do_trap
-        .rept TRAP_nr - ((. - exception_table) / 8)
-        .quad do_reserved_trap /* Architecturally reserved exceptions. */
-        .endr
-        .size exception_table, . - exception_table
-
 /* Table of automatically generated entry points.  One per vector. */
         .section .init.rodata, "a", @progbits
 GLOBAL(autogen_entrypoints)
diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h
index e8c2f02e99..9c70a98aef 100644
--- a/xen/include/asm-x86/processor.h
+++ b/xen/include/asm-x86/processor.h
@@ -501,7 +501,6 @@ DECLARE_TRAP_HANDLER(entry_int82);
 
 void trap_nop(void);
 void enable_nmis(void);
-void do_reserved_trap(struct cpu_user_regs *regs);
 
 void sysenter_entry(void);
 void sysenter_eflags_saved(void);
-- 
2.15.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-01-29 12:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-29 12:26 [PATCH v3 0/5] clang fixes Roger Pau Monne
2018-01-29 12:26 ` [PATCH v3 1/5] build: filter out command line assembler arguments Roger Pau Monne
2018-01-29 14:12   ` Ian Jackson
2018-01-29 12:26 ` [PATCH v3 2/5] x86/clang: fix build with indirect thunks Roger Pau Monne
2018-01-29 16:42   ` Jan Beulich
2018-01-29 12:26 ` [PATCH v3 3/5] x86: fix indirect thunk usage of CONFIG_INDIRECT_THUNK Roger Pau Monne
2018-01-29 16:45   ` Jan Beulich
2018-01-29 17:00     ` Roger Pau Monné
2018-01-29 12:26 ` Roger Pau Monne [this message]
2018-01-29 16:46   ` [PATCH v3 4/5] x86: move declaration of the exception_table to C Jan Beulich
2018-01-29 12:26 ` [PATCH v3 5/5] x86: remove usage of .skip with non-absolute expressions Roger Pau Monne
2018-01-29 12:43   ` Wei Liu
2018-01-29 12:53     ` Roger Pau Monné
2018-01-29 13:02     ` Jan Beulich
2018-01-29 13:05       ` Andrew Cooper
2018-01-29 13:39         ` Jan Beulich
2018-01-29 16:50   ` Jan Beulich
2018-01-29 18:22     ` Andrew Cooper
2018-01-30  9:23     ` Roger Pau Monné

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=20180129122643.13008-5-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.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 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).