[PATCH v4 08/12] tools/xenstored: Remove stubdom special casing

Jason Andryuk posted 12 patches 3 months, 1 week ago
There is a newer version of this series
[PATCH v4 08/12] tools/xenstored: Remove stubdom special casing
Posted by Jason Andryuk 3 months, 1 week ago
posix.c and minios.c implement the same named functions serving slightly
different purposes.

For xenbus_map()
posix.c maps the local /dev/xen/xsd_kva
minios.c maps dom0 via grant and there is open coding for stub_domid in
map_interface.

Change xenbus_map() to map the local domain's interface.  The default
grant table mapping is performed otherwise.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
---
 tools/xenstored/domain.c | 5 -----
 tools/xenstored/minios.c | 4 +---
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index e9e45ed8e8..ac4ac72f99 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -506,11 +506,6 @@ static void *map_interface(domid_t domid)
 	if (domid == xenbus_master_domid())
 		return xenbus_map();
 
-#ifdef __MINIOS__
-	if (domid == stub_domid)
-		return xenstore_buf;
-#endif
-
 	return xengnttab_map_grant_ref(*xgt_handle, domid,
 				       GNTTAB_RESERVED_XENSTORE,
 				       PROT_READ|PROT_WRITE);
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index a229954cf4..34f655f20a 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -48,13 +48,11 @@ evtchn_port_t get_xenbus_evtchn(void)
 
 void *xenbus_map(void)
 {
-	return xengnttab_map_grant_ref(*xgt_handle, xenbus_master_domid(),
-			GNTTAB_RESERVED_XENSTORE, PROT_READ|PROT_WRITE);
+	return xenstore_buf;
 }
 
 void unmap_xenbus(void *interface)
 {
-	xengnttab_unmap(*xgt_handle, interface, 1);
 }
 
 void early_init(bool live_update, bool dofork, const char *pidfile)
-- 
2.50.1
Re: [PATCH v4 08/12] tools/xenstored: Remove stubdom special casing
Posted by Jürgen Groß 3 months, 1 week ago
On 25.07.25 04:28, Jason Andryuk wrote:
> posix.c and minios.c implement the same named functions serving slightly
> different purposes.
> 
> For xenbus_map()
> posix.c maps the local /dev/xen/xsd_kva
> minios.c maps dom0 via grant and there is open coding for stub_domid in
> map_interface.
> 
> Change xenbus_map() to map the local domain's interface.  The default
> grant table mapping is performed otherwise.
> 
> Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
> ---
>   tools/xenstored/domain.c | 5 -----
>   tools/xenstored/minios.c | 4 +---
>   2 files changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
> index e9e45ed8e8..ac4ac72f99 100644
> --- a/tools/xenstored/domain.c
> +++ b/tools/xenstored/domain.c
> @@ -506,11 +506,6 @@ static void *map_interface(domid_t domid)
>   	if (domid == xenbus_master_domid())
>   		return xenbus_map();
>   
> -#ifdef __MINIOS__
> -	if (domid == stub_domid)
> -		return xenstore_buf;
> -#endif
> -
>   	return xengnttab_map_grant_ref(*xgt_handle, domid,
>   				       GNTTAB_RESERVED_XENSTORE,
>   				       PROT_READ|PROT_WRITE);
> diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
> index a229954cf4..34f655f20a 100644
> --- a/tools/xenstored/minios.c
> +++ b/tools/xenstored/minios.c
> @@ -48,13 +48,11 @@ evtchn_port_t get_xenbus_evtchn(void)
>   
>   void *xenbus_map(void)
>   {
> -	return xengnttab_map_grant_ref(*xgt_handle, xenbus_master_domid(),
> -			GNTTAB_RESERVED_XENSTORE, PROT_READ|PROT_WRITE);
> +	return xenstore_buf;
>   }

I think this is correct only after patch 10.

In a Xenstore-stubdom you will swap buffers of dom0 and the stubdom with
this patch.


Juergen