From patchwork Sat Nov 12 23:25:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9424517 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 BA4CC60233 for ; Sat, 12 Nov 2016 23:26:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C11528CB5 for ; Sat, 12 Nov 2016 23:26:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EFA228CD6; Sat, 12 Nov 2016 23:26:18 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, URIBL_RED 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 50C9C28CB5 for ; Sat, 12 Nov 2016 23:26:17 +0000 (UTC) Received: from localhost ([::1]:59979 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c5hgd-0004CB-0v for patchwork-qemu-devel@patchwork.kernel.org; Sat, 12 Nov 2016 18:26:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c5hgK-0004C4-9v for qemu-devel@nongnu.org; Sat, 12 Nov 2016 18:25:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c5hgG-0004jc-36 for qemu-devel@nongnu.org; Sat, 12 Nov 2016 18:25:56 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:41204) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c5hgF-0004cU-Qe for qemu-devel@nongnu.org; Sat, 12 Nov 2016 18:25:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:Cc:References:To:Subject; bh=wPwVwuvzvNGCpOvsFXXpkvDUhqoQa8kcl4LhYfDsKXY=; b=bqhB9Z0ltUpid5Jht4PZGYxieE ifM4d0ELPpIuqlbToCGwgQfRZpstPE7FHysl+KAs8QgL6cwbq1OtHWf1GotTQuLil9AZwKItkPAr+ 4RURvvf68omKcVAFXHqsUe5rnqdTWH99J0kPC7KVl0Dluwrg3RVSBgTPpe+e2mR984lPRhq/fHEVz t1Z1oK6SqpwvVD9x2M0yrNFCFGymXy3g+5PWxL1awZyduFldZx5ePyT8nUP796XZAezveQawaQpqd m5MQ3OlLXIzJCqQaMuEujSh6MzlaFgLvWinOHN7g30LFTbIzuIgh9IvnaL58m9jP1OsU79cMt88Vp QEdJQmqw==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:45084 helo=server.roeck-us.net) by bh-25.webhostbox.net with esmtpsa (TLSv1:DHE-RSA-AES128-SHA:128) (Exim 4.86_1) (envelope-from ) id 1c5hfV-002pgR-C9; Sat, 12 Nov 2016 23:25:06 +0000 To: Marek Vasut References: <20161025195743.4558-1-marex@denx.de> <20161107035825.GA26942@roeck-us.net> <142d063a-4061-803d-b12c-0d17c8832c11@denx.de> <4ad504d5-9ba3-5216-8693-c731ce5b0bc9@roeck-us.net> <0419991c-a23f-8f2e-77c3-0401503dae17@denx.de> From: Guenter Roeck Message-ID: <62733dfe-5ccc-4d84-cc6e-92c100a1447e@roeck-us.net> Date: Sat, 12 Nov 2016 15:25:06 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <0419991c-a23f-8f2e-77c3-0401503dae17@denx.de> X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - nongnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: linux@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: linux@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.91.199.152 Subject: Re: [Qemu-devel] [V6, 2/7] nios2: Add architecture emulation support 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: Jeff Da Silva , Chris Wulff , qemu-devel@nongnu.org, Sandra Loosemore , Yves Vandervennet , Ley Foon Tan , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Hi Marek, On 11/12/2016 01:50 PM, Marek Vasut wrote: > On 11/07/2016 08:54 PM, Guenter Roeck wrote: >> Hi Marek, >> >> On 11/07/2016 10:14 AM, Marek Vasut wrote: >>> On 11/07/2016 04:58 AM, Guenter Roeck wrote: >>>> On Tue, Oct 25, 2016 at 09:57:43PM +0200, Marek Vasut wrote: >>>>> From: Chris Wulff >>>>> >>>>> Add support for emulating Altera NiosII R1 architecture into qemu. >>>>> This patch is based on previous work by Chris Wulff from 2012 and >>>>> updated to latest mainline QEMU. >>>>> >>>>> Signed-off-by: Marek Vasut >>>>> Cc: Chris Wulff >>>>> Cc: Jeff Da Silva >>>>> Cc: Ley Foon Tan >>>>> Cc: Sandra Loosemore >>>>> Cc: Yves Vandervennet >>>>> --- >>>>> V3: Thorough cleanup, deal with the review comments all over the place >>>>> V4: - Use extract32() >>>>> - Fix gen_goto_tb() , suppress tcg_gen_goto_tb() >>>>> - Clean up gen_check_supervisor() helper >>>>> - Use TCGMemOp type for flags >>>>> - Drop jump labels from wrctl/rdctl >>>>> - More TCG cleanup >>>>> V5: - Simplify load/store handling >>>>> - Handle loads into R_ZERO from protected page, add comment >>>>> V6: - Fix division opcode handling >>>>> - Add missing disas handling >>>>> - V5 review comments cleanup >>>>> --- >>>> [ ... ] >>>> >>>>> diff --git a/target-nios2/cpu.h b/target-nios2/cpu.h >>>>> new file mode 100644 >>>>> index 0000000..17c9a0f >>>> [ ... ] >>>> >>>>> +static inline void cpu_get_tb_cpu_state(CPUNios2State *env, >>>>> target_ulong *pc, >>>>> + target_ulong *cs_base, >>>>> uint32_t *flags) >>>>> +{ >>>>> + *pc = env->regs[R_PC]; >>>>> + *cs_base = 0; >>>>> + *flags = (env->regs[CR_STATUS] & (CR_STATUS_EH | CR_STATUS_U)); >>>>> +} >>>>> + >>>>> +#endif /* CPU_NIOS2_H */ >>>>> + >>>> >>>> The empty line at the end results in a whitespace message from git. >>> >>> Dropped, thanks. Is there anything else or is this patchset starting to >>> become acceptable ? >>> >> >> Hard for me to say. I tried to build and run the series with the latest >> linux >> kernel (v4.9-rc4), but it is stuck in early boot. I tried with >> 10m50_defconfig >> and 10m50_devboard.dtb. gcc is 6.1.0 built with buildroot, though I also >> tried >> with toolchains from CodeSourcery. Obviously I have no idea if there is a >> kernel bug or a qemu bug or a problem with the command line I used. >> >> Here is my command line: >> >> qemu-system-nios2 -M 10m50-ghrd -kernel vmlinux -dtb 10m50_devboard.dtb \ >> -append "earlycon=uart8250,mmio32,0x18001600,115200n8 console=ttyS0" >> >> This may be wrong, but the boot is stuck in an endless loop in >> mark_bootmem(), >> which seems early and odd. I tried with both vmlinux and >> arch/nios2/boot/vmImage, >> with the same results. >> >> Can you provide a working command line and kernel version, and/or >> directions how >> to create a working image if I need to run the image, for example, from >> u-boot ? >> Sorry if that is posted somewhere and I missed it. > > I guess Romain gave you something since I see you made some progress. > I'll have to look into that fdt loader issue. > Yes, WFM after This is my command line, running your patch series plus the above fixup on top of the qemu master branch: qemu-system-nios2 -M 10m50-ghrd \ -kernel vmlinux -no-reboot \ -dtb 10m50_devboard.dtb \ --append "rdinit=/sbin/init" \ -initrd busybox-nios2.cpio \ -nographic -monitor none I use 10m50_defconfig with CONFIG_NIOS2_PASS_CMDLINE=y and CONFIG_BLK_DEV_INITRD=y. One boot error I get is: cpu cpu0: Error -2 creating of_node link but that doesn't seem to have an impact. Also, I see altera_tse 400.ethernet (unnamed net_device) (uninitialized): MDIO bus altera_tse-0: created altera_tse 400.ethernet: Altera TSE MAC version 0.0 at 0x00000400 irq 3/4 altera_tse 400.ethernet eth0: Bad PHY UID 0x00000000 altera_tse 400.ethernet eth0: Cannot attach to PHY (error: -19) altera_tse 400.ethernet eth0 (unregistered): MDIO bus altera_tse-0: removed As far as I can see the ethernet controller isn't supported in qemu, so I guess that is as expected. Also, it still gives me qemu-system-nios2: Trying to execute code outside RAM or ROM at 0xd4000000 on reboot, suggesting something like "rom_add_blob_fixed()" might be useful, if I knew what to put there. If there is a means to get a clean reset, please let me know. Thanks, Guenter diff --git a/hw/nios2/boot.c b/hw/nios2/boot.c index 564dbae..e0a9aff 100644 --- a/hw/nios2/boot.c +++ b/hw/nios2/boot.c @@ -73,6 +73,11 @@ static void main_cpu_reset(void *opaque) } } +static uint64_t translate_kernel_address(void *opaque, uint64_t addr) +{ + return addr - 0xc0000000LL; +} + static int nios2_load_dtb(struct nios2_boot_info bi, const uint32_t ramsize, const char *kernel_cmdline, const char *dtb_filename) { @@ -97,21 +102,16 @@ static int nios2_load_dtb(struct nios2_boot_info bi, const uint32_t ramsize, if (bi.initrd_start) { qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start", - bi.initrd_start); + translate_kernel_address(NULL, bi.initrd_start)); qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end", - bi.initrd_end); + translate_kernel_address(NULL, bi.initrd_end)); } cpu_physical_memory_write(bi.fdt, fdt, fdt_size); return fdt_size; } -static uint64_t translate_kernel_address(void *opaque, uint64_t addr) -{ - return addr - 0xc0000000LL; -} - void nios2_load_kernel(Nios2CPU *cpu, hwaddr ddr_base,