From: "Roger Pau Monné" <roger.pau@citrix.com>
To: dmukhin@ford.com
Cc: xen-devel@lists.xenproject.org,
Andrew Cooper <andrew.cooper3@citrix.com>,
Jan Beulich <jbeulich@suse.com>, Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: [PATCH v2 17/35] xen/console: introduce consoled_is_enabled()
Date: Thu, 12 Dec 2024 10:31:12 +0100 [thread overview]
Message-ID: <Z1qtYO9Kr-9bzwEh@macbook.local> (raw)
In-Reply-To: <20241205-vuart-ns8250-v1-17-e9aa923127eb@ford.com>
On Thu, Dec 05, 2024 at 08:41:47PM -0800, Denis Mukhin via B4 Relay wrote:
> From: Denis Mukhin <dmukhin@ford.com>
>
> 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 for follow-on
> console switch logic cleanup.
>
> Signed-off-by: Denis Mukhin <dmukhin@ford.com>
> ---
> xen/drivers/char/console.c | 10 +++-------
> xen/drivers/char/consoled.c | 18 ++++++++++++++----
> xen/include/xen/consoled.h | 35 +++++++++++++++++++++++++++++++++--
> 3 files changed, 50 insertions(+), 13 deletions(-)
>
> diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
> index f034ce5aab3f3bf59b0df9fa583ee9ce32dbf665..60c055396b697869b04b9132b0dcfa832fabe932 100644
> --- a/xen/drivers/char/console.c
> +++ b/xen/drivers/char/console.c
> @@ -33,9 +33,9 @@
> #include <xen/pv_console.h>
> #include <asm/setup.h>
> #include <xen/sections.h>
> +#include <xen/consoled.h>
>
> #ifdef CONFIG_X86
> -#include <xen/consoled.h>
> #include <asm/guest.h>
> #endif
> #ifdef CONFIG_SBSA_VUART_CONSOLE
> @@ -505,11 +505,9 @@ static void console_find_owner(void)
> break;
> }
>
> -#ifdef CONFIG_PV_SHIM
> - if ( next_rx == 1 )
> + if ( consoled_is_enabled() && next_rx == 1 )
> domid = get_initial_domain_id();
> else
> -#endif
> domid = next_rx - 1;
> d = rcu_lock_domain_by_id(domid);
> if ( d )
> @@ -573,10 +571,8 @@ static void __serial_rx(char c)
> #endif
> }
>
> -#ifdef CONFIG_X86
> - if ( pv_shim && pv_console )
> + if ( consoled_is_enabled() )
> consoled_guest_tx(c);
> -#endif
> }
>
> static void cf_check serial_rx(char c)
> diff --git a/xen/drivers/char/consoled.c b/xen/drivers/char/consoled.c
> index b415b632cecc0a80e161b701d7b70ba4f3cc5fb8..d6624e7697f56e1a1959b0efa5dca104f34af002 100644
> --- a/xen/drivers/char/consoled.c
> +++ b/xen/drivers/char/consoled.c
> @@ -43,13 +43,13 @@ struct xencons_interface *consoled_get_ring_addr(void)
> static char buf[BUF_SZ + 1];
>
> /* Receives characters from a domain's PV console */
> -void consoled_guest_rx(void)
> +int consoled_guest_rx(void)
> {
> size_t idx = 0;
> XENCONS_RING_IDX cons, prod;
>
> if ( !cons_ring )
> - return;
> + return 0;
>
> spin_lock(&rx_lock);
>
> @@ -91,15 +91,17 @@ void consoled_guest_rx(void)
>
> out:
> spin_unlock(&rx_lock);
> +
> + return 0;
> }
>
> /* Sends a character into a domain's PV console */
> -void consoled_guest_tx(char c)
> +int consoled_guest_tx(char c)
> {
> XENCONS_RING_IDX cons, prod;
>
> if ( !cons_ring )
> - return;
> + return 0;
>
> cons = ACCESS_ONCE(cons_ring->in_cons);
> prod = cons_ring->in_prod;
> @@ -118,6 +120,7 @@ void consoled_guest_tx(char c)
>
> cons_ring->in[MASK_XENCONS_IDX(prod++, cons_ring->in)] = c;
>
> +
> /* Write to the ring before updating the pointer */
> smp_wmb();
> ACCESS_ONCE(cons_ring->in_prod) = prod;
> @@ -125,6 +128,13 @@ void consoled_guest_tx(char c)
> notify:
> /* Always notify the guest: prevents receive path from getting stuck. */
> pv_shim_inject_evtchn(pv_console_evtchn());
> +
> + return 0;
> +}
> +
> +bool consoled_is_enabled(void)
> +{
> + return pv_shim && pv_console;
> }
>
> /*
> diff --git a/xen/include/xen/consoled.h b/xen/include/xen/consoled.h
> index bd7ab6329ee8a7c466484021247241ded8ed03c7..696677fa5a3be458a0ec93360e08376c3471f95b 100644
> --- a/xen/include/xen/consoled.h
> +++ b/xen/include/xen/consoled.h
> @@ -3,10 +3,41 @@
>
> #include <public/io/console.h>
>
> +#if defined(CONFIG_PV_SHIM)
> +
> void consoled_set_ring_addr(struct xencons_interface *ring);
> struct xencons_interface *consoled_get_ring_addr(void);
> -void consoled_guest_rx(void);
> -void consoled_guest_tx(char c);
> +int consoled_guest_rx(void);
> +int consoled_guest_tx(char c);
> +bool consoled_is_enabled(void);
> +
> +#else
> +
> +static inline void consoled_set_ring_addr(struct xencons_interface *ring)
> +{
> +}
> +
> +static inline struct xencons_interface *consoled_get_ring_addr(void)
> +{
> + return NULL;
> +}
> +
> +static inline int consoled_guest_rx(void)
> +{
> + return 0;
> +}
You don't need to provide dummy implementations of
consoled_{set,get}_ring_addr() and consoled_guest_rx(), they are only
called from code that's build when CONFIG_PV_SHIM is selected.
> +static inline int consoled_guest_tx(char c)
> +{
> + return 0;
For consoled_guest_tx() you want to add an ASSERT_UNREACHABLE(), as
it should never be called if !CONFIG_PV_SHIM?
Thanks, Roger.
next prev parent reply other threads:[~2024-12-12 9:31 UTC|newest]
Thread overview: 218+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-06 4:41 [PATCH v2 00/35] Introduce NS8250 UART emulator Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-06 4:41 ` [PATCH v2 01/35] xen: introduce resource.h Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 13:13 ` Jan Beulich
2025-01-04 2:23 ` Denis Mukhin
2024-12-11 11:01 ` Roger Pau Monné
2025-01-04 3:10 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 02/35] xen/irq: introduce NO_IRQ Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 13:17 ` Jan Beulich
2025-01-04 2:26 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 03/35] xen/ctype: introduce isconsole() Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 13:22 ` Jan Beulich
2025-01-04 2:31 ` Denis Mukhin
2025-01-06 8:55 ` Jan Beulich
2024-12-06 4:41 ` [PATCH v2 04/35] arm/vuart: use guest_printk() Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-06 4:41 ` [PATCH v2 05/35] arm/vuart: make domain_has_vuart() public Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-06 4:41 ` [PATCH v2 06/35] riscv/domain: introduce domain_has_vuart() Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-06 4:41 ` [PATCH v2 07/35] ppc/domain: " Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 13:24 ` Jan Beulich
2024-12-06 4:41 ` [PATCH v2 08/35] x86/domain: " Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 13:26 ` Jan Beulich
2025-01-04 2:34 ` Denis Mukhin
2024-12-11 15:13 ` Roger Pau Monné
2025-01-04 3:11 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 09/35] x86/domain: print emulation_flags Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 13:30 ` Jan Beulich
2025-01-04 3:55 ` Denis Mukhin
2024-12-11 15:19 ` Roger Pau Monné
2024-12-12 11:53 ` Jan Beulich
2024-12-12 12:11 ` Roger Pau Monné
2024-12-12 12:50 ` Jan Beulich
2025-01-04 3:56 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 10/35] xen/domain: add get_initial_domain_id() Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 13:50 ` Jan Beulich
2025-01-04 2:50 ` Denis Mukhin
2024-12-11 16:50 ` Roger Pau Monné
2025-01-04 4:44 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 11/35] xen/domain: enable max_init_domid for all architectures Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 13:57 ` Jan Beulich
2025-01-04 2:51 ` Denis Mukhin
2024-12-11 17:00 ` Roger Pau Monné
2025-01-04 3:13 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 12/35] xen/console: move vpl011-related code to vpl011 emulator Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 13:33 ` Jan Beulich
2025-01-04 2:49 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 13/35] xen/console: rename console_input_domain Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 14:01 ` Jan Beulich
2025-01-04 2:53 ` Denis Mukhin
2024-12-11 17:17 ` Roger Pau Monné
2025-01-04 3:13 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 14/35] xen/console: rename switch_serial_input() to console_find_owner() Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 14:13 ` Jan Beulich
2024-12-11 17:22 ` Roger Pau Monné
2025-01-04 3:14 ` Denis Mukhin
2025-01-04 2:54 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 15/35] xen/console: rename console_rx to console_owner Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 14:23 ` Jan Beulich
2024-12-12 8:58 ` Roger Pau Monné
2025-01-04 3:20 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 16/35] xen/console: introduce printk_common() Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 14:27 ` Jan Beulich
2025-01-04 2:57 ` Denis Mukhin
2025-01-06 9:04 ` Jan Beulich
2024-12-12 9:14 ` Roger Pau Monné
2024-12-12 11:57 ` Jan Beulich
2024-12-12 12:15 ` Roger Pau Monné
2024-12-12 12:52 ` Jan Beulich
2024-12-12 15:25 ` Roger Pau Monné
2024-12-13 1:03 ` Stefano Stabellini
2025-01-04 4:11 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 17/35] xen/console: introduce consoled_is_enabled() Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 14:31 ` Jan Beulich
2025-01-04 3:00 ` Denis Mukhin
2025-01-06 9:05 ` Jan Beulich
2024-12-12 9:31 ` Roger Pau Monné [this message]
2025-01-04 3:21 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 18/35] xen/console: introduce use of 'is_console' flag Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 14:52 ` Jan Beulich
2025-01-04 3:05 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 19/35] xen/console: introduce console_set_owner() Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 15:02 ` Jan Beulich
2025-01-04 3:07 ` Denis Mukhin
2025-01-06 9:08 ` Jan Beulich
2024-12-12 10:12 ` Roger Pau Monné
2024-12-12 11:59 ` Jan Beulich
2024-12-12 12:16 ` Roger Pau Monné
2025-01-04 3:31 ` Denis Mukhin
2025-01-04 3:30 ` Denis Mukhin
2025-01-06 9:58 ` Jan Beulich
2025-01-06 20:03 ` Denis Mukhin
2025-01-07 8:37 ` Jan Beulich
2024-12-06 4:41 ` [PATCH v2 20/35] xen/console: introduce console_owner_domid() Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 22:11 ` Jason Andryuk
2024-12-11 7:33 ` Jan Beulich
2025-01-04 4:16 ` Denis Mukhin
2025-01-04 4:12 ` Denis Mukhin
2024-12-11 7:28 ` Jan Beulich
2025-01-04 4:15 ` Denis Mukhin
2025-01-06 9:14 ` Jan Beulich
2025-01-06 18:48 ` Stefano Stabellini
2025-01-07 8:40 ` Jan Beulich
2025-01-07 23:40 ` Stefano Stabellini
2025-01-08 7:28 ` Jan Beulich
2025-01-08 8:04 ` Roger Pau Monné
2025-01-08 8:13 ` Jan Beulich
2025-01-08 8:35 ` Roger Pau Monné
2025-01-08 22:15 ` Denis Mukhin
2025-01-09 0:29 ` Stefano Stabellini
2025-01-09 8:06 ` Roger Pau Monné
2025-01-09 23:46 ` Stefano Stabellini
2025-01-10 1:39 ` Denis Mukhin
2025-01-09 8:25 ` Jan Beulich
2025-01-09 8:27 ` Jan Beulich
2025-01-10 1:34 ` Denis Mukhin
2024-12-12 10:18 ` Roger Pau Monné
2025-01-04 4:11 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 21/35] xen/console: introduce console_init_owner() Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-10 22:30 ` Jason Andryuk
2024-12-11 7:31 ` Jan Beulich
2025-01-04 3:22 ` Denis Mukhin
2024-12-12 10:23 ` Roger Pau Monné
2025-01-04 3:23 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 22/35] xen/console: introduce handle_keypress_in_domain() Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-12 10:51 ` Roger Pau Monné
2025-01-04 3:25 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 23/35] xen/console: introduce console_write() Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-12 12:04 ` Roger Pau Monné
2025-01-04 3:50 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 24/35] xen/console: introduce hwdom_crashconsole= Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-12 12:29 ` Roger Pau Monné
2025-01-04 4:48 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 25/35] xen/console: simplify console owner switch hint Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-06 4:41 ` [PATCH v2 26/35] xen/console: make console buffer size configurable Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-12 12:47 ` Roger Pau Monné
2025-01-04 3:52 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 27/35] xen/console: flush console ring to physical console Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-12 14:21 ` Roger Pau Monné
2025-01-04 3:56 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 28/35] xen/8250-uart: add missing definitions Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-12 14:29 ` Roger Pau Monné
2025-01-04 4:01 ` Denis Mukhin
2024-12-12 15:07 ` Jan Beulich
2025-01-04 4:00 ` Denis Mukhin
2024-12-06 4:41 ` [PATCH v2 29/35] x86/hvm: add HVM-specific Kconfig Denis Mukhin
2024-12-06 4:41 ` Denis Mukhin via B4 Relay
2024-12-12 15:06 ` Roger Pau Monné
2025-01-04 3:58 ` Denis Mukhin
2024-12-06 4:42 ` [PATCH v2 30/35] x86/hvm: add helpers for raising guest IRQs Denis Mukhin
2024-12-06 4:42 ` Denis Mukhin via B4 Relay
2024-12-12 16:18 ` Roger Pau Monné
2025-01-04 4:02 ` Denis Mukhin
2024-12-06 4:42 ` [PATCH v2 31/35] x86/hvm: introduce NS8250 UART emulator Denis Mukhin
2024-12-06 4:42 ` Denis Mukhin via B4 Relay
2024-12-13 11:43 ` Roger Pau Monné
2025-01-04 6:28 ` Denis Mukhin
2024-12-16 15:04 ` Jan Beulich
2025-01-04 5:31 ` Denis Mukhin
2025-01-06 9:19 ` Jan Beulich
2025-01-06 20:16 ` Denis Mukhin
2025-01-07 8:43 ` Jan Beulich
2024-12-06 4:42 ` [PATCH v2 32/35] x86/hvm: add debugging facility to " Denis Mukhin
2024-12-06 4:42 ` Denis Mukhin via B4 Relay
2024-12-13 12:08 ` Roger Pau Monné
2025-01-04 4:31 ` Denis Mukhin
2024-12-16 15:08 ` Jan Beulich
2025-01-04 4:37 ` Denis Mukhin
2024-12-06 4:42 ` [PATCH v2 33/35] x86/domain: implement domain_has_vuart() Denis Mukhin
2024-12-06 4:42 ` Denis Mukhin via B4 Relay
2024-12-13 12:23 ` Roger Pau Monné
2024-12-13 20:45 ` Stefano Stabellini
2024-12-16 8:40 ` Roger Pau Monné
2025-01-04 5:26 ` Denis Mukhin
2025-01-04 5:19 ` Denis Mukhin
2025-01-07 15:16 ` Roger Pau Monné
2025-01-07 17:33 ` Denis Mukhin
2024-12-16 15:11 ` Jan Beulich
2025-01-04 5:26 ` Denis Mukhin
2024-12-06 4:42 ` [PATCH v2 34/35] xen/console: enable console owners w/ emulated NS8250 Denis Mukhin
2024-12-06 4:42 ` Denis Mukhin via B4 Relay
2024-12-10 22:46 ` Jason Andryuk
2024-12-11 7:35 ` Jan Beulich
2024-12-11 7:38 ` Jan Beulich
2025-01-04 3:12 ` Denis Mukhin
2025-01-04 3:08 ` Denis Mukhin
2024-12-06 4:42 ` [PATCH v2 35/35] docs/misc: update console documentation Denis Mukhin
2024-12-06 4:42 ` Denis Mukhin via B4 Relay
2024-12-14 18:05 ` [PATCH v2 00/35] Introduce NS8250 UART emulator Marek Marczykowski-Górecki
2024-12-16 9:04 ` Roger Pau Monné
2025-01-04 4:28 ` Denis Mukhin
2025-01-04 4:27 ` Denis Mukhin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z1qtYO9Kr-9bzwEh@macbook.local \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=dmukhin@ford.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.