The patch registers EEH RTAS services, which are emulated with the
help of vfio_eeh_handler() that was introduced in the previous
patch.
Signed-off-by: Gavin Shan <address@hidden>
---
hw/ppc/spapr_pci.c | 228 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 228 insertions(+)
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index a9f307a..d82e954 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -22,6 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#include <linux/vfio.h>
#include "hw/hw.h"
#include "hw/pci/pci.h"
#include "hw/pci/msi.h"
@@ -29,6 +30,7 @@
#include "hw/pci/pci_host.h"
#include "hw/ppc/spapr.h"
#include "hw/pci-host/spapr.h"
+#include "hw/misc/vfio.h"
#include "exec/address-spaces.h"
#include <libfdt.h>
#include "trace.h"
@@ -422,6 +424,219 @@ static void
rtas_ibm_query_interrupt_source_number(PowerPCCPU *cpu,
rtas_st(rets, 2, 1);/* 0 == level; 1 == edge */
}
+static void rtas_ibm_set_eeh_option(PowerPCCPU *cpu,
+ sPAPREnvironment *spapr,
+ uint32_t token, uint32_t nargs,
+ target_ulong args, uint32_t nret,
+ target_ulong rets)
+{
+ struct vfio_eeh_pe_set_option option;
+ uint32_t addr;
+ uint64_t buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2);
+ sPAPRPHBState *sphb = spapr_find_phb(spapr, buid);
+ int32_t ret;
+
+ if (!sphb || !sphb->parent_obj.bus) {
+ rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
+ return;
+ }
+
+ if ((nargs != 4) || (nret != 1)) {
+ rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
+ return;
+ }
+
+ addr = rtas_ld(args, 0);
+ option.argsz = sizeof(option);
+ option.option = rtas_ld(args, 3);
+ if (option.option > 3) {
+ rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
+ return;
+ }
+
+ ret = vfio_eeh_handler(VFIO_EEH_PE_SET_OPTION, &option,
+ sphb->parent_obj.bus, addr);