From patchwork Sun Apr 16 23:23:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 9683265 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 C0A1E60138 for ; Sun, 16 Apr 2017 23:30:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A595427BA5 for ; Sun, 16 Apr 2017 23:30:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 966CF27CF3; Sun, 16 Apr 2017 23:30:06 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_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 4001427BA5 for ; Sun, 16 Apr 2017 23:30:06 +0000 (UTC) Received: from localhost ([::1]:33929 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztcL-0007SK-E8 for patchwork-qemu-devel@patchwork.kernel.org; Sun, 16 Apr 2017 19:30:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztWp-0003ti-MM for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cztWo-00082I-Ni for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:23 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:33309) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cztWo-00081r-I7 for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:22 -0400 Received: by mail-pg0-x244.google.com with SMTP id 63so10928262pgh.0 for ; Sun, 16 Apr 2017 16:24:22 -0700 (PDT) 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 :in-reply-to:references; bh=hJ3I2eAkMTzVMg55DO03/vxNfV0D/TTh6XKlmrMelKg=; b=S5vkJFrD7aTpP1awNPx4GsPvYKkL6Mk1LfESD9/DFgujcJd/exGnvVrSdvf1TyCNH+ n1b2dgJW58DPV0u/rKuRDpT3wUbHKHRwVuMTdTP6xk4/aTmbR0Sd4SckIr/3OLL0EKz4 Z1krdXHFB3dfVIkl+Xepi+uuTDpSJHVv51h1/1TdauLsqmZJEFgam3d6vGrMY1V/2GyO legBZxmFzmqOwNaLU0XnTJkLjsTDBknqr+9fi7PkvscsQW+4jCaAbapvfq3z0M0VCmAT xohSvXcZOe7ntJTzZhtjgmrLtMJqACYsAMuINM1VSvWhekv8OhYriT30qXoKxP5MpRQH upwQ== 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:in-reply-to:references; bh=hJ3I2eAkMTzVMg55DO03/vxNfV0D/TTh6XKlmrMelKg=; b=a9bZFgb5v1yiDn12z1CPtuKlldsM+d/twSgiKOp8iNhRuiG6JztyvRbuQPrhqqC31Y fYV6WmDourHKJOcRlQ7zqvSQz3GZOqeBWvzOposrOmdKeI0rocpmHDgFT9adx9UQbkJb Yu0doK4hlPZRaX8Xs9FMMvFYscvwrBQdbcPMCZb7OGe+TjB2LeQm5q6FiaxGFbsTdwRO CwF5Ga8cMd7zYPCQoJbYrnrJ6O9SEM/aLuciQ+gpBD04nE7zAQRwAVD9i6qpz9FuU2PY kFeWAZEHbUxGq0zGm8/8HEF5zOjjF1I/DcXLxtR6hJjBhdg15PFu/ToWdcbVT24Rk+CX nIGg== X-Gm-Message-State: AN3rC/7eIxZ4wvzbPH+nqvVixHsIQGGLhSBIx66vwb8YzQxAfBT/SiD5 yL88CiKuiSnsLO4H X-Received: by 10.98.1.7 with SMTP id 7mr8986818pfb.51.1492385061587; Sun, 16 Apr 2017 16:24:21 -0700 (PDT) Received: from localhost (z24.124-44-184.ppp.wakwak.ne.jp. [124.44.184.24]) by smtp.gmail.com with ESMTPSA id s14sm14059543pgs.0.2017.04.16.16.24.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 16 Apr 2017 16:24:21 -0700 (PDT) From: Stafford Horne To: qemu-devel@nongnu.org Date: Mon, 17 Apr 2017 08:23:56 +0900 Message-Id: X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH 7/7] target/openrisc: Implement full vmstate serialization 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: Stafford Horne , openrisc@lists.librecores.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Previously serialization did not persist the tlb, timer, pic and other key state items. This meant snapshotting and restoring a running os would crash. After adding these I am able to take snapshots of a running linux os and restore at a later time. I am currently not trying to maintain capatibility with older versions as I do not believe this really worked before or anyone used it. Signed-off-by: Stafford Horne --- target/openrisc/machine.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/target/openrisc/machine.c b/target/openrisc/machine.c index 27cc751..2adcda8 100644 --- a/target/openrisc/machine.c +++ b/target/openrisc/machine.c @@ -30,9 +30,59 @@ static int env_post_load(void *opaque, int version_id) env->gpr = env->shadow_gpr[0]; + /* Restore MMU handlers */ + if (env->sr & SR_DME) { + env->tlb->cpu_openrisc_map_address_data = + &cpu_openrisc_get_phys_data; + } else { + env->tlb->cpu_openrisc_map_address_data = + &cpu_openrisc_get_phys_nommu; + } + + if (env->sr & SR_IME) { + env->tlb->cpu_openrisc_map_address_code = + &cpu_openrisc_get_phys_code; + } else { + env->tlb->cpu_openrisc_map_address_code = + &cpu_openrisc_get_phys_nommu; + } + + return 0; } +static const VMStateDescription vmstate_tlb_entry = { + .name = "tlb_entry", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField[]) { + VMSTATE_UINTTL(mr, OpenRISCTLBEntry), + VMSTATE_UINTTL(tr, OpenRISCTLBEntry), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_cpu_tlb = { + .name = "cpu_tlb", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField[]) { + VMSTATE_STRUCT_2DARRAY(itlb, CPUOpenRISCTLBContext, + ITLB_WAYS, ITLB_SIZE, 0, + vmstate_tlb_entry, OpenRISCTLBEntry), + VMSTATE_STRUCT_2DARRAY(dtlb, CPUOpenRISCTLBContext, + DTLB_WAYS, DTLB_SIZE, 0, + vmstate_tlb_entry, OpenRISCTLBEntry), + VMSTATE_END_OF_LIST() + } +}; + +#define VMSTATE_CPU_TLB(_f, _s) \ + VMSTATE_STRUCT_POINTER(_f, _s, vmstate_cpu_tlb, CPUOpenRISCTLBContext) + + static int get_sr(QEMUFile *f, void *opaque, size_t size, VMStateField *field) { CPUOpenRISCState *env = opaque; @@ -92,6 +142,16 @@ static const VMStateDescription vmstate_env = { VMSTATE_UINT32(esr, CPUOpenRISCState), VMSTATE_UINT32(fpcsr, CPUOpenRISCState), VMSTATE_UINT64(mac, CPUOpenRISCState), + + VMSTATE_CPU_TLB(tlb, CPUOpenRISCState), + + VMSTATE_TIMER_PTR(timer, CPUOpenRISCState), + VMSTATE_UINT32(ttmr, CPUOpenRISCState), + VMSTATE_UINT32(ttcr, CPUOpenRISCState), + + VMSTATE_UINT32(picmr, CPUOpenRISCState), + VMSTATE_UINT32(picsr, CPUOpenRISCState), + VMSTATE_END_OF_LIST() } };