From patchwork Tue Nov 22 02:13:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 697504 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tN8LB0fJCz9svs for ; Tue, 22 Nov 2016 13:19:30 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3tN8L96WMVzDwKX for ; Tue, 22 Nov 2016 13:19:29 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3tN8JJ4DR9zDwG3 for ; Tue, 22 Nov 2016 13:17:52 +1100 (AEDT) Received: from pasglop.ozlabs.ibm.com (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id uAM2DZdH015261; Mon, 21 Nov 2016 20:13:53 -0600 From: Benjamin Herrenschmidt To: skiboot@lists.ozlabs.org Date: Tue, 22 Nov 2016 13:13:09 +1100 Message-Id: <1479780814-6162-7-git-send-email-benh@kernel.crashing.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479780814-6162-1-git-send-email-benh@kernel.crashing.org> References: <1479780814-6162-1-git-send-email-benh@kernel.crashing.org> Subject: [Skiboot] [PATCH 07/32] xive: Add basic opal_xive_reset() call and exploitation mode X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This adds an opal_xive_reset() call that currently does nothing other than store the mode (emulation vs. exploitation), and returns the appropriate error code if emulation mode calls are done while in exploitation mode. Signed-off-by: Benjamin Herrenschmidt --- hw/xive.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/hw/xive.c b/hw/xive.c index 66b9539..980333b 100644 --- a/hw/xive.c +++ b/hw/xive.c @@ -227,6 +227,15 @@ #endif +/* The xive operation mode indicates the active "API" and corresponds + * to the "version" parameter of the opal_xive_reset() call + */ +static enum { + XIVE_MODE_EMU = 0, + XIVE_MODE_EXPL = 1, +} xive_mode; + + /* Each source controller has one of these. There's one embedded * in the XIVE struct for IPIs */ @@ -2018,6 +2027,8 @@ static int64_t opal_xive_eoi(uint32_t xirr) struct xive *src_x; bool special_ipi = false; + if (xive_mode != XIVE_MODE_EMU) + return OPAL_WRONG_STATE; if (!xs) return OPAL_INTERNAL_ERROR; @@ -2120,6 +2131,8 @@ static int64_t opal_xive_get_xirr(uint32_t *out_xirr, bool just_poll) uint16_t ack; uint8_t active, old_cppr; + if (xive_mode != XIVE_MODE_EMU) + return OPAL_WRONG_STATE; if (!xs) return OPAL_INTERNAL_ERROR; if (!out_xirr) @@ -2236,6 +2249,9 @@ static int64_t opal_xive_set_cppr(uint8_t cppr) struct cpu_thread *c = this_cpu(); struct xive_cpu_state *xs = c->xstate; + if (xive_mode != XIVE_MODE_EMU) + return OPAL_WRONG_STATE; + /* Limit supported CPPR values */ cppr = xive_sanitize_cppr(cppr); @@ -2258,6 +2274,8 @@ static int64_t opal_xive_set_mfrr(uint32_t cpu, uint8_t mfrr) struct xive_cpu_state *xs; uint8_t old_mfrr; + if (xive_mode != XIVE_MODE_EMU) + return OPAL_WRONG_STATE; if (!c) return OPAL_PARAMETER; xs = c->xstate; @@ -2275,6 +2293,16 @@ static int64_t opal_xive_set_mfrr(uint32_t cpu, uint8_t mfrr) return OPAL_SUCCESS; } +static int64_t opal_xive_reset(uint64_t version) +{ + if (version > 1) + return OPAL_PARAMETER; + + xive_mode = version; + + return OPAL_SUCCESS; +} + void init_xive(void) { struct dt_node *np; @@ -2307,5 +2335,8 @@ void init_xive(void) opal_register(OPAL_INT_SET_CPPR, opal_xive_set_cppr, 1); opal_register(OPAL_INT_EOI, opal_xive_eoi, 1); opal_register(OPAL_INT_SET_MFRR, opal_xive_set_mfrr, 2); + + /* Register XIVE exploitation calls */ + opal_register(OPAL_XIVE_RESET, opal_xive_reset, 1); }