From patchwork Thu Oct 20 06:59:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 9387013 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4471E607D0 for ; Thu, 20 Oct 2016 14:59:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33F8029C50 for ; Thu, 20 Oct 2016 14:59:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26D9529C70; Thu, 20 Oct 2016 14:59:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BC5A729C50 for ; Thu, 20 Oct 2016 14:59:05 +0000 (UTC) Received: from localhost ([::1]:55352 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxEoC-00044e-VS for patchwork-qemu-devel@patchwork.kernel.org; Thu, 20 Oct 2016 10:59:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bx7KH-0007kv-CD for qemu-devel@nongnu.org; Thu, 20 Oct 2016 02:59:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bx7KG-0002bb-DI for qemu-devel@nongnu.org; Thu, 20 Oct 2016 02:59:41 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:36677) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bx7KG-0002aT-7i; Thu, 20 Oct 2016 02:59:40 -0400 Received: by mail-pf0-x241.google.com with SMTP id r16so4664945pfg.3; Wed, 19 Oct 2016 23:59:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L+85Gpeo0BKFz/QKaFbydj+kv56lxinVuYAAamUeF2c=; b=ls3CQFk7WXBuHQlRjVLPSWuPfb7SFJA5/cuDe2e7pbjsrWxFkLZWFGygywfv6l3D8q FhHw5SXgEIyT1TB8TErcNr6m/SfigKbO6IYwlfD8RIw4BuzrEglpHkmMh7r0m/a2WwPX MtRebn5Fq0+fjgfaLDW8zEh8UBPZymRs3f81jKUBajUSIbLScIJXaFX71OTeH+CH41VN Pnj5QwsheSYVIdnh3AINjys31gK1wIYKQiyCZmrHYUCG6kVL5Lc+2P9zLPPaxSw2RKXh kQdUu3Ce1yKBdkSVMnMnp9P7W+FgHRezO+kWTXxq69gydcMtmoBrRCw4+FEUMYAX6k9h 5lJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=L+85Gpeo0BKFz/QKaFbydj+kv56lxinVuYAAamUeF2c=; b=mP9k6u4iwBQN57nMtn9AtjT91TmwTt596f630hkr0cWIecv4NliZ+aI/rB4LeBi7o2 YqI96+4C/FNU64bTiOT6oukRZS02UfbKaDF6Ij4vpprfwCtahpHPNm+6jdff0vNAp/SP SuHM2DSUhf2DsEwKBsDc8t652E8NY/mnoWINkh0xNFipNcQCUNDevbpnVxaXClnck/xO DGrYNp7wXdaI/aWxDk5A1UAXQic95qZWlWGm6COezWluB881G/hXA6+QS0PvrBT++WII X0Yc5fTk6NIczRun8e9xnZxQhQUSXwLUHqGKZNyWifgi8NTGUqMggPKpg4hrugAyRCzB dX/Q== X-Gm-Message-State: AA6/9RnZtGsXKx17kaq3GC974G7DLk56PxjzszxU2BcKY93f4V+QlwjRLnPSLSg52ghHsg== X-Received: by 10.98.137.206 with SMTP id n75mr18654262pfk.132.1476946779185; Wed, 19 Oct 2016 23:59:39 -0700 (PDT) Received: from roar.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id u10sm68754223pau.32.2016.10.19.23.59.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Oct 2016 23:59:38 -0700 (PDT) From: Nicholas Piggin To: qemu-devel@nongnu.org Date: Thu, 20 Oct 2016 17:59:12 +1100 Message-Id: <20161020065912.16132-4-npiggin@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161020065912.16132-1-npiggin@gmail.com> References: <20161020065912.16132-1-npiggin@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::241 X-Mailman-Approved-At: Thu, 20 Oct 2016 10:46:21 -0400 Subject: [Qemu-devel] [PATCH 3/3] ppc/spapr: implement H_SIGNAL_SYS_RESET X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , qemu-ppc@nongnu.org, Alexander Graf , Nicholas Piggin , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The H_SIGNAL_SYS_RESET hcall allows a guest CPU to raise a system reset exception on other CPUs in the same guest. Signed-off-by: Nicholas Piggin --- hw/ppc/spapr_hcall.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 8 +++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index c5e7e8c..5ae84f0 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -880,6 +880,47 @@ static target_ulong h_set_mode(PowerPCCPU *cpu, sPAPRMachineState *spapr, return ret; } +static void do_sys_reset(CPUState *cs, void *arg) +{ + cpu_synchronize_state(cs); + ppc_cpu_do_system_reset(cs); +} + +static target_ulong h_signal_sys_reset(PowerPCCPU *cpu, + sPAPRMachineState *spapr, + target_ulong opcode, target_ulong *args) +{ + target_long target = args[0]; + CPUState *cs; + + if (target < H_SIGNAL_SYS_RESET_ALLBUTSELF) { + return H_PARAMETER; + } + + CPU_FOREACH(cs) { + PowerPCCPU *c = POWERPC_CPU(cs); + + if (cpu->cpu_dt_id == target) { + run_on_cpu(cs, do_sys_reset, NULL); + return H_SUCCESS; + } + + if (target == H_SIGNAL_SYS_RESET_ALLBUTSELF) { + if (c == cpu) { + continue; + } + } + + run_on_cpu(cs, do_sys_reset, NULL); + } + + if (target >= 0) { + return H_PARAMETER; + } + + return H_SUCCESS; +} + /* * Return the offset to the requested option vector @vector in the * option vector table @table. @@ -1113,6 +1154,7 @@ static void hypercall_register_types(void) /* hcall-splpar */ spapr_register_hypercall(H_REGISTER_VPA, h_register_vpa); spapr_register_hypercall(H_CEDE, h_cede); + spapr_register_hypercall(H_SIGNAL_SYS_RESET, h_signal_sys_reset); /* processor register resource access h-calls */ spapr_register_hypercall(H_SET_SPRG0, h_set_sprg0); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index aeaba3e..a28538b 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -339,7 +339,13 @@ struct sPAPRMachineState { #define H_XIRR_X 0x2FC #define H_RANDOM 0x300 #define H_SET_MODE 0x31C -#define MAX_HCALL_OPCODE H_SET_MODE +#define H_SIGNAL_SYS_RESET 0x380 +#define MAX_HCALL_OPCODE H_SIGNAL_SYS_RESET + +/* Parameters to H_SIGNAL_SYS_RESET */ +#define H_SIGNAL_SYS_RESET_ALL -1 +#define H_SIGNAL_SYS_RESET_ALLBUTSELF -2 + /* The hcalls above are standardized in PAPR and implemented by pHyp * as well.