From patchwork Thu Mar 24 15:28:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 8662201 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8BA939F3D1 for ; Thu, 24 Mar 2016 15:30:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C130202A1 for ; Thu, 24 Mar 2016 15:30:03 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 0C08A2026D for ; Thu, 24 Mar 2016 15:30:02 +0000 (UTC) Received: from localhost ([::1]:51048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj7Cz-0006uq-G1 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Mar 2016 11:30:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj7CL-0006Iy-DT for qemu-devel@nongnu.org; Thu, 24 Mar 2016 11:29:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aj7CG-0006Nr-DA for qemu-devel@nongnu.org; Thu, 24 Mar 2016 11:29:21 -0400 Received: from e06smtp06.uk.ibm.com ([195.75.94.102]:51383) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj7CG-0006Ni-3g for qemu-devel@nongnu.org; Thu, 24 Mar 2016 11:29:16 -0400 Received: from localhost by e06smtp06.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 24 Mar 2016 15:29:13 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp06.uk.ibm.com (192.168.101.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 24 Mar 2016 15:29:11 -0000 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: clg@fr.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org;qemu-ppc@nongnu.org Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 4AFA5219005E; Thu, 24 Mar 2016 15:28:52 +0000 (GMT) Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u2OFTBEn7537076; Thu, 24 Mar 2016 15:29:11 GMT Received: from d06av11.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u2OFTAcY022020; Thu, 24 Mar 2016 09:29:10 -0600 Received: from hermes.ibm.com (icon-9-164-191-85.megacenter.de.ibm.com [9.164.191.85]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u2OFT90h021961; Thu, 24 Mar 2016 09:29:09 -0600 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Date: Thu, 24 Mar 2016 16:28:53 +0100 Message-Id: <1458833333-24103-1-git-send-email-clg@fr.ibm.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16032415-0025-0000-0000-000009251BF7 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.102 Cc: Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Greg Kurz Subject: [Qemu-devel] [PATCH] spapr: compute interrupt vector address from LPCR X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This address is changed by the linux kernel using the H_SET_MODE hcall and needs to be migrated in order to restart a spapr VM running in TCG. This can be done using the AIL bits from the LPCR register. The patch introduces a spapr_h_set_mode_resource_addr() helper to share some code with the H_SET_MODE hcall. Signed-off-by: Cédric Le Goater --- hw/ppc/spapr.c | 21 +++++++++++++++++++++ hw/ppc/spapr_hcall.c | 13 ++----------- include/hw/ppc/spapr.h | 14 ++++++++++++++ 3 files changed, 37 insertions(+), 11 deletions(-) Index: qemu-dgibson-for-2.6.git/hw/ppc/spapr.c =================================================================== --- qemu-dgibson-for-2.6.git.orig/hw/ppc/spapr.c +++ qemu-dgibson-for-2.6.git/hw/ppc/spapr.c @@ -1244,6 +1244,24 @@ static bool spapr_vga_init(PCIBus *pci_b } } +static int load_excp_prefix(void) +{ + CPUState *cs; + + CPU_FOREACH(cs) { + CPUPPCState *env = &POWERPC_CPU(cs)->env; + int ail = (env->spr[SPR_LPCR] & LPCR_AIL) >> LPCR_AIL_SHIFT; + + env->excp_prefix = spapr_h_set_mode_resource_addr(ail); + if (env->excp_prefix == H_UNSUPPORTED_FLAG) { + error_report("LPCR has an invalid AIL value"); + return -EINVAL; + } + } + + return 0; +} + static int spapr_post_load(void *opaque, int version_id) { sPAPRMachineState *spapr = (sPAPRMachineState *)opaque; @@ -1257,6 +1275,9 @@ static int spapr_post_load(void *opaque, err = spapr_rtc_import_offset(spapr->rtc, spapr->rtc_offset); } + if (!err) { + err = load_excp_prefix(); + } return err; } Index: qemu-dgibson-for-2.6.git/include/hw/ppc/spapr.h =================================================================== --- qemu-dgibson-for-2.6.git.orig/include/hw/ppc/spapr.h +++ qemu-dgibson-for-2.6.git/include/hw/ppc/spapr.h @@ -561,6 +561,20 @@ struct sPAPREventLogEntry { QTAILQ_ENTRY(sPAPREventLogEntry) next; }; +static inline target_ulong spapr_h_set_mode_resource_addr(target_ulong mflags) +{ + switch (mflags) { + case H_SET_MODE_ADDR_TRANS_NONE: + return 0; + case H_SET_MODE_ADDR_TRANS_0001_8000: + return 0x18000; + case H_SET_MODE_ADDR_TRANS_C000_0000_0000_4000: + return 0xC000000000004000ULL; + default: + return H_UNSUPPORTED_FLAG; + } +} + void spapr_events_init(sPAPRMachineState *sm); void spapr_events_fdt_skel(void *fdt, uint32_t epow_irq); int spapr_h_cas_compose_response(sPAPRMachineState *sm, Index: qemu-dgibson-for-2.6.git/hw/ppc/spapr_hcall.c =================================================================== --- qemu-dgibson-for-2.6.git.orig/hw/ppc/spapr_hcall.c +++ qemu-dgibson-for-2.6.git/hw/ppc/spapr_hcall.c @@ -835,17 +835,8 @@ static target_ulong h_set_mode_resource_ return H_P4; } - switch (mflags) { - case H_SET_MODE_ADDR_TRANS_NONE: - prefix = 0; - break; - case H_SET_MODE_ADDR_TRANS_0001_8000: - prefix = 0x18000; - break; - case H_SET_MODE_ADDR_TRANS_C000_0000_0000_4000: - prefix = 0xC000000000004000ULL; - break; - default: + prefix = spapr_h_set_mode_resource_addr(mflags); + if (prefix == H_UNSUPPORTED_FLAG) { return H_UNSUPPORTED_FLAG; }