* [XTF v2 v2 0/4] Small fixes and improvements
@ 2020-04-23 10:19 Pawel Wieczorkiewicz
2020-04-23 10:19 ` [XTF v2 v2 1/4] lib: Add XEN_MAJOR() and XEN_MINOR() macros Pawel Wieczorkiewicz
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Pawel Wieczorkiewicz @ 2020-04-23 10:19 UTC (permalink / raw)
To: xen-devel
Cc: julien, wipawel, paul, semelpaul, andrew.cooper3, wipawel, nmanthey
This is the first series of XTF patches I intend to send.
It covers some relatively small changes displaying Xen version on test
start, as well as adding serial consol support for HVM guests..
Paul Semel (1):
Enabled serial writing for hvm guests
Pawel Wieczorkiewicz (3):
lib: Add XEN_MAJOR() and XEN_MINOR() macros
lib: always append CR after LF in vsnprintf()
setup: Detect and display Xen version on test startup
arch/x86/setup.c | 22 +++++++++++++++++++++-
common/console.c | 3 ++-
common/libc/vsnprintf.c | 10 ++++++++++
common/setup.c | 6 +++++-
include/xtf/framework.h | 2 +-
include/xtf/lib.h | 3 +++
tests/xsa-213/main.c | 4 ++--
7 files changed, 44 insertions(+), 6 deletions(-)
--
2.16.6
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
^ permalink raw reply [flat|nested] 5+ messages in thread
* [XTF v2 v2 1/4] lib: Add XEN_MAJOR() and XEN_MINOR() macros
2020-04-23 10:19 [XTF v2 v2 0/4] Small fixes and improvements Pawel Wieczorkiewicz
@ 2020-04-23 10:19 ` Pawel Wieczorkiewicz
2020-04-23 10:19 ` [XTF v2 v2 2/4] lib: always append CR after LF in vsnprintf() Pawel Wieczorkiewicz
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Pawel Wieczorkiewicz @ 2020-04-23 10:19 UTC (permalink / raw)
To: xen-devel
Cc: julien, wipawel, paul, semelpaul, andrew.cooper3, wipawel, nmanthey
These are just a simple macros obtaining major, minor values as
returned by xen_version hypercall.
Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
---
include/xtf/lib.h | 3 +++
tests/xsa-213/main.c | 4 ++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/xtf/lib.h b/include/xtf/lib.h
index 3348464..40e5731 100644
--- a/include/xtf/lib.h
+++ b/include/xtf/lib.h
@@ -20,6 +20,9 @@
#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
+#define XEN_MAJOR(v) (((v) >> 16) & 0xFFFF)
+#define XEN_MINOR(v) ((v) & 0xFFFF)
+
void __noreturn panic(const char *fmt, ...) __printf(1, 2);
#define ASSERT(cond) \
diff --git a/tests/xsa-213/main.c b/tests/xsa-213/main.c
index 64e7065..0353168 100644
--- a/tests/xsa-213/main.c
+++ b/tests/xsa-213/main.c
@@ -121,8 +121,8 @@ void test_main(void)
{
long rc, xen_version = hypercall_xen_version(XENVER_version, NULL);
- printk("Found Xen %ld.%ld\n",
- (xen_version >> 16) & 0xffff, xen_version & 0xffff);
+ printk("Found Xen %ld.%ld\n", XEN_MAJOR(xen_version),
+ XEN_MINOR(xen_version));
xtf_set_idte(X86_VEC_AVAIL, &idte);
--
2.16.6
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [XTF v2 v2 2/4] lib: always append CR after LF in vsnprintf()
2020-04-23 10:19 [XTF v2 v2 0/4] Small fixes and improvements Pawel Wieczorkiewicz
2020-04-23 10:19 ` [XTF v2 v2 1/4] lib: Add XEN_MAJOR() and XEN_MINOR() macros Pawel Wieczorkiewicz
@ 2020-04-23 10:19 ` Pawel Wieczorkiewicz
2020-04-23 10:19 ` [XTF v2 v2 3/4] Enabled serial writing for hvm guests Pawel Wieczorkiewicz
2020-04-23 10:19 ` [XTF v2 v2 4/4] setup: Detect and display Xen version on test startup Pawel Wieczorkiewicz
3 siblings, 0 replies; 5+ messages in thread
From: Pawel Wieczorkiewicz @ 2020-04-23 10:19 UTC (permalink / raw)
To: xen-devel
Cc: julien, wipawel, paul, semelpaul, andrew.cooper3, wipawel, nmanthey
The explicit LFCR sequence guarantees proper line by line formatting
in the output.
The '\n' character alone on some terminals is not automatically
converted to LFCR.
Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
---
Changed since v1:
* Emit CRLF instead of LFCR
common/libc/vsnprintf.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/common/libc/vsnprintf.c b/common/libc/vsnprintf.c
index a49fd30..b9a4fab 100644
--- a/common/libc/vsnprintf.c
+++ b/common/libc/vsnprintf.c
@@ -284,7 +284,17 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
/* Put regular characters into the destination. */
if ( *fmt != '%' )
{
+ /*
+ * The '\n' character alone on some terminals is not automatically
+ * converted to CRLF.
+ * The explicit CRLF sequence guarantees proper line by line
+ * formatting in the output.
+ */
+ if ( *fmt == '\n' && str < end )
+ PUT('\r');
+
PUT(*fmt);
+
continue;
}
--
2.16.6
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [XTF v2 v2 3/4] Enabled serial writing for hvm guests
2020-04-23 10:19 [XTF v2 v2 0/4] Small fixes and improvements Pawel Wieczorkiewicz
2020-04-23 10:19 ` [XTF v2 v2 1/4] lib: Add XEN_MAJOR() and XEN_MINOR() macros Pawel Wieczorkiewicz
2020-04-23 10:19 ` [XTF v2 v2 2/4] lib: always append CR after LF in vsnprintf() Pawel Wieczorkiewicz
@ 2020-04-23 10:19 ` Pawel Wieczorkiewicz
2020-04-23 10:19 ` [XTF v2 v2 4/4] setup: Detect and display Xen version on test startup Pawel Wieczorkiewicz
3 siblings, 0 replies; 5+ messages in thread
From: Pawel Wieczorkiewicz @ 2020-04-23 10:19 UTC (permalink / raw)
To: xen-devel
Cc: julien, wipawel, paul, semelpaul, andrew.cooper3, wipawel, nmanthey
From: Paul Semel <phentex@amazon.de>
setup.c: PV console writing is not working in Xen 4.2 for hvm
guests, so we make xtf write to COM1 serial port to get its output
Signed-off-by: Paul Semel <phentex@amazon.de>
Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
---
Changed since v1:
* Increase callbacks array
arch/x86/setup.c | 14 ++++++++++++++
common/console.c | 3 ++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/arch/x86/setup.c b/arch/x86/setup.c
index 3c84e96..f6fa4df 100644
--- a/arch/x86/setup.c
+++ b/arch/x86/setup.c
@@ -238,6 +238,13 @@ static void qemu_console_write(const char *buf, size_t len)
: "d" (0x12));
}
+static void com1_write(const char *buf, size_t len)
+{
+ asm volatile("rep; outsb"
+ : "+S" (buf), "+c" (len)
+ : "d" (0x3f8));
+}
+
static void xen_console_write(const char *buf, size_t len)
{
hypercall_console_write(buf, len);
@@ -246,7 +253,14 @@ static void xen_console_write(const char *buf, size_t len)
void arch_setup(void)
{
if ( IS_DEFINED(CONFIG_HVM) && !pvh_start_info )
+ {
register_console_callback(qemu_console_write);
+ }
+
+ if ( IS_DEFINED(CONFIG_HVM) )
+ {
+ register_console_callback(com1_write);
+ }
register_console_callback(xen_console_write);
diff --git a/common/console.c b/common/console.c
index 0724fc9..00dbbca 100644
--- a/common/console.c
+++ b/common/console.c
@@ -13,8 +13,9 @@
* - Xen hypervisor console
* - PV console
* - Qemu debug console
+ * - COM1 serial console
*/
-static cons_output_cb output_fns[3];
+static cons_output_cb output_fns[4];
static unsigned int nr_cons_cb;
/* Guest PV console details. */
--
2.16.6
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [XTF v2 v2 4/4] setup: Detect and display Xen version on test startup
2020-04-23 10:19 [XTF v2 v2 0/4] Small fixes and improvements Pawel Wieczorkiewicz
` (2 preceding siblings ...)
2020-04-23 10:19 ` [XTF v2 v2 3/4] Enabled serial writing for hvm guests Pawel Wieczorkiewicz
@ 2020-04-23 10:19 ` Pawel Wieczorkiewicz
3 siblings, 0 replies; 5+ messages in thread
From: Pawel Wieczorkiewicz @ 2020-04-23 10:19 UTC (permalink / raw)
To: xen-devel
Cc: julien, wipawel, paul, semelpaul, andrew.cooper3, wipawel, nmanthey
In arch_setup() detect Xen version by issuing xen_version hypercall
and optionally pass the version to main_xtf().
Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
---
Changed since v1:
* Do not limit setup_pv_console() to HVM only. It does not crash.
It merely panics because the callbacks array wasn't increased.
arch/x86/setup.c | 8 +++++++-
common/setup.c | 6 +++++-
include/xtf/framework.h | 2 +-
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/arch/x86/setup.c b/arch/x86/setup.c
index f6fa4df..15ca3bb 100644
--- a/arch/x86/setup.c
+++ b/arch/x86/setup.c
@@ -250,8 +250,10 @@ static void xen_console_write(const char *buf, size_t len)
hypercall_console_write(buf, len);
}
-void arch_setup(void)
+void arch_setup(int *version)
{
+ int xen_version;
+
if ( IS_DEFINED(CONFIG_HVM) && !pvh_start_info )
{
register_console_callback(qemu_console_write);
@@ -272,6 +274,10 @@ void arch_setup(void)
init_hypercalls();
+ xen_version = hypercall_xen_version(XENVER_version, NULL);
+ if ( version )
+ *version = xen_version;
+
if ( !is_initdomain() )
{
setup_pv_console();
diff --git a/common/setup.c b/common/setup.c
index 932fc09..1d3da15 100644
--- a/common/setup.c
+++ b/common/setup.c
@@ -19,9 +19,13 @@
*/
void __noreturn xtf_main(void)
{
- arch_setup();
+ int xen_version;
+
+ arch_setup(&xen_version);
printk("--- Xen Test Framework ---\n");
+ printk("Found Xen: %d.%d\n", XEN_MAJOR(xen_version),
+ XEN_MINOR(xen_version));
printk("Environment: %s\n", environment_description);
printk("%s\n", test_title);
diff --git a/include/xtf/framework.h b/include/xtf/framework.h
index a71bf39..6664733 100644
--- a/include/xtf/framework.h
+++ b/include/xtf/framework.h
@@ -2,7 +2,7 @@
#define XTF_FRAMEWORK_H
/* To be implemented by each arch */
-void arch_setup(void);
+void arch_setup(int *);
void test_setup(void);
/* Single line summary of execution environment. */
--
2.16.6
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-04-23 10:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-23 10:19 [XTF v2 v2 0/4] Small fixes and improvements Pawel Wieczorkiewicz
2020-04-23 10:19 ` [XTF v2 v2 1/4] lib: Add XEN_MAJOR() and XEN_MINOR() macros Pawel Wieczorkiewicz
2020-04-23 10:19 ` [XTF v2 v2 2/4] lib: always append CR after LF in vsnprintf() Pawel Wieczorkiewicz
2020-04-23 10:19 ` [XTF v2 v2 3/4] Enabled serial writing for hvm guests Pawel Wieczorkiewicz
2020-04-23 10:19 ` [XTF v2 v2 4/4] setup: Detect and display Xen version on test startup Pawel Wieczorkiewicz
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.