Skip to contentSkip to conversation

ppc: adding some RTAS calls in tests/libqos

PATCH Superseded Daniel Henrique Barboza 2 participants 7 messages Oct 26, 2017 – Oct 30, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover ppc: adding some RTAS calls in tests/libqos

This series implements a few RTAS hypercalls in tests/libqos that, used together, implement the DRC state transition described in PAPR 2.7+, 13.4.

This started as an attempt of implementing hot unplug qtests for the sPAPR machine but I've found a few issues that will require more time solving:

- CPU hot unplug: for some reason the machine freezes after the callback is returned.

- LMB hot unplug: not supported by the sPAPR machine if not set in CAS.

I have a feeling that the CPU hot unplug issue might be related with the lack of CAS negotiation step as well, but only way to be sure is to further understanding how the CAS negotation interfere with the device hot unplug. If needed we'll have to implement the client architecture support hypercall as well in the future.

Until then, I believe these hypercalls have a value of their own and are worth being pushed upstream.

Daniel Henrique Barboza (3):
tests: adding 'check_exception' RTAS implementation
tests: adding 'set_indicator' RTAS call
tests: ibm,configure-connector RTAS call implementation

 tests/libqos/rtas.c | 105 +++++++++++++++++++++++++
 tests/libqos/rtas.h |   5 ++
 tests/rtas-test.c   | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 328 insertions(+)
Signature · 1 line
2.13.6
#1 lore raw

PATCH 1/3 tests: adding 'check_exception' RTAS implementation

In the sPAPR guest, events such as device hotplug/unplug are retrieved by the check_exception RTAS call after the guest receives an IRQ pulse. For both hotplug and unplug operations, guest intervention is required to transit the DRC state of the attached device to the configured state.

Without guest intervention, we are still able of qtesting hotplug devices in the same manner that we support device hotplug in early (pre-CAS) stages.

Unfortunately, hot unplugs qtests relies on callbacks that demands guest intervention to complete - otherwise we risk leaving the guest in an inconsistent state that might impact other hotplug/unplug operations later on. If we want to make hot unplug qtests we'll need to simulate the guest behavior in the scenario in which a hot unplug is received, allowing the hot unplug process to go as intended.

This patch is the first step towards hot unplug qtests in sPAPR, implementing the check_exception RTAS hypercall in libqos. This hypercall is used to fetch events such as hotplug/hot unplug from the sPAPR machine after the guest receives an IRQ pulse (or, in the case of the test implemented here, we simply know when there is/isn't an event to be retrieved).

---
 tests/libqos/rtas.c | 37 +++++++++++++++++++++++++
 tests/libqos/rtas.h |  2 ++
 tests/rtas-test.c   | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 116 insertions(+)
tests/libqos/rtas.c +37 -0
index 0269803ce0..fdeab448f7 100644
@@ -114,3 +114,40 @@ int qrtas_ibm_write_pci_config(QGuestAllocator *alloc, uint64_t buid,
 
     return 0;
 }
+
+/*
+ * check_exception as defined by PAPR 2.7+, 7.3.3.2
+ *
+ * nargs = 7 (with Extended Information)
+ * nrets = 1
+ *
+ * arg[2] = mask of event classes to process
+ * arg[4] = real address of error log
+ * arg[5] = length of error log
+ *
+ * arg[0] (Vector Offset), arg[1] and arg[6] (Additional information)
+ * and arg[3] (Critical) aren't used in the logic of check_exception
+ * in hw/ppc/spapr_events.c and can be ignored.
+ *
+ * If there is an event that matches the given mask, check-exception writes
+ * it in buf_addr up to a max of buf_len bytes.
+ *
+ */
+int qrtas_check_exception(QGuestAllocator *alloc, uint32_t mask,
+                          uint32_t buf_addr, uint32_t buf_len)
+{
+    uint32_t args[7], ret[1];
+    int res;
+
+    args[0] = args[1] = args[3] = args[6] = 0;
+    args[2] = mask;
+    args[4] = buf_addr;
+    args[5] = buf_len;
+
+    res = qrtas_call(alloc, "check-exception", 7, args, 1, ret);
+    if (res != 0) {
+        return -1;
+    }
+
+    return ret[0];
+}
tests/libqos/rtas.h +2 -0
index 498eb19230..330ecfd397 100644
@@ -12,4 +12,6 @@ uint32_t qrtas_ibm_read_pci_config(QGuestAllocator *alloc, uint64_t buid,
                                    uint32_t addr, uint32_t size);
 int qrtas_ibm_write_pci_config(QGuestAllocator *alloc, uint64_t buid,
                                uint32_t addr, uint32_t size, uint32_t val);
+int qrtas_check_exception(QGuestAllocator *alloc, uint32_t mask,
+                          uint32_t buf_addr, uint32_t buf_len);
 #endif /* LIBQOS_RTAS_H */
tests/rtas-test.c +77 -0

95 lines not on this page · raw message

Signature · 1 line
2.13.6
#3 lore raw

PATCH 3/3 tests: ibm, configure-connector RTAS call implementation

In reply to Daniel Henrique Barboza

'ibm,configure-connector' hypercall is used by the guest OS to start the configuration of a given device, where the machine configures the said device and all its sub-devices, giving back FDTs to the caller for each sub-device.

This hypercall is supposed to be called multiple times by the guest OS until it returns RTAS_OUT_SUCESS (code 0), indicating that the device is now properly configured and ready to be used, or a return value < 0 when an error occurs.

This patch implements the 'ibm,configure-connector' RTAS hypercall in tests/libqos/rtas.c, with an extra test case for it inside tests/rtas-tests.c.

---
 tests/libqos/rtas.c | 35 +++++++++++++++++++++++++++
 tests/libqos/rtas.h |  1 +
 tests/rtas-test.c   | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+)
tests/libqos/rtas.c +35 -0
index ade572a84f..1cb9e2b495 100644
@@ -184,3 +184,38 @@ int qrtas_set_indicator(QGuestAllocator *alloc, uint32_t type, uint32_t idx,
 
     return ret[0];
 }
+
+/*
+ * ibm,configure-connector as defined by PAPR 2.7+, 13.5.3.5
+ *
+ * nargs = 2
+ * nrets = 1
+ *
+ * args[0] and args[1] compose the 64 bit Work Area address.
+ *
+ * This call will configure not only the device reported in the first
+ * offset of the Work Area but all of its siblingis as well, returning
+ * the FDT of each configured sub-device as well as a return code
+ * 'Next child', 'Next property' or 'Previous parent'. When the whole
+ * configuration is done, 'Configuration completed' (0) is returned.
+ *
+ * configure-connector will always reply with status code 'Next child'(2)
+ * on the first successful call. The DRC configuration will be
+ * completed when configure-connector returns status 0. Any return
+ * status < 0 indicates an error.
+ */
+int qrtas_ibm_configure_connector(QGuestAllocator *alloc, uintptr_t wa_addr)
+{
+    uint32_t args[2], ret[1];
+    int res;
+
+    args[0] = (uint32_t)(wa_addr);
+    args[1] = (uint32_t)(wa_addr >> 32);
+
+    res = qrtas_call(alloc, "ibm,configure-connector", 2, args, 1, ret);
+    if (res != 0) {
+        return -1;
+    }
+
+    return ret[0];
+}
tests/libqos/rtas.h +1 -0
index 9dfa18f32b..35c44fb967 100644
@@ -16,4 +16,5 @@ int qrtas_check_exception(QGuestAllocator *alloc, uint32_t mask,
                           uint32_t buf_addr, uint32_t buf_len);
 int qrtas_set_indicator(QGuestAllocator *alloc, uint32_t type, uint32_t idx,
                         uint32_t new_state);
+int qrtas_ibm_configure_connector(QGuestAllocator *alloc, uintptr_t wa_addr);
 #endif /* LIBQOS_RTAS_H */
tests/rtas-test.c +68 -0

86 lines not on this page · raw message

Signature · 1 line
2.13.6
#2 lore raw

PATCH 2/3 tests: adding 'set_indicator' RTAS call

In reply to Daniel Henrique Barboza

'set_indicator' is a RTAS hypercall that is used to change the state of both physical and logical devices DRCs by setting allocation-state, isolation-state and dr-indicator.

This patch implements the set_indicator RTAS call in tests/libqos/rtas.c, adding its test in tests/rtas-test.c.

---
 tests/libqos/rtas.c | 33 ++++++++++++++++++++++++
 tests/libqos/rtas.h |  2 ++
 tests/rtas-test.c   | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 108 insertions(+)
tests/libqos/rtas.c +33 -0
index fdeab448f7..ade572a84f 100644
@@ -151,3 +151,36 @@ int qrtas_check_exception(QGuestAllocator *alloc, uint32_t mask,
 
     return ret[0];
 }
+
+/*
+ * set_indicator as defined by PAPR 2.7+, 7.3.5.4
+ *
+ * nargs = 3
+ * nrets = 1
+ *
+ * arg[0] = the type of the indicator
+ * arg[1] = index of the specific indicator
+ * arg[2] = desired new state
+ *
+ * Depending on the input, set_indicator will call set_isolation_state,
+ * set_allocation_state or set_dr_indicator in hw/ppc/spapr_drc.c.
+ * These functions allows the guest to control the state of hotplugged
+ * and hot unplugged devices.
+ */
+int qrtas_set_indicator(QGuestAllocator *alloc, uint32_t type, uint32_t idx,
+                        uint32_t new_state)
+{
+    uint32_t args[3], ret[1];
+    int res;
+
+    args[0] = type;
+    args[1] = idx;
+    args[2] = new_state;
+
+    res = qrtas_call(alloc, "set-indicator", 3, args, 1, ret);
+    if (res != 0) {
+        return -1;
+    }
+
+    return ret[0];
+}
tests/libqos/rtas.h +2 -0
index 330ecfd397..9dfa18f32b 100644
@@ -14,4 +14,6 @@ int qrtas_ibm_write_pci_config(QGuestAllocator *alloc, uint64_t buid,
                                uint32_t addr, uint32_t size, uint32_t val);
 int qrtas_check_exception(QGuestAllocator *alloc, uint32_t mask,
                           uint32_t buf_addr, uint32_t buf_len);
+int qrtas_set_indicator(QGuestAllocator *alloc, uint32_t type, uint32_t idx,
+                        uint32_t new_state);
 #endif /* LIBQOS_RTAS_H */
tests/rtas-test.c +73 -0

91 lines not on this page · raw message

Signature · 1 line
2.13.6
#4 lore raw
In reply to Daniel Henrique Barboza
Quoted 14 lines · Daniel Henrique Barboza

This series implements a few RTAS hypercalls in tests/libqos that, used together, implement the DRC state transition described in PAPR 2.7+, 13.4.

This started as an attempt of implementing hot unplug qtests for the sPAPR machine but I've found a few issues that will require more time solving:

- CPU hot unplug: for some reason the machine freezes after the callback is returned.

- LMB hot unplug: not supported by the sPAPR machine if not set in CAS.

Quoted 8 lines

I have a feeling that the CPU hot unplug issue might be related with the lack of CAS negotiation step as well, but only way to be sure is to further understanding how the CAS negotation interfere with the device hot unplug. If needed we'll have to implement the client architecture support hypercall as well in the future.

Until then, I believe these hypercalls have a value of their own and are worth being pushed upstream.

Unfortunately, these changes break the Travis build on MacOS.

Quoted 12 lines

Daniel Henrique Barboza (3):
tests: adding 'check_exception' RTAS implementation
tests: adding 'set_indicator' RTAS call
tests: ibm,configure-connector RTAS call implementation

 tests/libqos/rtas.c | 105 +++++++++++++++++++++++++
 tests/libqos/rtas.h |   5 ++
 tests/rtas-test.c   | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 328 insertions(+)
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#5 lore raw
Quoted 21 lines · David Gibson
Quoted 20 lines · Daniel Henrique Barboza

This series implements a few RTAS hypercalls in tests/libqos that, used together, implement the DRC state transition described in PAPR 2.7+, 13.4.

This started as an attempt of implementing hot unplug qtests for the sPAPR machine but I've found a few issues that will require more time solving:

- CPU hot unplug: for some reason the machine freezes after the callback is returned.

- LMB hot unplug: not supported by the sPAPR machine if not set in CAS.

I have a feeling that the CPU hot unplug issue might be related with the lack of CAS negotiation step as well, but only way to be sure is to further understanding how the CAS negotation interfere with the device hot unplug. If needed we'll have to implement the client architecture support hypercall as well in the future.

Quoted 3 lines
Quoted 2 lines

Until then, I believe these hypercalls have a value of their own and are worth being pushed upstream.

Unfortunately, these changes break the Travis build on MacOS.

Hmpf .... how can I run this Travis build to see the errors? I've searched here and found out something about making a Github pull request and then https://travis-ci.org/qemu/qemu runs the Travis build in the request. Is this a valid way of running it?

Thanks,

Daniel

Quoted 11 lines
Quoted 11 lines

Daniel Henrique Barboza (3):
tests: adding 'check_exception' RTAS implementation
tests: adding 'set_indicator' RTAS call
tests: ibm,configure-connector RTAS call implementation

  tests/libqos/rtas.c | 105 +++++++++++++++++++++++++
  tests/libqos/rtas.h |   5 ++
  tests/rtas-test.c   | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 328 insertions(+)
#6 lore raw
Quoted 24 lines · Daniel Henrique Barboza
Quoted 21 lines · David Gibson
Quoted 20 lines · Daniel Henrique Barboza

This series implements a few RTAS hypercalls in tests/libqos that, used together, implement the DRC state transition described in PAPR 2.7+, 13.4.

This started as an attempt of implementing hot unplug qtests for the sPAPR machine but I've found a few issues that will require more time solving:

- CPU hot unplug: for some reason the machine freezes after the callback is returned.

- LMB hot unplug: not supported by the sPAPR machine if not set in CAS.

I have a feeling that the CPU hot unplug  issue might be related with the lack of CAS negotiation step as well, but only way to be sure is to further understanding how the CAS negotation interfere with the device hot unplug. If needed we'll have to implement the client architecture support hypercall as well in the future.

Quoted 9 lines
Quoted 3 lines
Quoted 2 lines

Until then, I believe these hypercalls have a value of their own and are worth being pushed upstream.

Unfortunately, these changes break the Travis build on MacOS.

Hmpf .... how can I run this Travis build to see the errors? I've searched here and found out something about making a Github pull request and then https://travis-ci.org/qemu/qemu runs the Travis build in the request. Is this a valid way of running it?

Just managed to run the build and saw the error. I'll fix it in v2.

Daniel

Quoted 19 lines

Thanks,

Daniel

Quoted 12 lines
Quoted 12 lines

Daniel Henrique Barboza (3):
   tests: adding 'check_exception' RTAS implementation
   tests: adding 'set_indicator' RTAS call
   tests: ibm,configure-connector RTAS call implementation

  tests/libqos/rtas.c | 105 +++++++++++++++++++++++++ tests/libqos/rtas.h |   5 ++ tests/rtas-test.c   | 218
++++++++++++++++++++++++++++++++++++++++++++++++++++

  3 files changed, 328 insertions(+)