[PATCH 34/36] x86/domain: implement domain_has_vuart()

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Add new emulation flag for virtual UART on x86 and plumb it through the stack. This change enables NS8250 emulator initialization. Signed-off-by: Denis Mukhin --- tools/libs/light/libxl_x86.c | 6 +- tools/ocaml/libs/xc/xenctrl.ml| 1 + tools/ocaml/libs/xc/xe

[PATCH 36/36] docs/misc: update console documentation

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Minor update related to virtual UART support. Also: s/pv/PV/g s/hvm/HVM/g Signed-off-by: Denis Mukhin --- docs/misc/console.txt | 48 +--- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/docs/misc/console.txt b/d

[PATCH 00/36] Introduce NS8250 UART emulator

2024-11-26 Thread Denis Mukhin via B4 Relay
The patch series introduces initial in-hypervisor emulator for NS8250/NS16x50-compatible UARTs under CONFIG_HAS_VUART_NS8250. In parallel domain creation scenario (hyperlaunch), NS8520 emulator helps early guest OS bringup debugging, because it eliminates dependency on the external emulator being

[PATCH 30/36] xen/8250-uart: add missing definitions

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Added missing definitions needed for NS8250 UART emulator. Signed-off-by: Denis Mukhin --- xen/include/xen/8250-uart.h | 82 + 1 file changed, 61 insertions(+), 21 deletions(-) diff --git a/xen/include/xen/8250-uart.h b/xen/includ

[PATCH 08/36] arm/vuart: make domain_has_vuart() public

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Move domain_has_vuart() to arch namespace as preparation code change for architecture-agnostic way of forwarding physical console to the guest OS w/ in-hypervisor UART emulator. Signed-off-by: Denis Mukhin --- xen/arch/arm/include/asm/domain.h | 9 + xen/arch/arm/vpl

[PATCH 04/36] xen/irq: introduce NO_IRQ

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Introduce definition for IRQ resource checks. Signed-off-by: Denis Mukhin --- xen/include/xen/irq.h | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h index 95034c0d6bb5f0aa7d5bb572aca59872508a438a..aee878293ecc0de6a938bcfea114

[PATCH 24/36] xen/console: introduce console_init_owner()

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin console_init_owner() is introduced for selecting the boot-time console owner. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 27 +-- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers

[PATCH 06/36] xen/ctype: introduce isconsole()

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin There are several console drivers which have same checks w.r.t. printable characters. The check is moved to new isconsole() macro and re-used in the console drivers. Signed-off-by: Denis Mukhin --- xen/arch/arm/vuart.c | 3 +-- xen/arch/x86/hvm/hvm.c | 3 +-- xen/d

[PATCH 07/36] arm/vuart: use guest_printk()

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Use guest_printk() in all current in-hypervisor UART emulators. That slightly improves the logging as guest_printk() already prints the domain ID. Signed-off-by: Denis Mukhin --- xen/arch/arm/vpl011.c | 2 +- xen/arch/arm/vuart.c | 2 +- 2 files changed, 2 insertions(+), 2

[PATCH 11/36] x86/domain: introduce domain_has_vuart()

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Introduce domain_has_vuart() for x86 port to be used in the console driver. Signed-off-by: Denis Mukhin --- xen/arch/x86/include/asm/domain.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h index

[PATCH 03/36] xen: introduce resource.h

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Move resource definitions to a new architecture-agnostic shared header file. It will be used in follow on NS8250 emulator code to describe legacy PC COM resources. Signed-off-by: Denis Mukhin --- xen/common/device-tree/device-tree.c | 21 +-- xen/drivers/pas

[PATCH 13/36] xen/domain: add get_initial_domain_id()

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Move get_initial_domain_id() to a public API and enable for all architectures. That is pre-requisite change for console focus switch logic cleanup. Signed-off-by: Denis Mukhin --- xen/arch/x86/include/asm/pv/shim.h | 4 ++-- xen/arch/x86/pv/shim.c | 4 ++-- xen

[PATCH 17/36] xen/console: rename switch_serial_input() to console_find_owner()

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Updated the name to highlight the logic of selection the physical console owner: existing code does not switch only serial console, it also switches video console and debugging console (debug I/O port and console hypercall). Signed-off-by: Denis Mukhin --- xen/drivers/char/c

[PATCH 14/36] xen/domain: enable max_init_domid for all architectures

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Move max_init_domid to a public API and enable for all architectures. That is pre-requisite change for console focus switch logic cleanup. Signed-off-by: Denis Mukhin --- xen/arch/arm/include/asm/setup.h | 2 -- xen/arch/arm/setup.c | 2 -- xen/arch/ppc/inclu

[PATCH 10/36] ppc/domain: introduce domain_has_vuart()

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Introduce domain_has_vuart() for PPC port to be used in the console driver. Signed-off-by: Denis Mukhin --- xen/arch/ppc/include/asm/domain.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/ppc/include/asm/domain.h b/xen/arch/ppc/include/asm/domain.h index 3

[PATCH 02/36] xsm/flask: missing breaks, MISRA rule 16.4

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin While working on console forwarding for virtual NS8250 I stepped into flask_domain_alloc_security() where break statement was missing in default case which violates MISRA rule 16.4. Fixed everywhere in hooks.c. Signed-off-by: Denis Mukhin --- xen/xsm/flask/hooks.c | 4 +++

[PATCH 12/36] x86/domain: print emulation_flags

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Print d->arch.emulation_flags on the console for better traceability while debugging in-hypervisor hardware emulators. Signed-off-by: Denis Mukhin --- xen/arch/x86/domain.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/domain.c b/xe

[PATCH 01/36] x86/setup: fix typo in acpi=off description

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Signed-off-by: Denis Mukhin --- xen/arch/x86/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index d8661d7ca699c96f38229c75ad0a8626c6f675d4..0a748e2c14122d6c5d692bc5691e8cbe13a32c81 100644 --- a/xen/arc

[PATCH 09/36] riscv/domain: introduce domain_has_vuart()

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Introduce domain_has_vuart() for RISC-V port to be used in the console driver. Signed-off-by: Denis Mukhin --- xen/arch/riscv/include/asm/domain.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/riscv/include/asm/domain.h b/xen/arch/riscv/include/asm/domain.h

[PATCH 05/36] xen/xmalloc: add kmalloc() and kfree() aliases

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Move existing aliases to a common header so those could be used in the new code. The code looks simpler w/ kmalloc(): type specification of the object being allocated is not required, e.g.: ... struct my_obj_s *obj; obj = kmalloc(sizeof(*obj), 0); ... Signed-off-by: Deni

[PATCH 20/36] xen/console: introduce consoled_is_enabled()

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin There are few places which check pv_shim console under CONFIG_PV_SHIM in xen console driver. Instead of #ifdef-ing, use new consoled_is_enabled() to customize the logic. Header file now can be included w/o CONFIG_X86. Signature of consoled_guest_{rx,tx} has changed to account

[PATCH 27/36] xen/console: introduce hwdom_crashconsole=

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin The new command line switch `hwdom_crashconsole=BOOL` allows to switch serial console input focus to xen for machine state inspection using keyhandler mechanism after the hardware domain crashes. The new command line switch is aliased via `dom0=...,crashconsole` knob. Such fu

[PATCH 18/36] xen/console: rename console_rx to console_owner

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Preparation for the follow on change to switch console_owner to domid_t address space. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/xen/drivers/char/console.c b/xen

[PATCH 16/36] xen/console: rename console_input_domain

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin console_input_domain() takes an RCU lock to protect domain structure. That implies call to rcu_unlock_domain() after use. Rename console_input_domain() to rcu_lock_domain_console_owner() to highlight the need of calling rcu_unlock_domain(). Signed-off-by: Denis Mukhin --- x

[PATCH 32/36] x86/hvm: add helpers for raising guest IRQs

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Added convenience wrappers for asserting/de-asserting interrupts in the hardware emulation code. That will be used for PCI-based NS8250 emulator. Signed-off-by: Denis Mukhin --- xen/arch/x86/hvm/irq.c | 24 xen/arch/x86/include/asm/hvm/i

[PATCH 31/36] x86/hvm: add HVM-specific Kconfig

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Add separate menu for configuring HVM build-time settings. That will help organizing HVM-specific options under a separate menu. Signed-off-by: Denis Mukhin --- xen/arch/x86/Kconfig | 66 +++- xen/arch/x86/hvm/Kconfig | 63

[PATCH 23/36] xen/console: introduce console_owner_domid()

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin console_owner_domid() is introduced to obtain the "console owner" domain ID. The call is used in NS8250 emulator to identify the case when physical xen console focus is owned by the domain w/ NS8250 emulator, in which case, messages from guest OS are formatted w/o '(XEN)' pref

[PATCH 28/36] xen/console: simplify console owner switch hint

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Update the hint w/ the combination of keys to press to switch physical console to the next owner. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/

[PATCH 19/36] xen/console: introduce printk_common()

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Introduce new printk() variant for convenient printouts which skip '(XEN)' prefix on xen console. This is needed for the case when physical console is owned by a domain w/ in-hypervisor UART emulation enabled. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 8 ++

[PATCH 21/36] xen/console: introduce use of 'is_console' flag

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin The code now inspects d->is_console flag to decide whether the console focus should move to the domain w/ console after administrator presses . To do that max_init_domid is updated in domain_create(). Console owner domain switch logic updated accordingly. Signed-off-by: Deni

[PATCH 26/36] xen/console: introduce console_write()

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin PV Linux kernel uses HYPERVISOR_console_io hypercall for early console which ends up being handled by Xen's console driver's guest_console_write(). guest_console_write() duplicates the code from __putstr(), elimitate code duplication. Signed-off-by: Denis Mukhin --- xen/dri

[PATCH 22/36] xen/console: introduce console_set_owner()

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin console_set_owner() is introduced for setting the new console owner. Switches console owner to domain ID vs range of integer numbers mapped to domain IDs. This a public API to console driver, will be used in the follow on code change. Signed-off-by: Denis Mukhin --- xen/dr

[PATCH 29/36] xen/console: make console buffer size configurable

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Add new CONRING_LOG_SHIFT Kconfig parameter to specify the boot console buffer size as a power of 2. Bump default size to 32 KiB. Link: https://gitlab.com/xen-project/xen/-/issues/185 Signed-off-by: Denis Mukhin --- xen/drivers/char/Kconfig | 23 +++ x

[PATCH 35/36] xen/console: enable console owners w/ emulated NS8250

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Enable console focus for domains w/ virtual NS8250. Code change allows to capture the output from the guest OS now and send it to the physical console device. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 5 + 1 file changed, 5 insertions(+) diff --git a

[PATCH 33/36] x86/hvm: introduce NS8250 UART emulator

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Add initial in-hypervisor emulator for NS8250/NS16x50-compatible UARTs under CONFIG_HAS_VUART_NS8250. In parallel domain creation scenario (hyperlaunch), NS8520 emulator helps early guest OS bringup debugging, because it eliminates dependency on the external emulator being ope

[PATCH 15/36] xen/console: move vpl011-related code to vpl011 emulator

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Xen console driver has vpl011-related logic which shall belong vpl011 emulator code. Move vpl011-related to vpl011.c. Signed-off-by: Denis Mukhin --- xen/arch/arm/include/asm/vpl011.h | 2 +- xen/arch/arm/vpl011.c | 15 --- xen/drivers/char/console.c

[PATCH 25/36] xen/console: introduce handle_keypress_in_domain()

2024-11-26 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin With introduction of NS8250 emulator for x86, the logic of switching console focus gets more convoluted: HVM domain w/ NS8205 must be able to receive the physical console input for guest VM debugging. Also, existing code does not honor `hardware_dom=` xen command line paramete

[PATCH v2 06/35] riscv/domain: introduce domain_has_vuart()

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Introduce domain_has_vuart() for RISC-V port to be used in the console driver. Signed-off-by: Denis Mukhin Reviewed-by: Oleksii Kurochko --- xen/arch/riscv/include/asm/domain.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/riscv/include/asm/domain.h b/xen/

[PATCH v2 01/35] xen: introduce resource.h

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Move resource definitions to a new architecture-agnostic shared header file. It will be used in follow on NS8250 emulator code to describe legacy PC COM resources. Signed-off-by: Denis Mukhin --- xen/common/device-tree/device-tree.c | 21 +-- xen/drivers/pas

[PATCH v2 35/35] docs/misc: update console documentation

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Minor update related to virtual UART support. Also: s/pv/PV/g s/hvm/HVM/g Signed-off-by: Denis Mukhin --- docs/misc/console.txt | 50 ++ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/docs/misc/console.txt b

[PATCH v2 16/35] xen/console: introduce printk_common()

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Introduce new printk() variant for convenient printouts which skip '(XEN)' prefix on xen console. This is needed for the case when physical console is owned by a domain w/ in-hypervisor UART emulation enabled. Signed-off-by: Denis Mukhin --- automation/eclair_analysis/ECLAIR

[PATCH v2 07/35] ppc/domain: introduce domain_has_vuart()

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Introduce domain_has_vuart() for PPC port to be used in the console driver. Signed-off-by: Denis Mukhin --- xen/arch/ppc/include/asm/domain.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/ppc/include/asm/domain.h b/xen/arch/ppc/include/asm/domain.h index 3

[PATCH v2 04/35] arm/vuart: use guest_printk()

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Use guest_printk() in all current in-hypervisor UART emulators. That slightly improves the logging as guest_printk() already prints the domain ID. Signed-off-by: Denis Mukhin --- xen/arch/arm/vpl011.c | 2 +- xen/arch/arm/vuart.c | 2 +- 2 files changed, 2 insertions(+), 2

[PATCH v2 11/35] xen/domain: enable max_init_domid for all architectures

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Move max_init_domid to a public API and enable for all architectures. That is pre-requisite change for console focus switch logic cleanup. max_init_domid is updated in domain_create(). Signed-off-by: Denis Mukhin --- xen/arch/arm/include/asm/setup.h | 2 -- xen/arch/arm/s

[PATCH v2 08/35] x86/domain: introduce domain_has_vuart()

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Introduce domain_has_vuart() for x86 port to be used in the console driver. Signed-off-by: Denis Mukhin --- xen/arch/x86/include/asm/domain.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h index

[PATCH v2 10/35] xen/domain: add get_initial_domain_id()

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Move get_initial_domain_id() to a public API and enable for all architectures. That is pre-requisite change for console focus switch logic cleanup. Signed-off-by: Denis Mukhin --- xen/arch/x86/include/asm/pv/shim.h | 4 ++-- xen/arch/x86/pv/shim.c | 4 ++-- xen

[PATCH v2 12/35] xen/console: move vpl011-related code to vpl011 emulator

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Xen console driver has vpl011-related logic which shall belong vpl011 emulator code. Move vpl011-related to vpl011.c. Signed-off-by: Denis Mukhin --- xen/arch/arm/include/asm/vpl011.h | 2 +- xen/arch/arm/vpl011.c | 15 +++ xen/drivers/char/console.c

[PATCH v2 18/35] xen/console: introduce use of 'is_console' flag

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin The code now inspects d->is_console flag to decide whether the console focus should move to the domain w/ console after administrator presses . Console owner domain switch logic updated accordingly. Signed-off-by: Denis Mukhin --- xen/arch/arm/dom0less-build.c | 2 +- xen/

[PATCH v2 09/35] x86/domain: print emulation_flags

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Print d->arch.emulation_flags on the console for better traceability while debugging in-hypervisor hardware emulators. Signed-off-by: Denis Mukhin --- xen/arch/x86/domain.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/domain.c b/xe

[PATCH v2 14/35] xen/console: rename switch_serial_input() to console_find_owner()

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Updated the name to highlight the logic of selection the physical console owner: existing code does not switch only serial console, it also switches video console and debugging console (debug I/O port and console hypercall). Signed-off-by: Denis Mukhin --- xen/drivers/char/c

[PATCH v2 00/35] Introduce NS8250 UART emulator

2024-12-05 Thread Denis Mukhin via B4 Relay
The patch series introduces initial in-hypervisor emulator for NS8250/NS16x50-compatible UARTs under CONFIG_HAS_VUART_NS8250. In parallel domain creation scenario (hyperlaunch), NS8520 emulator helps early guest OS bringup debugging, because it eliminates dependency on the external emulator being

[PATCH v2 20/35] xen/console: introduce console_owner_domid()

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin console_owner_domid() is introduced to obtain the "console owner" domain ID. The call is used in NS8250 emulator to identify the case when physical xen console focus is owned by the domain w/ NS8250 emulator, in which case, messages from guest OS are formatted w/o '(XEN)' pref

[PATCH v2 15/35] xen/console: rename console_rx to console_owner

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Preparation for the follow on change to switch console_owner to domid_t address space. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/xen/drivers/char/console.c b/xen

[PATCH v2 03/35] xen/ctype: introduce isconsole()

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin There are several console drivers which have same checks w.r.t. printable characters. The check is moved to new isconsole() macro and re-used in the console drivers. Signed-off-by: Denis Mukhin --- xen/arch/arm/vuart.c | 3 +-- xen/arch/x86/hvm/hvm.c | 3 +-- xen/d

[PATCH v2 02/35] xen/irq: introduce NO_IRQ

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Introduce definition for IRQ resource checks. Signed-off-by: Denis Mukhin --- xen/include/xen/irq.h | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h index 95034c0d6bb5f0aa7d5bb572aca59872508a438a..aee878293ecc0de6a938bcfea114

[PATCH v2 05/35] arm/vuart: make domain_has_vuart() public

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Move domain_has_vuart() to arch namespace as preparation code change for architecture-agnostic way of forwarding physical console to the guest OS w/ in-hypervisor UART emulator. Signed-off-by: Denis Mukhin --- xen/arch/arm/dom0less-build.c | 2 ++ xen/arch/arm/domain.c

[PATCH v2 17/35] xen/console: introduce consoled_is_enabled()

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin There are few places which check pv_shim console under CONFIG_PV_SHIM in xen console driver. Instead of #ifdef-ing, use new consoled_is_enabled() to customize the logic. Header file now can be included w/o CONFIG_X86. Signature of consoled_guest_{rx,tx} has changed to account

[PATCH v2 13/35] xen/console: rename console_input_domain

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin console_input_domain() takes an RCU lock to protect domain structure. That implies call to rcu_unlock_domain() after use. Rename console_input_domain() to rcu_lock_domain_console_owner() to highlight the need of calling rcu_unlock_domain(). Signed-off-by: Denis Mukhin --- x

[PATCH v2 34/35] xen/console: enable console owners w/ emulated NS8250

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Enable console focus for domains w/ virtual NS8250. Code change allows to capture the output from the guest OS now and send it to the physical console device. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 5 + 1 file changed, 5 insertions(+) diff --git a

[PATCH v2 22/35] xen/console: introduce handle_keypress_in_domain()

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin With introduction of NS8250 emulator for x86, the logic of switching console focus gets more convoluted: HVM domain w/ NS8205 must be able to receive the physical console input for guest VM debugging. Also, existing code does not honor `hardware_dom=` xen command line paramete

[PATCH v2 33/35] x86/domain: implement domain_has_vuart()

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Add new emulation flag for virtual UART on x86 and plumb it through the stack. This change enables NS8250 emulator initialization. Signed-off-by: Denis Mukhin --- tools/libs/light/libxl_x86.c | 6 +- tools/ocaml/libs/xc/xenctrl.ml| 1 + tools/ocaml/libs/xc/xe

[PATCH v2 29/35] x86/hvm: add HVM-specific Kconfig

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Add separate menu for configuring HVM build-time settings. That will help organizing HVM-specific options under a separate menu. Signed-off-by: Denis Mukhin --- xen/arch/x86/Kconfig | 66 +++- xen/arch/x86/hvm/Kconfig | 63

[PATCH v2 25/35] xen/console: simplify console owner switch hint

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Update the hint w/ the combination of keys to press to switch physical console to the next owner. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/

[PATCH v3 01/24] xen/ctype: introduce is_console_printable()

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin There are several console drivers which have same checks w.r.t. printable characters. The check is moved to new is_console_printable() function and re-used in the UART emulation / guest logging code. Also, MISRA rule 21.13 for ctype.h has been exploited while working on the co

[PATCH v3 12/24] xen/console: introduce console_{get,set}_owner()

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Switch console_owner address spaces from integers mapped to domain IDs to straight domain IDs, which simplifies console focus handling code. console_set_owner() is introduced for setting the new console owner. This is a public API to Xen console driver (it will be used in the

[PATCH v3 13/24] xen/console: introduce hwdom_crashconsole=

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin The new command line switch `hwdom_crashconsole=BOOL` allows to switch serial console input focus to xen for machine state inspection using keyhandler mechanism after the hardware domain crashes. The new command line switch is aliased via `dom0=...,crashconsole` knob. Such fu

[PATCH v3 00/24] x86: introduce NS16550-compatible UART emulator

2025-01-03 Thread Denis Mukhin via B4 Relay
x86 port of Xen lacks vUART facility similar to Arm's vpl011 to support x86 guest OS bring up in the embedded setups. This patch series introduces initial in-hypervisor emulator for NS8250/NS16x50-compatible UARTs under CONFIG_VUART_NS16550. In parallel domain creation scenario (hyperlaunch), NS1

[PATCH v3 02/24] arm/vuart: move vpl011-related code to vpl011 emulator

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Xen console driver has vpl011-related logic which shall belong vpl011 emulator code (Arm port). Move vpl011-related code from arch-independent console driver to Arm's vpl011.c. Signed-off-by: Denis Mukhin --- xen/arch/arm/include/asm/vpl011.h | 2 +- xen/arch/arm/vpl011.c

[PATCH v3 03/24] arm/vuart: add hwdom prefix to UART emulator

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Using "vuart" in UART emulator designed for hardware domain debugging is confusing in generic Arm code (e.g. vpl011 is also "vuart"). Fix that by adding hwdom prefix to all symbols in arm/vuart.c. Also, remove domain_has_vuart() from arm/vuart.c since it is not needed. Signed

[PATCH v3 09/24] xen/console: rename console_rx to console_owner

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Update the symbol name to prepare for the follow on semantic change of console owner identifier. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/xen/drivers/char/console.c

[PATCH v3 05/24] xen/console: introduce consoled_is_enabled()

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin There are few places which check pv_shim console under CONFIG_PV_SHIM in xen console driver. Instead of #ifdef-ing, use new consoled_is_enabled() to customize the logic. Header file now can be included w/o CONFIG_X86. Signature of consoled_guest_{rx,tx} has changed so the err

[PATCH v3 06/24] xen/domain: introduce hardware emulation flags

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Define an architecture-independent location for describing hardware emulation flags for configuring in-hypervisor emulators. Print d->arch.emulation_flags from 'q' keyhandler for better traceability while debugging in-hypervisor hardware emulators. Also, expanded the error me

[PATCH v3 16/24] xen/console: introduce console_write()

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin PV Linux kernel uses HYPERVISOR_console_io hypercall for early console which ends up being handled by Xen's console driver's guest_console_write(). guest_console_write() duplicates the code from __putstr(), elimitate code duplication. Signed-off-by: Denis Mukhin --- xen/dri

[PATCH v3 14/24] xen/console: simplify console owner switch hint

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Update the hint with the combination of keys to press for the physical console focus switch between the domains. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/drivers/char/console.c b/xe

[PATCH v3 21/24] x86/hvm: introduce NS16550-compatible UART emulator

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Add initial in-hypervisor emulator for NS8250/NS16x50-compatible UARTs under CONFIG_VUART_NS16550. x86 port of Xen lacks vUART facility similar to Arm's vpl011 to support x86 guest OS bring up in the embedded setups. In parallel domain creation scenario (hyperlaunch), NS16550

[PATCH v3 19/24] xen/8250-uart: add missing definitions

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Added missing definitions needed for NS8250 UART emulator. Re-used newly introduced MSR definitions in the existing ns16550 driver. Also, fixed indentation in a comment for FCR register. Signed-off-by: Denis Mukhin --- xen/drivers/char/ns16550.c | 6 ++-- xen/include/xen

[PATCH v3 24/24] xen/console: unify printout behavior for UART emulators

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin If virtual UART prints on the physical console, the behavior is updated to: - no prefix for Dom0 output; - DOM$NUM for DomUs when not in focus, otherwise no prefix. Introduce printk_noprefix() for convenient printouts which skip '(XEN)' prefix on the physical console. This is

[PATCH v3 07/24] xen/console: introduce framework for UART emulators

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Introduce a driver framework to abstract UART emulators in the hypervisor. That allows for architecture-independent handling of virtual UARTs from Xen console driver and simplifies enabling new architecture-dependent UART emulators. The framework is built under CONFIG_HAS_VUA

[PATCH v3 08/24] xen/console: rename switch_serial_input() to console_switch_input()

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Updated the name to highlight the physical console input selection logic: existing code does not switch only serial console, it also switches debugging console (debug I/O port and console hypercall). Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 6 +++--- 1 fi

[PATCH v3 10/24] xen/console: introduce use of 'is_console' flag

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin The code inspects d->is_console flag to decide whether the console focus should move to the domain with console after administrator uses key combination to switch the console focus. Console owner switch logic updated accordingly. Signed-off-by: Denis Mukhin --- xen/arch/ar

[PATCH v3 20/24] x86/hvm: add HVM-specific Kconfig

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Add separate menu for configuring HVM build-time settings to help organizing HVM-specific options. Signed-off-by: Denis Mukhin --- xen/arch/x86/Kconfig | 76 +--- xen/arch/x86/hvm/Kconfig | 74 ++

[PATCH v3 04/24] xen/console: introduce console_{get,put}_domain()

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin console_input_domain() takes an RCU lock to protect domain structure. That implies call to rcu_unlock_domain() after use. Introduce a pair of console_get_domain() / console_put_domain() to highlight the correct use of the call within the code interacting with Xen console drive

[PATCH v3 22/24] x86/hvm: enable NS16550-compatible UART emulator

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Introduce new emulation flag for virtual UART on x86 and plumb it through domain creation code so NS16550 emulator is enabled properly. Virtual UART facility is enabled for HVM domains only. Enabling it for PVH domains requires some work, as vPIC is not enabled in PVH. Also,

[PATCH v3 11/24] xen/domain: move get_initial_domain_id() to arch-independent header

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Honor 'hardware_domid=' parameter across all architectures and update max_init_domid correctly so that toolstack and, subsequently, console driver could iterate across known domains more efficiently. Also, move max_init_domid to arch-independent location. Signed-off-by: Denis

[PATCH v3 15/24] xen/console: make console buffer size configurable

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Add new CONRING_SIZE Kconfig parameter to specify the boot console buffer size in bytes. The value is rounded to the nearest power of 2 to match existing conring_size= behavior. The supported range is [16KiB..128MiB]. Bump default size to 32 KiB. Link: https://gitlab.com/xen

[PATCH v3 18/24] xen/include: introduce resource.h

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Move common resource definitions to a new architecture-agnostic shared header file. Signed-off-by: Denis Mukhin --- It will be used in follow on NS8250 emulator code to describe legacy PC COM resources. --- --- xen/common/device-tree/device-tree.c | 21 +

[PATCH v3 17/24] xen/console: flush console ring to physical console

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Internal console ring is used to hold Xen messages before external consoles (serial, VGA) consoles are fully initialized. Ensure all messages are sent to all external consoles after their initialization is completed. Link: https://gitlab.com/xen-project/xen/-/issues/184 Signe

[PATCH v3 23/24] docs/misc: update console documentation

2025-01-03 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Minor update related to virtual UART support. Also: s/pv/PV/g s/hvm/HVM/g Signed-off-by: Denis Mukhin --- docs/misc/console.txt | 50 ++ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/docs/misc/console.txt b

[PATCH v2 26/35] xen/console: make console buffer size configurable

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Add new CONRING_LOG_SHIFT Kconfig parameter to specify the boot console buffer size as a power of 2. Bump default size to 32 KiB. Link: https://gitlab.com/xen-project/xen/-/issues/185 Signed-off-by: Denis Mukhin --- xen/drivers/char/Kconfig | 23 +++ x

[PATCH v2 27/35] xen/console: flush console ring to physical console

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Messages printed before the serial and VGA consoles are initialized end up in the internal console buffer (conring). Flush contents of conring to all external consoles after external consoles are fully initialied. Link: https://gitlab.com/xen-project/xen/-/issues/184 Signed-of

[PATCH v2 32/35] x86/hvm: add debugging facility to NS8250 UART emulator

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Enable keyhandler mechanism for dumping state of emulated NS8250 on the console. Signed-off-by: Denis Mukhin --- xen/arch/x86/hvm/vuart_ns8250.c | 122 1 file changed, 122 insertions(+) diff --git a/xen/arch/x86/hvm/vuart_ns8250.c b/

[PATCH v2 21/35] xen/console: introduce console_init_owner()

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin console_init_owner() is introduced for selecting the boot-time console owner. Signed-off-by: Denis Mukhin --- xen/drivers/char/console.c | 27 +-- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers

[PATCH v2 23/35] xen/console: introduce console_write()

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin PV Linux kernel uses HYPERVISOR_console_io hypercall for early console which ends up being handled by Xen's console driver's guest_console_write(). guest_console_write() duplicates the code from __putstr(), elimitate code duplication. Signed-off-by: Denis Mukhin --- xen/dri

[PATCH v2 31/35] x86/hvm: introduce NS8250 UART emulator

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Add initial in-hypervisor emulator for NS8250/NS16x50-compatible UARTs under CONFIG_HAS_VUART_NS8250. In parallel domain creation scenario (hyperlaunch), NS8520 emulator helps early guest OS bringup debugging, because it eliminates dependency on the external emulator being ope

[PATCH v2 19/35] xen/console: introduce console_set_owner()

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin console_set_owner() is introduced for setting the new console owner. Switches console owner to domain ID vs range of integer numbers mapped to domain IDs. This a public API to console driver, will be used in the follow on code change. Signed-off-by: Denis Mukhin --- xen/dr

[PATCH v2 30/35] x86/hvm: add helpers for raising guest IRQs

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Added convenience wrappers for asserting/de-asserting interrupts in the hardware emulation code. That will be used for PCI-based NS8250 emulator. Signed-off-by: Denis Mukhin --- xen/arch/x86/hvm/irq.c | 24 xen/arch/x86/include/asm/hvm/i

[PATCH v2 24/35] xen/console: introduce hwdom_crashconsole=

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin The new command line switch `hwdom_crashconsole=BOOL` allows to switch serial console input focus to xen for machine state inspection using keyhandler mechanism after the hardware domain crashes. The new command line switch is aliased via `dom0=...,crashconsole` knob. Such fu

[PATCH v2 28/35] xen/8250-uart: add missing definitions

2024-12-05 Thread Denis Mukhin via B4 Relay
From: Denis Mukhin Added missing definitions needed for NS8250 UART emulator. Signed-off-by: Denis Mukhin --- xen/include/xen/8250-uart.h | 81 + 1 file changed, 60 insertions(+), 21 deletions(-) diff --git a/xen/include/xen/8250-uart.h b/xen/includ