From patchwork Thu Jan 11 21:04:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10158609 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 C4305601A1 for ; Thu, 11 Jan 2018 21:21:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B64B628878 for ; Thu, 11 Jan 2018 21:21:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3D602888E; Thu, 11 Jan 2018 21:21:30 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, HK_RANDOM_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 2E66B288AA for ; Thu, 11 Jan 2018 21:21:30 +0000 (UTC) Received: from localhost ([::1]:43032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZkHx-00029R-7E for patchwork-qemu-devel@patchwork.kernel.org; Thu, 11 Jan 2018 16:21:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZk2W-0004rv-T9 for qemu-devel@nongnu.org; Thu, 11 Jan 2018 16:05:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZk2V-0008Sc-BI for qemu-devel@nongnu.org; Thu, 11 Jan 2018 16:05:32 -0500 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]:36885) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZk2U-0008Rj-LJ for qemu-devel@nongnu.org; Thu, 11 Jan 2018 16:05:30 -0500 Received: by mail-lf0-x242.google.com with SMTP id f3so3999741lfe.4 for ; Thu, 11 Jan 2018 13:05:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lOBXmxcxnav8YnFDGeTNg8dFfBtczA+1CwWqowZx8w4=; b=NtvcPKxL8rW7okRln1uosY2BgFU6mBWuaPpqCIlI3WjRUcYhVFRuKSVNzE+iWi6gFp 4Enm81HCDDLYL71w8ksriK0wFlnj66ZftP0W28QnjtlwG8TrWA8J+MiaPyPXBosVemKZ x2cG4ZAp8bcQrxQHCgyMgRPvkTrXyskzGfiSOvBcgbTqn5SEfcL4fXK5MCW/wdafvBYW FMz0Zw2pKFggQn/VenuTsdJpD+Mn2lMgvE30Xz+kp0szdZ+B/7Uhwo48Zhmn7a6RQdzS c/FjHKEa2nCvB3P3eWBjBjyOSLIVyVvwuNqxllu5S06cuPcHQb3c1cr6bYtFOrrcY84D A5Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lOBXmxcxnav8YnFDGeTNg8dFfBtczA+1CwWqowZx8w4=; b=IKK1jrARDpYfakzwh169N/hau5O5qffesi6xvFgGddFWMrqUiI5jFMc7lJMgwCZ5mI PVuUYC4kLuP87j61aWjS+FybXHWzJtD08tbnuTdSvK3vpl8Hr1jJpWZoMBJWIVTkAYwU sPOiVooSBA+VDHpsclTe7TnxQ62py6qfZgs57GPKFgwPu9qCDcksNogKmacmbEtmu9CG eWC8sQnVBfWD/Cyxlxn1McRTh1M9goW6jYD1dr68AB3OOOHYPufa4RJWWajawo2qhjyM d970z8ZvLWTO56oIaqtv2HQOy3MCZC+R/ii7RJDuikU01dS5z5C5Vn3Sd52THje84eZw CIEw== X-Gm-Message-State: AKwxyteImACeTsDr1YNzJGQd1eiMPgK9sm8W7UQc7LTPsxFfqinC4j2t AkTVD8QC24gqeFzbf9Jf3p23VA== X-Google-Smtp-Source: ACJfBos/HomuFuplV/ggWjdAokvfQ2X+8Mr1ru89qHOs5vCf1uyj7YE2QSO62BJ0WoemKTfbehdFnQ== X-Received: by 10.46.58.20 with SMTP id h20mr9382747lja.2.1515704729181; Thu, 11 Jan 2018 13:05:29 -0800 (PST) Received: from octofox.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id f126sm2313225lff.82.2018.01.11.13.05.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Jan 2018 13:05:28 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Date: Thu, 11 Jan 2018 13:04:55 -0800 Message-Id: <1515704703-10347-2-git-send-email-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1515704703-10347-1-git-send-email-jcmvbkbc@gmail.com> References: <1515704703-10347-1-git-send-email-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::242 Subject: [Qemu-devel] [PATCH 1/9] hw/xtensa/xtfpga: rewrite mini bootloader 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: Max Filippov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Don't load jump target into the CPU config, instead put it and initial a2 as literals into the mini bootloader and use l32r to load them natively. With these changes it should be possible to do warm reboot of the guest. Signed-off-by: Max Filippov --- hw/xtensa/xtfpga.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index 1971ecfdc5a3..ba681683d608 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -372,15 +372,33 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine) } } if (entry_point != env->pc) { - static const uint8_t jx_a0[] = { + uint8_t boot[] = { #ifdef TARGET_WORDS_BIGENDIAN - 0x0a, 0, 0, + 0x60, 0x00, 0x08, /* j 1f */ + 0x00, /* .literal_position */ + 0x00, 0x00, 0x00, 0x00, /* .literal entry_pc */ + 0x00, 0x00, 0x00, 0x00, /* .literal entry_a2 */ + /* 1: */ + 0x10, 0xff, 0xfe, /* l32r a0, entry_pc */ + 0x12, 0xff, 0xfe, /* l32r a2, entry_a2 */ + 0x0a, 0x00, 0x00, /* jx a0 */ #else - 0xa0, 0, 0, + 0x06, 0x02, 0x00, /* j 1f */ + 0x00, /* .literal_position */ + 0x00, 0x00, 0x00, 0x00, /* .literal entry_pc */ + 0x00, 0x00, 0x00, 0x00, /* .literal entry_a2 */ + /* 1: */ + 0x01, 0xfe, 0xff, /* l32r a0, entry_pc */ + 0x21, 0xfe, 0xff, /* l32r a2, entry_a2 */ + 0xa0, 0x00, 0x00, /* jx a0 */ #endif }; - env->regs[0] = entry_point; - cpu_physical_memory_write(env->pc, jx_a0, sizeof(jx_a0)); + uint32_t entry_pc = tswap32(entry_point); + uint32_t entry_a2 = tswap32(tagptr); + + memcpy(boot + 4, &entry_pc, sizeof(entry_pc)); + memcpy(boot + 8, &entry_a2, sizeof(entry_a2)); + cpu_physical_memory_write(env->pc, boot, sizeof(boot)); } } else { if (flash) {