Make hvm_fep available to non-debug build
v4 cover Make hvm_fep available to non-debug build
Wei Liu (3):
xen: add warning infrastructure
console: use warning infrastructure for sync console warning
xen: make available hvm_fep to non-debug build as well
docs/misc/xen-command-line.markdown | 8 ++++-- xen/arch/x86/Kconfig | 17 ++++++++++++ xen/arch/x86/hvm/hvm.c | 12 +++++++- xen/common/Makefile | 1 + xen/common/kernel.c | 6 ++-- xen/common/warning.c | 55 +++++++++++++++++++++++++++++++++++++ xen/drivers/char/console.c | 37 +++++++------------------ xen/include/asm-x86/hvm/hvm.h | 2 +- xen/include/xen/lib.h | 1 + xen/include/xen/warning.h | 7 +++++ 10 files changed, 113 insertions(+), 33 deletions(-) create mode 100644 xen/common/warning.c create mode 100644 xen/include/xen/warning.h
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v4 1/3 xen: add warning infrastructure
Use an array to keep track of warning text, provide a function to add warning text to track. Print warnings (if any) in console_endboot.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
v4:
1. Fix __initdata annotation.
2. Move warning_print to console_endboot.
3. Use obj-bin-y in Makefile.
4. Print asterisks in warning_print.
v3: new
--- xen/common/Makefile | 1 + xen/common/warning.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++ xen/drivers/char/console.c | 3 +++ xen/include/xen/warning.h | 7 ++++++ 4 files changed, 66 insertions(+) create mode 100644 xen/common/warning.c create mode 100644 xen/include/xen/warning.h
xen/common/Makefile +1 -0
@@ -59,6 +59,7 @@ obj-y += vm_event.o obj-y += vmap.o obj-y += vsprintf.o obj-y += wait.o +obj-bin-y += warning.init.o obj-$(CONFIG_XENOPROF) += xenoprof.o obj-y += xmalloc_tlsf.o
xen/common/warning.c new file +55 -0
55 lines not on this page · raw message
xen/drivers/char/console.c +3 -0
@@ -25,6 +25,7 @@#include <xen/video.h> #include <xen/kexec.h> #include <xen/ctype.h> +#include <xen/warning.h> #include <asm/debugger.h> #include <asm/div64.h> #include <xen/hypercall.h> /* for do_console_io */
@@ -796,6 +797,8 @@ void __init console_endboot(void)printk (" (Rate-limited: %s)" ,loglvl_str (xenlog_guest_upper_thresh));printk ("\n" ); +warning_print (); +if ( opt_sync_console ) {printk ("**********************************************\n" );
xen/include/xen/warning.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef _WARNING_H_ +#define _WARNING_H_ + +void warning_add (const char *warning); +void warning_print (void ); + +#endif
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v4 1/3] xen: add warning infrastructure
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 23.06.16 at 17:10, <[email protected]> wrote:
Use an array to keep track of warning text, provide a function to add warning text to track. Print warnings (if any) in
console_endboot.Signed-off-by Wei Liu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v4 1/3] xen: add warning infrastructure
In reply to Wei LiuQuoted 4 lines · Wei Liu
Use an array to keep track of warning text, provide a function to add warning text to track. Print warnings (if any) in
console_endboot.Signed-off-by Wei Liu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v4 2/3 console: use warning infrastructure for sync console warning
In reply to Wei LiuMove the warning text to a static variable and marked that as initconst data. Call warning_add in console_init_preirq. Finally remove all unused bits.
---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
v4:
1. Fix declaration of warning_sync_console.
2. Remove all asterisks in warning text.
v3: new
--- xen/drivers/char/console.c | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-)
xen/drivers/char/console.c +8 -28
@@ -18,7 +18,6 @@#include <xen/serial.h> #include <xen/softirq.h> #include <xen/keyhandler.h> -#include <xen/delay.h> #include <xen/guest_access.h> #include <xen/watchdog.h> #include <xen/shutdown.h>
@@ -30,6 +29,7 @@#include <asm/div64.h> #include <xen/hypercall.h> /* for do_console_io */ #include <xen/early_printk.h> +#include <xen/warning.h> /* console: comma-separated list of console outputs. */ static char __initdata opt_console[30 ] =OPT_CONSOLE_STR ;
@@ -45,6 +45,12 @@ string_param("conswitch", opt_conswitch);/* sync_console: force synchronous console output (useful for debugging). */ static bool_t __initdata opt_sync_console;boolean_param ("sync_console" , opt_sync_console); +static const char __initconst warning_sync_console[] = +"WARNING: CONSOLE OUTPUT IS SYNCHRONOUS\n" +"This option is intended to aid debugging of Xen by ensuring\n" +"that all output is synchronously delivered on the serial line.\n" +"However it can introduce SIGNIFICANT latencies and affect\n" +"timekeeping. It is NOT recommended for production use!\n" ;/* console_to_ring: send guest (incl. dom 0) console data to console ring. */ static bool_t __read_mostly opt_console_to_ring;
@@ -740,6 +746,7 @@ void __init console_init_preirq(void)serial_start_sync (sercon_handle);add_taint (TAINT_SYNC_CONSOLE );printk ("Console output is synchronous.\n" ); +warning_add (warning_sync_console); } }
@@ -787,8 +794,6 @@ void __init console_init_postirq(void)void __init console_endboot (void ) { -int i, j; -printk ("Std. Loglevel: %s" ,loglvl_str (xenlog_lower_thresh));if ( xenlog_upper_thresh != xenlog_lower_thresh )printk (" (Rate-limited: %s)" ,loglvl_str (xenlog_upper_thresh));
@@ -799,31 +804,6 @@ void __init console_endboot(void)warning_print (); -if ( opt_sync_console ) - { -printk ("**********************************************\n" ); -printk ("******* WARNING: CONSOLE OUTPUT IS SYNCHRONOUS\n" ); -printk ("******* This option is intended to aid debugging " -"of Xen by ensuring\n" ); -printk ("******* that all output is synchronously delivered " -"on the serial line.\n" ); -printk ("******* However it can introduce SIGNIFICANT latencies " -"and affect\n" ); -printk ("******* timekeeping. It is NOT recommended for " -"production use!\n" ); -printk ("**********************************************\n" ); -for ( i =0 ; i <3 ; i++ ) - { -printk ("%d... " ,3 -i); -for ( j =0 ; j <100 ; j++ ) - { -process_pending_softirqs (); -mdelay (10 ); - } - } -printk ("\n" ); - } -video_endboot ();/*
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v4 2/3] console: use warning infrastructure for sync console warning
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 23.06.16 at 17:10, <[email protected]> wrote:
Move the warning text to a static variable and marked that as initconst data. Call
warning_addinconsole_init_preirq. Finally remove all unused bits.Signed-off-by Wei Liu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v4 2/3] console: use warning infrastructure for sync console warning
In reply to Wei LiuQuoted 5 lines · Wei Liu
Move the warning text to a static variable and marked that as initconst data. Call
warning_addinconsole_init_preirq. Finally remove all unused bits.Signed-off-by Wei Liu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v4 3/3 xen: make available hvm_fep to non-debug build as well
In reply to Wei LiuOriginally hvm_fep was guarded by NDEBUG, which means it was only available to debug builds.
However there is value to have it for non-debug builds as well. User can use that to run tests in setup that replicates production setup.
Make it clear with a sync_console style warning that this option can't be used in production setup. Update command line documentation accordingly. Finally mark Xen as tainted when this feature is used.
Add a kconfig option under x86 to configure hvm_fep.
---
Cc: Andrew Cooper <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Doug Goldstein <[email protected]>
v4:
1. Fix declaration of warning_hvm_fep.
2. Remove stars in warning text.
v3:
1. Make config HVM_FEP an expert option and default to DEBUG.
2. Change some ifdefs
3. Update docs
4. Use the new warning infrastructure
v2:
1. unsigned -> unsigned int
2. %d -> %u
3. Add spaces around "-"
4. Update warning message
5. Only taint hv when fep is used
6. Add kconfig option
--- docs/misc/xen-command-line.markdown | 8 ++++++-- xen/arch/x86/Kconfig | 17 +++++++++++++++++ xen/arch/x86/hvm/hvm.c | 12 +++++++++++- xen/common/kernel.c | 6 ++++-- xen/include/asm-x86/hvm/hvm.h | 2 +- xen/include/xen/lib.h | 1 + 6 files changed, 40 insertions(+), 6 deletions(-)
docs/misc/xen-command-line.markdown +6 -2
@@ -886,8 +886,12 @@ Recognized in debug builds of the hypervisor only. Allow use of the Forced Emulation Prefix in HVM guests, to allow emulation of arbitrary instructions. -This option is intended for development purposes, and is only available in -debug builds of the hypervisor. +This option is intended for development and testing purposes. + +*Warning* +As this feature opens up the instruction emulator to arbitrary +instruction from an HVM guest, don't use this in production system. No +security support is provided when this flag is set. ### hvm\_port80 > `= <boolean>`
xen/arch/x86/Kconfig +17 -0
@@ -59,6 +59,23 @@ config BIGMEM If unsure, say N. +config HVM_FEP + bool "HVM Forced Emulation Prefix support" if EXPERT = "y" + default DEBUG + ---help--- + + Compiles in a feature that allows HVM guest to arbitrarily + exercise the instruction emulator. + + This feature can only be enabled during boot time with + appropriate hypervisor command line option. Please read + hypervisor command line documentation before trying to use + this feature. + + This is strictly for testing purposes, and not appropriate + for use in production. + + If unsure, say N. endmenu source "common/Kconfig"
xen/arch/x86/hvm/hvm.c +11 -1
@@ -37,6 +37,7 @@#include <xen/mem_access.h> #include <xen/rangeset.h> #include <xen/vm_event.h> +#include <xen/warning.h> #include <asm/shadow.h> #include <asm/hap.h> #include <asm/current.h>
@@ -97,9 +98,14 @@ boolean_param("hap", opt_hap_enabled);#ifndef opt_hvm_fep/* Permit use of the Forced Emulation Prefix in HVM guests */ -bool_t opt_hvm_fep; +bool_t __read_mostly opt_hvm_fep;boolean_param ("hvm_fep" , opt_hvm_fep);#endif +static const char __initconst warning_hvm_fep[] = +"WARNING: HVM FORCED EMULATION PREFIX IS AVAILABLE\n" +"This option is *ONLY* intended to aid testing of Xen.\n" +"It has implications on the security of the system.\n" +"Please *DO NOT* use this in production.\n" ;/* Xen command-line option to enable altp2m */ static bool_t __initdata opt_altp2m_enabled =0 ;
@@ -182,6 +188,9 @@ static int __init hvm_enable(void)if ( !opt_altp2m_enabled ) hvm_funcs.altp2m_supported =0 ; +if ( opt_hvm_fep ) +warning_add (warning_hvm_fep); +/* * Allow direct access to the PC debug ports 0x80 and 0xed (they are * often used for I/O delays, but the vmexits simply slow things down).
@@ -3910,6 +3919,7 @@ void hvm_ud_intercept(struct cpu_user_regs *regs) { regs->eip +=sizeof (sig); regs->eflags &= ~X86_EFLAGS_RF ; +add_taint (TAINT_HVM_FEP ); } }
xen/common/kernel.c +4 -2
@@ -175,6 +175,7 @@ int __init parse_bool(const char *s)* 'M' - Machine had a machine check experience. * 'B' - System has hit bad_page. * 'C' - Console output is synchronous. +* 'H' - HVM forced emulation prefix is permitted. * * The string is overwritten by the next call to print_taint(). */
@@ -182,11 +183,12 @@ char *print_tainted(char *str) {if ( tainted ) { -snprintf (str,TAINT_STRING_MAX_LEN ,"Tainted: %c%c%c%c" , +snprintf (str,TAINT_STRING_MAX_LEN ,"Tainted: %c%c%c%c%c" , tainted &TAINT_UNSAFE_SMP ?'S' :' ' , tainted &TAINT_MACHINE_CHECK ?'M' :' ' , tainted &TAINT_BAD_PAGE ?'B' :' ' , - tainted &TAINT_SYNC_CONSOLE ?'C' :' ' ); + tainted &TAINT_SYNC_CONSOLE ?'C' :' ' , + tainted &TAINT_HVM_FEP ?'H' :' ' ); }else {
xen/include/asm-x86/hvm/hvm.h +1 -1
@@ -27,7 +27,7 @@#include <public/hvm/save.h> #include <xen/mm.h> -#ifndef NDEBUG +#ifdef CONFIG_HVM_FEP /* Permit use of the Forced Emulation Prefix in HVM guests */ extern bool_t opt_hvm_fep;#else
xen/include/xen/lib.h +1 -0
@@ -142,6 +142,7 @@ uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);#define TAINT_BAD_PAGE (1<<2)#define TAINT_SYNC_CONSOLE (1<<3)#define TAINT_ERROR_INJECT (1<<4) +#define TAINT_HVM_FEP (1<<5)extern int tainted;#define TAINT_STRING_MAX_LEN 20extern char *print_tainted (char *str);
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v4 3/3] xen: make available hvm_fep to non-debug build as well
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 23.06.16 at 17:10, <[email protected]> wrote:
Originally
hvm_fepwas guarded by NDEBUG, which means it was only available to debug builds.However there is value to have it for non-debug builds as well. User can use that to run tests in setup that replicates production setup.
Quoted 7 lines
Make it clear with a
sync_consolestyle warning that this option can't be used in production setup. Update command line documentation accordingly. Finally mark Xen as tainted when this feature is used.Add a kconfig option under x86 to configure
hvm_fep.Signed-off-by Wei Liu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v4 3/3] xen: make available hvm_fep to non-debug build as well
In reply to Wei LiuQuoted 5 lines · Wei Liu
Originally
hvm_fepwas guarded by NDEBUG, which means it was only available to debug builds.However there is value to have it for non-debug builds as well. User can use that to run tests in setup that replicates production setup.
That is odd phrasing. Perhaps "Users can use it to..." ?
Quoted 8 lines
Make it clear with a
sync_consolestyle warning that this option can't be used in production setup. Update command line documentation accordingly. Finally mark Xen as tainted when this feature is used.Add a kconfig option under x86 to configure
hvm_fep.Signed-off-by Wei Liu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v4 3/3] xen: make available hvm_fep to non-debug build as well
Quoted 9 lines · Andrew Cooper
Quoted 5 lines · Wei Liu
Originally
hvm_fepwas guarded by NDEBUG, which means it was only available to debug builds.However there is value to have it for non-debug builds as well. User can use that to run tests in setup that replicates production setup.
That is odd phrasing. Perhaps "Users can use it to..." ?
Feel free to change it as you wish to make it sounds more native.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v4 3/3] xen: make available hvm_fep to non-debug build as well
Quoted 10 lines · Wei Liu
Quoted 8 lines · Andrew Cooper
Quoted 5 lines · Wei Liu
Originally
hvm_fepwas guarded by NDEBUG, which means it was only available to debug builds.However there is value to have it for non-debug builds as well. User can use that to run tests in setup that replicates production setup.
That is odd phrasing. Perhaps "Users can use it to..." ?
Feel free to change it as you wish to make it sounds more native.
Ok - I will fix it on commit. I will pick the series up in just a moment.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v4 3/3] xen: make available hvm_fep to non-debug build as well
In reply to Wei LiuQuoted 5 lines · Wei Liu
Originally
hvm_fepwas guarded by NDEBUG, which means it was only available to debug builds.However there is value to have it for non-debug builds as well. User can use that to run tests in setup that replicates production setup.
"Users can use it to run tests in a setup that replicates a production setup" is what I think was meant?
Quoted 8 lines
Make it clear with a
sync_consolestyle warning that this option can't be used in production setup. Update command line documentation accordingly. Finally mark Xen as tainted when this feature is used.Add a kconfig option under x86 to configure
hvm_fep.Signed-off-by Wei Liu <[email protected]>
Otherwise the change looks good.
Signature · 1 line
Doug Goldstein
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 4 lines · Wei Liu
Wei Liu (3):
xen: add warning infrastructure
console: use warning infrastructure for sync console warning
xen: make availablehvm_fepto non-debug build as well
Committed, including the small adjustments.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel