[{"id":1766344,"web_url":"http://patchwork.ozlabs.org/comment/1766344/","msgid":"<CAFEAcA_G8mEzB0Mox0TTz578LQKXgvhNHeZ8Bk7OwC4NbqiXPg@mail.gmail.com>","list_archive_url":null,"date":"2017-09-11T14:39:01","subject":"Re: [Qemu-devel] [PATCH v2 2/3] hmp: fix \"dump-quest-memory\"\n\tsegfault (arm)","submitter":{"id":5111,"url":"http://patchwork.ozlabs.org/api/people/5111/","name":"Peter Maydell","email":"peter.maydell@linaro.org"},"content":"On 11 September 2017 at 15:20, Laurent Vivier <lvivier@redhat.com> wrote:\n> Commit fd5d23babf (hmp: fix \"dump-quest-memory\" segfault)\n> fixes the problem for i386, do the same for arm.\n>\n> Running QEMU with\n>     qemu-system-aarch64 -M none -nographic -m 256\n> and executing\n>     dump-guest-memory /dev/null 0 8192\n> results in segfault\n>\n> Fix by checking if we have CPU.\n>\n> Signed-off-by: Laurent Vivier <lvivier@redhat.com>\n\nIt seems a little arbitrary to assume that if there's no\nCPU what you wanted was a 32-bit little-endian dump.\n\nWhy do we have a machine without a CPU anyway ?\n\nthanks\n-- PMM","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"WdopzJD+\"; dkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrVvR3vNBz9s81\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 00:40:03 +1000 (AEST)","from localhost ([::1]:58148 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1drPsX-0001XD-N3\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 10:40:01 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:56987)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <peter.maydell@linaro.org>) id 1drPrw-0001Uy-Ij\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 10:39:25 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <peter.maydell@linaro.org>) id 1drPrv-0007Ww-Mb\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 10:39:24 -0400","from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]:45634)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <peter.maydell@linaro.org>)\n\tid 1drPrv-0007WA-Fm\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 10:39:23 -0400","by mail-wm0-x22f.google.com with SMTP id f199so41494434wme.0\n\tfor <qemu-devel@nongnu.org>; Mon, 11 Sep 2017 07:39:23 -0700 (PDT)","by 10.223.139.215 with HTTP; Mon, 11 Sep 2017 07:39:01 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=MuMo85r3apztMDgni/MRHqbhbTvHnGiBWEk4ElK3hTU=;\n\tb=WdopzJD+uxNH1f/SES70MCec0UOAKVSAqD1jEBwwFliPaZ0ksm+XJzpn0bJjtS7j6H\n\tiTRGpB9g8V/5EX3nhj03d3OhpniWCWWe40L/kfL9tpIlE5qDQnPB6P3pGzVEv+2FbCE3\n\tAvVlPC2aamFN9FKuBlkdBUNgNtoi/5Sw/SFpg=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=MuMo85r3apztMDgni/MRHqbhbTvHnGiBWEk4ElK3hTU=;\n\tb=HbV6ocWi+X5zl5WEnSAY14PHmN1BvbsMSG0xU+lJ2hqHaRyqF1tf36r/H92FZu6PdE\n\tclKB2WVTz1WqRJHl7E4esI4IR3xa6Suz24EPFGcD+wLkgDYN98PFuneR2/H5R3vYwduf\n\ttBIt1s9LfsKIRseAUzzi5qhO9E3sCaFkqB7/YZQ+06ioJSiYiBxKI8RctyMu2bhLlntN\n\t/G2RnQfYXiZJrLFwBizGhBQwAQsY8WN7Fl3Y9PrjlELASqKoTPydPK2MWtdHuxk6b4UM\n\txPY+u7ikKu+YQfwhpJzHz9txsaWTekh9w/KMXGlnkVEPl05qbg5gEKrBhTCnBQwwoBH2\n\tFJCA==","X-Gm-Message-State":"AHPjjUjoGiRACwPoCKk8ogeC5V3yKvg/mXPjZ8Bnx6q+i88Qu2Oag0lb\n\tdCuBJfLmysqy+8NlOngrZC8L+7aa3m9t","X-Google-Smtp-Source":"AOwi7QDUU26/F8WNKgFhxUEpXXW/9JnQZIylG6VhsUlNzC3iMM2P+0+b3SXDdp4v0dOhQRELB7jMCxOiLJfxUwwN8v0=","X-Received":"by 10.28.52.81 with SMTP id b78mr7037885wma.11.1505140762224;\n\tMon, 11 Sep 2017 07:39:22 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<20170911142056.15643-3-lvivier@redhat.com>","References":"<20170911142056.15643-1-lvivier@redhat.com>\n\t<20170911142056.15643-3-lvivier@redhat.com>","From":"Peter Maydell <peter.maydell@linaro.org>","Date":"Mon, 11 Sep 2017 15:39:01 +0100","Message-ID":"<CAFEAcA_G8mEzB0Mox0TTz578LQKXgvhNHeZ8Bk7OwC4NbqiXPg@mail.gmail.com>","To":"Laurent Vivier <lvivier@redhat.com>","Content-Type":"text/plain; charset=\"UTF-8\"","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2a00:1450:400c:c09::22f","Subject":"Re: [Qemu-devel] [PATCH v2 2/3] hmp: fix \"dump-quest-memory\"\n\tsegfault (arm)","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Thomas Huth <thuth@redhat.com>, Cornelia Huck <cohuck@redhat.com>,\n\tQEMU Developers <qemu-devel@nongnu.org>,\n\t\"Dr . David Alan Gilbert\" <dgilbert@redhat.com>,\n\tGreg Kurz <groug@kaod.org>, qemu-arm <qemu-arm@nongnu.org>,\n\t\"qemu-ppc@nongnu.org\" <qemu-ppc@nongnu.org>,\n\tDavid Gibson <david@gibson.dropbear.id.au>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1766348,"web_url":"http://patchwork.ozlabs.org/comment/1766348/","msgid":"<889d6ce7-073f-7860-e091-619c1202b1cd@redhat.com>","list_archive_url":null,"date":"2017-09-11T14:45:22","subject":"Re: [Qemu-devel] [PATCH v2 2/3] hmp: fix \"dump-quest-memory\"\n\tsegfault (arm)","submitter":{"id":66152,"url":"http://patchwork.ozlabs.org/api/people/66152/","name":"Thomas Huth","email":"thuth@redhat.com"},"content":"On 11.09.2017 16:39, Peter Maydell wrote:\n> On 11 September 2017 at 15:20, Laurent Vivier <lvivier@redhat.com> wrote:\n>> Commit fd5d23babf (hmp: fix \"dump-quest-memory\" segfault)\n>> fixes the problem for i386, do the same for arm.\n>>\n>> Running QEMU with\n>>     qemu-system-aarch64 -M none -nographic -m 256\n>> and executing\n>>     dump-guest-memory /dev/null 0 8192\n>> results in segfault\n>>\n>> Fix by checking if we have CPU.\n>>\n>> Signed-off-by: Laurent Vivier <lvivier@redhat.com>\n> \n> It seems a little arbitrary to assume that if there's no\n> CPU what you wanted was a 32-bit little-endian dump.\n> \n> Why do we have a machine without a CPU anyway ?\n\nThe \"none\" machine is always started without a default CPU.\n\n Thomas","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=thuth@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrW3C53Z7z9s4q\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 00:46:47 +1000 (AEST)","from localhost ([::1]:58197 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1drPz3-00059n-Sg\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 10:46:45 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:59394)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <thuth@redhat.com>) id 1drPxt-0004SK-0C\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 10:45:33 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <thuth@redhat.com>) id 1drPxs-0003DJ-9d\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 10:45:33 -0400","from mx1.redhat.com ([209.132.183.28]:35552)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <thuth@redhat.com>)\n\tid 1drPxn-00039n-5X; Mon, 11 Sep 2017 10:45:27 -0400","from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 2091732D306;\n\tMon, 11 Sep 2017 14:45:26 +0000 (UTC)","from [10.36.116.113] (ovpn-116-113.ams2.redhat.com [10.36.116.113])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 9C29A5C898;\n\tMon, 11 Sep 2017 14:45:23 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 2091732D306","To":"Peter Maydell <peter.maydell@linaro.org>,\n\tLaurent Vivier <lvivier@redhat.com>","References":"<20170911142056.15643-1-lvivier@redhat.com>\n\t<20170911142056.15643-3-lvivier@redhat.com>\n\t<CAFEAcA_G8mEzB0Mox0TTz578LQKXgvhNHeZ8Bk7OwC4NbqiXPg@mail.gmail.com>","From":"Thomas Huth <thuth@redhat.com>","Message-ID":"<889d6ce7-073f-7860-e091-619c1202b1cd@redhat.com>","Date":"Mon, 11 Sep 2017 16:45:22 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<CAFEAcA_G8mEzB0Mox0TTz578LQKXgvhNHeZ8Bk7OwC4NbqiXPg@mail.gmail.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.16","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.30]);\n\tMon, 11 Sep 2017 14:45:26 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v2 2/3] hmp: fix \"dump-quest-memory\"\n\tsegfault (arm)","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Cornelia Huck <cohuck@redhat.com>,\n\tQEMU Developers <qemu-devel@nongnu.org>, \n\t\"Dr . David Alan Gilbert\" <dgilbert@redhat.com>,\n\tGreg Kurz <groug@kaod.org>, qemu-arm <qemu-arm@nongnu.org>,\n\t\"qemu-ppc@nongnu.org\" <qemu-ppc@nongnu.org>,\n\tDavid Gibson <david@gibson.dropbear.id.au>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1766355,"web_url":"http://patchwork.ozlabs.org/comment/1766355/","msgid":"<20170911170804.0ee06c00@bahia.lan>","list_archive_url":null,"date":"2017-09-11T15:08:04","subject":"Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 2/3] hmp: fix\n\t\"dump-quest-memory\" segfault (arm)","submitter":{"id":69178,"url":"http://patchwork.ozlabs.org/api/people/69178/","name":"Greg Kurz","email":"groug@kaod.org"},"content":"On Mon, 11 Sep 2017 16:20:55 +0200\nLaurent Vivier <lvivier@redhat.com> wrote:\n\n> Commit fd5d23babf (hmp: fix \"dump-quest-memory\" segfault)\n> fixes the problem for i386, do the same for arm.\n> \n> Running QEMU with\n>     qemu-system-aarch64 -M none -nographic -m 256\n> and executing\n>     dump-guest-memory /dev/null 0 8192\n> results in segfault\n> \n> Fix by checking if we have CPU.\n> \n> Signed-off-by: Laurent Vivier <lvivier@redhat.com>\n> ---\n>  target/arm/arch_dump.c | 52 +++++++++++++++++++++++++++++++++-----------------\n>  1 file changed, 34 insertions(+), 18 deletions(-)\n> \n> diff --git a/target/arm/arch_dump.c b/target/arm/arch_dump.c\n> index 1a9861f69b..1f58cff256 100644\n> --- a/target/arm/arch_dump.c\n> +++ b/target/arm/arch_dump.c\n> @@ -273,8 +273,6 @@ int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs,\n>  int cpu_get_dump_info(ArchDumpInfo *info,\n>                        const GuestPhysBlockList *guest_phys_blocks)\n>  {\n> -    ARMCPU *cpu = ARM_CPU(first_cpu);\n> -    CPUARMState *env = &cpu->env;\n>      GuestPhysBlock *block;\n>      hwaddr lowest_addr = ULLONG_MAX;\n>  \n> @@ -290,13 +288,32 @@ int cpu_get_dump_info(ArchDumpInfo *info,\n>          }\n>      }\n>  \n> -    if (arm_feature(env, ARM_FEATURE_AARCH64)) {\n> -        info->d_machine = EM_AARCH64;\n> -        info->d_class = ELFCLASS64;\n> -        info->page_size = (1 << 16); /* aarch64 max pagesize */\n> -        if (lowest_addr != ULLONG_MAX) {\n> -            info->phys_base = lowest_addr;\n> +    if (first_cpu) {\n> +        ARMCPU *cpu = ARM_CPU(first_cpu);\n> +        CPUARMState *env = &cpu->env;\n> +        if (arm_feature(env, ARM_FEATURE_AARCH64)) {\n> +            info->d_machine = EM_AARCH64;\n> +            info->d_class = ELFCLASS64;\n> +            info->page_size = (1 << 16); /* aarch64 max pagesize */\n> +            if (lowest_addr != ULLONG_MAX) {\n> +                info->phys_base = lowest_addr;\n> +            }\n> +        } else {\n> +            info->d_machine = EM_ARM;\n> +            info->d_class = ELFCLASS32;\n> +            info->page_size = (1 << 12);\n> +            if (lowest_addr < UINT_MAX) {\n> +                info->phys_base = lowest_addr;\n> +            }\n>          }\n> +\n> +        /* We assume the relevant endianness is that of EL1; this is right\n> +         * for kernels, but might give the wrong answer if you're trying to\n> +         * dump a hypervisor that happens to be running an opposite-endian\n> +         * kernel.\n> +         */\n> +        info->d_endian = (env->cp15.sctlr_el[1] & SCTLR_EE) != 0\n> +                         ? ELFDATA2MSB : ELFDATA2LSB;\n>      } else {\n>          info->d_machine = EM_ARM;\n>          info->d_class = ELFCLASS32;\n> @@ -304,25 +321,24 @@ int cpu_get_dump_info(ArchDumpInfo *info,\n>          if (lowest_addr < UINT_MAX) {\n>              info->phys_base = lowest_addr;\n>          }\n> +        info->d_endian = ELFDATA2LSB;\n>      }\n>  \n> -    /* We assume the relevant endianness is that of EL1; this is right\n> -     * for kernels, but might give the wrong answer if you're trying to\n> -     * dump a hypervisor that happens to be running an opposite-endian\n> -     * kernel.\n> -     */\n> -    info->d_endian = (env->cp15.sctlr_el[1] & SCTLR_EE) != 0\n> -                     ? ELFDATA2MSB : ELFDATA2LSB;\n> -\n>      return 0;\n>  }\n>  \n>  ssize_t cpu_get_note_size(int class, int machine, int nr_cpus)\n>  {\n> -    ARMCPU *cpu = ARM_CPU(first_cpu);\n> -    CPUARMState *env = &cpu->env;\n> +    ARMCPU *cpu;\n> +    CPUARMState *env;\n>      size_t note_size;\n>  \n> +    if (first_cpu == NULL) {\n> +        return 0;\n> +    }\n> +\n\nLooking at the function's code, it seems that env is only needed if\nclass != ELFCLASS64... I guess that all the code dealing with first_cpu\nshould go to the else block.\n\n> +    cpu = ARM_CPU(first_cpu);\n> +    env = &cpu->env;\n>      if (class == ELFCLASS64) {\n>          note_size = AARCH64_PRSTATUS_NOTE_SIZE;\n>          note_size += AARCH64_PRFPREG_NOTE_SIZE;","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrWbz6d03z9s7C\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 01:11:43 +1000 (AEST)","from localhost ([::1]:58337 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1drQNB-0007FE-Un\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 11:11:41 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:41432)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <groug@kaod.org>) id 1drQMZ-0007Ev-Ao\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 11:11:04 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <groug@kaod.org>) id 1drQMV-00030V-53\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 11:11:03 -0400","from 12.mo1.mail-out.ovh.net ([87.98.162.229]:36735)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <groug@kaod.org>) id 1drQMU-0002ze-SS\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 11:10:59 -0400","from player169.ha.ovh.net (b9.ovh.net [213.186.33.59])\n\tby mo1.mail-out.ovh.net (Postfix) with ESMTP id 1056193640\n\tfor <qemu-devel@nongnu.org>; Mon, 11 Sep 2017 17:10:57 +0200 (CEST)","from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139])\n\t(Authenticated sender: groug@kaod.org)\n\tby player169.ha.ovh.net (Postfix) with ESMTPSA id 3B19F5800A2;\n\tMon, 11 Sep 2017 17:10:45 +0200 (CEST)"],"Date":"Mon, 11 Sep 2017 17:08:04 +0200","From":"Greg Kurz <groug@kaod.org>","To":"Laurent Vivier <lvivier@redhat.com>","Message-ID":"<20170911170804.0ee06c00@bahia.lan>","In-Reply-To":"<20170911142056.15643-3-lvivier@redhat.com>","References":"<20170911142056.15643-1-lvivier@redhat.com>\n\t<20170911142056.15643-3-lvivier@redhat.com>","X-Mailer":"Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu)","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha1;\n\tboundary=\"Sig_/x60EAfplRCPZUs_wUeQDKkr\";\n\tprotocol=\"application/pgp-signature\"","X-Ovh-Tracer-Id":"12069647002008262950","X-VR-SPAMSTATE":"OK","X-VR-SPAMSCORE":"-100","X-VR-SPAMCAUSE":"gggruggvucftvghtrhhoucdtuddrfeelledrgedtgdeklecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"87.98.162.229","Subject":"Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 2/3] hmp: fix\n\t\"dump-quest-memory\" segfault (arm)","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Peter Maydell <peter.maydell@linaro.org>, Thomas Huth <thuth@redhat.com>,\n\tCornelia Huck <cohuck@redhat.com>, qemu-devel@nongnu.org,\n\t\"Dr . David Alan Gilbert\" <dgilbert@redhat.com>,\n\tqemu-arm@nongnu.org, qemu-ppc@nongnu.org,\n\tDavid Gibson <david@gibson.dropbear.id.au>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1766366,"web_url":"http://patchwork.ozlabs.org/comment/1766366/","msgid":"<5b7621f0-072f-9bf0-c4bb-23f85a8faaec@redhat.com>","list_archive_url":null,"date":"2017-09-11T15:25:23","subject":"Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 2/3] hmp: fix\n\t\"dump-quest-memory\" segfault (arm)","submitter":{"id":66421,"url":"http://patchwork.ozlabs.org/api/people/66421/","name":"Laurent Vivier","email":"lvivier@redhat.com"},"content":"On 11/09/2017 17:08, Greg Kurz wrote:\n> On Mon, 11 Sep 2017 16:20:55 +0200\n> Laurent Vivier <lvivier@redhat.com> wrote:\n> \n>> Commit fd5d23babf (hmp: fix \"dump-quest-memory\" segfault)\n>> fixes the problem for i386, do the same for arm.\n>>\n>> Running QEMU with\n>>     qemu-system-aarch64 -M none -nographic -m 256\n>> and executing\n>>     dump-guest-memory /dev/null 0 8192\n>> results in segfault\n>>\n>> Fix by checking if we have CPU.\n>>\n>> Signed-off-by: Laurent Vivier <lvivier@redhat.com>\n>> ---\n>>  target/arm/arch_dump.c | 52 +++++++++++++++++++++++++++++++++-----------------\n>>  1 file changed, 34 insertions(+), 18 deletions(-)\n>>\n>> diff --git a/target/arm/arch_dump.c b/target/arm/arch_dump.c\n>> index 1a9861f69b..1f58cff256 100644\n>> --- a/target/arm/arch_dump.c\n>> +++ b/target/arm/arch_dump.c\n>> @@ -273,8 +273,6 @@ int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs,\n>>  int cpu_get_dump_info(ArchDumpInfo *info,\n>>                        const GuestPhysBlockList *guest_phys_blocks)\n>>  {\n>> -    ARMCPU *cpu = ARM_CPU(first_cpu);\n>> -    CPUARMState *env = &cpu->env;\n>>      GuestPhysBlock *block;\n>>      hwaddr lowest_addr = ULLONG_MAX;\n>>  \n>> @@ -290,13 +288,32 @@ int cpu_get_dump_info(ArchDumpInfo *info,\n>>          }\n>>      }\n>>  \n>> -    if (arm_feature(env, ARM_FEATURE_AARCH64)) {\n>> -        info->d_machine = EM_AARCH64;\n>> -        info->d_class = ELFCLASS64;\n>> -        info->page_size = (1 << 16); /* aarch64 max pagesize */\n>> -        if (lowest_addr != ULLONG_MAX) {\n>> -            info->phys_base = lowest_addr;\n>> +    if (first_cpu) {\n>> +        ARMCPU *cpu = ARM_CPU(first_cpu);\n>> +        CPUARMState *env = &cpu->env;\n>> +        if (arm_feature(env, ARM_FEATURE_AARCH64)) {\n>> +            info->d_machine = EM_AARCH64;\n>> +            info->d_class = ELFCLASS64;\n>> +            info->page_size = (1 << 16); /* aarch64 max pagesize */\n>> +            if (lowest_addr != ULLONG_MAX) {\n>> +                info->phys_base = lowest_addr;\n>> +            }\n>> +        } else {\n>> +            info->d_machine = EM_ARM;\n>> +            info->d_class = ELFCLASS32;\n>> +            info->page_size = (1 << 12);\n>> +            if (lowest_addr < UINT_MAX) {\n>> +                info->phys_base = lowest_addr;\n>> +            }\n>>          }\n>> +\n>> +        /* We assume the relevant endianness is that of EL1; this is right\n>> +         * for kernels, but might give the wrong answer if you're trying to\n>> +         * dump a hypervisor that happens to be running an opposite-endian\n>> +         * kernel.\n>> +         */\n>> +        info->d_endian = (env->cp15.sctlr_el[1] & SCTLR_EE) != 0\n>> +                         ? ELFDATA2MSB : ELFDATA2LSB;\n>>      } else {\n>>          info->d_machine = EM_ARM;\n>>          info->d_class = ELFCLASS32;\n>> @@ -304,25 +321,24 @@ int cpu_get_dump_info(ArchDumpInfo *info,\n>>          if (lowest_addr < UINT_MAX) {\n>>              info->phys_base = lowest_addr;\n>>          }\n>> +        info->d_endian = ELFDATA2LSB;\n>>      }\n>>  \n>> -    /* We assume the relevant endianness is that of EL1; this is right\n>> -     * for kernels, but might give the wrong answer if you're trying to\n>> -     * dump a hypervisor that happens to be running an opposite-endian\n>> -     * kernel.\n>> -     */\n>> -    info->d_endian = (env->cp15.sctlr_el[1] & SCTLR_EE) != 0\n>> -                     ? ELFDATA2MSB : ELFDATA2LSB;\n>> -\n>>      return 0;\n>>  }\n>>  \n>>  ssize_t cpu_get_note_size(int class, int machine, int nr_cpus)\n>>  {\n>> -    ARMCPU *cpu = ARM_CPU(first_cpu);\n>> -    CPUARMState *env = &cpu->env;\n>> +    ARMCPU *cpu;\n>> +    CPUARMState *env;\n>>      size_t note_size;\n>>  \n>> +    if (first_cpu == NULL) {\n>> +        return 0;\n>> +    }\n>> +\n> \n> Looking at the function's code, it seems that env is only needed if\n> class != ELFCLASS64... I guess that all the code dealing with first_cpu\n> should go to the else block.\n\nif first_cpu is NULL, nr_cpus is 0 and the function always returns 0.\n\nThanks,\nLaurent","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx01.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx01.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=lvivier@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrXJd4cZPz9s7B\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 01:43:29 +1000 (AEST)","from localhost ([::1]:58506 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1drQrv-0005lC-Oj\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 11:43:27 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:50268)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <lvivier@redhat.com>) id 1drQaf-0007B5-3w\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 11:25:38 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <lvivier@redhat.com>) id 1drQae-0007ZB-07\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 11:25:37 -0400","from mx1.redhat.com ([209.132.183.28]:53566)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <lvivier@redhat.com>)\n\tid 1drQaW-0007Jv-4I; Mon, 11 Sep 2017 11:25:28 -0400","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 17F46C3FB2;\n\tMon, 11 Sep 2017 15:25:27 +0000 (UTC)","from [10.36.116.239] (ovpn-116-239.ams2.redhat.com [10.36.116.239])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id BD71660A98;\n\tMon, 11 Sep 2017 15:25:24 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 17F46C3FB2","To":"Greg Kurz <groug@kaod.org>","References":"<20170911142056.15643-1-lvivier@redhat.com>\n\t<20170911142056.15643-3-lvivier@redhat.com>\n\t<20170911170804.0ee06c00@bahia.lan>","From":"Laurent Vivier <lvivier@redhat.com>","Message-ID":"<5b7621f0-072f-9bf0-c4bb-23f85a8faaec@redhat.com>","Date":"Mon, 11 Sep 2017 17:25:23 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170911170804.0ee06c00@bahia.lan>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.13","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.25]);\n\tMon, 11 Sep 2017 15:25:27 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 2/3] hmp: fix\n\t\"dump-quest-memory\" segfault (arm)","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Peter Maydell <peter.maydell@linaro.org>, Thomas Huth <thuth@redhat.com>,\n\tCornelia Huck <cohuck@redhat.com>, qemu-devel@nongnu.org,\n\t\"Dr . David Alan Gilbert\" <dgilbert@redhat.com>,\n\tqemu-arm@nongnu.org, qemu-ppc@nongnu.org,\n\tDavid Gibson <david@gibson.dropbear.id.au>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1766369,"web_url":"http://patchwork.ozlabs.org/comment/1766369/","msgid":"<309f01b9-3066-60fd-47d5-5206ae6360ed@redhat.com>","list_archive_url":null,"date":"2017-09-11T15:35:34","subject":"Re: [Qemu-devel] [PATCH v2 2/3] hmp: fix \"dump-quest-memory\"\n\tsegfault (arm)","submitter":{"id":66421,"url":"http://patchwork.ozlabs.org/api/people/66421/","name":"Laurent Vivier","email":"lvivier@redhat.com"},"content":"On 11/09/2017 16:39, Peter Maydell wrote:\n> On 11 September 2017 at 15:20, Laurent Vivier <lvivier@redhat.com> wrote:\n>> Commit fd5d23babf (hmp: fix \"dump-quest-memory\" segfault)\n>> fixes the problem for i386, do the same for arm.\n>>\n>> Running QEMU with\n>>     qemu-system-aarch64 -M none -nographic -m 256\n>> and executing\n>>     dump-guest-memory /dev/null 0 8192\n>> results in segfault\n>>\n>> Fix by checking if we have CPU.\n>>\n>> Signed-off-by: Laurent Vivier <lvivier@redhat.com>\n> \n> It seems a little arbitrary to assume that if there's no\n> CPU what you wanted was a 32-bit little-endian dump.\n\nWe need a default value.  Is 64bit and/or big-endian better?\n\n> Why do we have a machine without a CPU anyway ?\n\nTo hotplug it later?\n\nAs we can, we should avoid the segfault.\n\nThanks,\nLaurent","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=lvivier@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrXNQ6HMLz9ryv\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 01:46:46 +1000 (AEST)","from localhost ([::1]:58525 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1drQv6-0008Hf-VM\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 11:46:44 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:54321)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <lvivier@redhat.com>) id 1drQkY-0007qb-0F\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 11:35:54 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <lvivier@redhat.com>) id 1drQkS-0003D5-9H\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 11:35:50 -0400","from mx1.redhat.com ([209.132.183.28]:46900)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <lvivier@redhat.com>)\n\tid 1drQkN-00038y-8n; Mon, 11 Sep 2017 11:35:39 -0400","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 398FD2F86FC;\n\tMon, 11 Sep 2017 15:35:38 +0000 (UTC)","from [10.36.116.239] (ovpn-116-239.ams2.redhat.com [10.36.116.239])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id D7EA419621;\n\tMon, 11 Sep 2017 15:35:35 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 398FD2F86FC","To":"Peter Maydell <peter.maydell@linaro.org>","References":"<20170911142056.15643-1-lvivier@redhat.com>\n\t<20170911142056.15643-3-lvivier@redhat.com>\n\t<CAFEAcA_G8mEzB0Mox0TTz578LQKXgvhNHeZ8Bk7OwC4NbqiXPg@mail.gmail.com>","From":"Laurent Vivier <lvivier@redhat.com>","Message-ID":"<309f01b9-3066-60fd-47d5-5206ae6360ed@redhat.com>","Date":"Mon, 11 Sep 2017 17:35:34 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<CAFEAcA_G8mEzB0Mox0TTz578LQKXgvhNHeZ8Bk7OwC4NbqiXPg@mail.gmail.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.11","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.29]);\n\tMon, 11 Sep 2017 15:35:38 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v2 2/3] hmp: fix \"dump-quest-memory\"\n\tsegfault (arm)","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Thomas Huth <thuth@redhat.com>, Cornelia Huck <cohuck@redhat.com>,\n\tQEMU Developers <qemu-devel@nongnu.org>,\n\t\"Dr . David Alan Gilbert\" <dgilbert@redhat.com>,\n\tGreg Kurz <groug@kaod.org>, qemu-arm <qemu-arm@nongnu.org>,\n\t\"qemu-ppc@nongnu.org\" <qemu-ppc@nongnu.org>,\n\tDavid Gibson <david@gibson.dropbear.id.au>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1766370,"web_url":"http://patchwork.ozlabs.org/comment/1766370/","msgid":"<20170911173825.0a4bd1a3@bahia.lan>","list_archive_url":null,"date":"2017-09-11T15:38:25","subject":"Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 2/3] hmp: fix\n\t\"dump-quest-memory\" segfault (arm)","submitter":{"id":69178,"url":"http://patchwork.ozlabs.org/api/people/69178/","name":"Greg Kurz","email":"groug@kaod.org"},"content":"On Mon, 11 Sep 2017 17:25:23 +0200\nLaurent Vivier <lvivier@redhat.com> wrote:\n\n> On 11/09/2017 17:08, Greg Kurz wrote:\n> > On Mon, 11 Sep 2017 16:20:55 +0200\n> > Laurent Vivier <lvivier@redhat.com> wrote:\n> >   \n> >> Commit fd5d23babf (hmp: fix \"dump-quest-memory\" segfault)\n> >> fixes the problem for i386, do the same for arm.\n> >>\n> >> Running QEMU with\n> >>     qemu-system-aarch64 -M none -nographic -m 256\n> >> and executing\n> >>     dump-guest-memory /dev/null 0 8192\n> >> results in segfault\n> >>\n> >> Fix by checking if we have CPU.\n> >>\n> >> Signed-off-by: Laurent Vivier <lvivier@redhat.com>\n> >> ---\n> >>  target/arm/arch_dump.c | 52 +++++++++++++++++++++++++++++++++-----------------\n> >>  1 file changed, 34 insertions(+), 18 deletions(-)\n> >>\n> >> diff --git a/target/arm/arch_dump.c b/target/arm/arch_dump.c\n> >> index 1a9861f69b..1f58cff256 100644\n> >> --- a/target/arm/arch_dump.c\n> >> +++ b/target/arm/arch_dump.c\n> >> @@ -273,8 +273,6 @@ int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs,\n> >>  int cpu_get_dump_info(ArchDumpInfo *info,\n> >>                        const GuestPhysBlockList *guest_phys_blocks)\n> >>  {\n> >> -    ARMCPU *cpu = ARM_CPU(first_cpu);\n> >> -    CPUARMState *env = &cpu->env;\n> >>      GuestPhysBlock *block;\n> >>      hwaddr lowest_addr = ULLONG_MAX;\n> >>  \n> >> @@ -290,13 +288,32 @@ int cpu_get_dump_info(ArchDumpInfo *info,\n> >>          }\n> >>      }\n> >>  \n> >> -    if (arm_feature(env, ARM_FEATURE_AARCH64)) {\n> >> -        info->d_machine = EM_AARCH64;\n> >> -        info->d_class = ELFCLASS64;\n> >> -        info->page_size = (1 << 16); /* aarch64 max pagesize */\n> >> -        if (lowest_addr != ULLONG_MAX) {\n> >> -            info->phys_base = lowest_addr;\n> >> +    if (first_cpu) {\n> >> +        ARMCPU *cpu = ARM_CPU(first_cpu);\n> >> +        CPUARMState *env = &cpu->env;\n> >> +        if (arm_feature(env, ARM_FEATURE_AARCH64)) {\n> >> +            info->d_machine = EM_AARCH64;\n> >> +            info->d_class = ELFCLASS64;\n> >> +            info->page_size = (1 << 16); /* aarch64 max pagesize */\n> >> +            if (lowest_addr != ULLONG_MAX) {\n> >> +                info->phys_base = lowest_addr;\n> >> +            }\n> >> +        } else {\n> >> +            info->d_machine = EM_ARM;\n> >> +            info->d_class = ELFCLASS32;\n> >> +            info->page_size = (1 << 12);\n> >> +            if (lowest_addr < UINT_MAX) {\n> >> +                info->phys_base = lowest_addr;\n> >> +            }\n> >>          }\n> >> +\n> >> +        /* We assume the relevant endianness is that of EL1; this is right\n> >> +         * for kernels, but might give the wrong answer if you're trying to\n> >> +         * dump a hypervisor that happens to be running an opposite-endian\n> >> +         * kernel.\n> >> +         */\n> >> +        info->d_endian = (env->cp15.sctlr_el[1] & SCTLR_EE) != 0\n> >> +                         ? ELFDATA2MSB : ELFDATA2LSB;\n> >>      } else {\n> >>          info->d_machine = EM_ARM;\n> >>          info->d_class = ELFCLASS32;\n> >> @@ -304,25 +321,24 @@ int cpu_get_dump_info(ArchDumpInfo *info,\n> >>          if (lowest_addr < UINT_MAX) {\n> >>              info->phys_base = lowest_addr;\n> >>          }\n> >> +        info->d_endian = ELFDATA2LSB;\n> >>      }\n> >>  \n> >> -    /* We assume the relevant endianness is that of EL1; this is right\n> >> -     * for kernels, but might give the wrong answer if you're trying to\n> >> -     * dump a hypervisor that happens to be running an opposite-endian\n> >> -     * kernel.\n> >> -     */\n> >> -    info->d_endian = (env->cp15.sctlr_el[1] & SCTLR_EE) != 0\n> >> -                     ? ELFDATA2MSB : ELFDATA2LSB;\n> >> -\n> >>      return 0;\n> >>  }\n> >>  \n> >>  ssize_t cpu_get_note_size(int class, int machine, int nr_cpus)\n> >>  {\n> >> -    ARMCPU *cpu = ARM_CPU(first_cpu);\n> >> -    CPUARMState *env = &cpu->env;\n> >> +    ARMCPU *cpu;\n> >> +    CPUARMState *env;\n> >>      size_t note_size;\n> >>  \n> >> +    if (first_cpu == NULL) {\n> >> +        return 0;\n> >> +    }\n> >> +  \n> > \n> > Looking at the function's code, it seems that env is only needed if\n> > class != ELFCLASS64... I guess that all the code dealing with first_cpu\n> > should go to the else block.  \n> \n> if first_cpu is NULL, nr_cpus is 0 and the function always returns 0.\n> \n\nTrue.\n\nReviewed-by: Greg Kurz <groug@kaod.org>\n\n> Thanks,\n> Laurent","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrXQJ4Y7nz9ryv\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 01:48:24 +1000 (AEST)","from localhost ([::1]:58530 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1drQwg-0000qF-OW\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 11:48:22 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:55826)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <groug@kaod.org>) id 1drQnN-0001s5-W4\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 11:38:47 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <groug@kaod.org>) id 1drQnK-0005Es-0l\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 11:38:45 -0400","from 7.mo1.mail-out.ovh.net ([87.98.158.110]:43344)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <groug@kaod.org>) id 1drQnJ-0005Do-Nl\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 11:38:41 -0400","from player169.ha.ovh.net (b9.ovh.net [213.186.33.59])\n\tby mo1.mail-out.ovh.net (Postfix) with ESMTP id F0E43935BD\n\tfor <qemu-devel@nongnu.org>; Mon, 11 Sep 2017 17:38:38 +0200 (CEST)","from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139])\n\t(Authenticated sender: groug@kaod.org)\n\tby player169.ha.ovh.net (Postfix) with ESMTPSA id DD5E558006F;\n\tMon, 11 Sep 2017 17:38:26 +0200 (CEST)"],"Date":"Mon, 11 Sep 2017 17:38:25 +0200","From":"Greg Kurz <groug@kaod.org>","To":"Laurent Vivier <lvivier@redhat.com>","Message-ID":"<20170911173825.0a4bd1a3@bahia.lan>","In-Reply-To":"<5b7621f0-072f-9bf0-c4bb-23f85a8faaec@redhat.com>","References":"<20170911142056.15643-1-lvivier@redhat.com>\n\t<20170911142056.15643-3-lvivier@redhat.com>\n\t<20170911170804.0ee06c00@bahia.lan>\n\t<5b7621f0-072f-9bf0-c4bb-23f85a8faaec@redhat.com>","X-Mailer":"Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu)","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha1;\n\tboundary=\"Sig_/FHwwXggkw07Uk2k8lJn4ItP\";\n\tprotocol=\"application/pgp-signature\"","X-Ovh-Tracer-Id":"12537458414897633574","X-VR-SPAMSTATE":"OK","X-VR-SPAMSCORE":"-100","X-VR-SPAMCAUSE":"gggruggvucftvghtrhhoucdtuddrfeelledrgedtgdelgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"87.98.158.110","Subject":"Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 2/3] hmp: fix\n\t\"dump-quest-memory\" segfault (arm)","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Peter Maydell <peter.maydell@linaro.org>, Thomas Huth <thuth@redhat.com>,\n\tCornelia Huck <cohuck@redhat.com>, qemu-devel@nongnu.org,\n\t\"Dr . David Alan Gilbert\" <dgilbert@redhat.com>,\n\tqemu-arm@nongnu.org, qemu-ppc@nongnu.org,\n\tDavid Gibson <david@gibson.dropbear.id.au>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1766386,"web_url":"http://patchwork.ozlabs.org/comment/1766386/","msgid":"<CAFEAcA9Wmq+G6H78NdsVs5mKDrMcUkB30yY2d=3+KOnbT-pmAQ@mail.gmail.com>","list_archive_url":null,"date":"2017-09-11T16:40:40","subject":"Re: [Qemu-devel] [PATCH v2 2/3] hmp: fix \"dump-quest-memory\"\n\tsegfault (arm)","submitter":{"id":5111,"url":"http://patchwork.ozlabs.org/api/people/5111/","name":"Peter Maydell","email":"peter.maydell@linaro.org"},"content":"On 11 September 2017 at 15:45, Thomas Huth <thuth@redhat.com> wrote:\n> On 11.09.2017 16:39, Peter Maydell wrote:\n>> On 11 September 2017 at 15:20, Laurent Vivier <lvivier@redhat.com> wrote:\n>>> Commit fd5d23babf (hmp: fix \"dump-quest-memory\" segfault)\n>>> fixes the problem for i386, do the same for arm.\n>>>\n>>> Running QEMU with\n>>>     qemu-system-aarch64 -M none -nographic -m 256\n>>> and executing\n>>>     dump-guest-memory /dev/null 0 8192\n>>> results in segfault\n>>>\n>>> Fix by checking if we have CPU.\n>>>\n>>> Signed-off-by: Laurent Vivier <lvivier@redhat.com>\n>>\n>> It seems a little arbitrary to assume that if there's no\n>> CPU what you wanted was a 32-bit little-endian dump.\n>>\n>> Why do we have a machine without a CPU anyway ?\n>\n> The \"none\" machine is always started without a default CPU.\n\nIf it has no CPU then how can we create a core dump for it?\nWe don't (in theory) even know whether it's x86 or ARM.\n(One day we may support multiple CPU architectures in\none QEMU binary...)\n\nIf the theory is hotplug-later then we're a bit stuck\nbecause we need to know information now that we can't\nknow until the CPU is actually hotplugged.\n\nthanks\n-- PMM","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"SE+q8EyC\"; dkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrYbn2VVsz9s7f\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 02:41:40 +1000 (AEST)","from localhost ([::1]:58965 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1drRmE-0003h0-8x\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 12:41:38 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:49355)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <peter.maydell@linaro.org>) id 1drRlf-0003fp-JR\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 12:41:04 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <peter.maydell@linaro.org>) id 1drRle-0005BU-PK\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 12:41:03 -0400","from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]:44516)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <peter.maydell@linaro.org>)\n\tid 1drRle-0005Ak-Ic\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 12:41:02 -0400","by mail-wm0-x22f.google.com with SMTP id 189so9972245wmh.1\n\tfor <qemu-devel@nongnu.org>; Mon, 11 Sep 2017 09:41:02 -0700 (PDT)","by 10.223.139.215 with HTTP; Mon, 11 Sep 2017 09:40:40 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=dRf+NPrFemHVCx7JAlwzW/eCa3eMomUCws1bobJX29s=;\n\tb=SE+q8EyCnYgQD+yeSppZmxQwsdbFTzcPbviNWrVXRQ/snTYwfxnzda52tEqx3J9XxM\n\t3kuKLF+h4QgcFGU8lbLyI1M57fHVk8HKCtrRZ/hU8YQ+TqP2DC3lmxPFTi72zWDnQAVf\n\tkT7yVrygPJeOQjGSwhacOTmVveUn9Jj6Dk9ZI=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=dRf+NPrFemHVCx7JAlwzW/eCa3eMomUCws1bobJX29s=;\n\tb=FGm3C+AUUevyIMDeT3LPRtqJ9uH2OcbW9rwnL2dkzqCD62bd2P+kuzaMdU03I3M6c3\n\t8BYvSQSOaRJ5R+SAIcsgcVEFQY3VLbBzRyWFspFHBC15ozYFUoU+2CumGfQvwYD9x94n\n\twweIENMWjFI3R366sn+C4i2+B7ho+s4rTXqru51IFMgNe6JWmlBUQRPApFpowUax035P\n\tF4ZE77nXc05qQfjPrGnMhLJvw2oRzsmquci5tF2kdfVE/9zbNV2ceG3b+nOHO78EtNYZ\n\tNHbu95jTxhZXV6cJVhcEgjtZmldvvR8KCNW5l21R3hNG/b+fD5fBPKIyQZVRQ3KW3d1k\n\tDZZQ==","X-Gm-Message-State":"AHPjjUiGZGR7sLLx6sL4gFhGY6rthSEzDgjQpPoK+DmhRhHSDbJ7BUzf\n\tfKf5d+82o+qbtn+UTBzK2MhhnzwQ2yDm","X-Google-Smtp-Source":"AOwi7QCrqBcRAdiai6YDJ+z1KY/X3aYtY7iPXzr3W1RpuG/wZJK1U1rAdJvWh0mWP9gAJnPXaNy7r4HVM/JlYQpPYj4=","X-Received":"by 10.28.166.135 with SMTP id p129mr4860250wme.147.1505148061445;\n\tMon, 11 Sep 2017 09:41:01 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<889d6ce7-073f-7860-e091-619c1202b1cd@redhat.com>","References":"<20170911142056.15643-1-lvivier@redhat.com>\n\t<20170911142056.15643-3-lvivier@redhat.com>\n\t<CAFEAcA_G8mEzB0Mox0TTz578LQKXgvhNHeZ8Bk7OwC4NbqiXPg@mail.gmail.com>\n\t<889d6ce7-073f-7860-e091-619c1202b1cd@redhat.com>","From":"Peter Maydell <peter.maydell@linaro.org>","Date":"Mon, 11 Sep 2017 17:40:40 +0100","Message-ID":"<CAFEAcA9Wmq+G6H78NdsVs5mKDrMcUkB30yY2d=3+KOnbT-pmAQ@mail.gmail.com>","To":"Thomas Huth <thuth@redhat.com>","Content-Type":"text/plain; charset=\"UTF-8\"","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2a00:1450:400c:c09::22f","Subject":"Re: [Qemu-devel] [PATCH v2 2/3] hmp: fix \"dump-quest-memory\"\n\tsegfault (arm)","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Laurent Vivier <lvivier@redhat.com>, Cornelia Huck <cohuck@redhat.com>, \n\tQEMU Developers <qemu-devel@nongnu.org>,\n\t\"Dr . David Alan Gilbert\" <dgilbert@redhat.com>,\n\tGreg Kurz <groug@kaod.org>, qemu-arm <qemu-arm@nongnu.org>,\n\t\"qemu-ppc@nongnu.org\" <qemu-ppc@nongnu.org>,\n\tDavid Gibson <david@gibson.dropbear.id.au>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1766405,"web_url":"http://patchwork.ozlabs.org/comment/1766405/","msgid":"<01a0cb88-6a84-6413-682f-67eb2af34b7f@redhat.com>","list_archive_url":null,"date":"2017-09-11T17:06:40","subject":"Re: [Qemu-devel] [PATCH v2 2/3] hmp: fix \"dump-quest-memory\"\n\tsegfault (arm)","submitter":{"id":66152,"url":"http://patchwork.ozlabs.org/api/people/66152/","name":"Thomas Huth","email":"thuth@redhat.com"},"content":"On 11.09.2017 18:40, Peter Maydell wrote:\n> On 11 September 2017 at 15:45, Thomas Huth <thuth@redhat.com> wrote:\n>> On 11.09.2017 16:39, Peter Maydell wrote:\n>>> On 11 September 2017 at 15:20, Laurent Vivier <lvivier@redhat.com> wrote:\n>>>> Commit fd5d23babf (hmp: fix \"dump-quest-memory\" segfault)\n>>>> fixes the problem for i386, do the same for arm.\n>>>>\n>>>> Running QEMU with\n>>>>     qemu-system-aarch64 -M none -nographic -m 256\n>>>> and executing\n>>>>     dump-guest-memory /dev/null 0 8192\n>>>> results in segfault\n>>>>\n>>>> Fix by checking if we have CPU.\n>>>>\n>>>> Signed-off-by: Laurent Vivier <lvivier@redhat.com>\n>>>\n>>> It seems a little arbitrary to assume that if there's no\n>>> CPU what you wanted was a 32-bit little-endian dump.\n>>>\n>>> Why do we have a machine without a CPU anyway ?\n>>\n>> The \"none\" machine is always started without a default CPU.\n> \n> If it has no CPU then how can we create a core dump for it?\n> We don't (in theory) even know whether it's x86 or ARM.\n> (One day we may support multiple CPU architectures in\n> one QEMU binary...)\n\nTrue. Maybe it's better to return -1 if first_cpu is NULL to signal that\na dump is not possible...?\n\n Thomas","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=thuth@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrZGY1NJwz9s81\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 03:11:49 +1000 (AEST)","from localhost ([::1]:59234 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1drSFP-00073Z-89\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 13:11:47 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:60384)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <thuth@redhat.com>) id 1drSAi-0003s9-HS\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:07:00 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <thuth@redhat.com>) id 1drSAh-0001El-Hu\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:06:56 -0400","from mx1.redhat.com ([209.132.183.28]:47906)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <thuth@redhat.com>)\n\tid 1drSAY-0001Bf-Dn; Mon, 11 Sep 2017 13:06:46 -0400","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 2DE6E1FE30E;\n\tMon, 11 Sep 2017 17:06:45 +0000 (UTC)","from [10.36.116.113] (ovpn-116-113.ams2.redhat.com [10.36.116.113])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id C5C7F60842;\n\tMon, 11 Sep 2017 17:06:41 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 2DE6E1FE30E","To":"Peter Maydell <peter.maydell@linaro.org>","References":"<20170911142056.15643-1-lvivier@redhat.com>\n\t<20170911142056.15643-3-lvivier@redhat.com>\n\t<CAFEAcA_G8mEzB0Mox0TTz578LQKXgvhNHeZ8Bk7OwC4NbqiXPg@mail.gmail.com>\n\t<889d6ce7-073f-7860-e091-619c1202b1cd@redhat.com>\n\t<CAFEAcA9Wmq+G6H78NdsVs5mKDrMcUkB30yY2d=3+KOnbT-pmAQ@mail.gmail.com>","From":"Thomas Huth <thuth@redhat.com>","Message-ID":"<01a0cb88-6a84-6413-682f-67eb2af34b7f@redhat.com>","Date":"Mon, 11 Sep 2017 19:06:40 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<CAFEAcA9Wmq+G6H78NdsVs5mKDrMcUkB30yY2d=3+KOnbT-pmAQ@mail.gmail.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.13","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.38]);\n\tMon, 11 Sep 2017 17:06:45 +0000 (UTC)","Content-Transfer-Encoding":"quoted-printable","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v2 2/3] hmp: fix \"dump-quest-memory\"\n\tsegfault (arm)","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Laurent Vivier <lvivier@redhat.com>, Cornelia Huck <cohuck@redhat.com>, \n\tQEMU Developers <qemu-devel@nongnu.org>,\n\t\"Dr . David Alan Gilbert\" <dgilbert@redhat.com>,\n\tGreg Kurz <groug@kaod.org>, qemu-arm <qemu-arm@nongnu.org>,\n\t\"qemu-ppc@nongnu.org\" <qemu-ppc@nongnu.org>,\n\tDavid Gibson <david@gibson.dropbear.id.au>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1766743,"web_url":"http://patchwork.ozlabs.org/comment/1766743/","msgid":"<315f4cc0-0cd2-4c68-1b0f-26b6979d85e5@redhat.com>","list_archive_url":null,"date":"2017-09-12T08:11:42","subject":"Re: [Qemu-devel] [PATCH v2 2/3] hmp: fix \"dump-quest-memory\"\n\tsegfault (arm)","submitter":{"id":66421,"url":"http://patchwork.ozlabs.org/api/people/66421/","name":"Laurent Vivier","email":"lvivier@redhat.com"},"content":"On 11/09/2017 18:40, Peter Maydell wrote:\n> On 11 September 2017 at 15:45, Thomas Huth <thuth@redhat.com> wrote:\n>> On 11.09.2017 16:39, Peter Maydell wrote:\n>>> On 11 September 2017 at 15:20, Laurent Vivier <lvivier@redhat.com> wrote:\n>>>> Commit fd5d23babf (hmp: fix \"dump-quest-memory\" segfault)\n>>>> fixes the problem for i386, do the same for arm.\n>>>>\n>>>> Running QEMU with\n>>>>     qemu-system-aarch64 -M none -nographic -m 256\n>>>> and executing\n>>>>     dump-guest-memory /dev/null 0 8192\n>>>> results in segfault\n>>>>\n>>>> Fix by checking if we have CPU.\n>>>>\n>>>> Signed-off-by: Laurent Vivier <lvivier@redhat.com>\n>>>\n>>> It seems a little arbitrary to assume that if there's no\n>>> CPU what you wanted was a 32-bit little-endian dump.\n>>>\n>>> Why do we have a machine without a CPU anyway ?\n>>\n>> The \"none\" machine is always started without a default CPU.\n> \n> If it has no CPU then how can we create a core dump for it?\n> We don't (in theory) even know whether it's x86 or ARM.\n> (One day we may support multiple CPU architectures in\n> one QEMU binary...)\n> \n> If the theory is hotplug-later then we're a bit stuck\n> because we need to know information now that we can't\n> know until the CPU is actually hotplugged.\n\nAs we have memory we should be able to dump memory, even without CPU.\n\nBut I can also do as proposed by Thomas and return -1 to cancel the dump\nif there is no CPU.\n\nThanks,\nLaurent","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=lvivier@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xryFp4T1tz9s7C\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 18:12:30 +1000 (AEST)","from localhost ([::1]:34200 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1drgJ2-0007BJ-Nb\n\tfor incoming@patchwork.ozlabs.org; Tue, 12 Sep 2017 04:12:28 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:53152)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <lvivier@redhat.com>) id 1drgIZ-00076r-HA\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 04:12:00 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <lvivier@redhat.com>) id 1drgIY-00006G-KA\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 04:11:59 -0400","from mx1.redhat.com ([209.132.183.28]:41560)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <lvivier@redhat.com>)\n\tid 1drgIR-0008PD-01; Tue, 12 Sep 2017 04:11:51 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 67E6F828;\n\tTue, 12 Sep 2017 08:11:47 +0000 (UTC)","from [10.36.116.239] (ovpn-116-239.ams2.redhat.com [10.36.116.239])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id D3BF36C52A;\n\tTue, 12 Sep 2017 08:11:43 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 67E6F828","To":"Peter Maydell <peter.maydell@linaro.org>, Thomas Huth <thuth@redhat.com>","References":"<20170911142056.15643-1-lvivier@redhat.com>\n\t<20170911142056.15643-3-lvivier@redhat.com>\n\t<CAFEAcA_G8mEzB0Mox0TTz578LQKXgvhNHeZ8Bk7OwC4NbqiXPg@mail.gmail.com>\n\t<889d6ce7-073f-7860-e091-619c1202b1cd@redhat.com>\n\t<CAFEAcA9Wmq+G6H78NdsVs5mKDrMcUkB30yY2d=3+KOnbT-pmAQ@mail.gmail.com>","From":"Laurent Vivier <lvivier@redhat.com>","Message-ID":"<315f4cc0-0cd2-4c68-1b0f-26b6979d85e5@redhat.com>","Date":"Tue, 12 Sep 2017 10:11:42 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<CAFEAcA9Wmq+G6H78NdsVs5mKDrMcUkB30yY2d=3+KOnbT-pmAQ@mail.gmail.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.14","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.29]);\n\tTue, 12 Sep 2017 08:11:47 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v2 2/3] hmp: fix \"dump-quest-memory\"\n\tsegfault (arm)","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Cornelia Huck <cohuck@redhat.com>,\n\tQEMU Developers <qemu-devel@nongnu.org>, \n\t\"Dr . David Alan Gilbert\" <dgilbert@redhat.com>,\n\tGreg Kurz <groug@kaod.org>, qemu-arm <qemu-arm@nongnu.org>,\n\t\"qemu-ppc@nongnu.org\" <qemu-ppc@nongnu.org>,\n\tDavid Gibson <david@gibson.dropbear.id.au>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]