xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [0/2] hvc_xen: fix xenboot on x86 and export to ARM
@ 2016-02-24 12:22 Stefano Stabellini
  2016-02-24 12:23 ` [PATCH 1/2] hvc_xen: add earlycon support Stefano Stabellini
  2016-02-24 12:23 ` [PATCH 2/2] hvc_xen: fix xenboot for DomUs Stefano Stabellini
  0 siblings, 2 replies; 11+ messages in thread
From: Stefano Stabellini @ 2016-02-24 12:22 UTC (permalink / raw)
  To: xen-devel
  Cc: linux-kernel, Stefano Stabellini, David Vrabel,
	Konrad Rzeszutek Wilk, boris.ostrovsky

Hi all,

this series includes a patch to export xenboot on ARM and ARM64 as
earlycon, and another patch to get xenboot fully working again for PV
DomUs on x86 (currently the xenboot output only goes to the hypervisor
via hypercall and not to the DomU console).

Cheers,

Stefano

Stefano Stabellini (2):
      hvc_xen: add earlycon support
      hvc_xen: fix xenboot for DomUs

 drivers/tty/hvc/hvc_xen.c |   80 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 63 insertions(+), 17 deletions(-)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/2] hvc_xen: add earlycon support
  2016-02-24 12:22 [0/2] hvc_xen: fix xenboot on x86 and export to ARM Stefano Stabellini
@ 2016-02-24 12:23 ` Stefano Stabellini
  2016-02-24 14:43   ` Boris Ostrovsky
  2016-02-24 12:23 ` [PATCH 2/2] hvc_xen: fix xenboot for DomUs Stefano Stabellini
  1 sibling, 1 reply; 11+ messages in thread
From: Stefano Stabellini @ 2016-02-24 12:23 UTC (permalink / raw)
  To: xen-devel
  Cc: linux-kernel, Stefano.Stabellini, david.vrabel, konrad.wilk,
	boris.ostrovsky, Stefano Stabellini

Introduce EARLYCON support in hvc_xen, useful for early debugging on arm
and arm64, where xen early_printk is not available. Differently from
xenboot_write_console on x86, we won't just return if !xen_pv_domain(),
because arm and arm64 guests are actually xen_hvm_domain() from linux
pov, and also because we want to capture all possible writes, including
the ones earlier than xen_early_init().

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 drivers/tty/hvc/hvc_xen.c |   48 ++++++++++++++++++++++++++++++++++-----------
 1 file changed, 37 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c
index fa816b7..34e8e9f 100644
--- a/drivers/tty/hvc/hvc_xen.c
+++ b/drivers/tty/hvc/hvc_xen.c
@@ -25,6 +25,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/list.h>
+#include <linux/serial_core.h>
 
 #include <asm/io.h>
 #include <asm/xen/hypervisor.h>
@@ -597,21 +598,11 @@ static int xen_cons_init(void)
 }
 console_initcall(xen_cons_init);
 
-#ifdef CONFIG_EARLY_PRINTK
-static void xenboot_write_console(struct console *console, const char *string,
-				  unsigned len)
+static void domU_write_early_console(const char *string, unsigned len)
 {
 	unsigned int linelen, off = 0;
 	const char *pos;
 
-	if (!xen_pv_domain())
-		return;
-
-	dom0_write_console(0, string, len);
-
-	if (xen_initial_domain())
-		return;
-
 	domU_write_console(0, "(early) ", 8);
 	while (off < len && NULL != (pos = strchr(string+off, '\n'))) {
 		linelen = pos-string+off;
@@ -625,6 +616,21 @@ static void xenboot_write_console(struct console *console, const char *string,
 		domU_write_console(0, string+off, len-off);
 }
 
+#ifdef CONFIG_EARLY_PRINTK
+static void xenboot_write_console(struct console *console, const char *string,
+				  unsigned len)
+{
+	if (!xen_pv_domain())
+		return;
+
+	dom0_write_console(0, string, len);
+
+	if (xen_initial_domain())
+		return;
+
+	domU_write_early_console(string, len);
+}
+
 struct console xenboot_console = {
 	.name		= "xenboot",
 	.write		= xenboot_write_console,
@@ -664,3 +670,23 @@ void xen_raw_printk(const char *fmt, ...)
 
 	xen_raw_console_write(buf);
 }
+
+static void xenboot_earlycon_write(struct console *console,
+				  const char *string,
+				  unsigned len)
+{
+	dom0_write_console(0, string, len);
+
+	if (xen_initial_domain())
+		return;
+
+	domU_write_early_console(string, len);
+}
+
+static int __init xenboot_earlycon_setup(struct earlycon_device *device,
+					    const char *opt)
+{
+	device->con->write = xenboot_earlycon_write;
+	return 0;
+}
+EARLYCON_DECLARE(xenboot, xenboot_earlycon_setup);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/2] hvc_xen: fix xenboot for DomUs
  2016-02-24 12:22 [0/2] hvc_xen: fix xenboot on x86 and export to ARM Stefano Stabellini
  2016-02-24 12:23 ` [PATCH 1/2] hvc_xen: add earlycon support Stefano Stabellini
@ 2016-02-24 12:23 ` Stefano Stabellini
  2016-02-24 12:53   ` kbuild test robot
  1 sibling, 1 reply; 11+ messages in thread
From: Stefano Stabellini @ 2016-02-24 12:23 UTC (permalink / raw)
  To: xen-devel
  Cc: linux-kernel, Stefano.Stabellini, david.vrabel, konrad.wilk,
	boris.ostrovsky, Stefano Stabellini

The xenboot early console has been partially broken for DomU for a long
time: the output would only go to the hypervisor via hypercall
(HYPERVISOR_console_io), while it wouldn't actually go to the DomU
console. The reason is that domU_write_console would return early as no
xencons structs are configured for it.

Add an appropriate xencons struct for xenboot from the xenboot setup
callback.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 drivers/tty/hvc/hvc_xen.c |   32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c
index 34e8e9f..20fe578 100644
--- a/drivers/tty/hvc/hvc_xen.c
+++ b/drivers/tty/hvc/hvc_xen.c
@@ -246,6 +246,18 @@ err:
 	return -ENODEV;
 }
 
+static int xen_early_pv_console_init(struct xencons_info *info, int vtermno)
+{
+	info->evtchn = xen_start_info->console.domU.evtchn;
+	/* GFN == MFN for PV guest */
+	info->intf = gfn_to_virt(xen_start_info->console.domU.mfn);
+	info->vtermno = vtermno;
+
+	list_add_tail(&info->list, &xenconsoles);
+
+	return 0;
+}
+
 static int xen_pv_console_init(void)
 {
 	struct xencons_info *info;
@@ -265,13 +277,8 @@ static int xen_pv_console_init(void)
 		/* already configured */
 		return 0;
 	}
-	info->evtchn = xen_start_info->console.domU.evtchn;
-	/* GFN == MFN for PV guest */
-	info->intf = gfn_to_virt(xen_start_info->console.domU.mfn);
-	info->vtermno = HVC_COOKIE;
-
 	spin_lock(&xencons_lock);
-	list_add_tail(&info->list, &xenconsoles);
+	xen_early_pv_console_init(info, HVC_COOKIE);
 	spin_unlock(&xencons_lock);
 
 	return 0;
@@ -617,6 +624,18 @@ static void domU_write_early_console(const char *string, unsigned len)
 }
 
 #ifdef CONFIG_EARLY_PRINTK
+static int xenboot_setup_console(struct console *console, char *string)
+{
+	static struct xencons_info xenboot;
+
+	if (xen_initial_domain())
+		return 0;
+	if (!xen_pv_domain())
+		return -ENODEV;
+
+	xen_early_pv_console_init(&xenboot, 0);
+}
+
 static void xenboot_write_console(struct console *console, const char *string,
 				  unsigned len)
 {
@@ -634,6 +653,7 @@ static void xenboot_write_console(struct console *console, const char *string,
 struct console xenboot_console = {
 	.name		= "xenboot",
 	.write		= xenboot_write_console,
+	.setup		= xenboot_setup_console,
 	.flags		= CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME,
 	.index		= -1,
 };
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] hvc_xen: fix xenboot for DomUs
  2016-02-24 12:23 ` [PATCH 2/2] hvc_xen: fix xenboot for DomUs Stefano Stabellini
@ 2016-02-24 12:53   ` kbuild test robot
  2016-02-24 15:48     ` Stefano Stabellini
  0 siblings, 1 reply; 11+ messages in thread
From: kbuild test robot @ 2016-02-24 12:53 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: kbuild-all, xen-devel, linux-kernel, Stefano.Stabellini,
	david.vrabel, konrad.wilk, boris.ostrovsky

[-- Attachment #1: Type: text/plain, Size: 1661 bytes --]

Hi Stefano,

[auto build test WARNING on tty/tty-testing]
[also build test WARNING on v4.5-rc5 next-20160223]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Stefano-Stabellini/hvc_xen-add-earlycon-support/20160224-203006
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
config: x86_64-randconfig-x009-201608 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/tty/hvc/hvc_xen.c: In function 'xenboot_setup_console':
>> drivers/tty/hvc/hvc_xen.c:637:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^

vim +637 drivers/tty/hvc/hvc_xen.c

   621		}
   622		if (off < len)
   623			domU_write_console(0, string+off, len-off);
   624	}
   625	
   626	#ifdef CONFIG_EARLY_PRINTK
   627	static int xenboot_setup_console(struct console *console, char *string)
   628	{
   629		static struct xencons_info xenboot;
   630	
   631		if (xen_initial_domain())
   632			return 0;
   633		if (!xen_pv_domain())
   634			return -ENODEV;
   635	
   636		xen_early_pv_console_init(&xenboot, 0);
 > 637	}
   638	
   639	static void xenboot_write_console(struct console *console, const char *string,
   640					  unsigned len)
   641	{
   642		if (!xen_pv_domain())
   643			return;
   644	
   645		dom0_write_console(0, string, len);

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 22016 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] hvc_xen: add earlycon support
  2016-02-24 12:23 ` [PATCH 1/2] hvc_xen: add earlycon support Stefano Stabellini
@ 2016-02-24 14:43   ` Boris Ostrovsky
  2016-02-24 15:55     ` Stefano Stabellini
  0 siblings, 1 reply; 11+ messages in thread
From: Boris Ostrovsky @ 2016-02-24 14:43 UTC (permalink / raw)
  To: Stefano Stabellini, xen-devel; +Cc: linux-kernel, david.vrabel, konrad.wilk

On 02/24/2016 07:23 AM, Stefano Stabellini wrote:
> Introduce EARLYCON support in hvc_xen, useful for early debugging on arm
> and arm64, where xen early_printk is not available. Differently from
> xenboot_write_console on x86, we won't just return if !xen_pv_domain(),
> because arm and arm64 guests are actually xen_hvm_domain() from linux
> pov, and also because we want to capture all possible writes, including
> the ones earlier than xen_early_init().
>
> Signed-off-by: Stefano Stabellini<stefano.stabellini@eu.citrix.com>
> ---
>   drivers/tty/hvc/hvc_xen.c |   48 ++++++++++++++++++++++++++++++++++-----------
>   1 file changed, 37 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c
> index fa816b7..34e8e9f 100644
> --- a/drivers/tty/hvc/hvc_xen.c
> +++ b/drivers/tty/hvc/hvc_xen.c
> @@ -25,6 +25,7 @@
>   #include <linux/init.h>
>   #include <linux/types.h>
>   #include <linux/list.h>
> +#include <linux/serial_core.h>
>   
>   #include <asm/io.h>
>   #include <asm/xen/hypervisor.h>
> @@ -597,21 +598,11 @@ static int xen_cons_init(void)
>   }
>   console_initcall(xen_cons_init);
>   
> -#ifdef CONFIG_EARLY_PRINTK
> -static void xenboot_write_console(struct console *console, const char *string,
> -				  unsigned len)
> +static void domU_write_early_console(const char *string, unsigned len)
>   {
>   	unsigned int linelen, off = 0;
>   	const char *pos;
>   
> -	if (!xen_pv_domain())
> -		return;
> -
> -	dom0_write_console(0, string, len);
> -
> -	if (xen_initial_domain())
> -		return;
> -
>   	domU_write_console(0, "(early) ", 8);
>   	while (off < len && NULL != (pos = strchr(string+off, '\n'))) {
>   		linelen = pos-string+off;
> @@ -625,6 +616,21 @@ static void xenboot_write_console(struct console *console, const char *string,
>   		domU_write_console(0, string+off, len-off);
>   }
>   
> +#ifdef CONFIG_EARLY_PRINTK
> +static void xenboot_write_console(struct console *console, const char *string,
> +				  unsigned len)
> +{
> +	if (!xen_pv_domain())
> +		return;

This, BTW, will break PVHv2 code (which is not there yet). Your patch is 
not making the code any different from what it is now but I wonder 
whether xenboot_write_console() can be made to work for HVM guests at 
this time since you making changes there anyway.

Or we can delay it until HVMlite/PVHv2 patches make it in.

> +
> +	dom0_write_console(0, string, len);
> +
> +	if (xen_initial_domain())
> +		return;
> +
> +	domU_write_early_console(string, len);
> +}
> +
>   struct console xenboot_console = {
>   	.name		= "xenboot",
>   	.write		= xenboot_write_console,
> @@ -664,3 +670,23 @@ void xen_raw_printk(const char *fmt, ...)
>   
>   	xen_raw_console_write(buf);
>   }
> +
> +static void xenboot_earlycon_write(struct console *console,
> +				  const char *string,
> +				  unsigned len)
> +{
> +	dom0_write_console(0, string, len);
> +
> +	if (xen_initial_domain())
> +		return;
> +
> +	domU_write_early_console(string, len);
> +}

xenboot_earlycon_write() and xenboot_write_console() share most of the 
code, can it be factored out?

-boris

> +
> +static int __init xenboot_earlycon_setup(struct earlycon_device *device,
> +					    const char *opt)
> +{
> +	device->con->write = xenboot_earlycon_write;
> +	return 0;
> +}
> +EARLYCON_DECLARE(xenboot, xenboot_earlycon_setup);

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] hvc_xen: fix xenboot for DomUs
  2016-02-24 12:53   ` kbuild test robot
@ 2016-02-24 15:48     ` Stefano Stabellini
  0 siblings, 0 replies; 11+ messages in thread
From: Stefano Stabellini @ 2016-02-24 15:48 UTC (permalink / raw)
  To: kbuild test robot
  Cc: Stefano Stabellini, kbuild-all, xen-devel, linux-kernel,
	david.vrabel, konrad.wilk, boris.ostrovsky

Hi kbuild test robot,

you are awesome as always. I'll fix it in the next version.

Thanks,

Stefano

On Wed, 24 Feb 2016, kbuild test robot wrote:
> Hi Stefano,
> 
> [auto build test WARNING on tty/tty-testing]
> [also build test WARNING on v4.5-rc5 next-20160223]
> [if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
> 
> url:    https://github.com/0day-ci/linux/commits/Stefano-Stabellini/hvc_xen-add-earlycon-support/20160224-203006
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
> config: x86_64-randconfig-x009-201608 (attached as .config)
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=x86_64 
> 
> All warnings (new ones prefixed by >>):
> 
>    drivers/tty/hvc/hvc_xen.c: In function 'xenboot_setup_console':
> >> drivers/tty/hvc/hvc_xen.c:637:1: warning: control reaches end of non-void function [-Wreturn-type]
>     }
>     ^
> 
> vim +637 drivers/tty/hvc/hvc_xen.c
> 
>    621		}
>    622		if (off < len)
>    623			domU_write_console(0, string+off, len-off);
>    624	}
>    625	
>    626	#ifdef CONFIG_EARLY_PRINTK
>    627	static int xenboot_setup_console(struct console *console, char *string)
>    628	{
>    629		static struct xencons_info xenboot;
>    630	
>    631		if (xen_initial_domain())
>    632			return 0;
>    633		if (!xen_pv_domain())
>    634			return -ENODEV;
>    635	
>    636		xen_early_pv_console_init(&xenboot, 0);
>  > 637	}
>    638	
>    639	static void xenboot_write_console(struct console *console, const char *string,
>    640					  unsigned len)
>    641	{
>    642		if (!xen_pv_domain())
>    643			return;
>    644	
>    645		dom0_write_console(0, string, len);
> 
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] hvc_xen: add earlycon support
  2016-02-24 14:43   ` Boris Ostrovsky
@ 2016-02-24 15:55     ` Stefano Stabellini
  2016-02-24 17:18       ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 11+ messages in thread
From: Stefano Stabellini @ 2016-02-24 15:55 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Stefano Stabellini, xen-devel, linux-kernel, david.vrabel,
	konrad.wilk

On Wed, 24 Feb 2016, Boris Ostrovsky wrote:
> On 02/24/2016 07:23 AM, Stefano Stabellini wrote:
> > Introduce EARLYCON support in hvc_xen, useful for early debugging on arm
> > and arm64, where xen early_printk is not available. Differently from
> > xenboot_write_console on x86, we won't just return if !xen_pv_domain(),
> > because arm and arm64 guests are actually xen_hvm_domain() from linux
> > pov, and also because we want to capture all possible writes, including
> > the ones earlier than xen_early_init().
> > 
> > Signed-off-by: Stefano Stabellini<stefano.stabellini@eu.citrix.com>
> > ---
> >   drivers/tty/hvc/hvc_xen.c |   48
> > ++++++++++++++++++++++++++++++++++-----------
> >   1 file changed, 37 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c
> > index fa816b7..34e8e9f 100644
> > --- a/drivers/tty/hvc/hvc_xen.c
> > +++ b/drivers/tty/hvc/hvc_xen.c
> > @@ -25,6 +25,7 @@
> >   #include <linux/init.h>
> >   #include <linux/types.h>
> >   #include <linux/list.h>
> > +#include <linux/serial_core.h>
> >     #include <asm/io.h>
> >   #include <asm/xen/hypervisor.h>
> > @@ -597,21 +598,11 @@ static int xen_cons_init(void)
> >   }
> >   console_initcall(xen_cons_init);
> >   -#ifdef CONFIG_EARLY_PRINTK
> > -static void xenboot_write_console(struct console *console, const char
> > *string,
> > -				  unsigned len)
> > +static void domU_write_early_console(const char *string, unsigned len)
> >   {
> >   	unsigned int linelen, off = 0;
> >   	const char *pos;
> >   -	if (!xen_pv_domain())
> > -		return;
> > -
> > -	dom0_write_console(0, string, len);
> > -
> > -	if (xen_initial_domain())
> > -		return;
> > -
> >   	domU_write_console(0, "(early) ", 8);
> >   	while (off < len && NULL != (pos = strchr(string+off, '\n'))) {
> >   		linelen = pos-string+off;
> > @@ -625,6 +616,21 @@ static void xenboot_write_console(struct console
> > *console, const char *string,
> >   		domU_write_console(0, string+off, len-off);
> >   }
> >   +#ifdef CONFIG_EARLY_PRINTK
> > +static void xenboot_write_console(struct console *console, const char
> > *string,
> > +				  unsigned len)
> > +{
> > +	if (!xen_pv_domain())
> > +		return;
> 
> This, BTW, will break PVHv2 code (which is not there yet). Your patch is not
> making the code any different from what it is now but I wonder whether
> xenboot_write_console() can be made to work for HVM guests at this time since
> you making changes there anyway.
> 
> Or we can delay it until HVMlite/PVHv2 patches make it in.

I don't think it can be made to work with HVM guests unfortunately,
because in the HVM case Xen support is going to be discovered only at
some later point. We have the same problem on ARM, where all guests are
xen_hvm_domain(). In that case I solved the problem by calling
dom0_write_console unconditionally from xenboot_earlycon_write, see
below.

I could do the same here by dropping the if (!xen_pv_domain()) check
above, but then if somebody specifies earlyprintk=xenboot on a non-Xen
environment, I expect Linux would crash.


> > +
> > +	dom0_write_console(0, string, len);
> > +
> > +	if (xen_initial_domain())
> > +		return;
> > +
> > +	domU_write_early_console(string, len);
> > +}
> > +
> >   struct console xenboot_console = {
> >   	.name		= "xenboot",
> >   	.write		= xenboot_write_console,
> > @@ -664,3 +670,23 @@ void xen_raw_printk(const char *fmt, ...)
> >     	xen_raw_console_write(buf);
> >   }
> > +
> > +static void xenboot_earlycon_write(struct console *console,
> > +				  const char *string,
> > +				  unsigned len)
> > +{
> > +	dom0_write_console(0, string, len);
> > +
> > +	if (xen_initial_domain())
> > +		return;
> > +
> > +	domU_write_early_console(string, len);
> > +}

My explanation above made me realize that actually
domU_write_early_console can never be called here, so I'll drop it in
the next version.


> xenboot_earlycon_write() and xenboot_write_console() share most of the code,
> can it be factored out?

No, they are actually different. I don't think it would be better to
introduce #ifdef CONFIG_X86 in this file.


> > +
> > +static int __init xenboot_earlycon_setup(struct earlycon_device *device,
> > +					    const char *opt)
> > +{
> > +	device->con->write = xenboot_earlycon_write;
> > +	return 0;
> > +}
> > +EARLYCON_DECLARE(xenboot, xenboot_earlycon_setup);
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] hvc_xen: add earlycon support
  2016-02-24 15:55     ` Stefano Stabellini
@ 2016-02-24 17:18       ` Konrad Rzeszutek Wilk
  2016-02-24 17:22         ` [Xen-devel] " Andrew Cooper
  2016-02-25 11:53         ` Stefano Stabellini
  0 siblings, 2 replies; 11+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-02-24 17:18 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: Boris Ostrovsky, xen-devel, linux-kernel, david.vrabel

> I could do the same here by dropping the if (!xen_pv_domain()) check
> above, but then if somebody specifies earlyprintk=xenboot on a non-Xen
> environment, I expect Linux would crash.

Nah, you made it "Work" with:
commit eb5ef07151ba3c3cb4bcef0c8f146ff1115eaa55
Author: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Date:   Fri Jan 27 18:31:36 2012 +0000

    hvc_xen: support PV on HVM consoles

But this patch:

commit 04b772d2b819f0dda2163e3193fa7cd447a6245c

xen/hvc: If we use xen_raw_printk let it also work on HVM guests.
    
    The xen_raw_printk works great for debugging purposes. We use
    for PV guests and we can also use it for HVM guests.
    
    However, for HVM guests we have a fallback of using the 0xe9
    port in case the hypervisor does not support an HVM guest of
    using the console_io hypercall. As such lets use 0xe9 during
    early bootup, and once the hyper-page is setup and if the
    console_io hypercall is supported - use that. Otherwise we
    will fallback to using the 0xe9 after early bootup.
    
    We also alter the return value for dom0_write_console to return
    an error value instead of zero. The HVC API has been supporting
    returning error values for quite some time.
    
    P.S.
    To use (and to see the output in the Xen ring buffer) one has to build
    the hypervisor with 'debug=y'.

Should make it possible for HVM guests to actually work with HVM x86 guests
if tweaked.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Xen-devel] [PATCH 1/2] hvc_xen: add earlycon support
  2016-02-24 17:18       ` Konrad Rzeszutek Wilk
@ 2016-02-24 17:22         ` Andrew Cooper
  2016-02-25 12:00           ` Stefano Stabellini
  2016-02-25 11:53         ` Stefano Stabellini
  1 sibling, 1 reply; 11+ messages in thread
From: Andrew Cooper @ 2016-02-24 17:22 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk, Stefano Stabellini
  Cc: Boris Ostrovsky, xen-devel, linux-kernel, david.vrabel

On 24/02/16 17:18, Konrad Rzeszutek Wilk wrote:
>> I could do the same here by dropping the if (!xen_pv_domain()) check
>> above, but then if somebody specifies earlyprintk=xenboot on a non-Xen
>> environment, I expect Linux would crash.
> Nah, you made it "Work" with:
> commit eb5ef07151ba3c3cb4bcef0c8f146ff1115eaa55
> Author: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Date:   Fri Jan 27 18:31:36 2012 +0000
>
>     hvc_xen: support PV on HVM consoles
>
> But this patch:
>
> commit 04b772d2b819f0dda2163e3193fa7cd447a6245c
>
> xen/hvc: If we use xen_raw_printk let it also work on HVM guests.
>     
>     The xen_raw_printk works great for debugging purposes. We use
>     for PV guests and we can also use it for HVM guests.
>     
>     However, for HVM guests we have a fallback of using the 0xe9
>     port in case the hypervisor does not support an HVM guest of
>     using the console_io hypercall. As such lets use 0xe9 during
>     early bootup, and once the hyper-page is setup and if the
>     console_io hypercall is supported - use that. Otherwise we
>     will fallback to using the 0xe9 after early bootup.
>     
>     We also alter the return value for dom0_write_console to return
>     an error value instead of zero. The HVC API has been supporting
>     returning error values for quite some time.
>     
>     P.S.
>     To use (and to see the output in the Xen ring buffer) one has to build
>     the hypervisor with 'debug=y'.
>
> Should make it possible for HVM guests to actually work with HVM x86 guests
> if tweaked.

/me looks

+outb_print:
+               for (i = 0; i < len; i++)
+                       outb(str[i], 0xe9);
+#endif

You already have the length to hand.  Use outsb instead, for
substantially fewer vmexits.

~Andrew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] hvc_xen: add earlycon support
  2016-02-24 17:18       ` Konrad Rzeszutek Wilk
  2016-02-24 17:22         ` [Xen-devel] " Andrew Cooper
@ 2016-02-25 11:53         ` Stefano Stabellini
  1 sibling, 0 replies; 11+ messages in thread
From: Stefano Stabellini @ 2016-02-25 11:53 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: Stefano Stabellini, Boris Ostrovsky, xen-devel, linux-kernel,
	david.vrabel

On Wed, 24 Feb 2016, Konrad Rzeszutek Wilk wrote:
> > I could do the same here by dropping the if (!xen_pv_domain()) check
> > above, but then if somebody specifies earlyprintk=xenboot on a non-Xen
> > environment, I expect Linux would crash.
> 
> Nah, you made it "Work" with:
> commit eb5ef07151ba3c3cb4bcef0c8f146ff1115eaa55
> Author: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Date:   Fri Jan 27 18:31:36 2012 +0000
> 
>     hvc_xen: support PV on HVM consoles
> 
> But this patch:
> 
> commit 04b772d2b819f0dda2163e3193fa7cd447a6245c
> 
> xen/hvc: If we use xen_raw_printk let it also work on HVM guests.
>     
>     The xen_raw_printk works great for debugging purposes. We use
>     for PV guests and we can also use it for HVM guests.
>     
>     However, for HVM guests we have a fallback of using the 0xe9
>     port in case the hypervisor does not support an HVM guest of
>     using the console_io hypercall. As such lets use 0xe9 during
>     early bootup, and once the hyper-page is setup and if the
>     console_io hypercall is supported - use that. Otherwise we
>     will fallback to using the 0xe9 after early bootup.
>     
>     We also alter the return value for dom0_write_console to return
>     an error value instead of zero. The HVC API has been supporting
>     returning error values for quite some time.
>     
>     P.S.
>     To use (and to see the output in the Xen ring buffer) one has to build
>     the hypervisor with 'debug=y'.
> 
> Should make it possible for HVM guests to actually work with HVM x86 guests
> if tweaked.

That only makes xen_raw_printk and xen_raw_console_write work with HVM
x86 guests, not the generic early_printk calls, usually enabled in PV
guests with "earlyprintk=xen" on the kernel command line.

But the xen_cpuid_base() check and outbs could be used in
xenboot_write_console too to make early_printk work. I'll add a patch
for that.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Xen-devel] [PATCH 1/2] hvc_xen: add earlycon support
  2016-02-24 17:22         ` [Xen-devel] " Andrew Cooper
@ 2016-02-25 12:00           ` Stefano Stabellini
  0 siblings, 0 replies; 11+ messages in thread
From: Stefano Stabellini @ 2016-02-25 12:00 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Konrad Rzeszutek Wilk, Stefano Stabellini, Boris Ostrovsky,
	xen-devel, linux-kernel, david.vrabel

On Wed, 24 Feb 2016, Andrew Cooper wrote:
> On 24/02/16 17:18, Konrad Rzeszutek Wilk wrote:
> >> I could do the same here by dropping the if (!xen_pv_domain()) check
> >> above, but then if somebody specifies earlyprintk=xenboot on a non-Xen
> >> environment, I expect Linux would crash.
> > Nah, you made it "Work" with:
> > commit eb5ef07151ba3c3cb4bcef0c8f146ff1115eaa55
> > Author: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > Date:   Fri Jan 27 18:31:36 2012 +0000
> >
> >     hvc_xen: support PV on HVM consoles
> >
> > But this patch:
> >
> > commit 04b772d2b819f0dda2163e3193fa7cd447a6245c
> >
> > xen/hvc: If we use xen_raw_printk let it also work on HVM guests.
> >     
> >     The xen_raw_printk works great for debugging purposes. We use
> >     for PV guests and we can also use it for HVM guests.
> >     
> >     However, for HVM guests we have a fallback of using the 0xe9
> >     port in case the hypervisor does not support an HVM guest of
> >     using the console_io hypercall. As such lets use 0xe9 during
> >     early bootup, and once the hyper-page is setup and if the
> >     console_io hypercall is supported - use that. Otherwise we
> >     will fallback to using the 0xe9 after early bootup.
> >     
> >     We also alter the return value for dom0_write_console to return
> >     an error value instead of zero. The HVC API has been supporting
> >     returning error values for quite some time.
> >     
> >     P.S.
> >     To use (and to see the output in the Xen ring buffer) one has to build
> >     the hypervisor with 'debug=y'.
> >
> > Should make it possible for HVM guests to actually work with HVM x86 guests
> > if tweaked.
> 
> /me looks
> 
> +outb_print:
> +               for (i = 0; i < len; i++)
> +                       outb(str[i], 0xe9);
> +#endif
> 
> You already have the length to hand.  Use outsb instead, for
> substantially fewer vmexits.

I'll take the opportunity to make that change as well

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-02-25 12:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-24 12:22 [0/2] hvc_xen: fix xenboot on x86 and export to ARM Stefano Stabellini
2016-02-24 12:23 ` [PATCH 1/2] hvc_xen: add earlycon support Stefano Stabellini
2016-02-24 14:43   ` Boris Ostrovsky
2016-02-24 15:55     ` Stefano Stabellini
2016-02-24 17:18       ` Konrad Rzeszutek Wilk
2016-02-24 17:22         ` [Xen-devel] " Andrew Cooper
2016-02-25 12:00           ` Stefano Stabellini
2016-02-25 11:53         ` Stefano Stabellini
2016-02-24 12:23 ` [PATCH 2/2] hvc_xen: fix xenboot for DomUs Stefano Stabellini
2016-02-24 12:53   ` kbuild test robot
2016-02-24 15:48     ` Stefano Stabellini

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).