Skip to content

Commit ad22d05

Browse files
committed
Merge remote-tracking branch 'remotes/dg-gitlab/tags/ppc-for-6.2-20210827' into staging
ppc patch queue 2021-08-27 First ppc pull request for qemu-6.2. As usual, there's a fair bit here, since it's been queued during the 6.1 freeze. Highlights are: * Some fixes for 128 bit arithmetic and some vector opcodes that use them * Significant improvements to the powernv to support POWER10 cpus (more to come though) * Several cleanups to the ppc softmmu code * A few other assorted fixes # gpg: Signature made Fri 27 Aug 2021 08:09:12 BST # gpg: using RSA key 75F46586AE61A66CC44E87DC6C38CACA20D9B392 # gpg: Good signature from "David Gibson <[email protected]>" [full] # gpg: aka "David Gibson (Red Hat) <[email protected]>" [full] # gpg: aka "David Gibson (ozlabs.org) <[email protected]>" [full] # gpg: aka "David Gibson (kernel.org) <[email protected]>" [unknown] # Primary key fingerprint: 75F4 6586 AE61 A66C C44E 87DC 6C38 CACA 20D9 B392 * remotes/dg-gitlab/tags/ppc-for-6.2-20210827: target/ppc: fix vector registers access in gdbstub for little-endian include/qemu/int128.h: introduce bswap128s target/ppc: fix vextu[bhw][lr]x helpers include/qemu/int128.h: define struct Int128 according to the host endianness ppc/xive: Export xive_presenter_notify() ppc/xive: Export PQ get/set routines ppc/pnv: add a chip topology index for POWER10 ppc/pnv: Distribute RAM among the chips ppc/pnv: Use a simple incrementing index for the chip-id ppc/pnv: powerpc_excp: Do not discard HDECR exception when entering power-saving mode ppc/pnv: Change the POWER10 machine to support DD2 only ppc: Add a POWER10 DD2 CPU ppc/pnv: update skiboot to commit 820d43c0a775. target/ppc: moved store_40x_sler to helper_regs.c target/ppc: moved ppc_store_sdr1 to mmu_common.c target/ppc: divided mmu_helper.c in 2 files spapr_pci: Fix leak in spapr_phb_vfio_get_loc_code() with g_autofree xive: Remove extra '0x' prefix in trace events Signed-off-by: Peter Maydell <[email protected]>
2 parents 0289f62 + 0ff16b6 commit ad22d05

25 files changed

+1823
-1760
lines changed

hw/intc/spapr_xive_kvm.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ static uint8_t xive_esb_read(XiveSource *xsrc, int srcno, uint32_t offset)
297297
return xive_esb_rw(xsrc, srcno, offset, 0, 0) & 0x3;
298298
}
299299

300-
static void xive_esb_trigger(XiveSource *xsrc, int srcno)
300+
static void kvmppc_xive_esb_trigger(XiveSource *xsrc, int srcno)
301301
{
302302
uint64_t *addr = xsrc->esb_mmap + xive_source_esb_page(xsrc, srcno);
303303

@@ -322,7 +322,7 @@ uint64_t kvmppc_xive_esb_rw(XiveSource *xsrc, int srcno, uint32_t offset,
322322
offset == XIVE_ESB_LOAD_EOI) {
323323
xive_esb_read(xsrc, srcno, XIVE_ESB_SET_PQ_00);
324324
if (xsrc->status[srcno] & XIVE_STATUS_ASSERTED) {
325-
xive_esb_trigger(xsrc, srcno);
325+
kvmppc_xive_esb_trigger(xsrc, srcno);
326326
}
327327
return 0;
328328
} else {
@@ -366,7 +366,7 @@ void kvmppc_xive_source_set_irq(void *opaque, int srcno, int val)
366366
}
367367
}
368368

369-
xive_esb_trigger(xsrc, srcno);
369+
kvmppc_xive_esb_trigger(xsrc, srcno);
370370
}
371371

372372
/*
@@ -533,7 +533,7 @@ static void kvmppc_xive_change_state_handler(void *opaque, bool running,
533533
* generate a trigger.
534534
*/
535535
if (pq == XIVE_ESB_RESET && old_pq == XIVE_ESB_QUEUED) {
536-
xive_esb_trigger(xsrc, i);
536+
kvmppc_xive_esb_trigger(xsrc, i);
537537
}
538538
}
539539

hw/intc/trace-events

+5-5
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,14 @@ kvm_xive_source_reset(uint32_t srcno) "IRQ 0x%x"
219219
xive_tctx_accept(uint32_t index, uint8_t ring, uint8_t ipb, uint8_t pipr, uint8_t cppr, uint8_t nsr) "target=%d ring=0x%x IBP=0x%02x PIPR=0x%02x CPPR=0x%02x NSR=0x%02x ACK"
220220
xive_tctx_notify(uint32_t index, uint8_t ring, uint8_t ipb, uint8_t pipr, uint8_t cppr, uint8_t nsr) "target=%d ring=0x%x IBP=0x%02x PIPR=0x%02x CPPR=0x%02x NSR=0x%02x raise !"
221221
xive_tctx_set_cppr(uint32_t index, uint8_t ring, uint8_t ipb, uint8_t pipr, uint8_t cppr, uint8_t nsr) "target=%d ring=0x%x IBP=0x%02x PIPR=0x%02x new CPPR=0x%02x NSR=0x%02x"
222-
xive_source_esb_read(uint64_t addr, uint32_t srcno, uint64_t value) "@0x0x%"PRIx64" IRQ 0x%x val=0x0x%"PRIx64
223-
xive_source_esb_write(uint64_t addr, uint32_t srcno, uint64_t value) "@0x0x%"PRIx64" IRQ 0x%x val=0x0x%"PRIx64
222+
xive_source_esb_read(uint64_t addr, uint32_t srcno, uint64_t value) "@0x%"PRIx64" IRQ 0x%x val=0x%"PRIx64
223+
xive_source_esb_write(uint64_t addr, uint32_t srcno, uint64_t value) "@0x%"PRIx64" IRQ 0x%x val=0x%"PRIx64
224224
xive_router_end_notify(uint8_t end_blk, uint32_t end_idx, uint32_t end_data) "END 0x%02x/0x%04x -> enqueue 0x%08x"
225225
xive_router_end_escalate(uint8_t end_blk, uint32_t end_idx, uint8_t esc_blk, uint32_t esc_idx, uint32_t end_data) "END 0x%02x/0x%04x -> escalate END 0x%02x/0x%04x data 0x%08x"
226-
xive_tctx_tm_write(uint64_t offset, unsigned int size, uint64_t value) "@0x0x%"PRIx64" sz=%d val=0x%" PRIx64
227-
xive_tctx_tm_read(uint64_t offset, unsigned int size, uint64_t value) "@0x0x%"PRIx64" sz=%d val=0x%" PRIx64
226+
xive_tctx_tm_write(uint64_t offset, unsigned int size, uint64_t value) "@0x%"PRIx64" sz=%d val=0x%" PRIx64
227+
xive_tctx_tm_read(uint64_t offset, unsigned int size, uint64_t value) "@0x%"PRIx64" sz=%d val=0x%" PRIx64
228228
xive_presenter_notify(uint8_t nvt_blk, uint32_t nvt_idx, uint8_t ring) "found NVT 0x%x/0x%x ring=0x%x"
229-
xive_end_source_read(uint8_t end_blk, uint32_t end_idx, uint64_t addr) "END 0x%x/0x%x @0x0x%"PRIx64
229+
xive_end_source_read(uint8_t end_blk, uint32_t end_idx, uint64_t addr) "END 0x%x/0x%x @0x%"PRIx64
230230

231231
# pnv_xive.c
232232
pnv_xive_ic_hw_trigger(uint64_t addr, uint64_t val) "@0x%"PRIx64" val=0x%"PRIx64

hw/intc/xive.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ void xive_tctx_destroy(XiveTCTX *tctx)
816816
* XIVE ESB helpers
817817
*/
818818

819-
static uint8_t xive_esb_set(uint8_t *pq, uint8_t value)
819+
uint8_t xive_esb_set(uint8_t *pq, uint8_t value)
820820
{
821821
uint8_t old_pq = *pq & 0x3;
822822

@@ -826,7 +826,7 @@ static uint8_t xive_esb_set(uint8_t *pq, uint8_t value)
826826
return old_pq;
827827
}
828828

829-
static bool xive_esb_trigger(uint8_t *pq)
829+
bool xive_esb_trigger(uint8_t *pq)
830830
{
831831
uint8_t old_pq = *pq & 0x3;
832832

@@ -846,7 +846,7 @@ static bool xive_esb_trigger(uint8_t *pq)
846846
}
847847
}
848848

849-
static bool xive_esb_eoi(uint8_t *pq)
849+
bool xive_esb_eoi(uint8_t *pq)
850850
{
851851
uint8_t old_pq = *pq & 0x3;
852852

@@ -1514,10 +1514,10 @@ int xive_presenter_tctx_match(XivePresenter *xptr, XiveTCTX *tctx,
15141514
*
15151515
* The parameters represent what is sent on the PowerBus
15161516
*/
1517-
static bool xive_presenter_notify(XiveFabric *xfb, uint8_t format,
1518-
uint8_t nvt_blk, uint32_t nvt_idx,
1519-
bool cam_ignore, uint8_t priority,
1520-
uint32_t logic_serv)
1517+
bool xive_presenter_notify(XiveFabric *xfb, uint8_t format,
1518+
uint8_t nvt_blk, uint32_t nvt_idx,
1519+
bool cam_ignore, uint8_t priority,
1520+
uint32_t logic_serv)
15211521
{
15221522
XiveFabricClass *xfc = XIVE_FABRIC_GET_CLASS(xfb);
15231523
XiveTCTXMatch match = { .tctx = NULL, .ring = 0 };

hw/ppc/pnv.c

+32-14
Original file line numberDiff line numberDiff line change
@@ -710,13 +710,31 @@ static void pnv_chip_power10_pic_print_info(PnvChip *chip, Monitor *mon)
710710
pnv_psi_pic_print_info(&chip10->psi, mon);
711711
}
712712

713+
/* Always give the first 1GB to chip 0 else we won't boot */
714+
static uint64_t pnv_chip_get_ram_size(PnvMachineState *pnv, int chip_id)
715+
{
716+
MachineState *machine = MACHINE(pnv);
717+
uint64_t ram_per_chip;
718+
719+
assert(machine->ram_size >= 1 * GiB);
720+
721+
ram_per_chip = machine->ram_size / pnv->num_chips;
722+
if (ram_per_chip >= 1 * GiB) {
723+
return QEMU_ALIGN_DOWN(ram_per_chip, 1 * MiB);
724+
}
725+
726+
ram_per_chip = (machine->ram_size - 1 * GiB) / (pnv->num_chips - 1);
727+
return chip_id == 0 ? 1 * GiB : QEMU_ALIGN_DOWN(ram_per_chip, 1 * MiB);
728+
}
729+
713730
static void pnv_init(MachineState *machine)
714731
{
715732
const char *bios_name = machine->firmware ?: FW_FILE_NAME;
716733
PnvMachineState *pnv = PNV_MACHINE(machine);
717734
MachineClass *mc = MACHINE_GET_CLASS(machine);
718735
char *fw_filename;
719736
long fw_size;
737+
uint64_t chip_ram_start = 0;
720738
int i;
721739
char *chip_typename;
722740
DriveInfo *pnor = drive_get(IF_MTD, 0, 0);
@@ -809,32 +827,32 @@ static void pnv_init(MachineState *machine)
809827
* TODO: should we decide on how many chips we can create based
810828
* on #cores and Venice vs. Murano vs. Naples chip type etc...,
811829
*/
812-
if (!is_power_of_2(pnv->num_chips) || pnv->num_chips > 4) {
830+
if (!is_power_of_2(pnv->num_chips) || pnv->num_chips > 16) {
813831
error_report("invalid number of chips: '%d'", pnv->num_chips);
814-
error_printf("Try '-smp sockets=N'. Valid values are : 1, 2 or 4.\n");
832+
error_printf(
833+
"Try '-smp sockets=N'. Valid values are : 1, 2, 4, 8 and 16.\n");
815834
exit(1);
816835
}
817836

818837
pnv->chips = g_new0(PnvChip *, pnv->num_chips);
819838
for (i = 0; i < pnv->num_chips; i++) {
820839
char chip_name[32];
821840
Object *chip = OBJECT(qdev_new(chip_typename));
841+
int chip_id = i;
842+
uint64_t chip_ram_size = pnv_chip_get_ram_size(pnv, chip_id);
822843

823844
pnv->chips[i] = PNV_CHIP(chip);
824845

825-
/*
826-
* TODO: put all the memory in one node on chip 0 until we find a
827-
* way to specify different ranges for each chip
828-
*/
829-
if (i == 0) {
830-
object_property_set_int(chip, "ram-size", machine->ram_size,
831-
&error_fatal);
832-
}
846+
/* Distribute RAM among the chips */
847+
object_property_set_int(chip, "ram-start", chip_ram_start,
848+
&error_fatal);
849+
object_property_set_int(chip, "ram-size", chip_ram_size,
850+
&error_fatal);
851+
chip_ram_start += chip_ram_size;
833852

834-
snprintf(chip_name, sizeof(chip_name), "chip[%d]", PNV_CHIP_HWID(i));
853+
snprintf(chip_name, sizeof(chip_name), "chip[%d]", chip_id);
835854
object_property_add_child(OBJECT(pnv), chip_name, chip);
836-
object_property_set_int(chip, "chip-id", PNV_CHIP_HWID(i),
837-
&error_fatal);
855+
object_property_set_int(chip, "chip-id", chip_id, &error_fatal);
838856
object_property_set_int(chip, "nr-cores", machine->smp.cores,
839857
&error_fatal);
840858
object_property_set_int(chip, "nr-threads", machine->smp.threads,
@@ -1916,7 +1934,7 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data)
19161934
static const char compat[] = "qemu,powernv10\0ibm,powernv";
19171935

19181936
mc->desc = "IBM PowerNV (Non-Virtualized) POWER10";
1919-
mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power10_v1.0");
1937+
mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power10_v2.0");
19201938

19211939
pmc->compat = compat;
19221940
pmc->compat_size = sizeof(compat);

hw/ppc/pnv_core.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ static const TypeInfo pnv_core_infos[] = {
347347
DEFINE_PNV_CORE_TYPE(power8, "power8_v2.0"),
348348
DEFINE_PNV_CORE_TYPE(power8, "power8nvl_v1.0"),
349349
DEFINE_PNV_CORE_TYPE(power9, "power9_v2.0"),
350-
DEFINE_PNV_CORE_TYPE(power10, "power10_v1.0"),
350+
DEFINE_PNV_CORE_TYPE(power10, "power10_v2.0"),
351351
};
352352

353353
DEFINE_TYPES(pnv_core_infos)

hw/ppc/pnv_xscom.c

+2
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ int pnv_dt_xscom(PnvChip *chip, void *fdt, int root_offset,
284284
_FDT(xscom_offset);
285285
g_free(name);
286286
_FDT((fdt_setprop_cell(fdt, xscom_offset, "ibm,chip-id", chip->chip_id)));
287+
_FDT((fdt_setprop_cell(fdt, xscom_offset, "ibm,primary-topology-index",
288+
chip->chip_id)));
287289
_FDT((fdt_setprop_cell(fdt, xscom_offset, "#address-cells", 1)));
288290
_FDT((fdt_setprop_cell(fdt, xscom_offset, "#size-cells", 1)));
289291
_FDT((fdt_setprop(fdt, xscom_offset, "reg", reg, sizeof(reg))));

hw/ppc/spapr_pci.c

+9-13
Original file line numberDiff line numberDiff line change
@@ -782,33 +782,29 @@ static AddressSpace *spapr_pci_dma_iommu(PCIBus *bus, void *opaque, int devfn)
782782

783783
static char *spapr_phb_vfio_get_loc_code(SpaprPhbState *sphb, PCIDevice *pdev)
784784
{
785-
char *path = NULL, *buf = NULL, *host = NULL;
785+
g_autofree char *path = NULL;
786+
g_autofree char *host = NULL;
787+
g_autofree char *devspec = NULL;
788+
char *buf = NULL;
786789

787790
/* Get the PCI VFIO host id */
788791
host = object_property_get_str(OBJECT(pdev), "host", NULL);
789792
if (!host) {
790-
goto err_out;
793+
return NULL;
791794
}
792795

793796
/* Construct the path of the file that will give us the DT location */
794797
path = g_strdup_printf("/sys/bus/pci/devices/%s/devspec", host);
795-
g_free(host);
796-
if (!g_file_get_contents(path, &buf, NULL, NULL)) {
797-
goto err_out;
798+
if (!g_file_get_contents(path, &devspec, NULL, NULL)) {
799+
return NULL;
798800
}
799-
g_free(path);
800801

801802
/* Construct and read from host device tree the loc-code */
802-
path = g_strdup_printf("/proc/device-tree%s/ibm,loc-code", buf);
803-
g_free(buf);
803+
path = g_strdup_printf("/proc/device-tree%s/ibm,loc-code", devspec);
804804
if (!g_file_get_contents(path, &buf, NULL, NULL)) {
805-
goto err_out;
805+
return NULL;
806806
}
807807
return buf;
808-
809-
err_out:
810-
g_free(path);
811-
return NULL;
812808
}
813809

814810
static char *spapr_phb_get_loc_code(SpaprPhbState *sphb, PCIDevice *pdev)

include/hw/ppc/pnv.h

+8-27
Original file line numberDiff line numberDiff line change
@@ -170,29 +170,10 @@ DECLARE_INSTANCE_CHECKER(PnvChip, PNV_CHIP_POWER8NVL,
170170
DECLARE_INSTANCE_CHECKER(PnvChip, PNV_CHIP_POWER9,
171171
TYPE_PNV_CHIP_POWER9)
172172

173-
#define TYPE_PNV_CHIP_POWER10 PNV_CHIP_TYPE_NAME("power10_v1.0")
173+
#define TYPE_PNV_CHIP_POWER10 PNV_CHIP_TYPE_NAME("power10_v2.0")
174174
DECLARE_INSTANCE_CHECKER(PnvChip, PNV_CHIP_POWER10,
175175
TYPE_PNV_CHIP_POWER10)
176176

177-
/*
178-
* This generates a HW chip id depending on an index, as found on a
179-
* two socket system with dual chip modules :
180-
*
181-
* 0x0, 0x1, 0x10, 0x11
182-
*
183-
* 4 chips should be the maximum
184-
*
185-
* TODO: use a machine property to define the chip ids
186-
*/
187-
#define PNV_CHIP_HWID(i) ((((i) & 0x3e) << 3) | ((i) & 0x1))
188-
189-
/*
190-
* Converts back a HW chip id to an index. This is useful to calculate
191-
* the MMIO addresses of some controllers which depend on the chip id.
192-
*/
193-
#define PNV_CHIP_INDEX(chip) \
194-
(((chip)->chip_id >> 2) * 2 + ((chip)->chip_id & 0x3))
195-
196177
PowerPCCPU *pnv_chip_find_cpu(PnvChip *chip, uint32_t pir);
197178

198179
#define TYPE_PNV_MACHINE MACHINE_TYPE_NAME("powernv")
@@ -256,11 +237,11 @@ void pnv_bmc_set_pnor(IPMIBmc *bmc, PnvPnor *pnor);
256237
#define PNV_OCC_COMMON_AREA_SIZE 0x0000000000800000ull
257238
#define PNV_OCC_COMMON_AREA_BASE 0x7fff800000ull
258239
#define PNV_OCC_SENSOR_BASE(chip) (PNV_OCC_COMMON_AREA_BASE + \
259-
PNV_OCC_SENSOR_DATA_BLOCK_BASE(PNV_CHIP_INDEX(chip)))
240+
PNV_OCC_SENSOR_DATA_BLOCK_BASE((chip)->chip_id))
260241

261242
#define PNV_HOMER_SIZE 0x0000000000400000ull
262243
#define PNV_HOMER_BASE(chip) \
263-
(0x7ffd800000ull + ((uint64_t)PNV_CHIP_INDEX(chip)) * PNV_HOMER_SIZE)
244+
(0x7ffd800000ull + ((uint64_t)(chip)->chip_id) * PNV_HOMER_SIZE)
264245

265246

266247
/*
@@ -279,16 +260,16 @@ void pnv_bmc_set_pnor(IPMIBmc *bmc, PnvPnor *pnor);
279260
*/
280261
#define PNV_ICP_SIZE 0x0000000000100000ull
281262
#define PNV_ICP_BASE(chip) \
282-
(0x0003ffff80000000ull + (uint64_t) PNV_CHIP_INDEX(chip) * PNV_ICP_SIZE)
263+
(0x0003ffff80000000ull + (uint64_t) (chip)->chip_id * PNV_ICP_SIZE)
283264

284265

285266
#define PNV_PSIHB_SIZE 0x0000000000100000ull
286267
#define PNV_PSIHB_BASE(chip) \
287-
(0x0003fffe80000000ull + (uint64_t)PNV_CHIP_INDEX(chip) * PNV_PSIHB_SIZE)
268+
(0x0003fffe80000000ull + (uint64_t)(chip)->chip_id * PNV_PSIHB_SIZE)
288269

289270
#define PNV_PSIHB_FSP_SIZE 0x0000000100000000ull
290271
#define PNV_PSIHB_FSP_BASE(chip) \
291-
(0x0003ffe000000000ull + (uint64_t)PNV_CHIP_INDEX(chip) * \
272+
(0x0003ffe000000000ull + (uint64_t)(chip)->chip_id * \
292273
PNV_PSIHB_FSP_SIZE)
293274

294275
/*
@@ -324,11 +305,11 @@ void pnv_bmc_set_pnor(IPMIBmc *bmc, PnvPnor *pnor);
324305
#define PNV9_OCC_COMMON_AREA_SIZE 0x0000000000800000ull
325306
#define PNV9_OCC_COMMON_AREA_BASE 0x203fff800000ull
326307
#define PNV9_OCC_SENSOR_BASE(chip) (PNV9_OCC_COMMON_AREA_BASE + \
327-
PNV_OCC_SENSOR_DATA_BLOCK_BASE(PNV_CHIP_INDEX(chip)))
308+
PNV_OCC_SENSOR_DATA_BLOCK_BASE((chip)->chip_id))
328309

329310
#define PNV9_HOMER_SIZE 0x0000000000400000ull
330311
#define PNV9_HOMER_BASE(chip) \
331-
(0x203ffd800000ull + ((uint64_t)PNV_CHIP_INDEX(chip)) * PNV9_HOMER_SIZE)
312+
(0x203ffd800000ull + ((uint64_t)(chip)->chip_id) * PNV9_HOMER_SIZE)
332313

333314
/*
334315
* POWER10 MMIO base addresses - 16TB stride per chip

include/hw/ppc/xive.h

+8
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ static inline hwaddr xive_source_esb_mgmt(XiveSource *xsrc, int srcno)
261261
#define XIVE_ESB_QUEUED (XIVE_ESB_VAL_P | XIVE_ESB_VAL_Q)
262262
#define XIVE_ESB_OFF XIVE_ESB_VAL_Q
263263

264+
bool xive_esb_trigger(uint8_t *pq);
265+
bool xive_esb_eoi(uint8_t *pq);
266+
uint8_t xive_esb_set(uint8_t *pq, uint8_t value);
267+
264268
/*
265269
* "magic" Event State Buffer (ESB) MMIO offsets.
266270
*
@@ -404,6 +408,10 @@ int xive_presenter_tctx_match(XivePresenter *xptr, XiveTCTX *tctx,
404408
uint8_t format,
405409
uint8_t nvt_blk, uint32_t nvt_idx,
406410
bool cam_ignore, uint32_t logic_serv);
411+
bool xive_presenter_notify(XiveFabric *xfb, uint8_t format,
412+
uint8_t nvt_blk, uint32_t nvt_idx,
413+
bool cam_ignore, uint8_t priority,
414+
uint32_t logic_serv);
407415

408416
/*
409417
* XIVE Fabric (Interface between Interrupt Controller and Machine)

0 commit comments

Comments
 (0)