|
|
c687bc |
From cb9d5380b1376b2a44d91d84eaf09f948ef1e165 Mon Sep 17 00:00:00 2001
|
|
|
c687bc |
From: Greg Kurz <gkurz@redhat.com>
|
|
|
c687bc |
Date: Tue, 19 Jan 2021 15:09:50 -0500
|
|
|
c687bc |
Subject: [PATCH 2/9] spapr: Fold h_cas_compose_response() into
|
|
|
c687bc |
h_client_architecture_support()
|
|
|
c687bc |
|
|
|
c687bc |
RH-Author: Greg Kurz <gkurz@redhat.com>
|
|
|
c687bc |
Message-id: <20210119150954.1017058-3-gkurz@redhat.com>
|
|
|
c687bc |
Patchwork-id: 100687
|
|
|
c687bc |
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH v2 2/6] spapr: Fold h_cas_compose_response() into h_client_architecture_support()
|
|
|
c687bc |
Bugzilla: 1901837
|
|
|
c687bc |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
c687bc |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
c687bc |
RH-Acked-by: David Gibson <dgibson@redhat.com>
|
|
|
c687bc |
|
|
|
c687bc |
From: David Gibson <david@gibson.dropbear.id.au>
|
|
|
c687bc |
|
|
|
c687bc |
spapr_h_cas_compose_response() handles the last piece of the PAPR feature
|
|
|
c687bc |
negotiation process invoked via the ibm,client-architecture-support OF
|
|
|
c687bc |
call. Its only caller is h_client_architecture_support() which handles
|
|
|
c687bc |
most of the rest of that process.
|
|
|
c687bc |
|
|
|
c687bc |
I believe it was placed in a separate file originally to handle some
|
|
|
c687bc |
fiddly dependencies between functions, but mostly it's just confusing
|
|
|
c687bc |
to have the CAS process split into two pieces like this. Now that
|
|
|
c687bc |
compose response is simplified (by just generating the whole device
|
|
|
c687bc |
tree anew), it's cleaner to just fold it into
|
|
|
c687bc |
h_client_architecture_support().
|
|
|
c687bc |
|
|
|
c687bc |
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
|
|
|
c687bc |
Reviewed-by: Cedric Le Goater <clg@fr.ibm.com>
|
|
|
c687bc |
Reviewed-by: Greg Kurz <groug@kaod.org>
|
|
|
c687bc |
(cherry picked from commit 0c21e073541cc093b4cb8744640e24f130e6f8ba)
|
|
|
c687bc |
Signed-off-by: Greg Kurz <gkurz@redhat.com>
|
|
|
c687bc |
Signed-off-by: Jon Maloy <jmaloy.redhat.com>
|
|
|
c687bc |
---
|
|
|
c687bc |
hw/ppc/spapr.c | 61 +-----------------------------------------
|
|
|
c687bc |
hw/ppc/spapr_hcall.c | 55 ++++++++++++++++++++++++++++++++++---
|
|
|
c687bc |
include/hw/ppc/spapr.h | 4 +--
|
|
|
c687bc |
3 files changed, 54 insertions(+), 66 deletions(-)
|
|
|
c687bc |
|
|
|
c687bc |
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
|
|
|
c687bc |
index 92f63ad035..992bd08aaa 100644
|
|
|
c687bc |
--- a/hw/ppc/spapr.c
|
|
|
c687bc |
+++ b/hw/ppc/spapr.c
|
|
|
c687bc |
@@ -76,7 +76,6 @@
|
|
|
c687bc |
#include "hw/nmi.h"
|
|
|
c687bc |
#include "hw/intc/intc.h"
|
|
|
c687bc |
|
|
|
c687bc |
-#include "qemu/cutils.h"
|
|
|
c687bc |
#include "hw/ppc/spapr_cpu_core.h"
|
|
|
c687bc |
#include "hw/mem/memory-device.h"
|
|
|
c687bc |
#include "hw/ppc/spapr_tpm_proxy.h"
|
|
|
c687bc |
@@ -898,63 +897,6 @@ out:
|
|
|
c687bc |
return ret;
|
|
|
c687bc |
}
|
|
|
c687bc |
|
|
|
c687bc |
-static bool spapr_hotplugged_dev_before_cas(void)
|
|
|
c687bc |
-{
|
|
|
c687bc |
- Object *drc_container, *obj;
|
|
|
c687bc |
- ObjectProperty *prop;
|
|
|
c687bc |
- ObjectPropertyIterator iter;
|
|
|
c687bc |
-
|
|
|
c687bc |
- drc_container = container_get(object_get_root(), "/dr-connector");
|
|
|
c687bc |
- object_property_iter_init(&iter, drc_container);
|
|
|
c687bc |
- while ((prop = object_property_iter_next(&iter))) {
|
|
|
c687bc |
- if (!strstart(prop->type, "link<", NULL)) {
|
|
|
c687bc |
- continue;
|
|
|
c687bc |
- }
|
|
|
c687bc |
- obj = object_property_get_link(drc_container, prop->name, NULL);
|
|
|
c687bc |
- if (spapr_drc_needed(obj)) {
|
|
|
c687bc |
- return true;
|
|
|
c687bc |
- }
|
|
|
c687bc |
- }
|
|
|
c687bc |
- return false;
|
|
|
c687bc |
-}
|
|
|
c687bc |
-
|
|
|
c687bc |
-static void *spapr_build_fdt(SpaprMachineState *spapr, bool reset,
|
|
|
c687bc |
- size_t space);
|
|
|
c687bc |
-
|
|
|
c687bc |
-int spapr_h_cas_compose_response(SpaprMachineState *spapr,
|
|
|
c687bc |
- target_ulong addr, target_ulong size,
|
|
|
c687bc |
- SpaprOptionVector *ov5_updates)
|
|
|
c687bc |
-{
|
|
|
c687bc |
- void *fdt;
|
|
|
c687bc |
- SpaprDeviceTreeUpdateHeader hdr = { .version_id = 1 };
|
|
|
c687bc |
-
|
|
|
c687bc |
- if (spapr_hotplugged_dev_before_cas()) {
|
|
|
c687bc |
- return 1;
|
|
|
c687bc |
- }
|
|
|
c687bc |
-
|
|
|
c687bc |
- if (size < sizeof(hdr)) {
|
|
|
c687bc |
- error_report("SLOF provided insufficient CAS buffer "
|
|
|
c687bc |
- TARGET_FMT_lu " (min: %zu)", size, sizeof(hdr));
|
|
|
c687bc |
- exit(EXIT_FAILURE);
|
|
|
c687bc |
- }
|
|
|
c687bc |
-
|
|
|
c687bc |
- size -= sizeof(hdr);
|
|
|
c687bc |
-
|
|
|
c687bc |
- fdt = spapr_build_fdt(spapr, false, size);
|
|
|
c687bc |
- _FDT((fdt_pack(fdt)));
|
|
|
c687bc |
-
|
|
|
c687bc |
- cpu_physical_memory_write(addr, &hdr, sizeof(hdr));
|
|
|
c687bc |
- cpu_physical_memory_write(addr + sizeof(hdr), fdt, fdt_totalsize(fdt));
|
|
|
c687bc |
- trace_spapr_cas_continue(fdt_totalsize(fdt) + sizeof(hdr));
|
|
|
c687bc |
-
|
|
|
c687bc |
- g_free(spapr->fdt_blob);
|
|
|
c687bc |
- spapr->fdt_size = fdt_totalsize(fdt);
|
|
|
c687bc |
- spapr->fdt_initial_size = spapr->fdt_size;
|
|
|
c687bc |
- spapr->fdt_blob = fdt;
|
|
|
c687bc |
-
|
|
|
c687bc |
- return 0;
|
|
|
c687bc |
-}
|
|
|
c687bc |
-
|
|
|
c687bc |
static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt)
|
|
|
c687bc |
{
|
|
|
c687bc |
MachineState *ms = MACHINE(spapr);
|
|
|
c687bc |
@@ -1192,8 +1134,7 @@ static void spapr_dt_hypervisor(SpaprMachineState *spapr, void *fdt)
|
|
|
c687bc |
}
|
|
|
c687bc |
}
|
|
|
c687bc |
|
|
|
c687bc |
-static void *spapr_build_fdt(SpaprMachineState *spapr, bool reset,
|
|
|
c687bc |
- size_t space)
|
|
|
c687bc |
+void *spapr_build_fdt(SpaprMachineState *spapr, bool reset, size_t space)
|
|
|
c687bc |
{
|
|
|
c687bc |
MachineState *machine = MACHINE(spapr);
|
|
|
c687bc |
MachineClass *mc = MACHINE_GET_CLASS(machine);
|
|
|
c687bc |
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
|
|
|
c687bc |
index 05a7ca275b..0f19be794c 100644
|
|
|
c687bc |
--- a/hw/ppc/spapr_hcall.c
|
|
|
c687bc |
+++ b/hw/ppc/spapr_hcall.c
|
|
|
c687bc |
@@ -1,4 +1,5 @@
|
|
|
c687bc |
#include "qemu/osdep.h"
|
|
|
c687bc |
+#include "qemu/cutils.h"
|
|
|
c687bc |
#include "qapi/error.h"
|
|
|
c687bc |
#include "sysemu/hw_accel.h"
|
|
|
c687bc |
#include "sysemu/runstate.h"
|
|
|
c687bc |
@@ -15,6 +16,7 @@
|
|
|
c687bc |
#include "cpu-models.h"
|
|
|
c687bc |
#include "trace.h"
|
|
|
c687bc |
#include "kvm_ppc.h"
|
|
|
c687bc |
+#include "hw/ppc/fdt.h"
|
|
|
c687bc |
#include "hw/ppc/spapr_ovec.h"
|
|
|
c687bc |
#include "mmu-book3s-v3.h"
|
|
|
c687bc |
#include "hw/mem/memory-device.h"
|
|
|
c687bc |
@@ -1638,6 +1640,26 @@ static uint32_t cas_check_pvr(SpaprMachineState *spapr, PowerPCCPU *cpu,
|
|
|
c687bc |
return best_compat;
|
|
|
c687bc |
}
|
|
|
c687bc |
|
|
|
c687bc |
+static bool spapr_hotplugged_dev_before_cas(void)
|
|
|
c687bc |
+{
|
|
|
c687bc |
+ Object *drc_container, *obj;
|
|
|
c687bc |
+ ObjectProperty *prop;
|
|
|
c687bc |
+ ObjectPropertyIterator iter;
|
|
|
c687bc |
+
|
|
|
c687bc |
+ drc_container = container_get(object_get_root(), "/dr-connector");
|
|
|
c687bc |
+ object_property_iter_init(&iter, drc_container);
|
|
|
c687bc |
+ while ((prop = object_property_iter_next(&iter))) {
|
|
|
c687bc |
+ if (!strstart(prop->type, "link<", NULL)) {
|
|
|
c687bc |
+ continue;
|
|
|
c687bc |
+ }
|
|
|
c687bc |
+ obj = object_property_get_link(drc_container, prop->name, NULL);
|
|
|
c687bc |
+ if (spapr_drc_needed(obj)) {
|
|
|
c687bc |
+ return true;
|
|
|
c687bc |
+ }
|
|
|
c687bc |
+ }
|
|
|
c687bc |
+ return false;
|
|
|
c687bc |
+}
|
|
|
c687bc |
+
|
|
|
c687bc |
static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
|
|
|
c687bc |
SpaprMachineState *spapr,
|
|
|
c687bc |
target_ulong opcode,
|
|
|
c687bc |
@@ -1645,6 +1667,8 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
|
|
|
c687bc |
{
|
|
|
c687bc |
/* Working address in data buffer */
|
|
|
c687bc |
target_ulong addr = ppc64_phys_to_real(args[0]);
|
|
|
c687bc |
+ target_ulong fdt_buf = args[1];
|
|
|
c687bc |
+ target_ulong fdt_bufsize = args[2];
|
|
|
c687bc |
target_ulong ov_table;
|
|
|
c687bc |
uint32_t cas_pvr;
|
|
|
c687bc |
SpaprOptionVector *ov1_guest, *ov5_guest, *ov5_cas_old, *ov5_updates;
|
|
|
c687bc |
@@ -1788,16 +1812,41 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
|
|
|
c687bc |
|
|
|
c687bc |
spapr_irq_update_active_intc(spapr);
|
|
|
c687bc |
|
|
|
c687bc |
+ if (spapr_hotplugged_dev_before_cas()) {
|
|
|
c687bc |
+ spapr->cas_reboot = true;
|
|
|
c687bc |
+ }
|
|
|
c687bc |
+
|
|
|
c687bc |
if (!spapr->cas_reboot) {
|
|
|
c687bc |
+ void *fdt;
|
|
|
c687bc |
+ SpaprDeviceTreeUpdateHeader hdr = { .version_id = 1 };
|
|
|
c687bc |
+
|
|
|
c687bc |
/* If spapr_machine_reset() did not set up a HPT but one is necessary
|
|
|
c687bc |
* (because the guest isn't going to use radix) then set it up here. */
|
|
|
c687bc |
if ((spapr->patb_entry & PATE1_GR) && !guest_radix) {
|
|
|
c687bc |
/* legacy hash or new hash: */
|
|
|
c687bc |
spapr_setup_hpt_and_vrma(spapr);
|
|
|
c687bc |
}
|
|
|
c687bc |
- spapr->cas_reboot =
|
|
|
c687bc |
- (spapr_h_cas_compose_response(spapr, args[1], args[2],
|
|
|
c687bc |
- ov5_updates) != 0);
|
|
|
c687bc |
+
|
|
|
c687bc |
+ if (fdt_bufsize < sizeof(hdr)) {
|
|
|
c687bc |
+ error_report("SLOF provided insufficient CAS buffer "
|
|
|
c687bc |
+ TARGET_FMT_lu " (min: %zu)", fdt_bufsize, sizeof(hdr));
|
|
|
c687bc |
+ exit(EXIT_FAILURE);
|
|
|
c687bc |
+ }
|
|
|
c687bc |
+
|
|
|
c687bc |
+ fdt_bufsize -= sizeof(hdr);
|
|
|
c687bc |
+
|
|
|
c687bc |
+ fdt = spapr_build_fdt(spapr, false, fdt_bufsize);
|
|
|
c687bc |
+ _FDT((fdt_pack(fdt)));
|
|
|
c687bc |
+
|
|
|
c687bc |
+ cpu_physical_memory_write(fdt_buf, &hdr, sizeof(hdr));
|
|
|
c687bc |
+ cpu_physical_memory_write(fdt_buf + sizeof(hdr), fdt,
|
|
|
c687bc |
+ fdt_totalsize(fdt));
|
|
|
c687bc |
+ trace_spapr_cas_continue(fdt_totalsize(fdt) + sizeof(hdr));
|
|
|
c687bc |
+
|
|
|
c687bc |
+ g_free(spapr->fdt_blob);
|
|
|
c687bc |
+ spapr->fdt_size = fdt_totalsize(fdt);
|
|
|
c687bc |
+ spapr->fdt_initial_size = spapr->fdt_size;
|
|
|
c687bc |
+ spapr->fdt_blob = fdt;
|
|
|
c687bc |
}
|
|
|
c687bc |
|
|
|
c687bc |
spapr_ovec_cleanup(ov5_updates);
|
|
|
c687bc |
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
|
|
|
c687bc |
index e047dabf30..e5e2a99046 100644
|
|
|
c687bc |
--- a/include/hw/ppc/spapr.h
|
|
|
c687bc |
+++ b/include/hw/ppc/spapr.h
|
|
|
c687bc |
@@ -767,11 +767,9 @@ struct SpaprEventLogEntry {
|
|
|
c687bc |
QTAILQ_ENTRY(SpaprEventLogEntry) next;
|
|
|
c687bc |
};
|
|
|
c687bc |
|
|
|
c687bc |
+void *spapr_build_fdt(SpaprMachineState *spapr, bool reset, size_t space);
|
|
|
c687bc |
void spapr_events_init(SpaprMachineState *sm);
|
|
|
c687bc |
void spapr_dt_events(SpaprMachineState *sm, void *fdt);
|
|
|
c687bc |
-int spapr_h_cas_compose_response(SpaprMachineState *sm,
|
|
|
c687bc |
- target_ulong addr, target_ulong size,
|
|
|
c687bc |
- SpaprOptionVector *ov5_updates);
|
|
|
c687bc |
void close_htab_fd(SpaprMachineState *spapr);
|
|
|
c687bc |
void spapr_setup_hpt_and_vrma(SpaprMachineState *spapr);
|
|
|
c687bc |
void spapr_free_hpt(SpaprMachineState *spapr);
|
|
|
c687bc |
--
|
|
|
c687bc |
2.18.2
|
|
|
c687bc |
|