From nobody Thu May 2 01:39:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492385169932596.1734773899451; Sun, 16 Apr 2017 16:26:09 -0700 (PDT) Received: from localhost ([::1]:33919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztYW-0004uZ-G0 for importer@patchew.org; Sun, 16 Apr 2017 19:26:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztWb-0003iZ-2L for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cztWa-0007tF-4b for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:09 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:36847) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cztWZ-0007sn-Uy for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:08 -0400 Received: by mail-pg0-x241.google.com with SMTP id 34so21150970pgx.3 for ; Sun, 16 Apr 2017 16:24:07 -0700 (PDT) Received: from localhost (z24.124-44-184.ppp.wakwak.ne.jp. [124.44.184.24]) by smtp.gmail.com with ESMTPSA id y29sm14031373pfj.90.2017.04.16.16.24.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 16 Apr 2017 16:24:06 -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=dP8D5mXHfCmlZKkCceVV+mOKQHLFklS/BMRH3xOn8mI=; b=ieMbztEsLtKQxPsG2UCDKXmyR377A7+UisCB6PTvPb6u2XttRdJtSed3Jp+F6Aphrf 06l/0WTWW3d0tvtVXlqx7vo1nZAFi5y2vHV0zEZqMCfbv+G2MyedRft5lyBbgJQ20jOt R3P5dg5JuDZIr9DM64X5wKNMYBjDZVSoM0UCO9PmDQ37Xy+LV7JfyNU9tanLSeaWCl+b dM47ma2Z/Vn7fleFXh4fiaDuQeMi/BH9YUHFjHEkKIY6QopHYUmePDD+p3AgtH08DMLH 4KkaSjyXaGAkZgfTxUPY5xA/80L/q/ys7FggAh4vULzJ2XRDHVlb8E2EK7QvnDFPEBOU 9+aQ== 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=dP8D5mXHfCmlZKkCceVV+mOKQHLFklS/BMRH3xOn8mI=; b=kYUPhmCetza5+t6STFV9vNzDIEo/hT6HXbiz1sQp5buKE479tpjx2NI0YcG8m5wIbU 6Qho6aKzOmo59FnaS771xmjtqZcHhasd5ldoSB/d6FvkqmWnhzdnEpN9YEcYWmYT/3Ae Fc1ksIkT1sQVD0Ledm1JdQKdeAor0ztAJlgLc1jVoPaaxZ9M0skQ/i4iZo5xZusVU4tK BoPI85O9CExsW8kL1gZ8VgxZAMhOteHs/KNRY1/1ung/AcynHKR8EO2BL+1bEP/OeiwT f4SMZqnX7VL7xfvM2eUvrJSgJogc4+RhBZVXFtZvPc4V0qadceAANlk7YUpr847ZNY9l P0SA== X-Gm-Message-State: AN3rC/6Z57vRfofPcdZGO4+h9pfcG4d7Rj3FFeydzC2G2AwXNP1yD/eS EDoJsft604VS+g== X-Received: by 10.84.193.129 with SMTP id f1mr12110728pld.97.1492385047202; Sun, 16 Apr 2017 16:24:07 -0700 (PDT) From: Stafford Horne To: qemu-devel@nongnu.org Date: Mon, 17 Apr 2017 08:23:50 +0900 Message-Id: <575d21dff52df4fa53d17e77728018453f82e8e5.1492384862.git.shorne@gmail.com> 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::241 Subject: [Qemu-devel] [PATCH 1/7] target/openrisc: Fixes for memory debugging 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When debugging in gdb you might want to inspect instructions in mapped pages or in exception vectors like 0x800 etc. This was previously not possible in qemu since the *get_phys_page_debug() routine only looked into the data tlb. Change to fall back to look into instruction tlb and plain physical pages. Signed-off-by: Stafford Horne Reviewed-by: Richard Henderson --- target/openrisc/mmu.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c index 56b11d3..a6d7bcd 100644 --- a/target/openrisc/mmu.c +++ b/target/openrisc/mmu.c @@ -124,7 +124,7 @@ static int cpu_openrisc_get_phys_addr(OpenRISCCPU *cpu, { int ret =3D TLBRET_MATCH; =20 - if (rw =3D=3D 2) { /* ITLB */ + if (rw =3D=3D MMU_INST_FETCH) { /* ITLB */ *physical =3D 0; ret =3D cpu->env.tlb->cpu_openrisc_map_address_code(cpu, physical, prot, address, r= w); @@ -221,12 +221,27 @@ hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cs,= vaddr addr) OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); hwaddr phys_addr; int prot; + int miss; =20 - if (cpu_openrisc_get_phys_addr(cpu, &phys_addr, &prot, addr, 0)) { - return -1; + /* Check memory for any kind of address, since during debug the + gdb can ask for anything, check data tlb for address */ + miss =3D cpu_openrisc_get_phys_addr(cpu, &phys_addr, &prot, addr, 0); + + /* Check instruction tlb */ + if (miss) { + miss =3D cpu_openrisc_get_phys_addr(cpu, &phys_addr, &prot, addr, = MMU_INST_FETCH); + } + + /* Last, fall back to a plain address */ + if (miss) { + miss =3D cpu_openrisc_get_phys_nommu(cpu, &phys_addr, &prot, addr,= 0); } =20 - return phys_addr; + if (miss) { + return -1; + } else { + return phys_addr; + } } =20 void cpu_openrisc_mmu_init(OpenRISCCPU *cpu) --=20 2.9.3 From nobody Thu May 2 01:39:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492385173337713.7768702704142; Sun, 16 Apr 2017 16:26:13 -0700 (PDT) Received: from localhost ([::1]:33920 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztYZ-0004x2-TQ for importer@patchew.org; Sun, 16 Apr 2017 19:26:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztWd-0003jY-Gp for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cztWc-0007vJ-L7 for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:11 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:34661) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cztWc-0007up-Fr for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:10 -0400 Received: by mail-pf0-x244.google.com with SMTP id g23so7372895pfj.1 for ; Sun, 16 Apr 2017 16:24:10 -0700 (PDT) Received: from localhost (z24.124-44-184.ppp.wakwak.ne.jp. [124.44.184.24]) by smtp.gmail.com with ESMTPSA id s14sm14059208pgs.0.2017.04.16.16.24.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 16 Apr 2017 16:24:09 -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=/7nCUc5Oqr0hH5gdktnbwA7Ic/u4eLetTKmxuFQa0V4=; b=ryDaaFq9q+ap6xtTEQKyS7Kvr9LkXCGf7JgTqpv/Fybgsr0uBlAhC/4Q3fSdWNyPM0 LnoZsSXOmEhh4zT1PIVV9uOD068B0H42tuC07MFsDsmVk7pMUXWKZq4Jq7Kx389R03zd 47eSjEp7ic+7F/tFxul7LOunCLci7n8TZub0+Yzy7kFG06SY7Z75K2e9jtAcQYaSyb0D b4BZyJiGQwT88nvG+OovEa4nj9GMBygvMRxnQKnVJ0jB7ZAjXMMVs6pWWdgFBF36o0/L qCway+H2GUiMbewBPdfuUGrRb5A6rr0ePImt6bW8Rq6ALO61q+dDza58APXpzSuKewWW nGEA== 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=/7nCUc5Oqr0hH5gdktnbwA7Ic/u4eLetTKmxuFQa0V4=; b=OMH2QHt1Nwtuqfs9h/NVS708dO0UlBS7FmZCtGpXtfXeXZrz+sbXJFtoHs1XwZVEkt u0EJmXulw/m1wEJf8RhQXuHBNz/L2m8x7WbzD7DQDEtcC680jduDryUzul6cak/OtL04 A/e+ZxfZgDUzRx3M+fVM4YXiP8RCFOkcSzEE/T2nYVUCEjQbrK3Ky9xvflKUANxttzWm UWnlx/B+g+O1ksGi/QktE2MiFsiQ+FBmhjqc4lWBoQK+cDvySe0NMzJ41p4rr19Wk/IN 0DLuNNRXjVRLva2d98goqwhGH1FzzdiJ78rOjSvlCcawCoY6XZURArM0m+W+993YfDEB i83g== X-Gm-Message-State: AN3rC/7sKN/FsNsmm43scH9kGjxoVHknbH6UnOdTrj5Dr56IjFixEwou yD4aPKT3+7ANkQ== X-Received: by 10.98.192.129 with SMTP id g1mr8897471pfk.254.1492385049588; Sun, 16 Apr 2017 16:24:09 -0700 (PDT) From: Stafford Horne To: qemu-devel@nongnu.org Date: Mon, 17 Apr 2017 08:23:51 +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: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH 2/7] target/openrisc: add shutdown logic 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In openrisc simulators we use hooks like 'l.nop 1' to cause the simulator to exit. Implement that for qemu too. Reported-by: Waldemar Brodkorb Signed-off-by: Stafford Horne --- target/openrisc/helper.h | 1 + target/openrisc/sys_helper.c | 17 +++++++++++++++++ target/openrisc/translate.c | 5 ++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/target/openrisc/helper.h b/target/openrisc/helper.h index 4fd1a6b..b7838f5 100644 --- a/target/openrisc/helper.h +++ b/target/openrisc/helper.h @@ -59,3 +59,4 @@ DEF_HELPER_FLAGS_1(rfe, 0, void, env) /* sys */ DEF_HELPER_FLAGS_4(mtspr, 0, void, env, tl, tl, tl) DEF_HELPER_FLAGS_4(mfspr, TCG_CALL_NO_WG, tl, env, tl, tl, tl) +DEF_HELPER_1(nop, void, i32) diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index 60c3193..2eaff87 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -22,6 +22,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "exec/helper-proto.h" +#include "sysemu/sysemu.h" =20 #define TO_SPR(group, number) (((group) << 11) + (number)) =20 @@ -286,3 +287,19 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, /* for rd is passed in, if rd unchanged, just keep it back. */ return rd; } + +/* In openrisc simulators nop can be used to do intersting + * things like shut down the simulator */ +void HELPER(nop)(uint32_t arg) +{ +#ifndef CONFIG_USER_ONLY + switch (arg) { + case 0x001: /* NOP_EXIT */ + case 0x00c: /* NOP_EXIT_SILENT */ + qemu_system_shutdown_request(); + break; + default: + break; + } +#endif +} diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 7c4cbf2..74df245 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -755,8 +755,11 @@ static void dec_misc(DisasContext *dc, uint32_t insn) switch (op1) { case 0x01: /* l.nop */ LOG_DIS("l.nop %d\n", I16); + { + TCGv_i32 arg =3D tcg_const_i32(I16); + gen_helper_nop(arg); + } break; - default: gen_illegal_exception(dc); break; --=20 2.9.3 From nobody Thu May 2 01:39:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492385308403129.598921686347; Sun, 16 Apr 2017 16:28:28 -0700 (PDT) Received: from localhost ([::1]:33925 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztal-0006ia-7S for importer@patchew.org; Sun, 16 Apr 2017 19:28:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37954) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztWj-0003mG-AY for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cztWf-0007wy-Cl for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:17 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:34951) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cztWf-0007wT-7B for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:13 -0400 Received: by mail-pf0-x243.google.com with SMTP id a188so22059686pfa.2 for ; Sun, 16 Apr 2017 16:24:13 -0700 (PDT) Received: from localhost (z24.124-44-184.ppp.wakwak.ne.jp. [124.44.184.24]) by smtp.gmail.com with ESMTPSA id t2sm3864485pfl.34.2017.04.16.16.24.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 16 Apr 2017 16:24:11 -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=ZkArrvFbJGfcjdT5msw5+fCYI6szHZMz+VsxFUstK60=; b=D5fKf/bSWQDkvi7EFEq9IujDBPPLVlkFo9a5iFrhQ4mNOrLGReYezRMJHDMJiV5bqN A3tunCCxAwf6LJuy6BisZ0yeFKoH+dtbh3V5aSVOfX9kU2kEs2XG7zbjlQv8VS4jpWrL DIVnQKDIOy6ozyIeg8iVWBB+pL/aoiXJLVgocmuijAlqAC2WtRkhCdXxIZ32uAbtxir+ 6ErruAK/EyeQuU2T2nZQ6DOpJSVLf0XNaodvJs9fy8QCQhfccoXTSnkEQQWrmHd08hSp vj5IUfXUDLA5dK/c85zKrXSnWQgjuKO36FK8HT5zBKUqVzrUQ/tGNEGo8y4Mwz7ixkoN 4XXQ== 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=ZkArrvFbJGfcjdT5msw5+fCYI6szHZMz+VsxFUstK60=; b=cakwHolqEEFKqBqtndjeOLK2iMEDv3Lj3vkhE5cvEyINug6GEjGuI+DND5Ug0B0gi4 G+p5CYioTG8jsLv3v1OOGW2NjeBQolAfcKDeJFZD9qegUh0juYkD/FtdiPGeBR1YLAU1 aNbwWcijHDjvnqHhPynatuyylp+e4V0bWQ/yZfYA4kEhGeJK0Qgva6IlmL7yMYw6YF/b mZyykUgo6SLiAMN+PNdszmE1J0in1IfIT9F/wxNGLhR7Khcp5cUcKDwP2VafxoC9HiLZ EKy9gFWpIy0FK+5FpzvAv4cnLwFkbWGoDYwBD4xJz4YbEpWVQM5JCZfLNs5IJ7JV1nrY I3Mw== X-Gm-Message-State: AN3rC/4jBC7fgGewwj+hXqUk/r8/1BBqmIntx72R7tqFri4n0kYGIlQQ TOtQxtqoNTbpyw== X-Received: by 10.98.68.133 with SMTP id m5mr9038950pfi.60.1492385052352; Sun, 16 Apr 2017 16:24:12 -0700 (PDT) From: Stafford Horne To: qemu-devel@nongnu.org Date: Mon, 17 Apr 2017 08:23:52 +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: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH 3/7] target/openrisc: add numcores and coreid 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: Stafford Horne , openrisc@lists.librecores.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These are used to identify the processor in SMP system. Their definition has been defined in verilog cores but it not yet part of the spec but it will be soon. The proposal for this is available: https://openrisc.io/proposals/core-identifier-and-number-of-cores Signed-off-by: Stafford Horne Reviewed-by: Richard Henderson --- target/openrisc/sys_helper.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index 2eaff87..bd5051b 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -227,6 +227,12 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, case TO_SPR(0, 64): /* ESR */ return env->esr; =20 + case TO_SPR(0, 128): /* COREID */ + return 0; + + case TO_SPR(0, 129): /* NUMCORES */ + return 1; + case TO_SPR(1, 512) ... TO_SPR(1, 512+DTLB_SIZE-1): /* DTLBW0MR 0-127 = */ idx =3D spr - TO_SPR(1, 512); return env->tlb->dtlb[0][idx].mr; --=20 2.9.3 From nobody Thu May 2 01:39:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492385182166486.27266758820383; Sun, 16 Apr 2017 16:26:22 -0700 (PDT) Received: from localhost ([::1]:33921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztYi-00053x-T3 for importer@patchew.org; Sun, 16 Apr 2017 19:26:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztWj-0003mN-EL for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cztWh-0007y7-Qb for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:17 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:35018) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cztWh-0007xc-JK for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:15 -0400 Received: by mail-pg0-x242.google.com with SMTP id g2so24007635pge.2 for ; Sun, 16 Apr 2017 16:24:15 -0700 (PDT) Received: from localhost (z24.124-44-184.ppp.wakwak.ne.jp. [124.44.184.24]) by smtp.gmail.com with ESMTPSA id r185sm14024366pfr.72.2017.04.16.16.24.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 16 Apr 2017 16:24:14 -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=3QwNflO5pkqrqoHWVTWJ5z2CgXrUV3mCS8i3vV6s0C0=; b=dcdhI4zOZtacib7y+WoFUw/URwwd8It3ZOw0oUBSHFdVrcb2Ps0hQItCKXzdOT7/2H kgTYfSaARx3ASkKtypvRL8u32bOV384W4ShNbJangrYdO3emY6w/Z3d2dIPyijQv7rAi 4axgqm4200crLRQzIRy9U8xqiA+CUXuUDL+Shp5DkZ0gALawX2TFsSeEQYcLU2YDtvRB qN3D7QkCgbqcY4071LFlXoFfjqHLbNGiotQT698optItSoGpMWTQhtivxj3RfSlprVM+ enxq3ZmQinhm4uLgRKDZzxG7pUxg3IqGBPo/ajHop6uRa3T8qtDeM56HdhaammiHB81z x0Qw== 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=3QwNflO5pkqrqoHWVTWJ5z2CgXrUV3mCS8i3vV6s0C0=; b=DZLmMRMRx9RYamxGuXpMBfwLadUdH2HwIAuqHx0g4hr4X7UZZbQ+wYPbmWi9tkSYyo frWtrO8sNPOvvxfWuPgbLZh60kw6fUSvO3cGjZ5aMgI7eNwA744KVJYecuP+KohwODd/ eaVSKVQ5M2ePLgAtJRJg6BiAWfniui6lQSO1otY5BvXWrmzX0580OZyY/iP3wSJyj9pG TfTun9QnS0GVdZAF0RZzLK05hqKh02PNtLY2TiMPkdr9zzRdnFjpwlDNdgicDxckf5sO eCQxAbKOasWgvWXI1nps2e7XtQlU8GfhjyPxVScKaDtfQ3AtEooVcR3efXsn/joiTyo9 8WDA== X-Gm-Message-State: AN3rC/6pvk/zvvfcc5Ja4KElgbVQH6AJwi7Qyn/GdU4IU+5oM0oazO02 1+15WFhLgv584g== X-Received: by 10.99.125.73 with SMTP id m9mr9185054pgn.234.1492385054666; Sun, 16 Apr 2017 16:24:14 -0700 (PDT) From: Stafford Horne To: qemu-devel@nongnu.org Date: Mon, 17 Apr 2017 08:23:53 +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::242 Subject: [Qemu-devel] [PATCH 4/7] target/openrisc: implement shadow registers 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Shadow registers are part of the openrisc spec along with sr[cid], as part of the fast context switching feature. When exceptions occur, instead of having to save registers to the stack if enabled the CID will increment and a new set of registers will be available. This patch only implements shadow registers which can be used as extra scratch registers via the mfspr and mtspr if required. This is implemented in a way where it would be easy to add on the fast context switching, currently cid is hardcoded to 0. This is need for openrisc linux smp kernels to boot correctly. Signed-off-by: Stafford Horne --- target/openrisc/cpu.c | 5 ++++- target/openrisc/cpu.h | 4 +++- target/openrisc/machine.c | 16 +++++++++++++--- target/openrisc/sys_helper.c | 9 +++++++++ target/openrisc/translate.c | 3 ++- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index 7fd2b9a..dc8be21 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -46,13 +46,14 @@ static void openrisc_cpu_reset(CPUState *s) =20 memset(&cpu->env, 0, offsetof(CPUOpenRISCState, end_reset_fields)); =20 + cpu->env.gpr =3D cpu->env.shadow_gpr[0]; cpu->env.pc =3D 0x100; cpu->env.sr =3D SR_FO | SR_SM; cpu->env.lock_addr =3D -1; s->exception_index =3D -1; =20 cpu->env.upr =3D UPR_UP | UPR_DMP | UPR_IMP | UPR_PICP | UPR_TTP; - cpu->env.cpucfgr =3D CPUCFGR_OB32S | CPUCFGR_OF32S; + cpu->env.cpucfgr =3D CPUCFGR_OB32S | CPUCFGR_OF32S | CPUCFGR_NSGF; cpu->env.dmmucfgr =3D (DMMUCFGR_NTW & (0 << 2)) | (DMMUCFGR_NTS & (6 <= < 2)); cpu->env.immucfgr =3D (IMMUCFGR_NTW & (0 << 2)) | (IMMUCFGR_NTS & (6 <= < 2)); =20 @@ -132,6 +133,7 @@ static void or1200_initfn(Object *obj) { OpenRISCCPU *cpu =3D OPENRISC_CPU(obj); =20 + set_feature(cpu, OPENRISC_FEATURE_NSGF); set_feature(cpu, OPENRISC_FEATURE_OB32S); set_feature(cpu, OPENRISC_FEATURE_OF32S); } @@ -140,6 +142,7 @@ static void openrisc_any_initfn(Object *obj) { OpenRISCCPU *cpu =3D OPENRISC_CPU(obj); =20 + set_feature(cpu, OPENRISC_FEATURE_NSGF); set_feature(cpu, OPENRISC_FEATURE_OB32S); } =20 diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 418a0e6..78675e0 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -269,7 +269,9 @@ typedef struct CPUOpenRISCTLBContext { #endif =20 typedef struct CPUOpenRISCState { - target_ulong gpr[32]; /* General registers */ + target_ulong shadow_gpr[16][32]; /* Shadow registers */ + target_ulong * gpr; /* General registers (backed by shadow) */ + target_ulong pc; /* Program counter */ target_ulong ppc; /* Prev PC */ target_ulong jmp_pc; /* Jump PC */ diff --git a/target/openrisc/machine.c b/target/openrisc/machine.c index 686eaa3..27cc751 100644 --- a/target/openrisc/machine.c +++ b/target/openrisc/machine.c @@ -24,6 +24,15 @@ #include "hw/boards.h" #include "migration/cpu.h" =20 +static int env_post_load(void *opaque, int version_id) +{ + CPUOpenRISCState *env =3D opaque; + + env->gpr =3D env->shadow_gpr[0]; + + return 0; +} + static int get_sr(QEMUFile *f, void *opaque, size_t size, VMStateField *fi= eld) { CPUOpenRISCState *env =3D opaque; @@ -47,10 +56,11 @@ static const VMStateInfo vmstate_sr =3D { =20 static const VMStateDescription vmstate_env =3D { .name =3D "env", - .version_id =3D 4, - .minimum_version_id =3D 4, + .version_id =3D 5, + .minimum_version_id =3D 5, + .post_load =3D env_post_load, .fields =3D (VMStateField[]) { - VMSTATE_UINTTL_ARRAY(gpr, CPUOpenRISCState, 32), + VMSTATE_UINTTL_2DARRAY(shadow_gpr, CPUOpenRISCState, 16, 32), VMSTATE_UINTTL(pc, CPUOpenRISCState), VMSTATE_UINTTL(ppc, CPUOpenRISCState), VMSTATE_UINTTL(jmp_pc, CPUOpenRISCState), diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index bd5051b..04ff302 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -89,6 +89,11 @@ void HELPER(mtspr)(CPUOpenRISCState *env, case TO_SPR(0, 64): /* ESR */ env->esr =3D rb; break; + + case TO_SPR(0, 1024) ... TO_SPR(0, 1024 + (16 * 32)): /* Shadow GPRs */ + idx =3D (spr - 1024); + env->shadow_gpr[idx / 32][idx % 32] =3D rb; + case TO_SPR(1, 512) ... TO_SPR(1, 512+DTLB_SIZE-1): /* DTLBW0MR 0-127 = */ idx =3D spr - TO_SPR(1, 512); if (!(rb & 1)) { @@ -233,6 +238,10 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, case TO_SPR(0, 129): /* NUMCORES */ return 1; =20 + case TO_SPR(0, 1024) ... TO_SPR(0, 1024 + (16 * 32)): /* Shadow GPRs */ + idx =3D (spr - 1024); + return env->shadow_gpr[idx / 32][idx % 32]; + case TO_SPR(1, 512) ... TO_SPR(1, 512+DTLB_SIZE-1): /* DTLBW0MR 0-127 = */ idx =3D spr - TO_SPR(1, 512); return env->tlb->dtlb[0][idx].mr; diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 74df245..c7261cb 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -107,7 +107,8 @@ void openrisc_translate_init(void) "mac"); for (i =3D 0; i < 32; i++) { cpu_R[i] =3D tcg_global_mem_new(cpu_env, - offsetof(CPUOpenRISCState, gpr[i]), + offsetof(CPUOpenRISCState, + shadow_gpr[0][i]), regnames[i]); } cpu_R0 =3D cpu_R[0]; --=20 2.9.3 From nobody Thu May 2 01:39:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492385311739346.4912816187813; Sun, 16 Apr 2017 16:28:31 -0700 (PDT) Received: from localhost ([::1]:33926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztao-0006lc-Hz for importer@patchew.org; Sun, 16 Apr 2017 19:28:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37979) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztWk-0003nZ-Q3 for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cztWj-0007zG-U0 for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:18 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:33400) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cztWj-0007yk-OZ for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:17 -0400 Received: by mail-pf0-x242.google.com with SMTP id c198so22067249pfc.0 for ; Sun, 16 Apr 2017 16:24:17 -0700 (PDT) Received: from localhost (z24.124-44-184.ppp.wakwak.ne.jp. [124.44.184.24]) by smtp.gmail.com with ESMTPSA id d83sm8856129pfe.40.2017.04.16.16.24.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 16 Apr 2017 16:24:16 -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=+4Icp+M0RQj6v24329W16eXLptpcG7P4F8rWNRb6XDQ=; b=IzBRjXaaoJStS3KrkDSdtF5N5KeYLK7V00DrJVPUJd91MEgbqMS5pexoYQ7yS/R1iZ HUUU7ubvopjaeOWufBDJnKQLGasetsOFQyV2UlsP7seQpiyYUtLxycmjMiho5weFSh8y R8VG9s3nQwGLG9GJ3xxgAabxNMlPBsIV9BxrXpBIWC9cH8SEQ7lrCTwEaU1023aomD3g u1Cq8uBtzVGv1wZAMlKGaISO7Eyjyg4qcZzvRxJP546VEgHHhn8X8HX4yKJJ92rEWuvd VuJAZesFL2qeWZNE7FwqVK2b4GbufMCUN6vqvF4/60jAUnjKhxXBzZgyW4U2KMfTxNnd JhoA== 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=+4Icp+M0RQj6v24329W16eXLptpcG7P4F8rWNRb6XDQ=; b=XF7Ue/XKZ4ofZ+0yRoo8IQc04IPhkc6stgfvWaoopcX2GoqUdsKaNfTIXjr/NjCXtp wpL/IrK2GEe20QDKYyQDLVheuPt4lJ7X9nbEFAOnsqGvxL+/ZQGLbX8bxVvLM9yGGLsN ZVJyfktTg/ctKJLzgtIrMYL5tu76ps837bcJrpkrkF93ipIbzVdc3oMiqb/OGk2VGpb+ 8HtaXjsrvy+jtMOkuzhgV72Pfr9sMV5b2g9xo2tED3FDEpFo5qJU/iNkKbN8O9CgYN5X Ax6A7OC4jozE8O0idIJc2oDdc4E8o+enkdIPCxap8wv6T6AR6hNa/RDGxyBPfui/1UKi kLPw== X-Gm-Message-State: AN3rC/6mwCJ5QQEL/aNQl3pOgRP09CInfd+CPzFBp83CcgrWHxKbKI9d MiGR5rGd+RJTjw== X-Received: by 10.99.2.72 with SMTP id 69mr8996434pgc.23.1492385056948; Sun, 16 Apr 2017 16:24:16 -0700 (PDT) From: Stafford Horne To: qemu-devel@nongnu.org Date: Mon, 17 Apr 2017 08:23:54 +0900 Message-Id: <319fd7910ccc8ab543e2396f3d757f76084eac88.1492384862.git.shorne@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH 5/7] migration: Add VMSTATE_UINTTL_2DARRAY() 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In openRISC we are implementing the shadow registers as a 2d array. Using this target long method rather than direct 32-bit alternatives is consistent with the rest of our vm state serialization logic. Signed-off-by: Stafford Horne --- include/migration/cpu.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/migration/cpu.h b/include/migration/cpu.h index f3d5dfc..a40bd35 100644 --- a/include/migration/cpu.h +++ b/include/migration/cpu.h @@ -18,6 +18,8 @@ VMSTATE_UINT64_EQUAL_V(_f, _s, _v) #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \ VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) +#define VMSTATE_UINTTL_2DARRAY_V(_f, _s, _n1, _n2, _v) \ + VMSTATE_UINT64_2DARRAY_V(_f, _s, _n1, _n2, _v) #define VMSTATE_UINTTL_TEST(_f, _s, _t) \ VMSTATE_UINT64_TEST(_f, _s, _t) #define vmstate_info_uinttl vmstate_info_uint64 @@ -37,6 +39,8 @@ VMSTATE_UINT32_EQUAL_V(_f, _s, _v) #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v) \ VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) +#define VMSTATE_UINTTL_2DARRAY_V(_f, _s, _n1, _n2, _v) \ + VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, _v) #define VMSTATE_UINTTL_TEST(_f, _s, _t) \ VMSTATE_UINT32_TEST(_f, _s, _t) #define vmstate_info_uinttl vmstate_info_uint32 @@ -48,5 +52,8 @@ VMSTATE_UINTTL_EQUAL_V(_f, _s, 0) #define VMSTATE_UINTTL_ARRAY(_f, _s, _n) \ VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, 0) +#define VMSTATE_UINTTL_2DARRAY(_f, _s, _n1, _n2) \ + VMSTATE_UINTTL_2DARRAY_V(_f, _s, _n1, _n2, 0) + =20 #endif --=20 2.9.3 From nobody Thu May 2 01:39:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492385317600546.3944971492676; Sun, 16 Apr 2017 16:28:37 -0700 (PDT) Received: from localhost ([::1]:33927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztau-0006pb-EU for importer@patchew.org; Sun, 16 Apr 2017 19:28:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztWn-0003pp-5j for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cztWm-00080g-9U for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:21 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:34155) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cztWm-000804-3e for qemu-devel@nongnu.org; Sun, 16 Apr 2017 19:24:20 -0400 Received: by mail-pg0-x244.google.com with SMTP id o123so24023636pga.1 for ; Sun, 16 Apr 2017 16:24:20 -0700 (PDT) Received: from localhost (z24.124-44-184.ppp.wakwak.ne.jp. [124.44.184.24]) by smtp.gmail.com with ESMTPSA id v1sm14028358pgv.14.2017.04.16.16.24.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 16 Apr 2017 16:24:18 -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=1ULqFvCAucxpqTx+6eOt1U2rQEOVWS/jn5Ic4C9K95s=; b=Eyf4H8PDfBfSwheKZg7aaKoq7B2hdLHgFqbf4pSnQL3uAXz2wvCoV+gmtwiHYWDJlU tXzNxcUiLa1hkV8ZteIpv+McW8zZn8GPKSRgCZtTZ5thOHxGbq9yx98QSCr7z/kasi+T L2WwRsuFx2g0BTmnq/luyR2UI13MiIZk7otc78QU2p6H/KW5C5LpaSiA+8iLotGu2/OF STBRP+Y+5JDOQXquQcdsGvdQua2OzjOjgmbRMgM6GkeRwtpCfKMkPH1gvaZVjibqW6ST mXe/UTRzx6zqQvBXkFMV3/WegzCUl7TFSmb6J7r/khx/dBpse0XELtq+OlK6GcaT3BcX 9xhQ== 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=1ULqFvCAucxpqTx+6eOt1U2rQEOVWS/jn5Ic4C9K95s=; b=LN+1790EPpMyLW+Xakv13PVSCu6EToStrqYI6v+byDbSQLvTlN+yojFoIqbSP9gbU3 PBVDnejJ3jX6riP30KYF1mqyVhVMOGf4SPsGXYUBJZPndEAjZW3MW0dQ6Rsbj76bJvZu FahFHlwgGPLN38wsG9anTi0BXLXKPm2lT2K9FSSWx11AEWE+Ltb0/IDClX8xFDgp4HPn sWM27/OTuIttli+9UhSLVu9kCnvQa/1QtoXhxMVTdcLTqnJgIu8xF1ju5dmPw3hdoO9r QRHJEgqiFb5gZr6k7fmx/S/GRLN2ryuxl3oLLtiNsH2mAPfJ9tZ9L2h+1ZoCcsNKfa7m R/TA== X-Gm-Message-State: AN3rC/4bf1ThvPkKv3ydGG+d9XTn9arHoriKG1o7DkwKkLHw4lcZuMmr E5HQ4XTbWVBPIQ== X-Received: by 10.84.218.72 with SMTP id f8mr12043906plm.146.1492385059238; Sun, 16 Apr 2017 16:24:19 -0700 (PDT) From: Stafford Horne To: qemu-devel@nongnu.org Date: Mon, 17 Apr 2017 08:23:55 +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 6/7] migration: Add VMSTATE_STRUCT_2DARRAY() 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For openrisc we implement tlb state as a 2d array of tlb entry structs. This is added to allow easy storing of state of 2d arrays. Signed-off-by: Stafford Horne --- include/migration/vmstate.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index f2dbf84..9b7dcdc 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -499,6 +499,17 @@ extern const VMStateInfo vmstate_info_qtailq; .offset =3D vmstate_offset_array(_state, _field, _type, _num),\ } =20 +#define VMSTATE_STRUCT_2DARRAY_TEST(_field, _state, _n1, _n2, _test, _vers= ion, _vmsd, _type) { \ + .name =3D (stringify(_field)), = \ + .num =3D (_n1) * (_n2), = \ + .field_exists =3D (_test), = \ + .version_id =3D (_version), = \ + .vmsd =3D &(_vmsd), = \ + .size =3D sizeof(_type), = \ + .flags =3D VMS_STRUCT|VMS_ARRAY, = \ + .offset =3D vmstate_offset_2darray(_state, _field, _type, _n1, _= n2),\ +} + #define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, = _vmsd, _type) { \ .name =3D (stringify(_field)), \ .num_offset =3D vmstate_offset_value(_state, _field_num, uint8_t), \ @@ -746,6 +757,10 @@ extern const VMStateInfo vmstate_info_qtailq; VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version, \ _vmsd, _type) =20 +#define VMSTATE_STRUCT_2DARRAY(_field, _state, _n1, _n2, _version, _vmsd, = _type) \ + VMSTATE_STRUCT_2DARRAY_TEST(_field, _state, _n1, _n2, NULL, _version, = \ + _vmsd, _type) + #define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size)= \ VMSTATE_BUFFER_UNSAFE_INFO_TEST(_field, _state, NULL, _version, _info,= \ _size) --=20 2.9.3 From nobody Thu May 2 01:39:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492385425323563.6898613448323; Sun, 16 Apr 2017 16:30:25 -0700 (PDT) Received: from localhost ([::1]:33938 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cztce-00085p-6E for importer@patchew.org; Sun, 16 Apr 2017 19:30:24 -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) 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) 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) 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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) =20 env->gpr =3D env->shadow_gpr[0]; =20 + /* Restore MMU handlers */ + if (env->sr & SR_DME) { + env->tlb->cpu_openrisc_map_address_data =3D + &cpu_openrisc_get_phys_data; + } else { + env->tlb->cpu_openrisc_map_address_data =3D + &cpu_openrisc_get_phys_nommu; + } + + if (env->sr & SR_IME) { + env->tlb->cpu_openrisc_map_address_code =3D + &cpu_openrisc_get_phys_code; + } else { + env->tlb->cpu_openrisc_map_address_code =3D + &cpu_openrisc_get_phys_nommu; + } + + return 0; } =20 +static const VMStateDescription vmstate_tlb_entry =3D { + .name =3D "tlb_entry", + .version_id =3D 1, + .minimum_version_id =3D 1, + .minimum_version_id_old =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINTTL(mr, OpenRISCTLBEntry), + VMSTATE_UINTTL(tr, OpenRISCTLBEntry), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_cpu_tlb =3D { + .name =3D "cpu_tlb", + .version_id =3D 1, + .minimum_version_id =3D 1, + .minimum_version_id_old =3D 1, + .fields =3D (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 *fi= eld) { CPUOpenRISCState *env =3D opaque; @@ -92,6 +142,16 @@ static const VMStateDescription vmstate_env =3D { 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() } }; --=20 2.9.3