Skip to contentSkip to conversation

Mini-OS: preparations for 9pfs in xenstore-stubdom

PATCH Superseded Juergen Gross 4 participants 19 messages Nov 10, 2023 – Nov 13, 2023

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Mini-OS: preparations for 9pfs in xenstore-stubdom

This small patch series is doing some preparations for being able to use 9pfs in Xenstore-stubdom.

Changes in V2:
- added patches 2 and 5

Juergen Gross (5):
Mini-OS: make xenstore_buf externally visible
Mini-OS: get own domid
Mini-OS: don't crash if no shutdown node is available
Mini-OS: fix 9pfs stat receive format
Mini-OS: fix 9pfs response receiving

 9pfront.c        | 13 ++++++++-----
 events.c         | 32 ++++++++++++++++++++++++++++++++
 include/events.h |  2 ++
 include/xenbus.h |  2 ++
 shutdown.c       | 12 ++++--------
 xenbus.c         |  2 +-
 6 files changed, 49 insertions(+), 14 deletions(-)
Signature · 1 line
2.35.3
#1 lore raw

PATCH v2 1/5 Mini-OS: make xenstore_buf externally visible

For support of the 9pfs frontend in Xenstore-stubdom xenstore_buf needs to be externally visible.

---
 include/xenbus.h | 2 ++
 xenbus.c         | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
include/xenbus.h +2 -0
index c0fc0ac5..542ee456 100644
@@ -8,12 +8,14 @@ typedef unsigned long xenbus_transaction_t;
 
 #ifdef CONFIG_XENBUS
 extern uint32_t xenbus_evtchn;
+extern struct xenstore_domain_interface *xenstore_buf;
 
 /* Initialize the XenBus system. */
 void init_xenbus(void);
 void get_xenbus(void *p);
 #else
 #define xenbus_evtchn ~0
+#define xenstore_buf NULL
 
 static inline void init_xenbus(void)
 {
xenbus.c +1 -1
index 923e8181..8bfd5bd4 100644
@@ -44,7 +44,7 @@
 #define DEBUG(_f, _a...)    ((void)0)
 #endif
 
-static struct xenstore_domain_interface *xenstore_buf;
+struct xenstore_domain_interface *xenstore_buf;
 static DECLARE_WAIT_QUEUE_HEAD(xb_waitq);
 DECLARE_WAIT_QUEUE_HEAD(xenbus_watch_queue);
 static __DECLARE_SEMAPHORE_GENERIC(xb_write_sem, 1);
Signature · 1 line
2.35.3
#2 lore raw

PATCH v2 2/5 Mini-OS: get own domid

In reply to Juergen Gross

Get the own domid via creation of a temporary event channel. There is no "official" way to read the own domid in PV guests, so use the event channel interface to get it:

- allocate an unbound event channel specifying DOMID_SELF for the other end

- read the event channel status which will contain the own domid in unbound.dom

- close the event channel

---
V2:
- new patch

---
 events.c         | 32 ++++++++++++++++++++++++++++++++
 include/events.h |  2 ++
 2 files changed, 34 insertions(+)
events.c +32 -0
index cdae90f4..af9f9f9e 100644
@@ -261,6 +261,38 @@ int evtchn_get_peercontext(evtchn_port_t local_port, char *ctx, int size)
     return rc;
 }
 
+domid_t evtchn_get_domid(void)
+{
+    int rc;
+    domid_t domid = DOMID_INVALID;
+    evtchn_alloc_unbound_t op;
+    struct evtchn_status status;
+    struct evtchn_close close;
+
+    op.dom = DOMID_SELF;
+    op.remote_dom = DOMID_SELF;
+    rc = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &op);
+    if ( rc )
+    {
+        printk("ERROR: alloc_unbound failed with rc=%d", rc);
+        return domid;
+    }
+
+    status.dom = DOMID_SELF;
+    status.port = op.port;
+    rc = HYPERVISOR_event_channel_op(EVTCHNOP_status, &status);
+    if ( rc )
+        printk("ERROR: EVTCHNOP_status failed with rc=%d", rc);
+    else
+        domid = status.u.unbound.dom;
+
+    close.port = op.port;
+    rc = HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
+    if ( rc )
+        printk("WARN: close_port %d failed rc=%d. ignored\n", close.port, rc);
+
+    return domid;
+}
 
 /*
  * Local variables:
include/events.h +2 -0
index 705ad93a..87311481 100644
@@ -57,4 +57,6 @@ static inline int notify_remote_via_evtchn(evtchn_port_t port)
 void fini_events(void);
 void suspend_events(void);
 
+domid_t evtchn_get_domid(void);
+
 #endif /* _EVENTS_H_ */
Signature · 1 line
2.35.3
#3 lore raw

Re: [PATCH v2 2/5] Mini-OS: get own domid

Quoted 11 lines · Juergen Gross

Get the own domid via creation of a temporary event channel. There is no "official" way to read the own domid in PV guests, so use the event channel interface to get it:

- allocate an unbound event channel specifying DOMID_SELF for the other end

- read the event channel status which will contain the own domid in unbound.dom

- close the event channel

Should we look into introducing a way to expose the domid, so that in the future we might not need to resort to this workarounds to get the domid?

Maybe in the PV-specific cpuid leaf? It's a shame we didn't put it in a non-HVM specific leaf when it was made available to HVM for pvshim reasons.

Thanks, Roger.

#4 lore raw

Re: [PATCH v2 2/5] Mini-OS: get own domid

Quoted 13 lines · Roger Pau Monné
Quoted 11 lines · Juergen Gross

Get the own domid via creation of a temporary event channel. There is no "official" way to read the own domid in PV guests, so use the event channel interface to get it:

- allocate an unbound event channel specifying DOMID_SELF for the other end

- read the event channel status which will contain the own domid in unbound.dom

- close the event channel

Quoted 7 lines

Should we look into introducing a way to expose the domid, so that in the future we might not need to resort to this workarounds to get the domid?

Maybe in the PV-specific cpuid leaf? It's a shame we didn't put it in a non-HVM specific leaf when it was made available to HVM for pvshim reasons.

I'm in favor of an "official" way to get the domid.

As this might be needed on other architectures, too, I guess this will most likely require a (stable) hypercall.

As soon as this is available, I'd be happy to change Mini-OS again to use the new hypercall. In order not to block my Xenstore-stubdom series, I'd like to use the hack of this patch until then. Maybe I should rename the function to get_own_domid() in order to avoid having to change the user(s).

Juergen

#5 lore raw

Re: [PATCH v2 2/5] Mini-OS: get own domid

In reply to Roger Pau Monné
Quoted 13 lines · Roger Pau Monné
Quoted 11 lines · Juergen Gross

Get the own domid via creation of a temporary event channel. There is no "official" way to read the own domid in PV guests, so use the event channel interface to get it:

- allocate an unbound event channel specifying DOMID_SELF for the other end

- read the event channel status which will contain the own domid in unbound.dom

- close the event channel

Quoted 7 lines

Should we look into introducing a way to expose the domid, so that in the future we might not need to resort to this workarounds to get the domid?

Maybe in the PV-specific cpuid leaf? It's a shame we didn't put it in a non-HVM specific leaf when it was made available to HVM for pvshim reasons.

Couldn't we retroactively generalize the type-agnostic parts of that leaf?

Jan

#6 lore raw

Re: [PATCH v2 2/5] Mini-OS: get own domid

Hi Jan,

Quoted 18 lines · Jan Beulich
Quoted 17 lines · Roger Pau Monné
Quoted 11 lines · Juergen Gross

Get the own domid via creation of a temporary event channel. There is no "official" way to read the own domid in PV guests, so use the event channel interface to get it:

- allocate an unbound event channel specifying DOMID_SELF for the other end

- read the event channel status which will contain the own domid in unbound.dom

- close the event channel

Should we look into introducing a way to expose the domid, so that in the future we might not need to resort to this workarounds to get the domid?

Quoted 6 lines
Quoted 3 lines

Maybe in the PV-specific cpuid leaf? It's a shame we didn't put it in a non-HVM specific leaf when it was made available to HVM for pvshim reasons.

Couldn't we retroactively generalize the type-agnostic parts of that leaf?

This would only work for x86. I think we want to have a generic hypercalls so it can be used by all arch.

Cheers,

Signature · 1 line
Julien Grall
#7 lore raw

Re: [PATCH v2 2/5] Mini-OS: get own domid

Quoted 25 lines · Julien Grall

Hi Jan,

Quoted 22 lines · Jan Beulich
Quoted 20 lines · Roger Pau Monné
Quoted 11 lines · Juergen Gross

Get the own domid via creation of a temporary event channel. There is no "official" way to read the own domid in PV guests, so use the event channel interface to get it:

- allocate an unbound event channel specifying DOMID_SELF for the other end

- read the event channel status which will contain the own domid in unbound.dom

- close the event channel

Should we look into introducing a way to expose the domid, so that in the future we might not need to resort to this workarounds to get the domid?

Maybe in the PV-specific cpuid leaf? It's a shame we didn't put it in a non-HVM specific leaf when it was made available to HVM for pvshim reasons.

Quoted 5 lines
Quoted 2 lines

Couldn't we retroactively generalize the type-agnostic parts of that leaf?

This would only work for x86. I think we want to have a generic hypercalls so it can be used by all arch.

Hmm, yes, perhaps. Otoh it would seem desirable to me if arch-es also provided some extension to an arch-natural way of feature detection (which CPUID is on x86), without the need to invoke any hypercalls.

Jan

#8 lore raw

Re: [PATCH v2 2/5] Mini-OS: get own domid

Quoted 29 lines · Jan Beulich
Quoted 28 lines · Julien Grall

Hi Jan,

Quoted 24 lines · Jan Beulich
Quoted 13 lines · Roger Pau Monné
Quoted 11 lines · Juergen Gross

Get the own domid via creation of a temporary event channel. There is no "official" way to read the own domid in PV guests, so use the event channel interface to get it:

- allocate an unbound event channel specifying DOMID_SELF for the other end

- read the event channel status which will contain the own domid in unbound.dom

- close the event channel

Quoted 7 lines

Should we look into introducing a way to expose the domid, so that in the future we might not need to resort to this workarounds to get the domid?

Maybe in the PV-specific cpuid leaf? It's a shame we didn't put it in a non-HVM specific leaf when it was made available to HVM for pvshim reasons.

Couldn't we retroactively generalize the type-agnostic parts of that leaf?

Quoted 6 lines
Quoted 2 lines

This would only work for x86. I think we want to have a generic hypercalls so it can be used by all arch.

Hmm, yes, perhaps. Otoh it would seem desirable to me if arch-es also provided some extension to an arch-natural way of feature detection (which CPUID is on x86), without the need to invoke any hypercalls.

For Arm, I can't really think of anything other than hvc/smc which are used for calls to the hypervisor/monitor (so basically hypercalls).

Please suggest if you have a better idea.

Cheers,

Signature · 1 line
Julien Grall
#9 lore raw

Re: [PATCH v2 2/5] Mini-OS: get own domid

Quoted 35 lines · Julien Grall
Quoted 32 lines · Jan Beulich
Quoted 30 lines · Julien Grall

Hi Jan,

Quoted 18 lines · Jan Beulich
Quoted 17 lines · Roger Pau Monné
Quoted 11 lines · Juergen Gross

Get the own domid via creation of a temporary event channel. There is no "official" way to read the own domid in PV guests, so use the event channel interface to get it:

- allocate an unbound event channel specifying DOMID_SELF for the other end

- read the event channel status which will contain the own domid in unbound.dom

- close the event channel

Should we look into introducing a way to expose the domid, so that in the future we might not need to resort to this workarounds to get the domid?

Quoted 6 lines
Quoted 3 lines

Maybe in the PV-specific cpuid leaf? It's a shame we didn't put it in a non-HVM specific leaf when it was made available to HVM for pvshim reasons.

Couldn't we retroactively generalize the type-agnostic parts of that leaf?

This would only work for x86. I think we want to have a generic hypercalls so it can be used by all arch.

Quoted 8 lines
Quoted 3 lines

Hmm, yes, perhaps. Otoh it would seem desirable to me if arch-es also provided some extension to an arch-natural way of feature detection (which CPUID is on x86), without the need to invoke any hypercalls.

For Arm, I can't really think of anything other than hvc/smc which are used for calls to the hypervisor/monitor (so basically hypercalls).

Please suggest if you have a better idea.

I don't know enough Arm to properly suggest something. Arm64 has various id_* system registers, so I would be wondering whether having a properly virtual one reserved in system register space couldn't do the trick. (Clearly just one may not be sufficient long term, so there might be a scalability issue with such an approach. Unlike x86'es CPUID Arm's MRS, aiui, doesn't take inputs other than the coordinates of the system register to read.)

Jan

#10 lore raw

Re: [PATCH v2 2/5] Mini-OS: get own domid

Hi,

Quoted 40 lines · Jan Beulich
Quoted 39 lines · Julien Grall
Quoted 35 lines · Jan Beulich
Quoted 25 lines · Julien Grall

Hi Jan,

Quoted 22 lines · Jan Beulich
Quoted 20 lines · Roger Pau Monné
Quoted 11 lines · Juergen Gross

Get the own domid via creation of a temporary event channel. There is no "official" way to read the own domid in PV guests, so use the event channel interface to get it:

- allocate an unbound event channel specifying DOMID_SELF for the other end

- read the event channel status which will contain the own domid in unbound.dom

- close the event channel

Should we look into introducing a way to expose the domid, so that in the future we might not need to resort to this workarounds to get the domid?

Maybe in the PV-specific cpuid leaf? It's a shame we didn't put it in a non-HVM specific leaf when it was made available to HVM for pvshim reasons.

Quoted 5 lines
Quoted 2 lines

Couldn't we retroactively generalize the type-agnostic parts of that leaf?

This would only work for x86. I think we want to have a generic hypercalls so it can be used by all arch.

Hmm, yes, perhaps. Otoh it would seem desirable to me if arch-es also provided some extension to an arch-natural way of feature detection (which CPUID is on x86), without the need to invoke any hypercalls.

Quoted 8 lines
Quoted 4 lines

For Arm, I can't really think of anything other than hvc/smc which are used for calls to the hypervisor/monitor (so basically hypercalls).

Please suggest if you have a better idea.

I don't know enough Arm to properly suggest something. Arm64 has various id_* system registers, so I would be wondering whether having a properly virtual one reserved in system register space couldn't do the trick.

AFAIK there are none available. But if such exists, then I don't see how that would suit with my requests to have an arch-agnostic approach.

Each architecture would need to have to provide a way to expose those values. At which point, why not using hypercall? What's wrong with it?

Cheers,

Signature · 1 line
Julien Grall
#11 lore raw

Re: [PATCH v2 2/5] Mini-OS: get own domid

Quoted 52 lines · Julien Grall

Hi,

Quoted 40 lines · Jan Beulich
Quoted 39 lines · Julien Grall
Quoted 35 lines · Jan Beulich
Quoted 25 lines · Julien Grall

Hi Jan,

Quoted 22 lines · Jan Beulich
Quoted 20 lines · Roger Pau Monné
Quoted 11 lines · Juergen Gross

Get the own domid via creation of a temporary event channel. There is no "official" way to read the own domid in PV guests, so use the event channel interface to get it:

- allocate an unbound event channel specifying DOMID_SELF for the other end

- read the event channel status which will contain the own domid in unbound.dom

- close the event channel

Should we look into introducing a way to expose the domid, so that in the future we might not need to resort to this workarounds to get the domid?

Maybe in the PV-specific cpuid leaf? It's a shame we didn't put it in a non-HVM specific leaf when it was made available to HVM for pvshim reasons.

Quoted 5 lines
Quoted 2 lines

Couldn't we retroactively generalize the type-agnostic parts of that leaf?

This would only work for x86. I think we want to have a generic hypercalls so it can be used by all arch.

Hmm, yes, perhaps. Otoh it would seem desirable to me if arch-es also provided some extension to an arch-natural way of feature detection (which CPUID is on x86), without the need to invoke any hypercalls.

Quoted 8 lines
Quoted 4 lines

For Arm, I can't really think of anything other than hvc/smc which are used for calls to the hypervisor/monitor (so basically hypercalls).

Please suggest if you have a better idea.

I don't know enough Arm to properly suggest something. Arm64 has various id_* system registers, so I would be wondering whether having a properly virtual one reserved in system register space couldn't do the trick.

Quoted 5 lines

AFAIK there are none available. But if such exists, then I don't see how that would suit with my requests to have an arch-agnostic approach.

Each architecture would need to have to provide a way to expose those values.

Right. Just like hardware of each architecture also surfaces its capabilities in architecture-specific ways.

Quoted 1 line

At which point, why not using hypercall? What's wrong with it?

There's nothing "wrong" with hypercalls, they're just less natural to use in certain cases. Plus of course using them may require setup inside the guest.

I'm tempted to ask a counter question: Do you consider it a mistake that on x86 certain capability information is surfaced as CPUID data?

Jan

#12 lore raw

Re: [PATCH v2 2/5] Mini-OS: get own domid

Hi Jan,

Quoted 62 lines · Jan Beulich
Quoted 52 lines · Julien Grall

Hi,

Quoted 40 lines · Jan Beulich
Quoted 39 lines · Julien Grall
Quoted 35 lines · Jan Beulich
Quoted 25 lines · Julien Grall

Hi Jan,

Quoted 22 lines · Jan Beulich
Quoted 20 lines · Roger Pau Monné
Quoted 11 lines · Juergen Gross

Get the own domid via creation of a temporary event channel. There is no "official" way to read the own domid in PV guests, so use the event channel interface to get it:

- allocate an unbound event channel specifying DOMID_SELF for the other end

- read the event channel status which will contain the own domid in unbound.dom

- close the event channel

Should we look into introducing a way to expose the domid, so that in the future we might not need to resort to this workarounds to get the domid?

Maybe in the PV-specific cpuid leaf? It's a shame we didn't put it in a non-HVM specific leaf when it was made available to HVM for pvshim reasons.

Quoted 5 lines
Quoted 2 lines

Couldn't we retroactively generalize the type-agnostic parts of that leaf?

This would only work for x86. I think we want to have a generic hypercalls so it can be used by all arch.

Hmm, yes, perhaps. Otoh it would seem desirable to me if arch-es also provided some extension to an arch-natural way of feature detection (which CPUID is on x86), without the need to invoke any hypercalls.

Quoted 8 lines
Quoted 4 lines

For Arm, I can't really think of anything other than hvc/smc which are used for calls to the hypervisor/monitor (so basically hypercalls).

Please suggest if you have a better idea.

I don't know enough Arm to properly suggest something. Arm64 has various id_* system registers, so I would be wondering whether having a properly virtual one reserved in system register space couldn't do the trick.

Quoted 5 lines

AFAIK there are none available. But if such exists, then I don't see how that would suit with my requests to have an arch-agnostic approach.

Each architecture would need to have to provide a way to expose those values.

Right. Just like hardware of each architecture also surfaces its capabilities in architecture-specific ways.

Quoted 7 lines
Quoted 1 line

At which point, why not using hypercall? What's wrong with it?

There's nothing "wrong" with hypercalls, they're just less natural to use in certain cases. Plus of course using them may require setup inside the guest. >
I'm tempted to ask a counter question: Do you consider it a mistake that on x86 certain capability information is surfaced as CPUID data?

For anything non-x86 specific yes. I think information like domid should never have belonged to the CPUID and instead provided via an hypercalls.

Cheers,

Signature · 1 line
Julien Grall
#13 lore raw

Re: [PATCH v2 2/5] Mini-OS: get own domid

In reply to Jan Beulich
Quoted 18 lines · Jan Beulich
Quoted 17 lines · Roger Pau Monné
Quoted 11 lines · Juergen Gross

Get the own domid via creation of a temporary event channel. There is no "official" way to read the own domid in PV guests, so use the event channel interface to get it:

- allocate an unbound event channel specifying DOMID_SELF for the other end

- read the event channel status which will contain the own domid in unbound.dom

- close the event channel

Should we look into introducing a way to expose the domid, so that in the future we might not need to resort to this workarounds to get the domid?

Quoted 6 lines
Quoted 3 lines

Maybe in the PV-specific cpuid leaf? It's a shame we didn't put it in a non-HVM specific leaf when it was made available to HVM for pvshim reasons.

Couldn't we retroactively generalize the type-agnostic parts of that leaf?

Hm, maybe. In retrospective heaving leafs with PV or HVM only fields was not the best decision. It would have been better to have a generic leaf and then fields/flags that only apply to HVM or PV as necessary.

Thanks, Roger.

#14 lore raw

Re: [PATCH v2 2/5] Mini-OS: get own domid

In reply to Juergen Gross

Hi,

Quoted 27 lines · Juergen Gross

Get the own domid via creation of a temporary event channel. There is no "official" way to read the own domid in PV guests, so use the event channel interface to get it:

- allocate an unbound event channel specifying DOMID_SELF for the other end

- read the event channel status which will contain the own domid in unbound.dom

- close the event channel

---
V2:
- new patch

---
  events.c         | 32 ++++++++++++++++++++++++++++++++
  include/events.h |  2 ++
  2 files changed, 34 insertions(+)
events.c +0 -0
index cdae90f4..af9f9f9e 100644

events.c int evtchn_get_peercontext(evtchn_port_t local_port, char *ctx, int size) · line 264

Quoted 4 lines
events.c +1 -0
@@ -261,6 +261,38 @@ int evtchn_get_peercontext(evtchn_port_t local_port, char *ctx, int size)
      return rc;
  }
 
+domid_t evtchn_get_domid(void)

I think the function name should be generic so the caller doesn't need to be modified everytime the implementation is updated.

How about get_domid()?

Cheers,

Signature · 1 line
Julien Grall
#15 lore raw

Re: [PATCH v2 2/5] Mini-OS: get own domid

Quoted 36 lines · Julien Grall

Hi,

Quoted 27 lines · Juergen Gross

Get the own domid via creation of a temporary event channel. There is no "official" way to read the own domid in PV guests, so use the event channel interface to get it:

- allocate an unbound event channel specifying DOMID_SELF for the other end

- read the event channel status which will contain the own domid in unbound.dom

- close the event channel

---
V2:
- new patch

---
  events.c         | 32 ++++++++++++++++++++++++++++++++ include/events.h |  2 ++

  2 files changed, 34 insertions(+)
events.c +0 -0
index cdae90f4..af9f9f9e 100644

events.c int evtchn_get_peercontext(evtchn_port_t local_port, char · line 264

Quoted 4 lines
events.c +1 -0
@@ -261,6 +261,38 @@ int evtchn_get_peercontext(evtchn_port_t local_port, char 
 *ctx, int size)
       return rc;
   }
+domid_t evtchn_get_domid(void)

I think the function name should be generic so the caller doesn't need to be modified everytime the implementation is updated.

Quoted 1 line

How about get_domid()?

Fine with me. And I think it should have a prototype in include/lib.h

Juergen

#16 lore raw

PATCH v2 3/5 Mini-OS: don't crash if no shutdown node is available

In reply to Juergen Gross

It might be perfectly fine not to have a control/shutdown Xenstore node. If this is the case, don't crash, but just terminate the shutdown thread after issuing a message that shutdown isn't available.

In fini_shutdown() clearing the watch can result in an error now, in case the early exit above was taken. Just ignore this error now.

---
 shutdown.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
shutdown.c +4 -8
index bb2c6f11..ded6b64d 100644
@@ -75,7 +75,9 @@ static void shutdown_thread(void *p)
         xenbus_wait_for_watch(&events);
         if ((err = xenbus_read(XBT_NIL, path, &shutdown))) {
             free(err);
-            do_exit();
+            free(xenbus_unwatch_path_token(XBT_NIL, path, token));
+            printk("Shutdown Xenstore node not available.\n");
+            return;
         }
 
         if (end_shutdown_thread)
@@ -117,15 +119,9 @@ void init_shutdown(void)
 
 void fini_shutdown(void)
 {
-    char *err;
-
     end_shutdown_thread = 1;
     xenbus_release_wait_for_watch(&events);
-    err = xenbus_unwatch_path_token(XBT_NIL, path, token);
-    if (err) {
-        free(err);
-        do_exit();
-    }
+    free(xenbus_unwatch_path_token(XBT_NIL, path, token));
 }
 #endif
 
Signature · 1 line
2.35.3
#17 lore raw

PATCH v2 4/5 Mini-OS: fix 9pfs stat receive format

In reply to Juergen Gross

The format string of the received data for the 9pfs stat command is missing the initial 2 byte total length specifier. Add it.

Fixes 2d1dfccd3aa3 ("Mini-OS: add read and write support to 9pfsfront")
---
 9pfront.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
9pfront.c +5 -4
index 5da8a365..43c7409f 100644
@@ -711,6 +711,7 @@ static int p9_create(struct dev_9pfs *dev, uint32_t fid, char *path,
 static int p9_stat(struct dev_9pfs *dev, uint32_t fid, struct p9_stat *stat)
 {
     struct req *req = get_free_req(dev);
+    uint16_t total;
     int ret;
 
     if ( !req )
@@ -719,10 +720,10 @@ static int p9_stat(struct dev_9pfs *dev, uint32_t fid, struct p9_stat *stat)
     memset(stat, 0, sizeof(*stat));
     req->cmd = P9_CMD_STAT;
     send_9p(dev, req, "U", fid);
-    rcv_9p(dev, req, "uuUQUUULSSSSSUUU", &stat->size, &stat->type, &stat->dev,
-           stat->qid, &stat->mode, &stat->atime, &stat->mtime, &stat->length,
-           &stat->name, &stat->uid, &stat->gid, &stat->muid, &stat->extension,
-           &stat->n_uid, &stat->n_gid, &stat->n_muid);
+    rcv_9p(dev, req, "uuuUQUUULSSSSSUUU", &total, &stat->size, &stat->type,
+           &stat->dev, stat->qid, &stat->mode, &stat->atime, &stat->mtime,
+           &stat->length, &stat->name, &stat->uid, &stat->gid, &stat->muid,
+           &stat->extension, &stat->n_uid, &stat->n_gid, &stat->n_muid);
 
     ret = req->result;
 
Signature · 1 line
2.35.3
#18 lore raw

PATCH v2 5/5 Mini-OS: fix 9pfs response receiving

In reply to Juergen Gross

When copying a 9pfs response chunk from the ring buffer across the ring end, the local ring pointer and length field are not updated correctly. Fix that.

Fixes 0924fec1de58 ("Mini-OS: add 9pfs transport layer")

---
V2:
- new patch

---
 9pfront.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
9pfront.c +3 -1
index 43c7409f..35c5552b 100644
@@ -386,7 +386,9 @@ static void copy_bufs(unsigned char **buf1, unsigned char **buf2,
             printk("9pfs: short copy (dropping %u bytes)\n", len - *len1);
             len = *len1;
         }
-        memcpy(target, *buf1, *len1);
+        memcpy(target, *buf1, len);
+        *buf1 += len;
+        *len1 -= len;
     }
 }
 
Signature · 1 line
2.35.3