[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3 2/5] xen/console: introduce console_get_domid()



From: Denis Mukhin <dmukhin@xxxxxxxx>

Add console_get_domid() to the console driver to retrieve the current console
owner domain ID.

Use the function in vpl011 emulator which leads to simpler code.

Make console_{get,put}_domain() private to the console driver.

No functional change intended.

Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
Changes since v2:
- changed commit subject line
- Link to v2: 
https://lore.kernel.org/xen-devel/20250331230508.440198-8-dmukhin@xxxxxxxx/
---
 xen/arch/arm/vpl011.c      |  5 +----
 xen/drivers/char/console.c | 11 +++++++++--
 xen/include/xen/console.h  |  3 +--
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c
index 66047bf33c..0f58b2c900 100644
--- a/xen/arch/arm/vpl011.c
+++ b/xen/arch/arm/vpl011.c
@@ -78,12 +78,11 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t 
data)
     unsigned long flags;
     struct vpl011 *vpl011 = &d->arch.vpl011;
     struct vpl011_xen_backend *intf = vpl011->backend.xen;
-    struct domain *input = console_get_domain();
 
     VPL011_LOCK(d, flags);
 
     intf->out[intf->out_prod++] = data;
-    if ( d == input )
+    if ( d->domain_id == console_get_domid() )
     {
         if ( intf->out_prod == 1 )
         {
@@ -123,8 +122,6 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t 
data)
     vpl011_update_interrupt_status(d);
 
     VPL011_UNLOCK(d, flags);
-
-    console_put_domain(input);
 }
 
 /*
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index c8dde38376..86fd0b427d 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -474,19 +474,26 @@ static unsigned int __read_mostly console_rx = 0;
 
 #define max_console_rx (max_init_domid + 1)
 
-struct domain *console_get_domain(void)
+static struct domain *console_get_domain(void)
 {
     if ( console_rx == 0 )
             return NULL;
     return rcu_lock_domain_by_id(console_rx - 1);
 }
 
-void console_put_domain(struct domain *d)
+static void console_put_domain(struct domain *d)
 {
     if ( d )
         rcu_unlock_domain(d);
 }
 
+domid_t console_get_domid(void)
+{
+    if ( console_rx == 0 )
+        return DOMID_XEN;
+    return console_rx - 1;
+}
+
 static void console_switch_input(void)
 {
     unsigned int next_rx = console_rx;
diff --git a/xen/include/xen/console.h b/xen/include/xen/console.h
index 83cbc9fbda..c6f9d84d80 100644
--- a/xen/include/xen/console.h
+++ b/xen/include/xen/console.h
@@ -32,8 +32,7 @@ void console_end_sync(void);
 void console_start_log_everything(void);
 void console_end_log_everything(void);
 
-struct domain *console_get_domain(void);
-void console_put_domain(struct domain *d);
+domid_t console_get_domid(void);
 
 /*
  * Steal output from the console. Returns +ve identifier, else -ve error.
-- 
2.34.1





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.