* [PATCH kvm-unit-tests v2 0/3] realmode: print to serial port
@ 2013-05-09 14:55 Paolo Bonzini
2013-05-09 14:55 ` [PATCH kvm-unit-tests v2 1/3] realmode: restore DF at exit from exec_in_big_real_mode Paolo Bonzini
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Paolo Bonzini @ 2013-05-09 14:55 UTC (permalink / raw)
To: kvm
The realmode test is compiled in 16-bit mode, hence it uses a
cut-and-pasted version of the mini C library and is still printing
to the old debug port at 0xf1. Use the serial port instead.
v1->v2: set serial_inited, both in the original and the copied code [Gleb]
Paolo Bonzini (3):
realmode: restore DF at exit from exec_in_big_real_mode
io: only initialize serial port once
realmode: print to serial port
lib/x86/io.c | 1 +
x86/realmode.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 68 insertions(+), 3 deletions(-)
--
1.8.1.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH kvm-unit-tests v2 1/3] realmode: restore DF at exit from exec_in_big_real_mode
2013-05-09 14:55 [PATCH kvm-unit-tests v2 0/3] realmode: print to serial port Paolo Bonzini
@ 2013-05-09 14:55 ` Paolo Bonzini
2013-05-09 14:55 ` [PATCH kvm-unit-tests v2 2/3] io: only initialize serial port once Paolo Bonzini
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2013-05-09 14:55 UTC (permalink / raw)
To: kvm
Some tests fail if DF=1. Restore it directly after executing the test,
do not do it "magically" in print_serial.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
x86/realmode.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/x86/realmode.c b/x86/realmode.c
index 35ace08..71c8a7d 100644
--- a/x86/realmode.c
+++ b/x86/realmode.c
@@ -26,7 +26,7 @@ static void print_serial(const char *buf)
{
unsigned long len = strlen(buf);
- asm volatile ("cld; addr32/rep/outsb" : "+S"(buf), "+c"(len) : "d"(0xf1));
+ asm volatile ("addr32/rep/outsb" : "+S"(buf), "+c"(len) : "d"(0xf1));
}
static void exit(int code)
@@ -109,6 +109,8 @@ static void exec_in_big_real_mode(struct insn_desc *insn)
"pushfl \n\t"
"popl %[save]+36 \n\t"
+ /* Restore DF for the harness code */
+ "cld\n\t"
"xor %[tmp], %[tmp] \n\t"
"mov %[tmp], %%gs \n\t"
: [tmp]"=&r"(tmp), [save]"+m"(save)
--
1.8.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH kvm-unit-tests v2 2/3] io: only initialize serial port once
2013-05-09 14:55 [PATCH kvm-unit-tests v2 0/3] realmode: print to serial port Paolo Bonzini
2013-05-09 14:55 ` [PATCH kvm-unit-tests v2 1/3] realmode: restore DF at exit from exec_in_big_real_mode Paolo Bonzini
@ 2013-05-09 14:55 ` Paolo Bonzini
2013-05-09 14:55 ` [PATCH kvm-unit-tests v2 3/3] realmode: print to serial port Paolo Bonzini
2013-05-09 15:04 ` [PATCH kvm-unit-tests v2 0/3] " Gleb Natapov
3 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2013-05-09 14:55 UTC (permalink / raw)
To: kvm
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
lib/x86/io.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/x86/io.c b/lib/x86/io.c
index 0282888..d3b971e 100644
--- a/lib/x86/io.c
+++ b/lib/x86/io.c
@@ -46,6 +46,7 @@ static void print_serial(const char *buf)
unsigned long i;
if (!serial_inited) {
serial_init();
+ serial_inited = 1;
}
for (i = 0; i < len; i++) {
--
1.8.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH kvm-unit-tests v2 3/3] realmode: print to serial port
2013-05-09 14:55 [PATCH kvm-unit-tests v2 0/3] realmode: print to serial port Paolo Bonzini
2013-05-09 14:55 ` [PATCH kvm-unit-tests v2 1/3] realmode: restore DF at exit from exec_in_big_real_mode Paolo Bonzini
2013-05-09 14:55 ` [PATCH kvm-unit-tests v2 2/3] io: only initialize serial port once Paolo Bonzini
@ 2013-05-09 14:55 ` Paolo Bonzini
2013-05-09 15:04 ` [PATCH kvm-unit-tests v2 0/3] " Gleb Natapov
3 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2013-05-09 14:55 UTC (permalink / raw)
To: kvm
The realmode test is still printing to the old debug port at 0xf1.
Use the serial port instead.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
x86/realmode.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 64 insertions(+), 2 deletions(-)
diff --git a/x86/realmode.c b/x86/realmode.c
index 71c8a7d..981be08 100644
--- a/x86/realmode.c
+++ b/x86/realmode.c
@@ -1,3 +1,7 @@
+#ifndef USE_SERIAL
+#define USE_SERIAL
+#endif
+
asm(".code16gcc");
typedef unsigned char u8;
@@ -22,16 +26,74 @@ static int strlen(const char *str)
return n;
}
+static void outb(u8 data, u16 port)
+{
+ asm volatile("out %0, %1" : : "a"(data), "d"(port));
+}
+
+#ifdef USE_SERIAL
+static int serial_iobase = 0x3f8;
+static int serial_inited = 0;
+
+static u8 inb(u16 port)
+{
+ u8 data;
+ asm volatile("in %1, %0" : "=a"(data) : "d"(port));
+ return data;
+}
+
+static void serial_outb(char ch)
+{
+ u8 lsr;
+
+ do {
+ lsr = inb(serial_iobase + 0x05);
+ } while (!(lsr & 0x20));
+
+ outb(ch, serial_iobase + 0x00);
+}
+
+static void serial_init(void)
+{
+ u8 lcr;
+
+ /* set DLAB */
+ lcr = inb(serial_iobase + 0x03);
+ lcr |= 0x80;
+ outb(lcr, serial_iobase + 0x03);
+
+ /* set baud rate to 115200 */
+ outb(0x01, serial_iobase + 0x00);
+ outb(0x00, serial_iobase + 0x01);
+
+ /* clear DLAB */
+ lcr = inb(serial_iobase + 0x03);
+ lcr &= ~0x80;
+ outb(lcr, serial_iobase + 0x03);
+}
+#endif
+
static void print_serial(const char *buf)
{
unsigned long len = strlen(buf);
-
+#ifdef USE_SERIAL
+ unsigned long i;
+ if (!serial_inited) {
+ serial_init();
+ serial_inited = 1;
+ }
+
+ for (i = 0; i < len; i++) {
+ serial_outb(buf[i]);
+ }
+#else
asm volatile ("addr32/rep/outsb" : "+S"(buf), "+c"(len) : "d"(0xf1));
+#endif
}
static void exit(int code)
{
- asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));
+ outb(code, 0xf4);
}
struct regs {
--
1.8.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH kvm-unit-tests v2 0/3] realmode: print to serial port
2013-05-09 14:55 [PATCH kvm-unit-tests v2 0/3] realmode: print to serial port Paolo Bonzini
` (2 preceding siblings ...)
2013-05-09 14:55 ` [PATCH kvm-unit-tests v2 3/3] realmode: print to serial port Paolo Bonzini
@ 2013-05-09 15:04 ` Gleb Natapov
3 siblings, 0 replies; 5+ messages in thread
From: Gleb Natapov @ 2013-05-09 15:04 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm
On Thu, May 09, 2013 at 04:55:02PM +0200, Paolo Bonzini wrote:
> The realmode test is compiled in 16-bit mode, hence it uses a
> cut-and-pasted version of the mini C library and is still printing
> to the old debug port at 0xf1. Use the serial port instead.
>
> v1->v2: set serial_inited, both in the original and the copied code [Gleb]
>
> Paolo Bonzini (3):
> realmode: restore DF at exit from exec_in_big_real_mode
> io: only initialize serial port once
> realmode: print to serial port
>
Applied, thanks.
> lib/x86/io.c | 1 +
> x86/realmode.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
> 2 files changed, 68 insertions(+), 3 deletions(-)
>
> --
> 1.8.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Gleb.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-05-09 15:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-09 14:55 [PATCH kvm-unit-tests v2 0/3] realmode: print to serial port Paolo Bonzini
2013-05-09 14:55 ` [PATCH kvm-unit-tests v2 1/3] realmode: restore DF at exit from exec_in_big_real_mode Paolo Bonzini
2013-05-09 14:55 ` [PATCH kvm-unit-tests v2 2/3] io: only initialize serial port once Paolo Bonzini
2013-05-09 14:55 ` [PATCH kvm-unit-tests v2 3/3] realmode: print to serial port Paolo Bonzini
2013-05-09 15:04 ` [PATCH kvm-unit-tests v2 0/3] " Gleb Natapov
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.