# \[PATCH 3/9\] xen/x86: make "earlyprintk=xen" work better for PVH Dom0

- Subsystems: HYPERVISOR VIRTUAL CONSOLE DRIVER, THE REST, TTY LAYER AND SERIAL DRIVERS
- Maintainers: Linus Torvalds, Greg Kroah-Hartman, Jiri Slaby
- Status: SUPERSEDED (Superseded by v2 posted 2021-09-30)
- Superseded by v2 (posted 2021-09-30).
- Revision v1 (2 revisions archived).
- List: linuxppc-dev
- 2 messages, 2 authors
- Page: https://ratatoskr.run/linuxppc-dev/2021/09/1499031/t

## \[PATCH 3/9\] xen/x86: make "earlyprintk=xen" work better for PVH Dom0

- From: Jan Beulich \<hidden\>
- Date: 2021-09-07 10:09:24 
- Message: https://ratatoskr.run/linuxppc-dev/2021/09/1499031.md

```text
The xen_hvm_early_write() path better wouldn't be taken in this case;
while port 0xE9 can be used, the hypercall path is quite a bit more
efficient. Put that first, as it may also work for DomU-s (see also
xen_raw_console_write()).

While there also bail from the function when the first
domU_write_console() failed - later ones aren't going to succeed.

Signed-off-by: Jan Beulich <redacted>

--- a/drivers/tty/hvc/hvc_xen.c
+++ b/drivers/tty/hvc/hvc_xen.c
@@ -632,17 +632,16 @@ static void xenboot_write_console(struct
 	unsigned int linelen, off = 0;
 	const char *pos;
 
+	if (dom0_write_console(0, string, len) >= 0)
+		return;
+
 	if (!xen_pv_domain()) {
 		xen_hvm_early_write(0, string, len);
 		return;
 	}
 
-	dom0_write_console(0, string, len);
-
-	if (xen_initial_domain())
+	if (domU_write_console(0, "(early) ", 8) < 0)
 		return;
-
-	domU_write_console(0, "(early) ", 8);
 	while (off < len && NULL != (pos = strchr(string+off, '\n'))) {
 		linelen = pos-string+off;
 		if (off + linelen > len)

```

## Re: \[PATCH 3/9\] xen/x86: make "earlyprintk=xen" work better for PVH Dom0

- From: Juergen Gross \<jgross@suse.com\>
- Date: 2021-09-23 14:06:04 
- Message: https://ratatoskr.run/linuxppc-dev/2021/09/1519604.md

```text
On 07.09.21 12:09, Jan Beulich wrote:
> The xen_hvm_early_write() path better wouldn't be taken in this case;
> while port 0xE9 can be used, the hypercall path is quite a bit more
> efficient. Put that first, as it may also work for DomU-s (see also
> xen_raw_console_write()).
>
> While there also bail from the function when the first
> domU_write_console() failed - later ones aren't going to succeed.
>
> Signed-off-by: Jan Beulich <redacted>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen
```
