From patchwork Wed Mar 30 15:38:34 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: 8698641 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 5011A9F44D for ; Wed, 30 Mar 2016 15:39:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 887C12037F for ; Wed, 30 Mar 2016 15:39:07 +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 5822120376 for ; Wed, 30 Mar 2016 15:39:03 +0000 (UTC) Received: from localhost ([::1]:54916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alID0-0006wf-Pu for patchwork-qemu-devel@patchwork.kernel.org; Wed, 30 Mar 2016 11:39:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alICr-0006wN-Eu for qemu-devel@nongnu.org; Wed, 30 Mar 2016 11:38:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1alICo-0000rS-7o for qemu-devel@nongnu.org; Wed, 30 Mar 2016 11:38:53 -0400 Received: from e06smtp09.uk.ibm.com ([195.75.94.105]:33275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alICn-0000r1-Ua for qemu-devel@nongnu.org; Wed, 30 Mar 2016 11:38:50 -0400 Received: from localhost by e06smtp09.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 Mar 2016 16:38:48 +0100 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp09.uk.ibm.com (192.168.101.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 30 Mar 2016 16:38:46 +0100 X-IBM-Helo: d06dlp01.portsmouth.uk.ibm.com X-IBM-MailFrom: clg@fr.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org;qemu-ppc@nongnu.org Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id D5D0417D8042; Wed, 30 Mar 2016 16:39:22 +0100 (BST) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u2UFciI06160708; Wed, 30 Mar 2016 15:38:44 GMT Received: from d06av01.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u2UFciBO031243; Wed, 30 Mar 2016 09:38:44 -0600 Received: from hermes.ibm.com (icon-9-164-173-52.megacenter.de.ibm.com [9.164.173.52]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u2UFchI4031190; Wed, 30 Mar 2016 09:38:43 -0600 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Date: Wed, 30 Mar 2016 17:38:34 +0200 Message-Id: <1459352314-12552-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: 16033015-0037-0000-0000-000009702371 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.105 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 v2] 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 restored when migrating a spapr VM running in TCG. This can be done using the AIL bits from the LPCR register. The patch introduces a helper routine cpu_ppc_get_excp_prefix() which returns the effective address offset of the interrupt handler depending on the LPCR_AIL bits. The same helper can be used in the H_SET_MODE hcall, which lets us remove the H_SET_MODE_ADDR_TRANS_* defines. Signed-off-by: Cédric Le Goater Reviewed-by: Greg Kurz --- Changes since v1: - moved helper routine under target-ppc/ - moved the restore of excp_prefix under cpu_post_load() hw/ppc/spapr_hcall.c | 13 ++----------- include/hw/ppc/spapr.h | 5 ----- target-ppc/cpu.h | 9 +++++++++ target-ppc/machine.c | 20 +++++++++++++++++++- target-ppc/translate_init.c | 14 ++++++++++++++ 5 files changed, 44 insertions(+), 17 deletions(-) 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 = cpu_ppc_get_excp_prefix(mflags); + if (prefix == (target_ulong) -1ULL) { return H_UNSUPPORTED_FLAG; } Index: qemu-dgibson-for-2.6.git/target-ppc/machine.c =================================================================== --- qemu-dgibson-for-2.6.git.orig/target-ppc/machine.c +++ qemu-dgibson-for-2.6.git/target-ppc/machine.c @@ -156,12 +156,26 @@ static void cpu_pre_save(void *opaque) } } + +static int cpu_post_load_excp_prefix(CPUPPCState *env) +{ + int ail = (env->spr[SPR_LPCR] & LPCR_AIL) >> LPCR_AIL_SHIFT; + target_ulong prefix = cpu_ppc_get_excp_prefix(ail); + + if (prefix == (target_ulong) -1ULL) { + return -EINVAL; + } + env->excp_prefix = prefix; + return 0; +} + static int cpu_post_load(void *opaque, int version_id) { PowerPCCPU *cpu = opaque; CPUPPCState *env = &cpu->env; int i; target_ulong msr; + int ret = 0; /* * We always ignore the source PVR. The user or management @@ -201,7 +215,11 @@ static int cpu_post_load(void *opaque, i hreg_compute_mem_idx(env); - return 0; + if (env->spr[SPR_LPCR] & LPCR_AIL) { + ret = cpu_post_load_excp_prefix(env); + } + + return ret; } static bool fpu_needed(void *opaque) Index: qemu-dgibson-for-2.6.git/target-ppc/translate_init.c =================================================================== --- qemu-dgibson-for-2.6.git.orig/target-ppc/translate_init.c +++ qemu-dgibson-for-2.6.git/target-ppc/translate_init.c @@ -8522,6 +8522,20 @@ void cpu_ppc_set_papr(PowerPCCPU *cpu) } } +target_ulong cpu_ppc_get_excp_prefix(target_ulong ail) +{ + switch (ail) { + case AIL_NONE: + return 0; + case AIL_0001_8000: + return 0x18000; + case AIL_C000_0000_0000_4000: + return 0xC000000000004000ULL; + default: + return (target_ulong) -1ULL; + } +} + #endif /* !defined(CONFIG_USER_ONLY) */ #endif /* defined (TARGET_PPC64) */ Index: qemu-dgibson-for-2.6.git/target-ppc/cpu.h =================================================================== --- qemu-dgibson-for-2.6.git.orig/target-ppc/cpu.h +++ qemu-dgibson-for-2.6.git/target-ppc/cpu.h @@ -1269,6 +1269,7 @@ void store_booke_tsr (CPUPPCState *env, void ppc_tlb_invalidate_all (CPUPPCState *env); void ppc_tlb_invalidate_one (CPUPPCState *env, target_ulong addr); void cpu_ppc_set_papr(PowerPCCPU *cpu); +target_ulong cpu_ppc_get_excp_prefix(target_ulong ail); #endif #endif @@ -2277,6 +2278,14 @@ enum { HMER_XSCOM_STATUS_LSH = (63 - 23), }; +/* Alternate Interrupt Location (AIL) */ +enum { + AIL_NONE = 0, + AIL_RESERVED = 1, + AIL_0001_8000 = 2, + AIL_C000_0000_0000_4000 = 3, +}; + /*****************************************************************************/ static inline target_ulong cpu_read_xer(CPUPPCState *env) 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 @@ -204,11 +204,6 @@ struct sPAPRMachineState { #define H_SET_MODE_ENDIAN_BIG 0 #define H_SET_MODE_ENDIAN_LITTLE 1 -/* Flags for H_SET_MODE_RESOURCE_ADDR_TRANS_MODE */ -#define H_SET_MODE_ADDR_TRANS_NONE 0 -#define H_SET_MODE_ADDR_TRANS_0001_8000 2 -#define H_SET_MODE_ADDR_TRANS_C000_0000_0000_4000 3 - /* VASI States */ #define H_VASI_INVALID 0 #define H_VASI_ENABLED 1