From: Keir Fraser Subject: Re: Re: [Xen-changelog] [xen-3.4-testing] x86: Generalise BUGFRAME_dump mechanism to allow polled UART irq to Date: Wed, 24 Feb 2010 14:04:42 +0000 Message-ID: References: <521a4d121002240525n39524bbds3149fcac8f373f13@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <521a4d121002240525n39524bbds3149fcac8f373f13@mail.gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Mark Johnson , "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org Builds for me! :-) K. On 24/02/2010 13:25, "Mark Johnson" wrote: > FYI, I see the following build error with this patch... >=20 > MRJ >=20 >=20 > ---- new warnings/errors for xen ---- > keyhandler.c: In function `__dump_execstate': > keyhandler.c:96: warning: asm operand 1 probably doesn't match constraint= s > gmake[5]: *** [keyhandler.o] Error 1 > gmake[4]: *** [/tank/ws/xvm-3.4.3/xen.hg/xen/common/built_in.o] Error 2 > gmake[3]: *** [/tank/ws/xvm-3.4.3/xen.hg/xen/xen] Error 2 >=20 >=20 > static void __dump_execstate(void *unused) > { > dump_execution_state(); <=3D=3D=3D=3D keyhandler.c:96 >=20 >=20 >> +#define dump_execution_state() >> run_in_exception_handler(show_execution_state) >=20 >> +#define run_in_exception_handler(fn) \ >> asm volatile ( \ >> - "ud2 ; ret $0" \ >> - : : "i" (BUGFRAME_dump) ) >> + "ud2 ; ret %0" BUG_STR(1) \ >> + : : "i" (BUGFRAME_run_fn), \ >> + "i" (fn) ) >>=20 >=20 >=20 >=20 >=20 > On Wed, Feb 24, 2010 at 6:20 AM, Xen patchbot-3.4-testing > wrote: >> # HG changeset patch >> # User Keir Fraser >> # Date 1267009865 0 >> # Node ID 3ccf3e993d5ddc4e5dff15e464dc63d5485e984c >> # Parent =A0cddd503fb25401fdaabe1344fdf5e060ca158e7a >> x86: Generalise BUGFRAME_dump mechanism to allow polled UART irq to >> get proper regs argument. >>=20 >> Signed-off-by: Keir Fraser >> xen-unstable changeset: =A0 20969:8cb6e7eff2ba >> xen-unstable date: =A0 =A0 =A0 =A0Wed Feb 24 10:44:30 2010 +0000 >> --- >> =A0xen/arch/x86/traps.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 32 >> ++++++++++++++++++-------------- >> =A0xen/drivers/acpi/utilities/utglobal.c | =A0 =A01 + >> =A0xen/drivers/char/ns16550.c =A0 =A0 =A0 =A0 =A0 =A0| =A0 22 +++++++++++++++++----- >> =A0xen/include/asm-x86/bug.h =A0 =A0 =A0 =A0 =A0 =A0 | =A0 =A09 +++++---- >> =A0xen/include/asm-x86/processor.h =A0 =A0 =A0 | =A0 =A01 + >> =A05 files changed, 42 insertions(+), 23 deletions(-) >>=20 >> diff -r cddd503fb254 -r 3ccf3e993d5d xen/arch/x86/traps.c >> --- a/xen/arch/x86/traps.c =A0 =A0 =A0Wed Feb 24 11:10:09 2010 +0000 >> +++ b/xen/arch/x86/traps.c =A0 =A0 =A0Wed Feb 24 11:11:05 2010 +0000 >> @@ -840,6 +840,7 @@ asmlinkage void do_invalid_op(struct cpu >> =A0{ >> =A0 =A0 struct bug_frame bug; >> =A0 =A0 struct bug_frame_str bug_str; >> + =A0 =A0const void *p; >> =A0 =A0 const char *filename, *predicate, *eip =3D (char *)regs->eip; >> =A0 =A0 unsigned long fixup; >> =A0 =A0 int id, lineno; >> @@ -860,26 +861,29 @@ asmlinkage void do_invalid_op(struct cpu >> =A0 =A0 =A0 =A0 goto die; >> =A0 =A0 eip +=3D sizeof(bug); >>=20 >> - =A0 =A0id =3D bug.id & 3; >> - >> - =A0 =A0if ( id =3D=3D BUGFRAME_dump ) >> - =A0 =A0{ >> - =A0 =A0 =A0 =A0show_execution_state(regs); >> - =A0 =A0 =A0 =A0regs->eip =3D (unsigned long)eip; >> - =A0 =A0 =A0 =A0return; >> - =A0 =A0} >> - >> - =A0 =A0/* WARN, BUG or ASSERT: decode the filename pointer and line number= . */ >> + =A0 =A0/* Decode first pointer argument. */ >> =A0 =A0 if ( !is_kernel(eip) || >> =A0 =A0 =A0 =A0 =A0__copy_from_user(&bug_str, eip, sizeof(bug_str)) || >> =A0 =A0 =A0 =A0 =A0(bug_str.mov !=3D 0xbc) ) >> =A0 =A0 =A0 =A0 goto die; >> - =A0 =A0filename =3D bug_str(bug_str, eip); >> + =A0 =A0p =3D bug_str(bug_str, eip); >> + =A0 =A0if ( !is_kernel(p) ) >> + =A0 =A0 =A0 =A0goto die; >> =A0 =A0 eip +=3D sizeof(bug_str); >>=20 >> - =A0 =A0if ( !is_kernel(filename) ) >> - =A0 =A0 =A0 =A0filename =3D ""; >> - =A0 =A0lineno =A0 =3D bug.id >> 2; >> + =A0 =A0id =3D bug.id & 3; >> + >> + =A0 =A0if ( id =3D=3D BUGFRAME_run_fn ) >> + =A0 =A0{ >> + =A0 =A0 =A0 =A0const void (*fn)(struct cpu_user_regs *) =3D p; >> + =A0 =A0 =A0 =A0(*fn)(regs); >> + =A0 =A0 =A0 =A0regs->eip =3D (unsigned long)eip; >> + =A0 =A0 =A0 =A0return; >> + =A0 =A0} >> + >> + =A0 =A0/* WARN, BUG or ASSERT: decode the filename pointer and line number= . */ >> + =A0 =A0filename =3D p; >> + =A0 =A0lineno =3D bug.id >> 2; >>=20 >> =A0 =A0 if ( id =3D=3D BUGFRAME_warn ) >> =A0 =A0 { >> diff -r cddd503fb254 -r 3ccf3e993d5d xen/drivers/acpi/utilities/utglobal= .c >> --- a/xen/drivers/acpi/utilities/utglobal.c =A0 =A0 Wed Feb 24 11:10:09 2010 >> +0000 >> +++ b/xen/drivers/acpi/utilities/utglobal.c =A0 =A0 Wed Feb 24 11:11:05 2010 >> +0000 >> @@ -45,6 +45,7 @@ >>=20 >> =A0#include >> =A0#include >> +#include >> =A0#include >> =A0#include >>=20 >> diff -r cddd503fb254 -r 3ccf3e993d5d xen/drivers/char/ns16550.c >> --- a/xen/drivers/char/ns16550.c =A0 =A0 =A0 =A0Wed Feb 24 11:10:09 2010 +0000 >> +++ b/xen/drivers/char/ns16550.c =A0 =A0 =A0 =A0Wed Feb 24 11:11:05 2010 +0000 >> @@ -144,11 +144,13 @@ static void ns16550_interrupt( >> =A0 =A0 } >> =A0} >>=20 >> -static void ns16550_poll(void *data) >> -{ >> - =A0 =A0struct serial_port *port =3D data; >> - =A0 =A0struct ns16550 *uart =3D port->uart; >> - =A0 =A0struct cpu_user_regs *regs =3D guest_cpu_user_regs(); >> +/* Safe: ns16550_poll() runs in softirq context so not reentrant on a g= iven >> CPU. */ >> +static DEFINE_PER_CPU(struct serial_port *, poll_port); >> + >> +static void __ns16550_poll(struct cpu_user_regs *regs) >> +{ >> + =A0 =A0struct serial_port *port =3D this_cpu(poll_port); >> + =A0 =A0struct ns16550 *uart =3D port->uart; >>=20 >> =A0 =A0 if ( uart->intr_works ) >> =A0 =A0 =A0 =A0 return; =A0 =A0 /* Interrupts work - no more polling */ >> @@ -166,6 +168,16 @@ static void ns16550_poll(void *data) >> =A0 =A0 =A0 =A0 serial_tx_interrupt(port, regs); >>=20 >> =A0 =A0 set_timer(&uart->timer, NOW() + MILLISECS(uart->timeout_ms)); >> +} >> + >> +static void ns16550_poll(void *data) >> +{ >> + =A0 =A0this_cpu(poll_port) =3D data; >> +#ifdef run_in_exception_handler >> + =A0 =A0run_in_exception_handler(__ns16550_poll); >> +#else >> + =A0 =A0__ns16550_poll(guest_cpu_user_regs()); >> +#endif >> =A0} >>=20 >> =A0static int ns16550_tx_empty(struct serial_port *port) >> diff -r cddd503fb254 -r 3ccf3e993d5d xen/include/asm-x86/bug.h >> --- a/xen/include/asm-x86/bug.h Wed Feb 24 11:10:09 2010 +0000 >> +++ b/xen/include/asm-x86/bug.h Wed Feb 24 11:11:05 2010 +0000 >> @@ -13,15 +13,16 @@ struct bug_frame { >> =A0 =A0 unsigned short id; /* BUGFRAME_??? */ >> =A0} __attribute__((packed)); >>=20 >> -#define BUGFRAME_dump =A0 0 >> +#define BUGFRAME_run_fn 0 >> =A0#define BUGFRAME_warn =A0 1 >> =A0#define BUGFRAME_bug =A0 =A02 >> =A0#define BUGFRAME_assert 3 >>=20 >> -#define dump_execution_state() =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \ >> +#define run_in_exception_handler(fn) =A0 =A0 =A0 =A0 =A0 =A0 =A0 \ >> =A0 =A0 asm volatile ( =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \ >> - =A0 =A0 =A0 =A0"ud2 ; ret $0" =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \ >> - =A0 =A0 =A0 =A0: : "i" (BUGFRAME_dump) ) >> + =A0 =A0 =A0 =A0"ud2 ; ret %0" BUG_STR(1) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\ >> + =A0 =A0 =A0 =A0: : "i" (BUGFRAME_run_fn), =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \ >> + =A0 =A0 =A0 =A0 =A0 =A0"i" (fn) ) >>=20 >> =A0#define WARN() =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \ >> =A0 =A0 asm volatile ( =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \ >> diff -r cddd503fb254 -r 3ccf3e993d5d xen/include/asm-x86/processor.h >> --- a/xen/include/asm-x86/processor.h =A0 Wed Feb 24 11:10:09 2010 +0000 >> +++ b/xen/include/asm-x86/processor.h =A0 Wed Feb 24 11:11:05 2010 +0000 >> @@ -532,6 +532,7 @@ void show_stack_overflow(unsigned int cp >> =A0void show_stack_overflow(unsigned int cpu, unsigned long esp); >> =A0void show_registers(struct cpu_user_regs *regs); >> =A0void show_execution_state(struct cpu_user_regs *regs); >> +#define dump_execution_state() >> run_in_exception_handler(show_execution_state) >> =A0void show_page_walk(unsigned long addr); >> =A0asmlinkage void fatal_trap(int trapnr, struct cpu_user_regs *regs); >>=20 >>=20 >> _______________________________________________ >> Xen-changelog mailing list >> Xen-changelog@lists.xensource.com >> http://lists.xensource.com/xen-changelog >>=20 >=20 > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel