From patchwork Sun Jun 5 17:41:50 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: 9155647 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 3B06360467 for ; Sun, 5 Jun 2016 17:42:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 303A127B13 for ; Sun, 5 Jun 2016 17:42:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24745282EE; Sun, 5 Jun 2016 17:42:26 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 4538127B13 for ; Sun, 5 Jun 2016 17:42:24 +0000 (UTC) Received: from localhost ([::1]:38116 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9c46-0003v4-Ef for patchwork-qemu-devel@patchwork.kernel.org; Sun, 05 Jun 2016 13:42:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9c3n-0003ty-Nw for qemu-devel@nongnu.org; Sun, 05 Jun 2016 13:42:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9c3i-0003Y3-Eu for qemu-devel@nongnu.org; Sun, 05 Jun 2016 13:42:03 -0400 Received: from 1.mo68.mail-out.ovh.net ([46.105.41.146]:42243) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9c3i-0003Xl-5E for qemu-devel@nongnu.org; Sun, 05 Jun 2016 13:41:58 -0400 Received: from player695.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id B9D001000CBA for ; Sun, 5 Jun 2016 19:41:55 +0200 (CEST) Received: from [192.168.124.3] (LFbn-1-2234-107.w90-76.abo.wanadoo.fr [90.76.55.107]) (Authenticated sender: clg@kaod.org) by player695.ha.ovh.net (Postfix) with ESMTPSA id E9566460073; Sun, 5 Jun 2016 19:41:50 +0200 (CEST) To: Mark Cave-Ayland , David Gibson References: <1464955880-10176-1-git-send-email-clg@kaod.org> <57518BA1.1030400@ilande.co.uk> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Message-ID: <5754645E.8080504@kaod.org> Date: Sun, 5 Jun 2016 19:41:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.8.0 MIME-Version: 1.0 In-Reply-To: <57518BA1.1030400@ilande.co.uk> X-Ovh-Tracer-Id: 7233625428118768448 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeekledrieejgdduudeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 46.105.41.146 Subject: Re: [Qemu-devel] [PATCH 0/3] ppc: complete the new HV mode 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: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Hello Mark, On 06/03/2016 03:52 PM, Mark Cave-Ayland wrote: > On 03/06/16 13:11, Cédric Le Goater wrote: > >> This is follow up to complete the serie "ppc: preparing pnv landing >> (round 2)" plus a little fix on instruction privileges. >> >> Tested on a POWER8 pserie guest and on mac99. >> >> Benjamin Herrenschmidt (2): >> ppc: Fix hreg_store_msr() so that non-HV mode cannot alter MSR:HV >> ppc: Better figure out if processor has HV mode >> >> Cédric Le Goater (1): >> ppc: fix hrfid, tlbia and slbia privilege >> >> target-ppc/cpu.h | 4 ++++ >> target-ppc/excp_helper.c | 8 ++++++-- >> target-ppc/helper_regs.h | 4 ++-- >> target-ppc/translate.c | 10 ++++++---- >> target-ppc/translate_init.c | 19 +++++++++++++++---- >> 5 files changed, 33 insertions(+), 12 deletions(-) > > Hi Cédric, > > I can confirm that this patchset fixes starting up OpenBIOS for both > g3beige/mac99 in my tests here. With the escc fix also applied, the only > outstanding issue is the removal of the tlb_flush() statements which > causes Darwin, MacOS X and HelenOS 0.60 to panic on boot > > My only request is if it would be possible to move patch 2 "ppc: Better > figure out if processor has HV mode" to the front of this patchset which > will make the remaining patches bisectable for the Mac machines. With that: > > Tested-by: Mark Cave-Ayland > > Does anyone know if Ben has any ideas as to why the MMU tlb_flush > changes patch is causing such problems? Here is a fix I think. Could you give it a try ? Cheers, C. From: Cédric Le Goater Subject: [PATCH] ppc: fix tlb flushes for 32bit environment Date: Sun, 05 Jun 2016 18:46:19 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit cd0c6f473532 ('ppc: Do some batching of TCG tlb flushes') introduced an optimisation to flush TLBs only when a context synchronizing event is reached (interrupt, rfi). This was done for ppc64 but 32bit was forgotten on the way. Tested on mac99 and g3beige with qemu-system-ppc -cdrom darwinppc-602.cdr -boot d Signed-off-by: Cédric Le Goater Tested-by: Mark Cave-Ayland --- I think the hunk in powerpc_excp() is needed if we don't generate a context synchronizing event. what is best to do ? target-ppc/cpu.h | 2 +- target-ppc/excp_helper.c | 10 ++++++++++ target-ppc/helper_regs.h | 9 ++++++++- target-ppc/translate.c | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) Index: qemu-dgibson-for-2.7.git/target-ppc/translate.c =================================================================== --- qemu-dgibson-for-2.7.git.orig/target-ppc/translate.c +++ qemu-dgibson-for-2.7.git/target-ppc/translate.c @@ -3290,7 +3290,7 @@ static void gen_eieio(DisasContext *ctx) { } -#if !defined(CONFIG_USER_ONLY) && defined(TARGET_PPC64) +#if !defined(CONFIG_USER_ONLY) static inline void gen_check_tlb_flush(DisasContext *ctx) { TCGv_i32 t = tcg_temp_new_i32(); Index: qemu-dgibson-for-2.7.git/target-ppc/cpu.h =================================================================== --- qemu-dgibson-for-2.7.git.orig/target-ppc/cpu.h +++ qemu-dgibson-for-2.7.git/target-ppc/cpu.h @@ -958,9 +958,9 @@ struct CPUPPCState { /* PowerPC 64 SLB area */ ppc_slb_t slb[MAX_SLB_ENTRIES]; int32_t slb_nr; +#endif /* tcg TLB needs flush (deferred slb inval instruction typically) */ uint32_t tlb_need_flush; -#endif /* segment registers */ hwaddr htab_base; /* mask used to normalize hash value to PTEG index */ Index: qemu-dgibson-for-2.7.git/target-ppc/helper_regs.h =================================================================== --- qemu-dgibson-for-2.7.git.orig/target-ppc/helper_regs.h +++ qemu-dgibson-for-2.7.git/target-ppc/helper_regs.h @@ -121,6 +121,13 @@ static inline int hreg_store_msr(CPUPPCS } if (((value >> MSR_IR) & 1) != msr_ir || ((value >> MSR_DR) & 1) != msr_dr) { + /* A change of the instruction relocation bit in the MSR can + * cause an implicit branch in the address space. This + * requires a tlb flush. + */ + if (env->mmu_model & POWERPC_MMU_32B) { + env->tlb_need_flush = 1; + } cs->interrupt_request |= CPU_INTERRUPT_EXITTB; } if ((env->mmu_model & POWERPC_MMU_BOOKE) && @@ -151,7 +158,7 @@ static inline int hreg_store_msr(CPUPPCS return excp; } -#if !defined(CONFIG_USER_ONLY) && defined(TARGET_PPC64) +#if !defined(CONFIG_USER_ONLY) static inline void check_tlb_flush(CPUPPCState *env) { CPUState *cs = CPU(ppc_env_get_cpu(env)); Index: qemu-dgibson-for-2.7.git/target-ppc/excp_helper.c =================================================================== --- qemu-dgibson-for-2.7.git.orig/target-ppc/excp_helper.c +++ qemu-dgibson-for-2.7.git/target-ppc/excp_helper.c @@ -709,6 +709,16 @@ static inline void powerpc_excp(PowerPCC } } #endif + if (((new_msr >> MSR_IR) & 1) != msr_ir || + ((new_msr >> MSR_DR) & 1) != msr_dr) { + /* A change of the instruction relocation bit in the MSR can + * cause an implicit branch in the address space. This + * requires a tlb flush. + */ + if (env->mmu_model & POWERPC_MMU_32B) { + env->tlb_need_flush = 1; + } + } /* We don't use hreg_store_msr here as already have treated * any special case that could occur. Just store MSR and update hflags *