From patchwork Tue Jan 24 21:41:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Plotkin X-Patchwork-Id: 719430 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v7M9m18s4z9ryv for ; Wed, 25 Jan 2017 08:43:08 +1100 (AEDT) Received: from localhost ([::1]:55937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cW8rp-0002Rx-OJ for incoming@patchwork.ozlabs.org; Tue, 24 Jan 2017 16:43:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56926) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cW8qz-00020j-75 for qemu-devel@nongnu.org; Tue, 24 Jan 2017 16:42:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cW8qu-0007T8-4F for qemu-devel@nongnu.org; Tue, 24 Jan 2017 16:42:13 -0500 Received: from ol.sdf.org ([205.166.94.20]:64720 helo=mx.sdf.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cW8qb-0007Ql-ML for qemu-devel@nongnu.org; Tue, 24 Jan 2017 16:42:07 -0500 Received: from sdf.lonestar.org (IDENT:caliborn@sdf.lonestar.org [205.166.94.15]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id v0OLfY8U009734 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256 bits) verified NO); Tue, 24 Jan 2017 21:41:35 GMT Date: Tue, 24 Jan 2017 21:41:34 +0000 (UTC) From: Valentin Plotkin X-X-Sender: caliborn@sdf.lonestar.org To: Thomas Huth In-Reply-To: <4b93a2b8-097e-a502-875e-21ea394c617a@redhat.com> Message-ID: References: <4b93a2b8-097e-a502-875e-21ea394c617a@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 205.166.94.20 Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH] PPC: MMU compatibility check. 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-trivial@nongnu.org, qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, "Edgar E. Iglesias" , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" On Tue, 24 Jan 2017, Thomas Huth wrote: > Date: Tue, 24 Jan 2017 21:32:44 +0100 > From: Thomas Huth > To: Valentin Plotkin , qemu-trivial@nongnu.org > Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org > Subject: Re: [Qemu-ppc] [PATCH] PPC: MMU compatibility check. > > On 24.01.2017 19:56, Valentin Plotkin wrote: >> >> Hi everyone, >> >> I looked at the "qemu-system-ppc -nographic -cpu G2leGP3 -M ppce500" on >> the BiteSizedTasks page. The segfault was caused by machine >> initialization code which expected a certain MMU model, checked, so >> unused SPR were read, returning zeros. bamboo and virtex machines are >> affected as well, but it doesn't always cause segfault, usually running >> into unmapped memory and failing somewhat more nicely. >> >> I added the checks. It would be possible to add support for other MMU >> models, but I'm not sure if there is any point (would any guest OS >> support mutually exclusive CPU and machine)? > > Hi, > > great to have a fix for this crash! I don't think it make much sense to > add support for other MMU models here, so the simple checks should be > good enough. > However, your new code obviously does not follow the QEMU coding style. > Could you please run your patch through scripts/checkpatch.pl and fix > all issues that it reports? And when you resubmit, please make sure to > copy the maintainers on CC: as well (scripts/get_maintainers.pl is your > friend here). > > Thanks, > Thomas > > Here is fengshuised version (at least I hope so). Thanks for guiding me. Signed-off-by: Valentin Plotkin --- hw/ppc/e500.c | 6 ++++++ hw/ppc/ppc440_bamboo.c | 6 ++++++ hw/ppc/virtex_ml507.c | 6 ++++++ 3 files changed, 18 insertions(+) tlb->attr = 0; diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index cf8b122..683d9a9 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -631,6 +631,12 @@ static uint64_t mmubooke_initial_mapsize(CPUPPCState *env) static void mmubooke_create_initial_mapping(CPUPPCState *env) { + if (env->mmu_model != POWERPC_MMU_BOOKE206) { + fprintf(stderr, "MMU model %i not supported by this machine.\n", + env->mmu_model); + exit(-1); + } + ppcmas_tlb_t *tlb = booke206_get_tlbm(env, 1, 0, 0); hwaddr size; int ps; diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index 5c535b1..793b758 100644 --- a/hw/ppc/ppc440_bamboo.c +++ b/hw/ppc/ppc440_bamboo.c @@ -124,6 +124,12 @@ static void mmubooke_create_initial_mapping(CPUPPCState *env, target_ulong va, hwaddr pa) { + if (env->mmu_model != POWERPC_MMU_BOOKE) { + fprintf(stderr, "MMU model %i not supported by this machine.\n", + env->mmu_model); + exit(-1); + } + ppcemb_tlb_t *tlb = &env->tlb.tlbe[0]; tlb->attr = 0; diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index b97d966..c01415c 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -69,6 +69,12 @@ static void mmubooke_create_initial_mapping(CPUPPCState *env, target_ulong va, hwaddr pa) { + if (env->mmu_model != POWERPC_MMU_BOOKE) { + fprintf(stderr, "MMU model %i not supported by this machine.\n", + env->mmu_model); + exit(-1); + } + ppcemb_tlb_t *tlb = &env->tlb.tlbe[0];