[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 26/73] ppc/pnv: add a core mask to PnvChip
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 26/73] ppc/pnv: add a core mask to PnvChip |
Date: |
Fri, 28 Oct 2016 12:37:27 +1100 |
From: Cédric Le Goater <address@hidden>
This will be used to build real HW ids for the cores and enforce some
limits on the available cores per chip.
Signed-off-by: Cédric Le Goater <address@hidden>
Reviewed-by: David Gibson <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/pnv.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++-
include/hw/ppc/pnv.h | 4 +++
2 files changed, 76 insertions(+), 1 deletion(-)
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index aeafd7e..1705699 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -238,11 +238,38 @@ static void ppc_powernv_init(MachineState *machine)
object_property_add_child(OBJECT(pnv), chip_name, chip, &error_fatal);
object_property_set_int(chip, PNV_CHIP_HWID(i), "chip-id",
&error_fatal);
+ object_property_set_int(chip, smp_cores, "nr-cores", &error_fatal);
object_property_set_bool(chip, true, "realized", &error_fatal);
}
g_free(chip_typename);
}
+/* Allowed core identifiers on a POWER8 Processor Chip :
+ *
+ * <EX0 reserved>
+ * EX1 - Venice only
+ * EX2 - Venice only
+ * EX3 - Venice only
+ * EX4
+ * EX5
+ * EX6
+ * <EX7,8 reserved> <reserved>
+ * EX9 - Venice only
+ * EX10 - Venice only
+ * EX11 - Venice only
+ * EX12
+ * EX13
+ * EX14
+ * <EX15 reserved>
+ */
+#define POWER8E_CORE_MASK (0x7070ull)
+#define POWER8_CORE_MASK (0x7e7eull)
+
+/*
+ * POWER9 has 24 cores, ids starting at 0x20
+ */
+#define POWER9_CORE_MASK (0xffffff00000000ull)
+
static void pnv_chip_power8e_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -251,6 +278,7 @@ static void pnv_chip_power8e_class_init(ObjectClass *klass,
void *data)
k->cpu_model = "POWER8E";
k->chip_type = PNV_CHIP_POWER8E;
k->chip_cfam_id = 0x221ef04980000000ull; /* P8 Murano DD2.1 */
+ k->cores_mask = POWER8E_CORE_MASK;
dc->desc = "PowerNV Chip POWER8E";
}
@@ -269,6 +297,7 @@ static void pnv_chip_power8_class_init(ObjectClass *klass,
void *data)
k->cpu_model = "POWER8";
k->chip_type = PNV_CHIP_POWER8;
k->chip_cfam_id = 0x220ea04980000000ull; /* P8 Venice DD2.0 */
+ k->cores_mask = POWER8_CORE_MASK;
dc->desc = "PowerNV Chip POWER8";
}
@@ -287,6 +316,7 @@ static void pnv_chip_power8nvl_class_init(ObjectClass
*klass, void *data)
k->cpu_model = "POWER8NVL";
k->chip_type = PNV_CHIP_POWER8NVL;
k->chip_cfam_id = 0x120d304980000000ull; /* P8 Naples DD1.0 */
+ k->cores_mask = POWER8_CORE_MASK;
dc->desc = "PowerNV Chip POWER8NVL";
}
@@ -305,6 +335,7 @@ static void pnv_chip_power9_class_init(ObjectClass *klass,
void *data)
k->cpu_model = "POWER9";
k->chip_type = PNV_CHIP_POWER9;
k->chip_cfam_id = 0x100d104980000000ull; /* P9 Nimbus DD1.0 */
+ k->cores_mask = POWER9_CORE_MASK;
dc->desc = "PowerNV Chip POWER9";
}
@@ -315,15 +346,55 @@ static const TypeInfo pnv_chip_power9_info = {
.class_init = pnv_chip_power9_class_init,
};
+static void pnv_chip_core_sanitize(PnvChip *chip, Error **errp)
+{
+ PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip);
+ int cores_max;
+
+ /*
+ * No custom mask for this chip, let's use the default one from *
+ * the chip class
+ */
+ if (!chip->cores_mask) {
+ chip->cores_mask = pcc->cores_mask;
+ }
+
+ /* filter alien core ids ! some are reserved */
+ if ((chip->cores_mask & pcc->cores_mask) != chip->cores_mask) {
+ error_setg(errp, "warning: invalid core mask for chip Ox%"PRIx64" !",
+ chip->cores_mask);
+ return;
+ }
+ chip->cores_mask &= pcc->cores_mask;
+
+ /* now that we have a sane layout, let check the number of cores */
+ cores_max = hweight_long(chip->cores_mask);
+ if (chip->nr_cores > cores_max) {
+ error_setg(errp, "warning: too many cores for chip ! Limit is %d",
+ cores_max);
+ return;
+ }
+}
+
static void pnv_chip_realize(DeviceState *dev, Error **errp)
{
- /* left purposely empty */
+ PnvChip *chip = PNV_CHIP(dev);
+ Error *error = NULL;
+
+ /* Early checks on the core settings */
+ pnv_chip_core_sanitize(chip, &error);
+ if (error) {
+ error_propagate(errp, error);
+ return;
+ }
}
static Property pnv_chip_properties[] = {
DEFINE_PROP_UINT32("chip-id", PnvChip, chip_id, 0),
DEFINE_PROP_UINT64("ram-start", PnvChip, ram_start, 0),
DEFINE_PROP_UINT64("ram-size", PnvChip, ram_size, 0),
+ DEFINE_PROP_UINT32("nr-cores", PnvChip, nr_cores, 1),
+ DEFINE_PROP_UINT64("cores-mask", PnvChip, cores_mask, 0x0),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h
index 7189961..e084a8c 100644
--- a/include/hw/ppc/pnv.h
+++ b/include/hw/ppc/pnv.h
@@ -44,6 +44,9 @@ typedef struct PnvChip {
uint32_t chip_id;
uint64_t ram_start;
uint64_t ram_size;
+
+ uint32_t nr_cores;
+ uint64_t cores_mask;
} PnvChip;
typedef struct PnvChipClass {
@@ -54,6 +57,7 @@ typedef struct PnvChipClass {
const char *cpu_model;
PnvChipType chip_type;
uint64_t chip_cfam_id;
+ uint64_t cores_mask;
} PnvChipClass;
#define TYPE_PNV_CHIP_POWER8E TYPE_PNV_CHIP "-POWER8E"
--
2.7.4
- [Qemu-ppc] [PULL 03/73] tests: fix memory leak in virtio-scsi-test, (continued)
- [Qemu-ppc] [PULL 03/73] tests: fix memory leak in virtio-scsi-test, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 14/73] target-ppc: implement vnegw/d instructions, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 04/73] tests: don't check if qtest_spapr_boot() returns NULL, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 16/73] ppc/xics: add a xics_set_nr_servers common routine, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 02/73] ppc/xics: Add xics to the monitor "info pic" command, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 11/73] sparc: Use the new common NVRAM functions for system and free space partition, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 19/73] ppc: fix MSR_ME handling for system reset interrupt, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 09/73] spapr_pci: advertise explicit numa IDs even when there's 1 node, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 08/73] tests: enable virtio tests on SPAPR, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 24/73] ppc/pnv: add skeleton PowerNV platform, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 26/73] ppc/pnv: add a core mask to PnvChip,
David Gibson <=
- [Qemu-ppc] [PULL 10/73] nvram: Introduce helper functions for CHRP "system" and "free space" partitions, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 06/73] tests: rename target_big_endian() as qvirtio_is_big_endian(), David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 15/73] target-ppc: implement xxbr[qdwh] instruction, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 13/73] nvram: Rename openbios_firmware_abi.h into sun_nvram.h, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 12/73] nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch], David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 20/73] pseries: Remove unused callbacks from sPAPR VIO bus state, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 27/73] ppc/pnv: add a PIR handler to PnvChip, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 18/73] ppc/xics: change the icp_ routines API to use an 'ICPState *' argument, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 17/73] ppc/xics: add a XICSState backlink in ICPState, David Gibson, 2016/10/27
- [Qemu-ppc] [PULL 07/73] tests: use qtest_pc_boot()/qtest_shutdown() in virtio tests, David Gibson, 2016/10/27