[{"id":1770874,"web_url":"http://patchwork.ozlabs.org/comment/1770874/","msgid":"<20170919023943.GI27153@umbus>","list_archive_url":null,"date":"2017-09-19T02:39:43","subject":"Re: [Qemu-devel] [RFC PATCH v2 03/21] ppc/xive: define the XIVE\n\tinternal tables","submitter":{"id":47,"url":"http://patchwork.ozlabs.org/api/people/47/","name":"David Gibson","email":"david@gibson.dropbear.id.au"},"content":"On Mon, Sep 11, 2017 at 07:12:17PM +0200, Cédric Le Goater wrote:\n> The XIVE interrupt controller of the POWER9 uses a set of tables to\n> redirect exception from event sources to CPU threads. Among which we\n> choose to model :\n> \n>  - the State Bit Entries (SBE), also known as Event State Buffer\n>    (ESB). This is a two bit state machine for each event source which\n>    is used to trigger events. The bits are named \"P\" (pending) and \"Q\"\n>    (queued) and can be controlled by MMIO.\n> \n>  - the Interrupt Virtualization Entry (IVE) table, also known as Event\n>    Assignment Structure (EAS). This table is indexed by the IRQ number\n>    and is looked up to find the Event Queue associated with a\n>    triggered event.\n\nBoth the above are one entry per irq source, yes?  What's the\nrationale for having them as parallel tables, rather than bits in a\nsingle per-source structure?\n\n>  - the Event Queue Descriptor (EQD) table, also known as Event\n>    Notification Descriptor (END). The EQD contains fields that specify\n>    the Event Queue on which event data is posted (and later pulled by\n>    the OS) and also a target (or VPD) to notify.\n> \n> An additional table was not modeled but we might need to support the\n> H_INT_SET_OS_REPORTING_LINE hcall:\n> \n>  - the Virtual Processor Descriptor (VPD) table, also known as\n>    Notification Virtual Target (NVT).\n> \n> The XIVE object is expanded with the tables described above. The size\n> of each table depends on the number of provisioned IRQ and the maximum\n> number of CPUs in the system. The indexing is very basic and might\n> need to be improved for the EQs.\n> \n> Signed-off-by: Cédric Le Goater <clg@kaod.org>\n> ---\n>  hw/intc/spapr_xive.c        | 108 ++++++++++++++++++++++++++++++++++++++++++++\n>  hw/intc/xive-internal.h     | 105 ++++++++++++++++++++++++++++++++++++++++++\n>  include/hw/ppc/spapr_xive.h |   9 ++++\n>  3 files changed, 222 insertions(+)\n>  create mode 100644 hw/intc/xive-internal.h\n> \n> diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c\n> index c83796519586..6d98528fae68 100644\n> --- a/hw/intc/spapr_xive.c\n> +++ b/hw/intc/spapr_xive.c\n> @@ -25,11 +25,34 @@\n>  #include \"hw/ppc/xics.h\"\n>  #include \"hw/ppc/spapr_xive.h\"\n>  \n> +#include \"xive-internal.h\"\n>  \n>  /*\n>   * Main XIVE object\n>   */\n>  \n> +void spapr_xive_reset(void *dev)\n> +{\n> +    sPAPRXive *xive = SPAPR_XIVE(dev);\n> +    int i;\n> +\n> +    /* SBEs are initialized to 0b01 which corresponds to \"ints off\" */\n> +    memset(xive->sbe, 0x55, xive->sbe_size);\n> +\n> +    /* Validate all available IVEs in the IRQ number space. It would\n> +     * be more correct to validate only the allocated IRQs but this\n> +     * would require some callback routine from the spapr machine into\n> +     * XIVE. To be done later.\n> +     */\n> +    for (i = 0; i < xive->nr_irqs; i++) {\n> +        XiveIVE *ive = &xive->ivt[i];\n> +        ive->w = IVE_VALID | IVE_MASKED;\n> +    }\n> +\n> +    /* clear all EQs */\n> +    memset(xive->eqt, 0, xive->nr_eqs * sizeof(XiveEQ));\n> +}\n> +\n>  static void spapr_xive_realize(DeviceState *dev, Error **errp)\n>  {\n>      sPAPRXive *xive = SPAPR_XIVE(dev);\n> @@ -44,8 +67,64 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)\n>          error_setg(errp, \"Number of interrupts too small\");\n>          return;\n>      }\n> +\n> +    /* Allocate SBEs (State Bit Entry). 2 bits, so 4 entries per byte */\n> +    xive->sbe_size = DIV_ROUND_UP(xive->nr_irqs, 4);\n> +    xive->sbe = g_malloc0(xive->sbe_size);\n> +\n> +    /* Allocate the IVT (Interrupt Virtualization Table) */\n> +    xive->ivt = g_malloc0(xive->nr_irqs * sizeof(XiveIVE));\n> +\n> +    /* Allocate the EQDT (Event Queue Descriptor Table), 8 priorities\n> +     * for each thread in the system */\n> +    xive->nr_eqs = xive->nr_targets * XIVE_EQ_PRIORITY_COUNT;\n> +    xive->eqt = g_malloc0(xive->nr_eqs * sizeof(XiveEQ));\n> +\n> +    qemu_register_reset(spapr_xive_reset, dev);\n>  }\n>  \n> +static const VMStateDescription vmstate_spapr_xive_ive = {\n> +    .name = \"xive/ive\",\n> +    .version_id = 1,\n> +    .minimum_version_id = 1,\n> +    .fields = (VMStateField []) {\n> +        VMSTATE_UINT64(w, XiveIVE),\n> +        VMSTATE_END_OF_LIST()\n> +    },\n> +};\n> +\n> +static const VMStateDescription vmstate_spapr_xive_eq = {\n> +    .name = \"xive/eq\",\n> +    .version_id = 1,\n> +    .minimum_version_id = 1,\n> +    .fields = (VMStateField []) {\n> +        VMSTATE_UINT32(w0, XiveEQ),\n> +        VMSTATE_UINT32(w1, XiveEQ),\n> +        VMSTATE_UINT32(w2, XiveEQ),\n> +        VMSTATE_UINT32(w3, XiveEQ),\n> +        VMSTATE_UINT32(w4, XiveEQ),\n> +        VMSTATE_UINT32(w5, XiveEQ),\n> +        VMSTATE_UINT32(w6, XiveEQ),\n> +        VMSTATE_UINT32(w7, XiveEQ),\n> +        VMSTATE_END_OF_LIST()\n> +    },\n> +};\n> +\n> +static const VMStateDescription vmstate_xive = {\n> +    .name = \"xive\",\n> +    .version_id = 1,\n> +    .minimum_version_id = 1,\n> +    .fields = (VMStateField[]) {\n> +        VMSTATE_VARRAY_UINT32_ALLOC(sbe, sPAPRXive, sbe_size, 0,\n> +                                    vmstate_info_uint8, uint8_t),\n\nSince you're treating the SBE as a packed buffer of u8s anyway, it's\nprobably simpler to use VMSTATE_BUFFER().  I don't see that you need\nthe ALLOC - it should have already been allocated on the destination.\n\nMight be worth having a VMSTATE_UINT32_EQUAL to sanity check that\nsbe_size is equal at either end.\n\n> +        VMSTATE_STRUCT_VARRAY_UINT32_ALLOC(ivt, sPAPRXive, nr_irqs, 0,\n> +                                    vmstate_spapr_xive_ive, XiveIVE),\n> +        VMSTATE_STRUCT_VARRAY_UINT32_ALLOC(eqt, sPAPRXive, nr_eqs, 0,\n> +                                    vmstate_spapr_xive_eq, XiveEQ),\n> +        VMSTATE_END_OF_LIST()\n> +    },\n> +};\n> +\n>  static Property spapr_xive_properties[] = {\n>      DEFINE_PROP_UINT32(\"nr-irqs\", sPAPRXive, nr_irqs, 0),\n>      DEFINE_PROP_UINT32(\"nr-targets\", sPAPRXive, nr_targets, 0),\n> @@ -59,6 +138,7 @@ static void spapr_xive_class_init(ObjectClass *klass, void *data)\n>      dc->realize = spapr_xive_realize;\n>      dc->props = spapr_xive_properties;\n>      dc->desc = \"sPAPR XIVE interrupt controller\";\n> +    dc->vmsd = &vmstate_xive;\n>  }\n>  \n>  static const TypeInfo spapr_xive_info = {\n> @@ -74,3 +154,31 @@ static void spapr_xive_register_types(void)\n>  }\n>  \n>  type_init(spapr_xive_register_types)\n> +\n> +XiveIVE *spapr_xive_get_ive(sPAPRXive *xive, uint32_t idx)\n> +{\n> +    return idx < xive->nr_irqs ? &xive->ivt[idx] : NULL;\n> +}\n> +\n> +XiveEQ *spapr_xive_get_eq(sPAPRXive *xive, uint32_t idx)\n> +{\n> +    return idx < xive->nr_eqs ? &xive->eqt[idx] : NULL;\n> +}\n> +\n> +/* TODO: improve EQ indexing. This is very simple and relies on the\n> + * fact that target (CPU) numbers start at 0 and are contiguous. It\n> + * should be OK for sPAPR.\n> + */\n> +bool spapr_xive_eq_for_target(sPAPRXive *xive, uint32_t target,\n> +                              uint8_t priority, uint32_t *out_eq_idx)\n> +{\n> +    if (priority > XIVE_PRIORITY_MAX || target >= xive->nr_targets) {\n> +        return false;\n> +    }\n> +\n> +    if (out_eq_idx) {\n> +        *out_eq_idx = target + priority;\n\nDon't you need to multiply target by XIVE_EQ_PRIORITY_COUNT?\n\n> +    }\n> +\n> +    return true;\n> +}\n> diff --git a/hw/intc/xive-internal.h b/hw/intc/xive-internal.h\n> new file mode 100644\n> index 000000000000..95184bad5c1d\n> --- /dev/null\n> +++ b/hw/intc/xive-internal.h\n> @@ -0,0 +1,105 @@\n> +/*\n> + * QEMU PowerPC XIVE model\n> + *\n> + * Copyright 2016,2017 IBM Corporation.\n> + *\n> + * This program is free software; you can redistribute it and/or\n> + * modify it under the terms of the GNU General Public License\n> + * as published by the Free Software Foundation; either version\n> + * 2 of the License, or (at your option) any later version.\n> + */\n> +#ifndef _INTC_XIVE_INTERNAL_H\n> +#define _INTC_XIVE_INTERNAL_H\n> +\n> +/* Utilities to manipulate these (originaly from OPAL) */\n> +#define MASK_TO_LSH(m)          (__builtin_ffsl(m) - 1)\n> +#define GETFIELD(m, v)          (((v) & (m)) >> MASK_TO_LSH(m))\n> +#define SETFIELD(m, v, val)                             \\\n> +        (((v) & ~(m)) | ((((typeof(v))(val)) << MASK_TO_LSH(m)) & (m)))\n> +\n> +#define PPC_BIT(bit)            (0x8000000000000000UL >> (bit))\n> +#define PPC_BIT32(bit)          (0x80000000UL >> (bit))\n> +#define PPC_BIT8(bit)           (0x80UL >> (bit))\n> +#define PPC_BITMASK(bs, be)     ((PPC_BIT(bs) - PPC_BIT(be)) | PPC_BIT(bs))\n> +#define PPC_BITMASK32(bs, be)   ((PPC_BIT32(bs) - PPC_BIT32(be)) | \\\n> +                                 PPC_BIT32(bs))\n> +\n> +/* IVE/EAS\n> + *\n> + * One per interrupt source. Targets that interrupt to a given EQ\n> + * and provides the corresponding logical interrupt number (EQ data)\n> + *\n> + * We also map this structure to the escalation descriptor inside\n> + * an EQ, though in that case the valid and masked bits are not used.\n> + */\n> +typedef struct XiveIVE {\n> +        /* Use a single 64-bit definition to make it easier to\n> +         * perform atomic updates\n> +         */\n> +        uint64_t        w;\n> +#define IVE_VALID       PPC_BIT(0)\n> +#define IVE_EQ_BLOCK    PPC_BITMASK(4, 7)        /* Destination EQ block# */\n> +#define IVE_EQ_INDEX    PPC_BITMASK(8, 31)       /* Destination EQ index */\n> +#define IVE_MASKED      PPC_BIT(32)              /* Masked */\n> +#define IVE_EQ_DATA     PPC_BITMASK(33, 63)      /* Data written to the EQ */\n> +} XiveIVE;\n> +\n> +/* EQ */\n> +typedef struct XiveEQ {\n> +        uint32_t        w0;\n\nIt'd be nice if IBM came up with better names for its fields thatn w0,\nw1, etc.   Oh well.\n\n> +#define EQ_W0_VALID             PPC_BIT32(0)\n> +#define EQ_W0_ENQUEUE           PPC_BIT32(1)\n> +#define EQ_W0_UCOND_NOTIFY      PPC_BIT32(2)\n> +#define EQ_W0_BACKLOG           PPC_BIT32(3)\n> +#define EQ_W0_PRECL_ESC_CTL     PPC_BIT32(4)\n> +#define EQ_W0_ESCALATE_CTL      PPC_BIT32(5)\n> +#define EQ_W0_END_OF_INTR       PPC_BIT32(6)\n> +#define EQ_W0_QSIZE             PPC_BITMASK32(12, 15)\n> +#define EQ_W0_SW0               PPC_BIT32(16)\n> +#define EQ_W0_FIRMWARE          EQ_W0_SW0 /* Owned by FW */\n> +#define EQ_QSIZE_4K             0\n> +#define EQ_QSIZE_64K            4\n> +#define EQ_W0_HWDEP             PPC_BITMASK32(24, 31)\n> +        uint32_t        w1;\n> +#define EQ_W1_ESn               PPC_BITMASK32(0, 1)\n> +#define EQ_W1_ESn_P             PPC_BIT32(0)\n> +#define EQ_W1_ESn_Q             PPC_BIT32(1)\n> +#define EQ_W1_ESe               PPC_BITMASK32(2, 3)\n> +#define EQ_W1_ESe_P             PPC_BIT32(2)\n> +#define EQ_W1_ESe_Q             PPC_BIT32(3)\n> +#define EQ_W1_GENERATION        PPC_BIT32(9)\n> +#define EQ_W1_PAGE_OFF          PPC_BITMASK32(10, 31)\n> +        uint32_t        w2;\n> +#define EQ_W2_MIGRATION_REG     PPC_BITMASK32(0, 3)\n> +#define EQ_W2_OP_DESC_HI        PPC_BITMASK32(4, 31)\n> +        uint32_t        w3;\n> +#define EQ_W3_OP_DESC_LO        PPC_BITMASK32(0, 31)\n> +        uint32_t        w4;\n> +#define EQ_W4_ESC_EQ_BLOCK      PPC_BITMASK32(4, 7)\n> +#define EQ_W4_ESC_EQ_INDEX      PPC_BITMASK32(8, 31)\n> +        uint32_t        w5;\n> +#define EQ_W5_ESC_EQ_DATA       PPC_BITMASK32(1, 31)\n> +        uint32_t        w6;\n> +#define EQ_W6_FORMAT_BIT        PPC_BIT32(8)\n> +#define EQ_W6_NVT_BLOCK         PPC_BITMASK32(9, 12)\n> +#define EQ_W6_NVT_INDEX         PPC_BITMASK32(13, 31)\n> +        uint32_t        w7;\n> +#define EQ_W7_F0_IGNORE         PPC_BIT32(0)\n> +#define EQ_W7_F0_BLK_GROUPING   PPC_BIT32(1)\n> +#define EQ_W7_F0_PRIORITY       PPC_BITMASK32(8, 15)\n> +#define EQ_W7_F1_WAKEZ          PPC_BIT32(0)\n> +#define EQ_W7_F1_LOG_SERVER_ID  PPC_BITMASK32(1, 31)\n> +} XiveEQ;\n> +\n> +#define XIVE_EQ_PRIORITY_COUNT 8\n> +#define XIVE_PRIORITY_MAX  (XIVE_EQ_PRIORITY_COUNT - 1)\n> +\n> +void spapr_xive_reset(void *dev);\n> +XiveIVE *spapr_xive_get_ive(sPAPRXive *xive, uint32_t isn);\n> +XiveEQ *spapr_xive_get_eq(sPAPRXive *xive, uint32_t idx);\n> +\n> +bool spapr_xive_eq_for_target(sPAPRXive *xive, uint32_t target, uint8_t prio,\n> +                        uint32_t *out_eq_idx);\n> +\n> +\n> +#endif /* _INTC_XIVE_INTERNAL_H */\n> diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h\n> index 5b99f7fc2b81..b17dd4f17b0b 100644\n> --- a/include/hw/ppc/spapr_xive.h\n> +++ b/include/hw/ppc/spapr_xive.h\n> @@ -22,6 +22,8 @@\n>  #include <hw/sysbus.h>\n>  \n>  typedef struct sPAPRXive sPAPRXive;\n> +typedef struct XiveIVE XiveIVE;\n> +typedef struct XiveEQ XiveEQ;\n>  \n>  #define TYPE_SPAPR_XIVE \"spapr-xive\"\n>  #define SPAPR_XIVE(obj) OBJECT_CHECK(sPAPRXive, (obj), TYPE_SPAPR_XIVE)\n> @@ -32,6 +34,13 @@ struct sPAPRXive {\n>      /* Properties */\n>      uint32_t     nr_targets;\n>      uint32_t     nr_irqs;\n> +\n> +    /* XIVE internal tables */\n> +    uint8_t      *sbe;\n> +    uint32_t     sbe_size;\n> +    XiveIVE      *ivt;\n> +    XiveEQ       *eqt;\n> +    uint32_t     nr_eqs;\n>  };\n>  \n>  #endif /* PPC_SPAPR_XIVE_H */","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=gibson.dropbear.id.au\n\theader.i=@gibson.dropbear.id.au header.b=\"Jb4iAOKb\"; \n\tdkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxKnr6lXpz9s7m\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 21:06:56 +1000 (AEST)","from localhost ([::1]:41540 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1duGMg-0000V4-Qv\n\tfor incoming@patchwork.ozlabs.org; Tue, 19 Sep 2017 07:06:54 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:51265)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <dgibson@ozlabs.org>) id 1duFtY-0001H4-GR\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 06:36:55 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <dgibson@ozlabs.org>) id 1duFtT-0002t3-R3\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 06:36:48 -0400","from ozlabs.org ([103.22.144.67]:55143)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <dgibson@ozlabs.org>)\n\tid 1duFtT-0002oX-2I; Tue, 19 Sep 2017 06:36:43 -0400","by ozlabs.org (Postfix, from userid 1007)\n\tid 3xxK6q2zG7z9t48; Tue, 19 Sep 2017 20:36:33 +1000 (AEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple;\n\td=gibson.dropbear.id.au; s=201602; t=1505817395;\n\tbh=0ffrCHbZelBExZBD06Wa0F0PrdCgsNb/egE8I3mudK4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Jb4iAOKbhZBsHC+HNVCAyGfVV7ut718LRUC3Qu48RlR6/ca3SCvLVCJ6nDq7+xfrY\n\tZIRH7xRqG37y8hDjBD7OJgVX0d7MT+0y5zDC7+Keocizqx6s8SbCiMCEZV5nCdoEnS\n\tvk4OkgnD8Y4NI5OWzWMD6vcYuioz9k74CLa540qI=","Date":"Tue, 19 Sep 2017 12:39:43 +1000","From":"David Gibson <david@gibson.dropbear.id.au>","To":"=?iso-8859-1?q?C=E9dric?= Le Goater <clg@kaod.org>","Message-ID":"<20170919023943.GI27153@umbus>","References":"<20170911171235.29331-1-clg@kaod.org>\n\t<20170911171235.29331-4-clg@kaod.org>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"dMdWWqg3F2Dv/qfw\"","Content-Disposition":"inline","In-Reply-To":"<20170911171235.29331-4-clg@kaod.org>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"103.22.144.67","Subject":"Re: [Qemu-devel] [RFC PATCH v2 03/21] ppc/xive: define the XIVE\n\tinternal tables","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Alexey Kardashevskiy <aik@ozlabs.ru>, qemu-ppc@nongnu.org,\n\tqemu-devel@nongnu.org, Alexander Graf <agraf@suse.de>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1771036,"web_url":"http://patchwork.ozlabs.org/comment/1771036/","msgid":"<09082408-6f2f-4bd8-d6c6-69734fe7de44@kaod.org>","list_archive_url":null,"date":"2017-09-19T13:46:20","subject":"Re: [Qemu-devel] [RFC PATCH v2 03/21] ppc/xive: define the XIVE\n\tinternal tables","submitter":{"id":68548,"url":"http://patchwork.ozlabs.org/api/people/68548/","name":"Cédric Le Goater","email":"clg@kaod.org"},"content":"On 09/19/2017 04:39 AM, David Gibson wrote:\n> On Mon, Sep 11, 2017 at 07:12:17PM +0200, Cédric Le Goater wrote:\n>> The XIVE interrupt controller of the POWER9 uses a set of tables to\n>> redirect exception from event sources to CPU threads. Among which we\n>> choose to model :\n>>\n>>  - the State Bit Entries (SBE), also known as Event State Buffer\n>>    (ESB). This is a two bit state machine for each event source which\n>>    is used to trigger events. The bits are named \"P\" (pending) and \"Q\"\n>>    (queued) and can be controlled by MMIO.\n>>\n>>  - the Interrupt Virtualization Entry (IVE) table, also known as Event\n>>    Assignment Structure (EAS). This table is indexed by the IRQ number\n>>    and is looked up to find the Event Queue associated with a\n>>    triggered event.\n> \n> Both the above are one entry per irq source, yes?  What's the\n> rationale for having them as parallel tables, rather than bits in a\n> single per-source structure?\n\nFor the sPAPR machines, yes, we could use a struct to hold both \ninformation. But these tables are defined in the HW specs and \nare used as such by the PowerNV platform in skiboot. They are \nregistered by the firmware for the use of the XIVE interrupt \ncontroller.   \n\nWhen we model XIVE for PowerNV, it would be preferable to have \ncommon definitions for these tables I think. \n \n>>  - the Event Queue Descriptor (EQD) table, also known as Event\n>>    Notification Descriptor (END). The EQD contains fields that specify\n>>    the Event Queue on which event data is posted (and later pulled by\n>>    the OS) and also a target (or VPD) to notify.\n>>\n>> An additional table was not modeled but we might need to support the\n>> H_INT_SET_OS_REPORTING_LINE hcall:\n>>\n>>  - the Virtual Processor Descriptor (VPD) table, also known as\n>>    Notification Virtual Target (NVT).\n>>\n>> The XIVE object is expanded with the tables described above. The size\n>> of each table depends on the number of provisioned IRQ and the maximum\n>> number of CPUs in the system. The indexing is very basic and might\n>> need to be improved for the EQs.\n>>\n>> Signed-off-by: Cédric Le Goater <clg@kaod.org>\n>> ---\n>>  hw/intc/spapr_xive.c        | 108 ++++++++++++++++++++++++++++++++++++++++++++\n>>  hw/intc/xive-internal.h     | 105 ++++++++++++++++++++++++++++++++++++++++++\n>>  include/hw/ppc/spapr_xive.h |   9 ++++\n>>  3 files changed, 222 insertions(+)\n>>  create mode 100644 hw/intc/xive-internal.h\n>>\n>> diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c\n>> index c83796519586..6d98528fae68 100644\n>> --- a/hw/intc/spapr_xive.c\n>> +++ b/hw/intc/spapr_xive.c\n>> @@ -25,11 +25,34 @@\n>>  #include \"hw/ppc/xics.h\"\n>>  #include \"hw/ppc/spapr_xive.h\"\n>>  \n>> +#include \"xive-internal.h\"\n>>  \n>>  /*\n>>   * Main XIVE object\n>>   */\n>>  \n>> +void spapr_xive_reset(void *dev)\n>> +{\n>> +    sPAPRXive *xive = SPAPR_XIVE(dev);\n>> +    int i;\n>> +\n>> +    /* SBEs are initialized to 0b01 which corresponds to \"ints off\" */\n>> +    memset(xive->sbe, 0x55, xive->sbe_size);\n>> +\n>> +    /* Validate all available IVEs in the IRQ number space. It would\n>> +     * be more correct to validate only the allocated IRQs but this\n>> +     * would require some callback routine from the spapr machine into\n>> +     * XIVE. To be done later.\n>> +     */\n>> +    for (i = 0; i < xive->nr_irqs; i++) {\n>> +        XiveIVE *ive = &xive->ivt[i];\n>> +        ive->w = IVE_VALID | IVE_MASKED;\n>> +    }\n>> +\n>> +    /* clear all EQs */\n>> +    memset(xive->eqt, 0, xive->nr_eqs * sizeof(XiveEQ));\n>> +}\n>> +\n>>  static void spapr_xive_realize(DeviceState *dev, Error **errp)\n>>  {\n>>      sPAPRXive *xive = SPAPR_XIVE(dev);\n>> @@ -44,8 +67,64 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)\n>>          error_setg(errp, \"Number of interrupts too small\");\n>>          return;\n>>      }\n>> +\n>> +    /* Allocate SBEs (State Bit Entry). 2 bits, so 4 entries per byte */\n>> +    xive->sbe_size = DIV_ROUND_UP(xive->nr_irqs, 4);\n>> +    xive->sbe = g_malloc0(xive->sbe_size);\n>> +\n>> +    /* Allocate the IVT (Interrupt Virtualization Table) */\n>> +    xive->ivt = g_malloc0(xive->nr_irqs * sizeof(XiveIVE));\n>> +\n>> +    /* Allocate the EQDT (Event Queue Descriptor Table), 8 priorities\n>> +     * for each thread in the system */\n>> +    xive->nr_eqs = xive->nr_targets * XIVE_EQ_PRIORITY_COUNT;\n>> +    xive->eqt = g_malloc0(xive->nr_eqs * sizeof(XiveEQ));\n>> +\n>> +    qemu_register_reset(spapr_xive_reset, dev);\n>>  }\n>>  \n>> +static const VMStateDescription vmstate_spapr_xive_ive = {\n>> +    .name = \"xive/ive\",\n>> +    .version_id = 1,\n>> +    .minimum_version_id = 1,\n>> +    .fields = (VMStateField []) {\n>> +        VMSTATE_UINT64(w, XiveIVE),\n>> +        VMSTATE_END_OF_LIST()\n>> +    },\n>> +};\n>> +\n>> +static const VMStateDescription vmstate_spapr_xive_eq = {\n>> +    .name = \"xive/eq\",\n>> +    .version_id = 1,\n>> +    .minimum_version_id = 1,\n>> +    .fields = (VMStateField []) {\n>> +        VMSTATE_UINT32(w0, XiveEQ),\n>> +        VMSTATE_UINT32(w1, XiveEQ),\n>> +        VMSTATE_UINT32(w2, XiveEQ),\n>> +        VMSTATE_UINT32(w3, XiveEQ),\n>> +        VMSTATE_UINT32(w4, XiveEQ),\n>> +        VMSTATE_UINT32(w5, XiveEQ),\n>> +        VMSTATE_UINT32(w6, XiveEQ),\n>> +        VMSTATE_UINT32(w7, XiveEQ),\n>> +        VMSTATE_END_OF_LIST()\n>> +    },\n>> +};\n>> +\n>> +static const VMStateDescription vmstate_xive = {\n>> +    .name = \"xive\",\n>> +    .version_id = 1,\n>> +    .minimum_version_id = 1,\n>> +    .fields = (VMStateField[]) {\n>> +        VMSTATE_VARRAY_UINT32_ALLOC(sbe, sPAPRXive, sbe_size, 0,\n>> +                                    vmstate_info_uint8, uint8_t),\n> \n> Since you're treating the SBE as a packed buffer of u8s anyway, it's\n> probably simpler to use VMSTATE_BUFFER().  I don't see that you need\n> the ALLOC - it should have already been allocated on the destination.\n> \n> Might be worth having a VMSTATE_UINT32_EQUAL to sanity check that\n> sbe_size is equal at either end.\n\nOK. I will fix that.\n\n> \n>> +        VMSTATE_STRUCT_VARRAY_UINT32_ALLOC(ivt, sPAPRXive, nr_irqs, 0,\n>> +                                    vmstate_spapr_xive_ive, XiveIVE),\n>> +        VMSTATE_STRUCT_VARRAY_UINT32_ALLOC(eqt, sPAPRXive, nr_eqs, 0,\n>> +                                    vmstate_spapr_xive_eq, XiveEQ),\n>> +        VMSTATE_END_OF_LIST()\n>> +    },\n>> +};\n>> +\n>>  static Property spapr_xive_properties[] = {\n>>      DEFINE_PROP_UINT32(\"nr-irqs\", sPAPRXive, nr_irqs, 0),\n>>      DEFINE_PROP_UINT32(\"nr-targets\", sPAPRXive, nr_targets, 0),\n>> @@ -59,6 +138,7 @@ static void spapr_xive_class_init(ObjectClass *klass, void *data)\n>>      dc->realize = spapr_xive_realize;\n>>      dc->props = spapr_xive_properties;\n>>      dc->desc = \"sPAPR XIVE interrupt controller\";\n>> +    dc->vmsd = &vmstate_xive;\n>>  }\n>>  \n>>  static const TypeInfo spapr_xive_info = {\n>> @@ -74,3 +154,31 @@ static void spapr_xive_register_types(void)\n>>  }\n>>  \n>>  type_init(spapr_xive_register_types)\n>> +\n>> +XiveIVE *spapr_xive_get_ive(sPAPRXive *xive, uint32_t idx)\n>> +{\n>> +    return idx < xive->nr_irqs ? &xive->ivt[idx] : NULL;\n>> +}\n>> +\n>> +XiveEQ *spapr_xive_get_eq(sPAPRXive *xive, uint32_t idx)\n>> +{\n>> +    return idx < xive->nr_eqs ? &xive->eqt[idx] : NULL;\n>> +}\n>> +\n>> +/* TODO: improve EQ indexing. This is very simple and relies on the\n>> + * fact that target (CPU) numbers start at 0 and are contiguous. It\n>> + * should be OK for sPAPR.\n>> + */\n>> +bool spapr_xive_eq_for_target(sPAPRXive *xive, uint32_t target,\n>> +                              uint8_t priority, uint32_t *out_eq_idx)\n>> +{\n>> +    if (priority > XIVE_PRIORITY_MAX || target >= xive->nr_targets) {\n>> +        return false;\n>> +    }\n>> +\n>> +    if (out_eq_idx) {\n>> +        *out_eq_idx = target + priority;\n> \n> Don't you need to multiply target by XIVE_EQ_PRIORITY_COUNT?\n\nBecause this is a bug ... I was lucky to only use a high priority (7)\n\nThanks,\n\nC. \n\n> \n>> +    }\n>> +\n>> +    return true;\n>> +}\n>> diff --git a/hw/intc/xive-internal.h b/hw/intc/xive-internal.h\n>> new file mode 100644\n>> index 000000000000..95184bad5c1d\n>> --- /dev/null\n>> +++ b/hw/intc/xive-internal.h\n>> @@ -0,0 +1,105 @@\n>> +/*\n>> + * QEMU PowerPC XIVE model\n>> + *\n>> + * Copyright 2016,2017 IBM Corporation.\n>> + *\n>> + * This program is free software; you can redistribute it and/or\n>> + * modify it under the terms of the GNU General Public License\n>> + * as published by the Free Software Foundation; either version\n>> + * 2 of the License, or (at your option) any later version.\n>> + */\n>> +#ifndef _INTC_XIVE_INTERNAL_H\n>> +#define _INTC_XIVE_INTERNAL_H\n>> +\n>> +/* Utilities to manipulate these (originaly from OPAL) */\n>> +#define MASK_TO_LSH(m)          (__builtin_ffsl(m) - 1)\n>> +#define GETFIELD(m, v)          (((v) & (m)) >> MASK_TO_LSH(m))\n>> +#define SETFIELD(m, v, val)                             \\\n>> +        (((v) & ~(m)) | ((((typeof(v))(val)) << MASK_TO_LSH(m)) & (m)))\n>> +\n>> +#define PPC_BIT(bit)            (0x8000000000000000UL >> (bit))\n>> +#define PPC_BIT32(bit)          (0x80000000UL >> (bit))\n>> +#define PPC_BIT8(bit)           (0x80UL >> (bit))\n>> +#define PPC_BITMASK(bs, be)     ((PPC_BIT(bs) - PPC_BIT(be)) | PPC_BIT(bs))\n>> +#define PPC_BITMASK32(bs, be)   ((PPC_BIT32(bs) - PPC_BIT32(be)) | \\\n>> +                                 PPC_BIT32(bs))\n>> +\n>> +/* IVE/EAS\n>> + *\n>> + * One per interrupt source. Targets that interrupt to a given EQ\n>> + * and provides the corresponding logical interrupt number (EQ data)\n>> + *\n>> + * We also map this structure to the escalation descriptor inside\n>> + * an EQ, though in that case the valid and masked bits are not used.\n>> + */\n>> +typedef struct XiveIVE {\n>> +        /* Use a single 64-bit definition to make it easier to\n>> +         * perform atomic updates\n>> +         */\n>> +        uint64_t        w;\n>> +#define IVE_VALID       PPC_BIT(0)\n>> +#define IVE_EQ_BLOCK    PPC_BITMASK(4, 7)        /* Destination EQ block# */\n>> +#define IVE_EQ_INDEX    PPC_BITMASK(8, 31)       /* Destination EQ index */\n>> +#define IVE_MASKED      PPC_BIT(32)              /* Masked */\n>> +#define IVE_EQ_DATA     PPC_BITMASK(33, 63)      /* Data written to the EQ */\n>> +} XiveIVE;\n>> +\n>> +/* EQ */\n>> +typedef struct XiveEQ {\n>> +        uint32_t        w0;\n> \n> It'd be nice if IBM came up with better names for its fields thatn w0,\n> w1, etc.   Oh well.\n> \n>> +#define EQ_W0_VALID             PPC_BIT32(0)\n>> +#define EQ_W0_ENQUEUE           PPC_BIT32(1)\n>> +#define EQ_W0_UCOND_NOTIFY      PPC_BIT32(2)\n>> +#define EQ_W0_BACKLOG           PPC_BIT32(3)\n>> +#define EQ_W0_PRECL_ESC_CTL     PPC_BIT32(4)\n>> +#define EQ_W0_ESCALATE_CTL      PPC_BIT32(5)\n>> +#define EQ_W0_END_OF_INTR       PPC_BIT32(6)\n>> +#define EQ_W0_QSIZE             PPC_BITMASK32(12, 15)\n>> +#define EQ_W0_SW0               PPC_BIT32(16)\n>> +#define EQ_W0_FIRMWARE          EQ_W0_SW0 /* Owned by FW */\n>> +#define EQ_QSIZE_4K             0\n>> +#define EQ_QSIZE_64K            4\n>> +#define EQ_W0_HWDEP             PPC_BITMASK32(24, 31)\n>> +        uint32_t        w1;\n>> +#define EQ_W1_ESn               PPC_BITMASK32(0, 1)\n>> +#define EQ_W1_ESn_P             PPC_BIT32(0)\n>> +#define EQ_W1_ESn_Q             PPC_BIT32(1)\n>> +#define EQ_W1_ESe               PPC_BITMASK32(2, 3)\n>> +#define EQ_W1_ESe_P             PPC_BIT32(2)\n>> +#define EQ_W1_ESe_Q             PPC_BIT32(3)\n>> +#define EQ_W1_GENERATION        PPC_BIT32(9)\n>> +#define EQ_W1_PAGE_OFF          PPC_BITMASK32(10, 31)\n>> +        uint32_t        w2;\n>> +#define EQ_W2_MIGRATION_REG     PPC_BITMASK32(0, 3)\n>> +#define EQ_W2_OP_DESC_HI        PPC_BITMASK32(4, 31)\n>> +        uint32_t        w3;\n>> +#define EQ_W3_OP_DESC_LO        PPC_BITMASK32(0, 31)\n>> +        uint32_t        w4;\n>> +#define EQ_W4_ESC_EQ_BLOCK      PPC_BITMASK32(4, 7)\n>> +#define EQ_W4_ESC_EQ_INDEX      PPC_BITMASK32(8, 31)\n>> +        uint32_t        w5;\n>> +#define EQ_W5_ESC_EQ_DATA       PPC_BITMASK32(1, 31)\n>> +        uint32_t        w6;\n>> +#define EQ_W6_FORMAT_BIT        PPC_BIT32(8)\n>> +#define EQ_W6_NVT_BLOCK         PPC_BITMASK32(9, 12)\n>> +#define EQ_W6_NVT_INDEX         PPC_BITMASK32(13, 31)\n>> +        uint32_t        w7;\n>> +#define EQ_W7_F0_IGNORE         PPC_BIT32(0)\n>> +#define EQ_W7_F0_BLK_GROUPING   PPC_BIT32(1)\n>> +#define EQ_W7_F0_PRIORITY       PPC_BITMASK32(8, 15)\n>> +#define EQ_W7_F1_WAKEZ          PPC_BIT32(0)\n>> +#define EQ_W7_F1_LOG_SERVER_ID  PPC_BITMASK32(1, 31)\n>> +} XiveEQ;\n>> +\n>> +#define XIVE_EQ_PRIORITY_COUNT 8\n>> +#define XIVE_PRIORITY_MAX  (XIVE_EQ_PRIORITY_COUNT - 1)\n>> +\n>> +void spapr_xive_reset(void *dev);\n>> +XiveIVE *spapr_xive_get_ive(sPAPRXive *xive, uint32_t isn);\n>> +XiveEQ *spapr_xive_get_eq(sPAPRXive *xive, uint32_t idx);\n>> +\n>> +bool spapr_xive_eq_for_target(sPAPRXive *xive, uint32_t target, uint8_t prio,\n>> +                        uint32_t *out_eq_idx);\n>> +\n>> +\n>> +#endif /* _INTC_XIVE_INTERNAL_H */\n>> diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h\n>> index 5b99f7fc2b81..b17dd4f17b0b 100644\n>> --- a/include/hw/ppc/spapr_xive.h\n>> +++ b/include/hw/ppc/spapr_xive.h\n>> @@ -22,6 +22,8 @@\n>>  #include <hw/sysbus.h>\n>>  \n>>  typedef struct sPAPRXive sPAPRXive;\n>> +typedef struct XiveIVE XiveIVE;\n>> +typedef struct XiveEQ XiveEQ;\n>>  \n>>  #define TYPE_SPAPR_XIVE \"spapr-xive\"\n>>  #define SPAPR_XIVE(obj) OBJECT_CHECK(sPAPRXive, (obj), TYPE_SPAPR_XIVE)\n>> @@ -32,6 +34,13 @@ struct sPAPRXive {\n>>      /* Properties */\n>>      uint32_t     nr_targets;\n>>      uint32_t     nr_irqs;\n>> +\n>> +    /* XIVE internal tables */\n>> +    uint8_t      *sbe;\n>> +    uint32_t     sbe_size;\n>> +    XiveIVE      *ivt;\n>> +    XiveEQ       *eqt;\n>> +    uint32_t     nr_eqs;\n>>  };\n>>  \n>>  #endif /* PPC_SPAPR_XIVE_H */\n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxPP64gkZz9sMN\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 23:49:14 +1000 (AEST)","from localhost ([::1]:43012 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1duItk-0001ZG-OC\n\tfor incoming@patchwork.ozlabs.org; Tue, 19 Sep 2017 09:49:12 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:56785)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <clg@kaod.org>) id 1duIrH-0008LF-4j\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 09:46:41 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <clg@kaod.org>) id 1duIrA-00044m-Kv\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 09:46:39 -0400","from 19.mo3.mail-out.ovh.net ([178.32.98.231]:57005)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <clg@kaod.org>) id 1duIrA-00043v-Br\n\tfor qemu-devel@nongnu.org; Tue, 19 Sep 2017 09:46:32 -0400","from player797.ha.ovh.net (b9.ovh.net [213.186.33.59])\n\tby mo3.mail-out.ovh.net (Postfix) with ESMTP id 885D8154A88\n\tfor <qemu-devel@nongnu.org>; Tue, 19 Sep 2017 15:46:30 +0200 (CEST)","from zorba.kaod.org (deibp9eh1--blueice1n4.emea.ibm.com\n\t[195.212.29.166]) (Authenticated sender: postmaster@kaod.org)\n\tby player797.ha.ovh.net (Postfix) with ESMTPSA id 9369B2E007E;\n\tTue, 19 Sep 2017 15:46:21 +0200 (CEST)"],"To":"David Gibson <david@gibson.dropbear.id.au>","References":"<20170911171235.29331-1-clg@kaod.org>\n\t<20170911171235.29331-4-clg@kaod.org> <20170919023943.GI27153@umbus>","From":"=?utf-8?q?C=C3=A9dric_Le_Goater?= <clg@kaod.org>","Message-ID":"<09082408-6f2f-4bd8-d6c6-69734fe7de44@kaod.org>","Date":"Tue, 19 Sep 2017 15:46:20 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170919023943.GI27153@umbus>","Content-Type":"text/plain; charset=windows-1252","Content-Language":"en-US","X-Ovh-Tracer-Id":"2285013864711555960","X-VR-SPAMSTATE":"OK","X-VR-SPAMSCORE":"-100","X-VR-SPAMCAUSE":"gggruggvucftvghtrhhoucdtuddrfeelledrheejgdejtdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd","Content-Transfer-Encoding":"quoted-printable","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"178.32.98.231","Subject":"Re: [Qemu-devel] [RFC PATCH v2 03/21] ppc/xive: define the XIVE\n\tinternal tables","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Alexey Kardashevskiy <aik@ozlabs.ru>, qemu-ppc@nongnu.org,\n\tqemu-devel@nongnu.org, Alexander Graf <agraf@suse.de>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1771561,"web_url":"http://patchwork.ozlabs.org/comment/1771561/","msgid":"<20170920043308.GE5520@umbus.fritz.box>","list_archive_url":null,"date":"2017-09-20T04:33:08","subject":"Re: [Qemu-devel] [RFC PATCH v2 03/21] ppc/xive: define the XIVE\n\tinternal tables","submitter":{"id":47,"url":"http://patchwork.ozlabs.org/api/people/47/","name":"David Gibson","email":"david@gibson.dropbear.id.au"},"content":"On Tue, Sep 19, 2017 at 03:46:20PM +0200, Cédric Le Goater wrote:\n> On 09/19/2017 04:39 AM, David Gibson wrote:\n> > On Mon, Sep 11, 2017 at 07:12:17PM +0200, Cédric Le Goater wrote:\n> >> The XIVE interrupt controller of the POWER9 uses a set of tables to\n> >> redirect exception from event sources to CPU threads. Among which we\n> >> choose to model :\n> >>\n> >>  - the State Bit Entries (SBE), also known as Event State Buffer\n> >>    (ESB). This is a two bit state machine for each event source which\n> >>    is used to trigger events. The bits are named \"P\" (pending) and \"Q\"\n> >>    (queued) and can be controlled by MMIO.\n> >>\n> >>  - the Interrupt Virtualization Entry (IVE) table, also known as Event\n> >>    Assignment Structure (EAS). This table is indexed by the IRQ number\n> >>    and is looked up to find the Event Queue associated with a\n> >>    triggered event.\n> > \n> > Both the above are one entry per irq source, yes?  What's the\n> > rationale for having them as parallel tables, rather than bits in a\n> > single per-source structure?\n> \n> For the sPAPR machines, yes, we could use a struct to hold both \n> information. But these tables are defined in the HW specs and \n> are used as such by the PowerNV platform in skiboot. They are \n> registered by the firmware for the use of the XIVE interrupt \n> controller.   \n> \n> When we model XIVE for PowerNV, it would be preferable to have \n> common definitions for these tables I think.\n\nOk, that seems like a reasonable case.","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=gibson.dropbear.id.au\n\theader.i=@gibson.dropbear.id.au header.b=\"eEoNxg3U\"; \n\tdkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxnXJ62fkz9s82\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 14:56:48 +1000 (AEST)","from localhost ([::1]:46687 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1duX43-0001UY-11\n\tfor incoming@patchwork.ozlabs.org; Wed, 20 Sep 2017 00:56:47 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:36190)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <dgibson@ozlabs.org>) id 1duX1E-0007wM-IR\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 00:53:54 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <dgibson@ozlabs.org>) id 1duX1B-0001JT-Ao\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 00:53:52 -0400","from ozlabs.org ([103.22.144.67]:35041)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <dgibson@ozlabs.org>)\n\tid 1duX1A-00013q-FU; Wed, 20 Sep 2017 00:53:49 -0400","by ozlabs.org (Postfix, from userid 1007)\n\tid 3xxnSm5BnNz9sCZ; Wed, 20 Sep 2017 14:53:44 +1000 (AEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple;\n\td=gibson.dropbear.id.au; s=201602; t=1505883224;\n\tbh=fN0jMkVyCjtx5WckeALLmNb+HlX0KetyfseAGLd3f44=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=eEoNxg3Ujr6R/lmqhfoZhMWwxDdWe4NKgusgRDQNwU4lBwga4NTe7uRfO8tjSCa1G\n\tfdFR0pYrR5xHRW9PslaKxuzAXsE8NY3u0Unt0XP232wtrwpDWBu7UZfYBGFFiPRlpe\n\t6kxYwkoRQhUc9MEhKJnZhQ1Bx9XWRuV8VZ/HaQg4=","Date":"Wed, 20 Sep 2017 14:33:08 +1000","From":"David Gibson <david@gibson.dropbear.id.au>","To":"=?iso-8859-1?q?C=E9dric?= Le Goater <clg@kaod.org>","Message-ID":"<20170920043308.GE5520@umbus.fritz.box>","References":"<20170911171235.29331-1-clg@kaod.org>\n\t<20170911171235.29331-4-clg@kaod.org>\n\t<20170919023943.GI27153@umbus>\n\t<09082408-6f2f-4bd8-d6c6-69734fe7de44@kaod.org>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"TD8GDToEDw0WLGOL\"","Content-Disposition":"inline","In-Reply-To":"<09082408-6f2f-4bd8-d6c6-69734fe7de44@kaod.org>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"103.22.144.67","Subject":"Re: [Qemu-devel] [RFC PATCH v2 03/21] ppc/xive: define the XIVE\n\tinternal tables","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Alexey Kardashevskiy <aik@ozlabs.ru>, qemu-ppc@nongnu.org,\n\tqemu-devel@nongnu.org, Alexander Graf <agraf@suse.de>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]