From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529347569061688.3002174299274; Mon, 18 Jun 2018 11:46:09 -0700 (PDT) Received: from localhost ([::1]:36487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzAG-0006sA-96 for importer@patchew.org; Mon, 18 Jun 2018 14:46:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5E-0003LD-9p for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:40:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5C-0004H8-GP for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:40:56 -0400 Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]:42590) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5C-0004FX-9G for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:40:54 -0400 Received: by mail-pf0-x22d.google.com with SMTP id w7-v6so8602266pfn.9 for ; Mon, 18 Jun 2018 11:40:54 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.40.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h9EcEeIiRyzr77fdlYxvvGDt79bI/tlZcqhj03JY7uY=; b=Y5n6QCgPHQxdQeoo077jb9YMGpLAD5CEQIfAkgA2k1zUup55j5E++5ksc+OIylbCS8 afM2xlsHsYnbQKKTeb9BdgomFF5paGnt0vbwuvwq5mdmoCF7qHyQGgrviUWwR3cb3MU+ zzvNUnYg4ntMQXbr+iOx8QxT9tItpzMzWXeQA= 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:mime-version:content-transfer-encoding; bh=h9EcEeIiRyzr77fdlYxvvGDt79bI/tlZcqhj03JY7uY=; b=Y8pbcTjxBfbHRETQ3f/y+KUV4mNdVyROVAMARMKsxmQgHPUdX0CJkFO05b6IMq/kKA RGxyIcSe5I2TSSPlMnTbuWS05FyrXKiSqmzKyyfHPOwMZKjtLIhGixf3mo+xoTcH5p/w Ph6u3oVsKlp401Qw/p2bvdthOGNcof81lztxGvATYKtYPjWxiZQ/q6ZgsnoeP6eTznDy p5zEgJonKGjmpMmsOSJ23Qx/53jY3XG5rICRQomywRtuXVNyAvT7xc36HTN0ppeGwrlj uwGyhXOMsLdHc2pT8KXHbwAAYY7A3PVRf+HWS9ZmWnEpVjK+HaSfN0ylDtXXHpIMlu31 7wIQ== X-Gm-Message-State: APt69E1WwmKP6/yMrAp1q3UcLM5pWrxCR8+X8chsgSO8SjpvWxWWXkIx y9K+iWDWq+hZ/JRjsSuNonkasPdgAXg= X-Google-Smtp-Source: ADUXVKKUDD7eCi4Y3xdMMw90UOMKUgcVUjuxsOlnS0oSarRiX5txkYgOwjXA6ygdakq0mMP4JLyVPg== X-Received: by 2002:a62:e8d:: with SMTP id 13-v6mr14632383pfo.63.1529347252972; Mon, 18 Jun 2018 11:40:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:25 -1000 Message-Id: <20180618184046.6270-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22d Subject: [Qemu-devel] [PATCH v2 01/22] target/openrisc: Remove DISAS_JUMP & DISAS_TB_JUMP 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: shorne@gmail.com 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 These values are unused. Reviewed-by: Stafford Horne Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/openrisc/translate.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index d69f8d0422..2d7588a3eb 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -41,9 +41,7 @@ ## __VA_ARGS__) =20 /* is_jmp field values */ -#define DISAS_JUMP DISAS_TARGET_0 /* only pc was modified dynamically */ #define DISAS_UPDATE DISAS_TARGET_1 /* cpu state was modified dynamically= */ -#define DISAS_TB_JUMP DISAS_TARGET_2 /* only pc was modified statically */ =20 typedef struct DisasContext { DisasContextBase base; @@ -1467,8 +1465,6 @@ static void openrisc_tr_tb_stop(DisasContextBase *dcb= ase, CPUState *cs) gen_goto_tb(dc, 0, dc->base.pc_next); break; case DISAS_NORETURN: - case DISAS_JUMP: - case DISAS_TB_JUMP: break; case DISAS_UPDATE: /* indicate that the hash table must be used --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529347394170466.24844002608233; Mon, 18 Jun 2018 11:43:14 -0700 (PDT) Received: from localhost ([::1]:36470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz7J-0004TU-4p for importer@patchew.org; Mon, 18 Jun 2018 14:43:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5F-0003LG-7R for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:40:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5E-0004L7-5H for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:40:57 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:35480) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5D-0004J0-VW for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:40:56 -0400 Received: by mail-pg0-x242.google.com with SMTP id 15-v6so7928000pge.2 for ; Mon, 18 Jun 2018 11:40:55 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.40.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/UPpLQKJjB4WlC3Mt7cbg+cnQYnU8YCz/2dtHJ2hEe8=; b=WvZVaOzG7ExIVl893ySN1XT44icmngnyMdIJJM+AcVoCuuijW5NNVD1zZvWrtMHNQV r4Cv7t9x19Tj6jZ7ReEVsB7gzmKQLGNrj8WOkUCCgJDQILzwGpTFJfV+E2gxvagc+pCZ /EWmtLTewf45N/3MWq2y6VfTJk8JkHOOLycug= 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=/UPpLQKJjB4WlC3Mt7cbg+cnQYnU8YCz/2dtHJ2hEe8=; b=VxEYfAAEp1cnZovFKYHbfupo5YcDka7RIm8xHIxQ1GjzniPU4L3uJ4V9pODZSYY4RW rPQDiZ5SBUTpDvr7eRAM4knPiFGvDHn5HXQK8byfZ+oLTmWzg27PYk5zQZWaO5RTJJVA sODsUlT1WSCWAl2NcpnSIEqFmtMPnVZyEZfZNitrhVfIs2jw/6wCzgzD0yBSG7DNYk6M TVSh5G18Vez5B0HLFYduGiI+6Cg7jaTw4SLh/qnzmBOR4UPO+eZrsKnwUR6/nwg9XZzS ci+7t+Xi1/p6X3llBgHoznwGdyKiHJ8CiK1EviUhxPEYSstz2Miv2dsZfA0G+b4vGwvk 4myQ== X-Gm-Message-State: APt69E3VVHDHoe+ohsm8T6AqgjcH72zRfFnBfuIbb5GeWBvAQNhj1kdi pdqL81iUDJX8gHxHTVTBqjC5HwAWmIU= X-Google-Smtp-Source: ADUXVKJsQs0xF5J1RfImu9reFhhsTPquVbwPAXvUg9ldX7sRJ1Xxpzvvf6CQ+9mwhdsqO/NDB9Dhmw== X-Received: by 2002:a62:e401:: with SMTP id r1-v6mr14710985pfh.172.1529347254732; Mon, 18 Jun 2018 11:40:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:26 -1000 Message-Id: <20180618184046.6270-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v2 02/22] target/openrisc: Use exit_tb instead of CPU_INTERRUPT_EXITTB 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: shorne@gmail.com 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" No need to use the interrupt mechanisms when we can simply exit the tb directly. Reviewed-by: Stafford Horne Signed-off-by: Richard Henderson --- target/openrisc/interrupt_helper.c | 3 +-- target/openrisc/translate.c | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/target/openrisc/interrupt_helper.c b/target/openrisc/interrupt= _helper.c index 56620e0571..b865738f8b 100644 --- a/target/openrisc/interrupt_helper.c +++ b/target/openrisc/interrupt_helper.c @@ -26,7 +26,6 @@ void HELPER(rfe)(CPUOpenRISCState *env) { OpenRISCCPU *cpu =3D openrisc_env_get_cpu(env); - CPUState *cs =3D CPU(cpu); #ifndef CONFIG_USER_ONLY int need_flush_tlb =3D (cpu->env.sr & (SR_SM | SR_IME | SR_DME)) ^ (cpu->env.esr & (SR_SM | SR_IME | SR_DME)); @@ -53,8 +52,8 @@ void HELPER(rfe)(CPUOpenRISCState *env) } =20 if (need_flush_tlb) { + CPUState *cs =3D CPU(cpu); tlb_flush(cs); } #endif - cs->interrupt_request |=3D CPU_INTERRUPT_EXITTB; } diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 2d7588a3eb..c7c1f40782 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -41,6 +41,7 @@ ## __VA_ARGS__) =20 /* is_jmp field values */ +#define DISAS_EXIT DISAS_TARGET_0 /* force exit to main loop */ #define DISAS_UPDATE DISAS_TARGET_1 /* cpu state was modified dynamically= */ =20 typedef struct DisasContext { @@ -1233,7 +1234,7 @@ static bool trans_l_rfe(DisasContext *dc, arg_l_rfe *= a, uint32_t insn) gen_illegal_exception(dc); } else { gen_helper_rfe(cpu_env); - dc->base.is_jmp =3D DISAS_UPDATE; + dc->base.is_jmp =3D DISAS_EXIT; } #endif return true; @@ -1467,8 +1468,7 @@ static void openrisc_tr_tb_stop(DisasContextBase *dcb= ase, CPUState *cs) case DISAS_NORETURN: break; case DISAS_UPDATE: - /* indicate that the hash table must be used - to find the next TB */ + case DISAS_EXIT: tcg_gen_exit_tb(NULL, 0); break; default: --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529347769680211.15339781900752; Mon, 18 Jun 2018 11:49:29 -0700 (PDT) Received: from localhost ([::1]:36499 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzDK-0001BC-Mn for importer@patchew.org; Mon, 18 Jun 2018 14:49:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5G-0003Lf-NY for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:40:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5F-0004QR-Ss for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:40:58 -0400 Received: from mail-pg0-x231.google.com ([2607:f8b0:400e:c05::231]:44218) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5F-0004O3-Mi for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:40:57 -0400 Received: by mail-pg0-x231.google.com with SMTP id p21-v6so7919533pgd.11 for ; Mon, 18 Jun 2018 11:40:57 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.40.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=okrGuESigjgaQnuZmSE8aRSEUI5aZPcWynqKq+MblOQ=; b=Lhky2cjd5lpXu/Id/givO6Lb8+LZbx1QmxxiKkInklMr6vDbjEPAuHFepa7ENd1Ocg 6lstaGOB40/6fBWNlOIiBRJk8wJISKSQhDmYbXS2RDPeFeRprmGXSwHrDmyQCmwKxFNj HXKDoFuUcNJfuSmApQWYfv31cbJm5o3GMWCBk= 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=okrGuESigjgaQnuZmSE8aRSEUI5aZPcWynqKq+MblOQ=; b=N7jFSKg0a43BPdU9BRImOJ6TwBh7sWuXfsQ3xlKbfGK7x/SWG9JpJi7TIiKzvvkIlb 8wL7P9Cim7BwhnkbL+18aPWDUxCzbIE7GOFS3UK1xr0nMc0RGjmkRm/O3h3JMamM74Ra dG470RZ0Pqo4DoQBzmPQ27OmHIIOyzK6z7ULg9Q1bBmZJ8Td3f7vnDeOaUql0eoaK+6A 8mios5GsDXfRRXzv9cdIlq880+j/CdlS88Hl00jRNChY6/8BdsKPF/e2plFAIoQ3oqcu eqpEezej4ZLXG2pSjLGJ18ZBhZckvobjLcJJydNj0h/e3D6TtWkLe3LLV44kqCJ57gkv hu4A== X-Gm-Message-State: APt69E3ddsQ20amw5nrs0AgBwKvEcMTXverBqS1rp3oT2d5CH2/ivF+p OkTtP/qHCdvVi9GT939Y8ePXYTlLl0w= X-Google-Smtp-Source: ADUXVKIpHpubG8KWSmUw9Y/H5ICIcq9ja068oQybwEQ0moE3AJ8/RnQmsNJZjJckdm8SaqKb4ZrjXQ== X-Received: by 2002:a62:660a:: with SMTP id a10-v6mr14685794pfc.156.1529347256452; Mon, 18 Jun 2018 11:40:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:27 -1000 Message-Id: <20180618184046.6270-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::231 Subject: [Qemu-devel] [PATCH v2 03/22] target/openrisc: Fix singlestep_enabled 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: shorne@gmail.com 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" We failed to store to cpu_pc before raising the exception, which caused us to re-execute the same insn that we stepped. Reviewed-by: Stafford Horne Signed-off-by: Richard Henderson --- target/openrisc/translate.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index c7c1f40782..5c0c9dee09 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -1449,31 +1449,30 @@ static void openrisc_tr_tb_stop(DisasContextBase *d= cbase, CPUState *cs) { DisasContext *dc =3D container_of(dcbase, DisasContext, base); =20 + /* If we have already exited the TB, nothing following has effect. */ + if (dc->base.is_jmp =3D=3D DISAS_NORETURN) { + return; + } + if ((dc->tb_flags & TB_FLAGS_DFLAG ? 1 : 0) !=3D (dc->delayed_branch != =3D 0)) { tcg_gen_movi_i32(cpu_dflag, dc->delayed_branch !=3D 0); } =20 tcg_gen_movi_tl(cpu_ppc, dc->base.pc_next - 4); - if (dc->base.is_jmp =3D=3D DISAS_NEXT) { - dc->base.is_jmp =3D DISAS_UPDATE; - tcg_gen_movi_tl(cpu_pc, dc->base.pc_next); - } - if (unlikely(dc->base.singlestep_enabled)) { - gen_exception(dc, EXCP_DEBUG); - } else { - switch (dc->base.is_jmp) { - case DISAS_TOO_MANY: - gen_goto_tb(dc, 0, dc->base.pc_next); - break; - case DISAS_NORETURN: - break; - case DISAS_UPDATE: - case DISAS_EXIT: + switch (dc->base.is_jmp) { + case DISAS_TOO_MANY: + gen_goto_tb(dc, 0, dc->base.pc_next); + break; + case DISAS_UPDATE: + case DISAS_EXIT: + if (unlikely(dc->base.singlestep_enabled)) { + gen_exception(dc, EXCP_DEBUG); + } else { tcg_gen_exit_tb(NULL, 0); - break; - default: - g_assert_not_reached(); } + break; + default: + g_assert_not_reached(); } } =20 --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15293473991636.98153541687509; Mon, 18 Jun 2018 11:43:19 -0700 (PDT) Received: from localhost ([::1]:36471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz7W-0004cf-9r for importer@patchew.org; Mon, 18 Jun 2018 14:43:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5I-0003NG-Ur for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5H-0004W3-Ja for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:00 -0400 Received: from mail-pg0-x22d.google.com ([2607:f8b0:400e:c05::22d]:38562) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5H-0004Tb-BK for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:40:59 -0400 Received: by mail-pg0-x22d.google.com with SMTP id c9-v6so7927136pgf.5 for ; Mon, 18 Jun 2018 11:40:59 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.40.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:40:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FaKiF5Mv0q05VlVKt/nmhA9D7je+RB45Y1EqPHidJmQ=; b=edE3Da4yL+2BKhaVhjpiGJrVyFmvccwv1ZgVd9DQbvW0SwRYfVT2GJYEo2AGXSwRLL QFxWvyly0b9FKniLrvMMCv9nQ0UXn3S6l4UXpPt+TzEPJY7rgapPbRijr1n7Tc5CIRc/ m0yH/py89zgFawEXBzeENux2BO1wcR3u3GPiM= 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=FaKiF5Mv0q05VlVKt/nmhA9D7je+RB45Y1EqPHidJmQ=; b=qLWyo7uL3moNVaBgLnDmvkH3/AH7qU4qez7pvYhu3DuhA+iUBj7+/4qv0QY1Au+ncp S3SibuOR9IgDu5Rwss5xfHsW7i+9OJr1u66SoP0C5n9gzPQ6q51WyKQj2gIbjn2f6abs kigXkW25SJuCsfKYQv8Hdh/qQbe1YFVU5lap8jmF6T6UXrZBh48u3P9gFGtz03VFeD7k qAsTItTfxETT/T+kIgYEsz5vUCo9ALxGw4bAe6KeVGj0PUX8lZYXnc4OuIcrqo+JyYfR 5zvdmXqvmRevxga0PX7qmioa/QvxLUeS48W7psa+bNtvxu2M+H4xuLwbCqrfIYdgZzW9 tFug== X-Gm-Message-State: APt69E1O53B2pCha8+OQUTBZrR6TsJ7fTFcH5EMKRjxP+LDoWi9MJeOg t+pNiApW7KEbAh05U/eNfhXe1bs/Q/o= X-Google-Smtp-Source: ADUXVKLJUD7CZJrjQh3o/GCSind35XhgzPzV6FB35qxIeTrf+7gaGfQ4SJh0ATuzCsJYFJoqWwL1RA== X-Received: by 2002:a62:c809:: with SMTP id z9-v6mr14549475pff.5.1529347258077; Mon, 18 Jun 2018 11:40:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:28 -1000 Message-Id: <20180618184046.6270-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22d Subject: [Qemu-devel] [PATCH v2 04/22] target/openrisc: Link more translation blocks 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: shorne@gmail.com 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" Track direct jumps via dc->jmp_pc_imm. Use that in preference to jmp_pc when possible. Emit goto_tb in that case, and lookup_and_goto_tb otherwise. Reviewed-by: Stafford Horne Signed-off-by: Richard Henderson --- target/openrisc/translate.c | 82 +++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 5c0c9dee09..422f22d7f8 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -42,13 +42,16 @@ =20 /* is_jmp field values */ #define DISAS_EXIT DISAS_TARGET_0 /* force exit to main loop */ -#define DISAS_UPDATE DISAS_TARGET_1 /* cpu state was modified dynamically= */ +#define DISAS_JUMP DISAS_TARGET_1 /* exit via jmp_pc/jmp_pc_imm */ =20 typedef struct DisasContext { DisasContextBase base; uint32_t mem_idx; uint32_t tb_flags; uint32_t delayed_branch; + + /* If not -1, jmp_pc contains this value and so is a direct jump. */ + target_ulong jmp_pc_imm; } DisasContext; =20 /* Include the auto-generated decoder. */ @@ -164,34 +167,6 @@ static void check_ov64s(DisasContext *dc) } \ } while (0) =20 -static inline bool use_goto_tb(DisasContext *dc, target_ulong dest) -{ - if (unlikely(dc->base.singlestep_enabled)) { - return false; - } - -#ifndef CONFIG_USER_ONLY - return (dc->base.tb->pc & TARGET_PAGE_MASK) =3D=3D (dest & TARGET_PAGE= _MASK); -#else - return true; -#endif -} - -static void gen_goto_tb(DisasContext *dc, int n, target_ulong dest) -{ - if (use_goto_tb(dc, dest)) { - tcg_gen_movi_tl(cpu_pc, dest); - tcg_gen_goto_tb(n); - tcg_gen_exit_tb(dc->base.tb, n); - } else { - tcg_gen_movi_tl(cpu_pc, dest); - if (dc->base.singlestep_enabled) { - gen_exception(dc, EXCP_DEBUG); - } - tcg_gen_exit_tb(NULL, 0); - } -} - static void gen_ove_cy(DisasContext *dc) { if (dc->tb_flags & SR_OVE) { @@ -655,6 +630,7 @@ static bool trans_l_j(DisasContext *dc, arg_l_j *a, uin= t32_t insn) =20 LOG_DIS("l.j %d\n", a->n); tcg_gen_movi_tl(jmp_pc, tmp_pc); + dc->jmp_pc_imm =3D tmp_pc; dc->delayed_branch =3D 2; return true; } @@ -669,6 +645,7 @@ static bool trans_l_jal(DisasContext *dc, arg_l_jal *a,= uint32_t insn) /* Optimize jal being used to load the PC for PIC. */ if (tmp_pc !=3D ret_pc) { tcg_gen_movi_tl(jmp_pc, tmp_pc); + dc->jmp_pc_imm =3D tmp_pc; dc->delayed_branch =3D 2; } return true; @@ -1381,6 +1358,8 @@ static void openrisc_tr_init_disas_context(DisasConte= xtBase *dcb, CPUState *cs) dc->mem_idx =3D cpu_mmu_index(env, false); dc->tb_flags =3D dc->base.tb->flags; dc->delayed_branch =3D (dc->tb_flags & TB_FLAGS_DFLAG) !=3D 0; + dc->jmp_pc_imm =3D -1; + bound =3D -(dc->base.pc_first | TARGET_PAGE_MASK) / 4; dc->base.max_insns =3D MIN(dc->base.max_insns, bound); } @@ -1437,10 +1416,7 @@ static void openrisc_tr_translate_insn(DisasContextB= ase *dcbase, CPUState *cs) if (dc->delayed_branch) { dc->delayed_branch--; if (!dc->delayed_branch) { - tcg_gen_mov_tl(cpu_pc, jmp_pc); - tcg_gen_discard_tl(jmp_pc); - dc->base.is_jmp =3D DISAS_UPDATE; - return; + dc->base.is_jmp =3D DISAS_JUMP; } } } @@ -1448,22 +1424,56 @@ static void openrisc_tr_translate_insn(DisasContext= Base *dcbase, CPUState *cs) static void openrisc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) { DisasContext *dc =3D container_of(dcbase, DisasContext, base); + target_ulong jmp_dest; =20 /* If we have already exited the TB, nothing following has effect. */ if (dc->base.is_jmp =3D=3D DISAS_NORETURN) { return; } =20 + /* Adjust the delayed branch state for the next TB. */ if ((dc->tb_flags & TB_FLAGS_DFLAG ? 1 : 0) !=3D (dc->delayed_branch != =3D 0)) { tcg_gen_movi_i32(cpu_dflag, dc->delayed_branch !=3D 0); } =20 - tcg_gen_movi_tl(cpu_ppc, dc->base.pc_next - 4); + /* For DISAS_TOO_MANY, jump to the next insn. */ + jmp_dest =3D dc->base.pc_next; + tcg_gen_movi_tl(cpu_ppc, jmp_dest - 4); + switch (dc->base.is_jmp) { + case DISAS_JUMP: + jmp_dest =3D dc->jmp_pc_imm; + if (jmp_dest =3D=3D -1) { + /* The jump destination is indirect/computed; use jmp_pc. */ + tcg_gen_mov_tl(cpu_pc, jmp_pc); + tcg_gen_discard_tl(jmp_pc); + if (unlikely(dc->base.singlestep_enabled)) { + gen_exception(dc, EXCP_DEBUG); + } else { + tcg_gen_lookup_and_goto_ptr(); + } + break; + } + /* The jump destination is direct; use jmp_pc_imm. + However, we will have stored into jmp_pc as well; + we know now that it wasn't needed. */ + tcg_gen_discard_tl(jmp_pc); + /* fallthru */ + case DISAS_TOO_MANY: - gen_goto_tb(dc, 0, dc->base.pc_next); + if (unlikely(dc->base.singlestep_enabled)) { + tcg_gen_movi_tl(cpu_pc, jmp_dest); + gen_exception(dc, EXCP_DEBUG); + } else if ((dc->base.pc_first ^ jmp_dest) & TARGET_PAGE_MASK) { + tcg_gen_movi_tl(cpu_pc, jmp_dest); + tcg_gen_lookup_and_goto_ptr(); + } else { + tcg_gen_goto_tb(0); + tcg_gen_movi_tl(cpu_pc, jmp_dest); + tcg_gen_exit_tb(dc->base.tb, 0); + } break; - case DISAS_UPDATE: + case DISAS_EXIT: if (unlikely(dc->base.singlestep_enabled)) { gen_exception(dc, EXCP_DEBUG); --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529347582485723.2643527400838; Mon, 18 Jun 2018 11:46:22 -0700 (PDT) Received: from localhost ([::1]:36489 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzAT-00072t-Ot for importer@patchew.org; Mon, 18 Jun 2018 14:46:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5K-0003OS-Cj for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5J-0004aV-CL for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:02 -0400 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]:39329) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5J-0004Z2-5N for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:01 -0400 Received: by mail-pf0-x234.google.com with SMTP id r11-v6so8605136pfl.6 for ; Mon, 18 Jun 2018 11:41:01 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.40.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:40:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X/OnfOEs+OTqBzMgrZ12IPWbES9O1NO3eYX5pm9B6KM=; b=AATVWdwIQUp3k4NC1sh9cF8plSX/WzD0qTjm+oAlr+oLBkC7N7uuWZ8FxWTd6v2hfm Hw6A0UGQrJbQJqLWEuJYhzzZEmvsY4ulX9kud/rP2Td5+ZXcEgKKWjb32ETnyKkwFo4x rjuIcFbYo//GLPrFFK4mZY89UIYrw1efv18Rg= 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:mime-version:content-transfer-encoding; bh=X/OnfOEs+OTqBzMgrZ12IPWbES9O1NO3eYX5pm9B6KM=; b=GBBf4n5fadOjIS5/KtkzwAi09FhFz1KtpHQePI87uLmswZkME7NUKzSJuA5Rk4iZqs vOnhlJD8dYrbYPheC32XI2+XE4Re5wmcT/kEgib2xdNEqyR630pm1TWeP2b4ex708T5H cyOeNOIsCqLLyVMzYgNvkB1xeIup0ZptFolo/OFnYtc/meo3NmENVnZO+UVxJwKwJSVj b4o3JF1O5HAi9Hz1cGd5eO59Ktbx9k5qQe9ayHFIkgdxwuI7TqdGOs7GNcYPac2SiZNy oi3ROfKFtMRqgSwpt/9ueHH39Q7i3rik2hV84DiJfSsxfiz0iHigqTh+yRDA2Nwe3LiY i5VQ== X-Gm-Message-State: APt69E27ixcFxFkRkHmFFPYnCmu421HQVP+lkvuOVcALdm1STQjePzHU 1UqwSEWelx3hCgLxomx8I0YIxyNep+s= X-Google-Smtp-Source: ADUXVKJq9qD27EjVLL5jVlLr2yuvcQ0JQ3HMGhJ2smet7M++hinBHfrmbKkezMYqJSWFfkYbPGyxEQ== X-Received: by 2002:a62:4e07:: with SMTP id c7-v6mr14763005pfb.149.1529347259951; Mon, 18 Jun 2018 11:40:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:29 -1000 Message-Id: <20180618184046.6270-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::234 Subject: [Qemu-devel] [PATCH v2 05/22] target/openrisc: Split out is_user 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: shorne@gmail.com 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 This allows us to limit the amount of ifdefs and isolate the test for usermode. Reviewed-by: Stafford Horne Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/openrisc/translate.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 422f22d7f8..16e69c75fa 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -54,6 +54,15 @@ typedef struct DisasContext { target_ulong jmp_pc_imm; } DisasContext; =20 +static inline bool is_user(DisasContext *dc) +{ +#ifdef CONFIG_USER_ONLY + return true; +#else + return dc->mem_idx =3D=3D MMU_USER_IDX; +#endif +} + /* Include the auto-generated decoder. */ #include "decode.inc.c" =20 @@ -914,17 +923,13 @@ static bool trans_l_mfspr(DisasContext *dc, arg_l_mfs= pr *a, uint32_t insn) LOG_DIS("l.mfspr r%d, r%d, %d\n", a->d, a->a, a->k); check_r0_write(a->d); =20 -#ifdef CONFIG_USER_ONLY - gen_illegal_exception(dc); -#else - if (dc->mem_idx =3D=3D MMU_USER_IDX) { + if (is_user(dc)) { gen_illegal_exception(dc); } else { TCGv_i32 ti =3D tcg_const_i32(a->k); gen_helper_mfspr(cpu_R[a->d], cpu_env, cpu_R[a->d], cpu_R[a->a], t= i); tcg_temp_free_i32(ti); } -#endif return true; } =20 @@ -932,17 +937,13 @@ static bool trans_l_mtspr(DisasContext *dc, arg_l_mts= pr *a, uint32_t insn) { LOG_DIS("l.mtspr r%d, r%d, %d\n", a->a, a->b, a->k); =20 -#ifdef CONFIG_USER_ONLY - gen_illegal_exception(dc); -#else - if (dc->mem_idx =3D=3D MMU_USER_IDX) { + if (is_user(dc)) { gen_illegal_exception(dc); } else { TCGv_i32 ti =3D tcg_const_i32(a->k); gen_helper_mtspr(cpu_env, cpu_R[a->a], cpu_R[a->b], ti); tcg_temp_free_i32(ti); } -#endif return true; } =20 @@ -1204,16 +1205,12 @@ static bool trans_l_rfe(DisasContext *dc, arg_l_rfe= *a, uint32_t insn) { LOG_DIS("l.rfe\n"); =20 -#ifdef CONFIG_USER_ONLY - gen_illegal_exception(dc); -#else - if (dc->mem_idx =3D=3D MMU_USER_IDX) { + if (is_user(dc)) { gen_illegal_exception(dc); } else { gen_helper_rfe(cpu_env); dc->base.is_jmp =3D DISAS_EXIT; } -#endif return true; } =20 --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15293477901021021.3354088267344; Mon, 18 Jun 2018 11:49:50 -0700 (PDT) Received: from localhost ([::1]:36501 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzDb-0001PV-NN for importer@patchew.org; Mon, 18 Jun 2018 14:49:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5N-0003OV-MQ for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5L-0004dq-6F for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:05 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:41991) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5L-0004cu-0P for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:03 -0400 Received: by mail-pl0-x241.google.com with SMTP id w17-v6so9497071pll.9 for ; Mon, 18 Jun 2018 11:41:02 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XOIEmxBFkBr/QGsQcVjBP400/Ed4lIS4eM3GEO+xQ9w=; b=YJy9l0hKHiGpDZ54l5pE+6G+7pfdbioGeTzHeDVJrONg7J5oFKfTZT9in+1vz9Hoxl 5O5HRWHznKTpXO4UmfFBc2o340PW9M4AWFEVgKYq0EjTqng+WI87LLWWxd4AvI69jS4c EQr5TWvgzohSfVv1PqQmrI6ehdCoVmVuddtqY= 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=XOIEmxBFkBr/QGsQcVjBP400/Ed4lIS4eM3GEO+xQ9w=; b=qjG+BQBRw1UdRc2w3Przi1s9mElXoVlELCsKBVJdT0Z0pgzyJaEjbP4di6h89ZJ62E TIeOwmvA5fSP+APwr+dqhG7B63XxfYWzbRvQbyY11rrfZakyfImbQ+XPIhtlSJosbxQW siDADw+6+q8wFcd0xn6rrXWABPO5aH4YV0UYFImWy1Fp+mh4pCUgeyBon1PKaY2CuCkr oHlsJTPc+oYvwY9QJUL2m4giUErCMBwMYp2Otdz349scX6HYm8XNyxqbuVpQbmm9l7gN 2M2q+7OPagUcmc+aM0/ehuP7slxF/BzoLURLq1F6cDKaUoYmnO3hs9U1tLmJgara40eT CJnw== X-Gm-Message-State: APt69E1MViMhoTOTQcsTCO2fARybRMlRdQT5YiQw6HpM8DDpMd9Qky78 8PO2dA+vHFO2bRmX+ijUboC6rnuyNPM= X-Google-Smtp-Source: ADUXVKJOyCKRABT/yhtYkN1lA6zBfgINgrT0LoLwkEwEb90smAdek8P7Bp+R0XvMO9i5r/eCOtM8dQ== X-Received: by 2002:a17:902:3c5:: with SMTP id d63-v6mr15637963pld.163.1529347261623; Mon, 18 Jun 2018 11:41:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:30 -1000 Message-Id: <20180618184046.6270-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 06/22] target/openrisc: Exit the TB after l.mtspr 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: shorne@gmail.com 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" A store to SR changes interrupt state, which should return to the main loop to recognize that state. Reviewed-by: Stafford Horne Signed-off-by: Richard Henderson --- target/openrisc/translate.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 16e69c75fa..6a7eb4a3e8 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -940,9 +940,31 @@ static bool trans_l_mtspr(DisasContext *dc, arg_l_mtsp= r *a, uint32_t insn) if (is_user(dc)) { gen_illegal_exception(dc); } else { - TCGv_i32 ti =3D tcg_const_i32(a->k); + TCGv_i32 ti; + + /* For SR, we will need to exit the TB to recognize the new + * exception state. For NPC, in theory this counts as a branch + * (although the SPR only exists for use by an ICE). Save all + * of the cpu state first, allowing it to be overwritten. + */ + if (dc->tb_flags & TB_FLAGS_DFLAG) { + tcg_gen_movi_i32(cpu_dflag, 0); + } + tcg_gen_movi_tl(cpu_ppc, dc->base.pc_next); + tcg_gen_movi_tl(cpu_pc, dc->base.pc_next + 4); + + ti =3D tcg_const_i32(a->k); gen_helper_mtspr(cpu_env, cpu_R[a->a], cpu_R[a->b], ti); tcg_temp_free_i32(ti); + + /* For PPC, we want the value that was just written and not + the generic update that we'd get from DISAS_EXIT. */ + if (unlikely(dc->base.singlestep_enabled)) { + gen_exception(dc, EXCP_DEBUG); + } else { + tcg_gen_exit_tb(NULL, 0); + } + dc->base.is_jmp =3D DISAS_NORETURN; } return true; } --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 152934796441190.86559548773698; Mon, 18 Jun 2018 11:52:44 -0700 (PDT) Received: from localhost ([::1]:36519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzGa-00042J-Kt for importer@patchew.org; Mon, 18 Jun 2018 14:52:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57321) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5O-0003Oz-1D for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5N-0004fl-04 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:06 -0400 Received: from mail-pl0-x231.google.com ([2607:f8b0:400e:c01::231]:46992) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5M-0004ez-Pw for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:04 -0400 Received: by mail-pl0-x231.google.com with SMTP id 30-v6so9485198pld.13 for ; Mon, 18 Jun 2018 11:41:04 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BsFg23nEm663+9fxFdlngMXgE0T1X/PUBHFSuSkivMY=; b=GaA5NihXvLC5E3rq2dzJypP1ZZYVSLBKV7Yzzd61tXdraJ1K89VDVSo8ytEG3eMrND vy12+rNXdzXHHq9YI5/NVKnvdNj3bHt49b+EoyGKIvzfatrtwsZlaq1J2qZZ0wD9StQL A8c5S0OvCmh7VAo1WLFN3fQDCQz88/EZ6ONWk= 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:mime-version:content-transfer-encoding; bh=BsFg23nEm663+9fxFdlngMXgE0T1X/PUBHFSuSkivMY=; b=dt8klgVmYBQhRlbULpQ5ZNjwBeB8LHdqW/FHvY5ikzElxESkMYalUCB8PtxRKl4lOA mkdWvE2o2GoIhd7BSXzpao8LpFCG31wz983QYwy3g2uGKxRNYgTMEm4JNb/s8R/zqAxh EfX0PIfXXwsxU6EAN6bTtLb1qvfVMGqB2rq1ZLY93U3KuRmSTN+Znt6VxedwZeCVQJvg hzoAWMoICh8DffE5L7brVewYMeE5Kgzvzdh/OyMQYGps16pjIyEbGmnFYjKrDVyVEVb1 tOJYy9QdB8Mwhhebhh/lwJRgHE0R4JH8FAhvtEAII+wvfbi+6BgkfGJReyjqW+BR55+2 c8XQ== X-Gm-Message-State: APt69E0Ff+44F1a4ZIzFmQFPGmAjZ2hYI3LaMp3uMHmydoxDOGheQ3zO 4vY/FpoYHqWuAHAzaMeh3rCb4FGq0s8= X-Google-Smtp-Source: ADUXVKK5052SSh2nN0dvrsXXyVd8mxR5GvfuQcTVy/UfrapFjUmCnlSSxhsKyrjFzSClomprg2tiyg== X-Received: by 2002:a17:902:aa83:: with SMTP id d3-v6mr15212501plr.323.1529347263494; Mon, 18 Jun 2018 11:41:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:31 -1000 Message-Id: <20180618184046.6270-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::231 Subject: [Qemu-devel] [PATCH v2 07/22] target/openrisc: Form the spr index from tcg 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: shorne@gmail.com 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 Rather than pass base+offset to the helper, pass the full index. In most cases the base is r0 and optimization yields a constant. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/openrisc/helper.h | 4 ++-- target/openrisc/sys_helper.c | 9 +++------ target/openrisc/translate.c | 16 +++++++++------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/target/openrisc/helper.h b/target/openrisc/helper.h index e37dabc77a..9db9bf3963 100644 --- a/target/openrisc/helper.h +++ b/target/openrisc/helper.h @@ -56,5 +56,5 @@ FOP_CMP(le) DEF_HELPER_FLAGS_1(rfe, 0, void, env) =20 /* 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_FLAGS_3(mtspr, 0, void, env, tl, tl) +DEF_HELPER_FLAGS_3(mfspr, TCG_CALL_NO_WG, tl, env, tl, tl) diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index b284064381..a8d287d6ef 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -27,13 +27,11 @@ =20 #define TO_SPR(group, number) (((group) << 11) + (number)) =20 -void HELPER(mtspr)(CPUOpenRISCState *env, - target_ulong ra, target_ulong rb, target_ulong offset) +void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong r= b) { #ifndef CONFIG_USER_ONLY OpenRISCCPU *cpu =3D openrisc_env_get_cpu(env); CPUState *cs =3D CPU(cpu); - int spr =3D (ra | offset); int idx; =20 switch (spr) { @@ -201,13 +199,12 @@ void HELPER(mtspr)(CPUOpenRISCState *env, #endif } =20 -target_ulong HELPER(mfspr)(CPUOpenRISCState *env, - target_ulong rd, target_ulong ra, uint32_t offs= et) +target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd, + target_ulong spr) { #ifndef CONFIG_USER_ONLY OpenRISCCPU *cpu =3D openrisc_env_get_cpu(env); CPUState *cs =3D CPU(cpu); - int spr =3D (ra | offset); int idx; =20 switch (spr) { diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 6a7eb4a3e8..f19f0d257b 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -926,9 +926,10 @@ static bool trans_l_mfspr(DisasContext *dc, arg_l_mfsp= r *a, uint32_t insn) if (is_user(dc)) { gen_illegal_exception(dc); } else { - TCGv_i32 ti =3D tcg_const_i32(a->k); - gen_helper_mfspr(cpu_R[a->d], cpu_env, cpu_R[a->d], cpu_R[a->a], t= i); - tcg_temp_free_i32(ti); + TCGv spr =3D tcg_temp_new(); + tcg_gen_ori_tl(spr, cpu_R[a->a], a->k); + gen_helper_mfspr(cpu_R[a->d], cpu_env, cpu_R[a->d], spr); + tcg_temp_free(spr); } return true; } @@ -940,7 +941,7 @@ static bool trans_l_mtspr(DisasContext *dc, arg_l_mtspr= *a, uint32_t insn) if (is_user(dc)) { gen_illegal_exception(dc); } else { - TCGv_i32 ti; + TCGv spr; =20 /* For SR, we will need to exit the TB to recognize the new * exception state. For NPC, in theory this counts as a branch @@ -953,9 +954,10 @@ static bool trans_l_mtspr(DisasContext *dc, arg_l_mtsp= r *a, uint32_t insn) tcg_gen_movi_tl(cpu_ppc, dc->base.pc_next); tcg_gen_movi_tl(cpu_pc, dc->base.pc_next + 4); =20 - ti =3D tcg_const_i32(a->k); - gen_helper_mtspr(cpu_env, cpu_R[a->a], cpu_R[a->b], ti); - tcg_temp_free_i32(ti); + spr =3D tcg_temp_new(); + tcg_gen_ori_tl(spr, cpu_R[a->a], a->k); + gen_helper_mtspr(cpu_env, spr, cpu_R[a->b]); + tcg_temp_free(spr); =20 /* For PPC, we want the value that was just written and not the generic update that we'd get from DISAS_EXIT. */ --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15293474159321000.7589597464084; Mon, 18 Jun 2018 11:43:35 -0700 (PDT) Received: from localhost ([::1]:36472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz7e-0004jJ-5X for importer@patchew.org; Mon, 18 Jun 2018 14:43:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5Q-0003RA-CT for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5O-0004iI-Op for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:08 -0400 Received: from mail-pl0-x230.google.com ([2607:f8b0:400e:c01::230]:35229) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5O-0004gu-GI for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:06 -0400 Received: by mail-pl0-x230.google.com with SMTP id k1-v6so9513603plt.2 for ; Mon, 18 Jun 2018 11:41:06 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WzTqScWIedf6KTMYwR89uaNRT1guN91ugAqhVXlJgsc=; b=MB2wNvx8Z6WDEs2LIrr7ZGqymNMfvewrk+mStc5eCoiD4PdTCupNngDCGkjQLiQY5P fW7O79CJITgpNsvz0ceNcOOHCSHmdHb+yOTRQpYVip5Xal//L/B10AQYQK1frmQatO/q v6EOaAZVfHidAWvqWVMSjLgkOoB5+hdnu/kfQ= 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=WzTqScWIedf6KTMYwR89uaNRT1guN91ugAqhVXlJgsc=; b=dFCYNofZrBKrBSDh0t1zMNVF0cLhphGfMbcIs1yrCptJ9tSAcEqMjUzD1CSL1FyOIx fxNE8PEaudlvl++7GF+hRHvZz0McLo0DXtsronUW8oCeSfwjL+xp9YRJtQRO1C+AF63v goatrFQtimGKcZpVWIXuy2Rk6TUWT1Uou7gzZZkzfuiOYTKCzx/vsRtByO7F5X/HJmey ooUBvO8v7P2atP+7JhrT/FnLeNSwLrViw3iJb7zTxNgyj5uIH36cGrCUKr8Hpoyxbal4 Vsz9AtY5yWPTh20fK4LRY11yju6l2ulZf9SfwzbwH4JbwJiVbl/W/mKLMQon2SCsmD4t akmQ== X-Gm-Message-State: APt69E3pKD1W9PPZlfnCxxWiEzlCXizGq06QEj7tPl6Ky3iC8OJXdTGu m0GvuOycAZHa+J4czf9dhgpUqn5et+k= X-Google-Smtp-Source: ADUXVKIRe3UeiEur71ux8uwJ8tEICnsYw4zvGGfFcvAsnXu8KQ69ThiZEMImbWZ3EjeVYcwIXnbuRQ== X-Received: by 2002:a17:902:784d:: with SMTP id e13-v6mr15013577pln.197.1529347265159; Mon, 18 Jun 2018 11:41:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:32 -1000 Message-Id: <20180618184046.6270-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::230 Subject: [Qemu-devel] [PATCH v2 08/22] target/openrisc: Merge tlb allocation into CPUOpenRISCState 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: shorne@gmail.com 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" There is no reason to allocate this separately. This was probably copied from target/mips which makes the same mistake. While doing so, move tlb into the clear-on-reset range. While not all of the TLB bits are guaranteed zero on reset, all of the valid bits are cleared, and the rest of the bits are unspecified. Therefore clearing the whole of the TLB is correct. Reviewed-by: Stafford Horne Signed-off-by: Richard Henderson --- target/openrisc/cpu.h | 6 ++++-- target/openrisc/interrupt.c | 4 ++-- target/openrisc/interrupt_helper.c | 8 +++---- target/openrisc/machine.c | 15 ++++++------- target/openrisc/mmu.c | 34 ++++++++++++++---------------- target/openrisc/sys_helper.c | 28 ++++++++++++------------ 6 files changed, 46 insertions(+), 49 deletions(-) diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 35cab65f11..edc06be40e 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -301,6 +301,10 @@ typedef struct CPUOpenRISCState { =20 uint32_t dflag; /* In delay slot (boolean) */ =20 +#ifndef CONFIG_USER_ONLY + CPUOpenRISCTLBContext tlb; +#endif + /* Fields up to this point are cleared by a CPU reset */ struct {} end_reset_fields; =20 @@ -310,8 +314,6 @@ typedef struct CPUOpenRISCState { uint32_t cpucfgr; /* CPU configure register */ =20 #ifndef CONFIG_USER_ONLY - CPUOpenRISCTLBContext * tlb; - QEMUTimer *timer; uint32_t ttmr; /* Timer tick mode register */ int is_counting; diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index 3959671c59..8b8b14ace0 100644 --- a/target/openrisc/interrupt.c +++ b/target/openrisc/interrupt.c @@ -62,8 +62,8 @@ void openrisc_cpu_do_interrupt(CPUState *cs) env->sr &=3D ~SR_TEE; env->pmr &=3D ~PMR_DME; env->pmr &=3D ~PMR_SME; - env->tlb->cpu_openrisc_map_address_data =3D &cpu_openrisc_get_phys_nom= mu; - env->tlb->cpu_openrisc_map_address_code =3D &cpu_openrisc_get_phys_nom= mu; + env->tlb.cpu_openrisc_map_address_data =3D &cpu_openrisc_get_phys_nomm= u; + env->tlb.cpu_openrisc_map_address_code =3D &cpu_openrisc_get_phys_nomm= u; env->lock_addr =3D -1; =20 if (cs->exception_index > 0 && cs->exception_index < EXCP_NR) { diff --git a/target/openrisc/interrupt_helper.c b/target/openrisc/interrupt= _helper.c index b865738f8b..dc97b38704 100644 --- a/target/openrisc/interrupt_helper.c +++ b/target/openrisc/interrupt_helper.c @@ -36,18 +36,18 @@ void HELPER(rfe)(CPUOpenRISCState *env) =20 #ifndef CONFIG_USER_ONLY if (cpu->env.sr & SR_DME) { - cpu->env.tlb->cpu_openrisc_map_address_data =3D + cpu->env.tlb.cpu_openrisc_map_address_data =3D &cpu_openrisc_get_phys_data; } else { - cpu->env.tlb->cpu_openrisc_map_address_data =3D + cpu->env.tlb.cpu_openrisc_map_address_data =3D &cpu_openrisc_get_phys_nommu; } =20 if (cpu->env.sr & SR_IME) { - cpu->env.tlb->cpu_openrisc_map_address_code =3D + cpu->env.tlb.cpu_openrisc_map_address_code =3D &cpu_openrisc_get_phys_code; } else { - cpu->env.tlb->cpu_openrisc_map_address_code =3D + cpu->env.tlb.cpu_openrisc_map_address_code =3D &cpu_openrisc_get_phys_nommu; } =20 diff --git a/target/openrisc/machine.c b/target/openrisc/machine.c index 0a793eb14d..c10d28b055 100644 --- a/target/openrisc/machine.c +++ b/target/openrisc/machine.c @@ -30,18 +30,18 @@ static int env_post_load(void *opaque, int version_id) =20 /* Restore MMU handlers */ if (env->sr & SR_DME) { - env->tlb->cpu_openrisc_map_address_data =3D + env->tlb.cpu_openrisc_map_address_data =3D &cpu_openrisc_get_phys_data; } else { - env->tlb->cpu_openrisc_map_address_data =3D + env->tlb.cpu_openrisc_map_address_data =3D &cpu_openrisc_get_phys_nommu; } =20 if (env->sr & SR_IME) { - env->tlb->cpu_openrisc_map_address_code =3D + env->tlb.cpu_openrisc_map_address_code =3D &cpu_openrisc_get_phys_code; } else { - env->tlb->cpu_openrisc_map_address_code =3D + env->tlb.cpu_openrisc_map_address_code =3D &cpu_openrisc_get_phys_nommu; } =20 @@ -77,10 +77,6 @@ static const VMStateDescription vmstate_cpu_tlb =3D { } }; =20 -#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; @@ -143,7 +139,8 @@ static const VMStateDescription vmstate_env =3D { VMSTATE_UINT32(fpcsr, CPUOpenRISCState), VMSTATE_UINT64(mac, CPUOpenRISCState), =20 - VMSTATE_CPU_TLB(tlb, CPUOpenRISCState), + VMSTATE_STRUCT(tlb, CPUOpenRISCState, 1, + vmstate_cpu_tlb, CPUOpenRISCTLBContext), =20 VMSTATE_TIMER_PTR(timer, CPUOpenRISCState), VMSTATE_UINT32(ttmr, CPUOpenRISCState), diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c index 2bd782f89b..5665bb7cc9 100644 --- a/target/openrisc/mmu.c +++ b/target/openrisc/mmu.c @@ -46,19 +46,19 @@ int cpu_openrisc_get_phys_code(OpenRISCCPU *cpu, int idx =3D vpn & ITLB_MASK; int right =3D 0; =20 - if ((cpu->env.tlb->itlb[0][idx].mr >> TARGET_PAGE_BITS) !=3D vpn) { + if ((cpu->env.tlb.itlb[0][idx].mr >> TARGET_PAGE_BITS) !=3D vpn) { return TLBRET_NOMATCH; } - if (!(cpu->env.tlb->itlb[0][idx].mr & 1)) { + if (!(cpu->env.tlb.itlb[0][idx].mr & 1)) { return TLBRET_INVALID; } =20 if (cpu->env.sr & SR_SM) { /* supervisor mode */ - if (cpu->env.tlb->itlb[0][idx].tr & SXE) { + if (cpu->env.tlb.itlb[0][idx].tr & SXE) { right |=3D PAGE_EXEC; } } else { - if (cpu->env.tlb->itlb[0][idx].tr & UXE) { + if (cpu->env.tlb.itlb[0][idx].tr & UXE) { right |=3D PAGE_EXEC; } } @@ -67,7 +67,7 @@ int cpu_openrisc_get_phys_code(OpenRISCCPU *cpu, return TLBRET_BADADDR; } =20 - *physical =3D (cpu->env.tlb->itlb[0][idx].tr & TARGET_PAGE_MASK) | + *physical =3D (cpu->env.tlb.itlb[0][idx].tr & TARGET_PAGE_MASK) | (address & (TARGET_PAGE_SIZE-1)); *prot =3D right; return TLBRET_MATCH; @@ -81,25 +81,25 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu, int idx =3D vpn & DTLB_MASK; int right =3D 0; =20 - if ((cpu->env.tlb->dtlb[0][idx].mr >> TARGET_PAGE_BITS) !=3D vpn) { + if ((cpu->env.tlb.dtlb[0][idx].mr >> TARGET_PAGE_BITS) !=3D vpn) { return TLBRET_NOMATCH; } - if (!(cpu->env.tlb->dtlb[0][idx].mr & 1)) { + if (!(cpu->env.tlb.dtlb[0][idx].mr & 1)) { return TLBRET_INVALID; } =20 if (cpu->env.sr & SR_SM) { /* supervisor mode */ - if (cpu->env.tlb->dtlb[0][idx].tr & SRE) { + if (cpu->env.tlb.dtlb[0][idx].tr & SRE) { right |=3D PAGE_READ; } - if (cpu->env.tlb->dtlb[0][idx].tr & SWE) { + if (cpu->env.tlb.dtlb[0][idx].tr & SWE) { right |=3D PAGE_WRITE; } } else { - if (cpu->env.tlb->dtlb[0][idx].tr & URE) { + if (cpu->env.tlb.dtlb[0][idx].tr & URE) { right |=3D PAGE_READ; } - if (cpu->env.tlb->dtlb[0][idx].tr & UWE) { + if (cpu->env.tlb.dtlb[0][idx].tr & UWE) { right |=3D PAGE_WRITE; } } @@ -111,7 +111,7 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu, return TLBRET_BADADDR; } =20 - *physical =3D (cpu->env.tlb->dtlb[0][idx].tr & TARGET_PAGE_MASK) | + *physical =3D (cpu->env.tlb.dtlb[0][idx].tr & TARGET_PAGE_MASK) | (address & (TARGET_PAGE_SIZE-1)); *prot =3D right; return TLBRET_MATCH; @@ -126,10 +126,10 @@ static int cpu_openrisc_get_phys_addr(OpenRISCCPU *cp= u, =20 if (rw =3D=3D MMU_INST_FETCH) { /* ITLB */ *physical =3D 0; - ret =3D cpu->env.tlb->cpu_openrisc_map_address_code(cpu, physical, + ret =3D cpu->env.tlb.cpu_openrisc_map_address_code(cpu, physical, prot, address, r= w); } else { /* DTLB */ - ret =3D cpu->env.tlb->cpu_openrisc_map_address_data(cpu, physical, + ret =3D cpu->env.tlb.cpu_openrisc_map_address_data(cpu, physical, prot, address, r= w); } =20 @@ -247,9 +247,7 @@ hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cs, v= addr addr) =20 void cpu_openrisc_mmu_init(OpenRISCCPU *cpu) { - cpu->env.tlb =3D g_malloc0(sizeof(CPUOpenRISCTLBContext)); - - cpu->env.tlb->cpu_openrisc_map_address_code =3D &cpu_openrisc_get_phys= _nommu; - cpu->env.tlb->cpu_openrisc_map_address_data =3D &cpu_openrisc_get_phys= _nommu; + cpu->env.tlb.cpu_openrisc_map_address_code =3D &cpu_openrisc_get_phys_= nommu; + cpu->env.tlb.cpu_openrisc_map_address_data =3D &cpu_openrisc_get_phys_= nommu; } #endif diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index a8d287d6ef..f26c688df6 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -61,18 +61,18 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong = spr, target_ulong rb) } cpu_set_sr(env, rb); if (env->sr & SR_DME) { - env->tlb->cpu_openrisc_map_address_data =3D + env->tlb.cpu_openrisc_map_address_data =3D &cpu_openrisc_get_phys_data; } else { - env->tlb->cpu_openrisc_map_address_data =3D + env->tlb.cpu_openrisc_map_address_data =3D &cpu_openrisc_get_phys_nommu; } =20 if (env->sr & SR_IME) { - env->tlb->cpu_openrisc_map_address_code =3D + env->tlb.cpu_openrisc_map_address_code =3D &cpu_openrisc_get_phys_code; } else { - env->tlb->cpu_openrisc_map_address_code =3D + env->tlb.cpu_openrisc_map_address_code =3D &cpu_openrisc_get_phys_nommu; } break; @@ -100,14 +100,14 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulon= g spr, target_ulong 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)) { - tlb_flush_page(cs, env->tlb->dtlb[0][idx].mr & TARGET_PAGE_MAS= K); + tlb_flush_page(cs, env->tlb.dtlb[0][idx].mr & TARGET_PAGE_MASK= ); } - env->tlb->dtlb[0][idx].mr =3D rb; + env->tlb.dtlb[0][idx].mr =3D rb; break; =20 case TO_SPR(1, 640) ... TO_SPR(1, 640+DTLB_SIZE-1): /* DTLBW0TR 0-127 = */ idx =3D spr - TO_SPR(1, 640); - env->tlb->dtlb[0][idx].tr =3D rb; + env->tlb.dtlb[0][idx].tr =3D rb; break; case TO_SPR(1, 768) ... TO_SPR(1, 895): /* DTLBW1MR 0-127 */ case TO_SPR(1, 896) ... TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ @@ -119,14 +119,14 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulon= g spr, target_ulong rb) case TO_SPR(2, 512) ... TO_SPR(2, 512+ITLB_SIZE-1): /* ITLBW0MR 0-12= 7 */ idx =3D spr - TO_SPR(2, 512); if (!(rb & 1)) { - tlb_flush_page(cs, env->tlb->itlb[0][idx].mr & TARGET_PAGE_MAS= K); + tlb_flush_page(cs, env->tlb.itlb[0][idx].mr & TARGET_PAGE_MASK= ); } - env->tlb->itlb[0][idx].mr =3D rb; + env->tlb.itlb[0][idx].mr =3D rb; break; =20 case TO_SPR(2, 640) ... TO_SPR(2, 640+ITLB_SIZE-1): /* ITLBW0TR 0-127 = */ idx =3D spr - TO_SPR(2, 640); - env->tlb->itlb[0][idx].tr =3D rb; + env->tlb.itlb[0][idx].tr =3D rb; break; case TO_SPR(2, 768) ... TO_SPR(2, 895): /* ITLBW1MR 0-127 */ case TO_SPR(2, 896) ... TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ @@ -258,11 +258,11 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, tar= get_ulong rd, =20 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; + return env->tlb.dtlb[0][idx].mr; =20 case TO_SPR(1, 640) ... TO_SPR(1, 640+DTLB_SIZE-1): /* DTLBW0TR 0-127 = */ idx =3D spr - TO_SPR(1, 640); - return env->tlb->dtlb[0][idx].tr; + return env->tlb.dtlb[0][idx].tr; =20 case TO_SPR(1, 768) ... TO_SPR(1, 895): /* DTLBW1MR 0-127 */ case TO_SPR(1, 896) ... TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ @@ -274,11 +274,11 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, tar= get_ulong rd, =20 case TO_SPR(2, 512) ... TO_SPR(2, 512+ITLB_SIZE-1): /* ITLBW0MR 0-127 = */ idx =3D spr - TO_SPR(2, 512); - return env->tlb->itlb[0][idx].mr; + return env->tlb.itlb[0][idx].mr; =20 case TO_SPR(2, 640) ... TO_SPR(2, 640+ITLB_SIZE-1): /* ITLBW0TR 0-127 = */ idx =3D spr - TO_SPR(2, 640); - return env->tlb->itlb[0][idx].tr; + return env->tlb.itlb[0][idx].tr; =20 case TO_SPR(2, 768) ... TO_SPR(2, 895): /* ITLBW1MR 0-127 */ case TO_SPR(2, 896) ... TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529348012752222.71602596900334; Mon, 18 Jun 2018 11:53:32 -0700 (PDT) Received: from localhost ([::1]:36522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzHQ-0004j2-1F for importer@patchew.org; Mon, 18 Jun 2018 14:53:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5S-0003Ss-5X for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5Q-0004k5-EW for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:10 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:40663) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5Q-0004jW-6a for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:08 -0400 Received: by mail-pg0-x244.google.com with SMTP id w8-v6so4899651pgp.7 for ; Mon, 18 Jun 2018 11:41:08 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vsv8Qi0KsvF5VBqJF9zsirXujEXF3UUnTiIAciiBb5I=; b=B0E6u75p6I5a29U/YekOUavlXbSgAikIy+WtTsxd77cRNls2ZKDKgLr10P8/T5qcR4 QDy4DqGkIPF4xR/kSZBir0QRyo/WDbLXWmbFbmLvlqh60vr/+Llju3cHv4TPuhomxMDC Ust0i/jajHAOBjE1jkmjPZBVaY6bmTykkO7Ow= 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=vsv8Qi0KsvF5VBqJF9zsirXujEXF3UUnTiIAciiBb5I=; b=SfH/vSkSkaal/NEkC2FIjC5zLTkjPIn46HDAiCIcvWjsI+SkuJ9ZkSO3v4EuMuRxUN FKKMkFlL+FfUS82otzDGeEtvcEfMJ52kwEW0ileRbIkk65G9GFR3+TZwR3WAG1qPQTCd wJTC9AD/uO6/Uhb5VIj/7osC9994zQEO5CTpbZp3rJygDMqenPUkM+Vu+JbCTkzcLmi8 bCp1OUd7+Frc8ksSWmung+Od+RwfuoFor+9bMIGhBbgsRkvtqEYJvBnBl47gSvubRoJA /rqug+KAJvZYKcpwn/e1HrAWEuTgAP/VYB30srQoGxKmyxqhgXje+NWtcQnI2qFzqU9S BA8w== X-Gm-Message-State: APt69E3voHltLWEcxGW7k7JsJHfOiH8tKpJ+F2o6Anj3L6S0vcPe9LU+ g9otPmZCgRC5g9fFOE0dDLzgNy4NQCY= X-Google-Smtp-Source: ADUXVKLkw+i7rskXFvzoJysqBakNHgOaMUdd90X20GEGzp0uwu898ptkP2Lxj1yEcjQEfpwAhwuDIw== X-Received: by 2002:a65:4c87:: with SMTP id m7-v6mr12247634pgt.364.1529347266902; Mon, 18 Jun 2018 11:41:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:33 -1000 Message-Id: <20180618184046.6270-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH v2 09/22] target/openrisc: Remove indirect function calls for mmu 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: shorne@gmail.com 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" There is no reason to use an indirect branch instead of simply testing the SR bits that control mmu state. Signed-off-by: Richard Henderson --- target/openrisc/cpu.h | 11 ----- target/openrisc/cpu.c | 4 -- target/openrisc/interrupt.c | 2 - target/openrisc/interrupt_helper.c | 25 ++--------- target/openrisc/machine.c | 26 ------------ target/openrisc/mmu.c | 66 +++++++++++++----------------- target/openrisc/sys_helper.c | 15 ------- 7 files changed, 31 insertions(+), 118 deletions(-) diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index edc06be40e..13107058cb 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -378,17 +378,6 @@ void cpu_openrisc_count_update(OpenRISCCPU *cpu); void cpu_openrisc_timer_update(OpenRISCCPU *cpu); void cpu_openrisc_count_start(OpenRISCCPU *cpu); void cpu_openrisc_count_stop(OpenRISCCPU *cpu); - -void cpu_openrisc_mmu_init(OpenRISCCPU *cpu); -int cpu_openrisc_get_phys_nommu(OpenRISCCPU *cpu, - hwaddr *physical, - int *prot, target_ulong address, int rw); -int cpu_openrisc_get_phys_code(OpenRISCCPU *cpu, - hwaddr *physical, - int *prot, target_ulong address, int rw); -int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu, - hwaddr *physical, - int *prot, target_ulong address, int rw); #endif =20 #define OPENRISC_CPU_TYPE_SUFFIX "-" TYPE_OPENRISC_CPU diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index a692a98ec0..4c166c6329 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -87,10 +87,6 @@ static void openrisc_cpu_initfn(Object *obj) OpenRISCCPU *cpu =3D OPENRISC_CPU(obj); =20 cs->env_ptr =3D &cpu->env; - -#ifndef CONFIG_USER_ONLY - cpu_openrisc_mmu_init(cpu); -#endif } =20 /* CPU models */ diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index 8b8b14ace0..d9cb363fea 100644 --- a/target/openrisc/interrupt.c +++ b/target/openrisc/interrupt.c @@ -62,8 +62,6 @@ void openrisc_cpu_do_interrupt(CPUState *cs) env->sr &=3D ~SR_TEE; env->pmr &=3D ~PMR_DME; env->pmr &=3D ~PMR_SME; - env->tlb.cpu_openrisc_map_address_data =3D &cpu_openrisc_get_phys_nomm= u; - env->tlb.cpu_openrisc_map_address_code =3D &cpu_openrisc_get_phys_nomm= u; env->lock_addr =3D -1; =20 if (cs->exception_index > 0 && cs->exception_index < EXCP_NR) { diff --git a/target/openrisc/interrupt_helper.c b/target/openrisc/interrupt= _helper.c index dc97b38704..a2e9003969 100644 --- a/target/openrisc/interrupt_helper.c +++ b/target/openrisc/interrupt_helper.c @@ -29,31 +29,12 @@ void HELPER(rfe)(CPUOpenRISCState *env) #ifndef CONFIG_USER_ONLY int need_flush_tlb =3D (cpu->env.sr & (SR_SM | SR_IME | SR_DME)) ^ (cpu->env.esr & (SR_SM | SR_IME | SR_DME)); -#endif - cpu->env.pc =3D cpu->env.epcr; - cpu_set_sr(&cpu->env, cpu->env.esr); - cpu->env.lock_addr =3D -1; - -#ifndef CONFIG_USER_ONLY - if (cpu->env.sr & SR_DME) { - cpu->env.tlb.cpu_openrisc_map_address_data =3D - &cpu_openrisc_get_phys_data; - } else { - cpu->env.tlb.cpu_openrisc_map_address_data =3D - &cpu_openrisc_get_phys_nommu; - } - - if (cpu->env.sr & SR_IME) { - cpu->env.tlb.cpu_openrisc_map_address_code =3D - &cpu_openrisc_get_phys_code; - } else { - cpu->env.tlb.cpu_openrisc_map_address_code =3D - &cpu_openrisc_get_phys_nommu; - } - if (need_flush_tlb) { CPUState *cs =3D CPU(cpu); tlb_flush(cs); } #endif + cpu->env.pc =3D cpu->env.epcr; + cpu->env.lock_addr =3D -1; + cpu_set_sr(&cpu->env, cpu->env.esr); } diff --git a/target/openrisc/machine.c b/target/openrisc/machine.c index c10d28b055..73e0abcfd7 100644 --- a/target/openrisc/machine.c +++ b/target/openrisc/machine.c @@ -24,31 +24,6 @@ #include "hw/boards.h" #include "migration/cpu.h" =20 -static int env_post_load(void *opaque, int version_id) -{ - CPUOpenRISCState *env =3D opaque; - - /* 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; -} - static const VMStateDescription vmstate_tlb_entry =3D { .name =3D "tlb_entry", .version_id =3D 1, @@ -102,7 +77,6 @@ static const VMStateDescription vmstate_env =3D { .name =3D "env", .version_id =3D 6, .minimum_version_id =3D 6, - .post_load =3D env_post_load, .fields =3D (VMStateField[]) { VMSTATE_UINTTL_2DARRAY(shadow_gpr, CPUOpenRISCState, 16, 32), VMSTATE_UINTTL(pc, CPUOpenRISCState), diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c index 5665bb7cc9..b2effaa6d7 100644 --- a/target/openrisc/mmu.c +++ b/target/openrisc/mmu.c @@ -29,18 +29,16 @@ #endif =20 #ifndef CONFIG_USER_ONLY -int cpu_openrisc_get_phys_nommu(OpenRISCCPU *cpu, - hwaddr *physical, - int *prot, target_ulong address, int rw) +static inline int get_phys_nommu(hwaddr *physical, int *prot, + target_ulong address) { *physical =3D address; *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; return TLBRET_MATCH; } =20 -int cpu_openrisc_get_phys_code(OpenRISCCPU *cpu, - hwaddr *physical, - int *prot, target_ulong address, int rw) +static int get_phys_code(OpenRISCCPU *cpu, hwaddr *physical, int *prot, + target_ulong address, int rw, bool supervisor) { int vpn =3D address >> TARGET_PAGE_BITS; int idx =3D vpn & ITLB_MASK; @@ -52,8 +50,7 @@ int cpu_openrisc_get_phys_code(OpenRISCCPU *cpu, if (!(cpu->env.tlb.itlb[0][idx].mr & 1)) { return TLBRET_INVALID; } - - if (cpu->env.sr & SR_SM) { /* supervisor mode */ + if (supervisor) { if (cpu->env.tlb.itlb[0][idx].tr & SXE) { right |=3D PAGE_EXEC; } @@ -62,7 +59,6 @@ int cpu_openrisc_get_phys_code(OpenRISCCPU *cpu, right |=3D PAGE_EXEC; } } - if ((rw & 2) && ((right & PAGE_EXEC) =3D=3D 0)) { return TLBRET_BADADDR; } @@ -73,9 +69,8 @@ int cpu_openrisc_get_phys_code(OpenRISCCPU *cpu, return TLBRET_MATCH; } =20 -int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu, - hwaddr *physical, - int *prot, target_ulong address, int rw) +static int get_phys_data(OpenRISCCPU *cpu, hwaddr *physical, int *prot, + target_ulong address, int rw, bool supervisor) { int vpn =3D address >> TARGET_PAGE_BITS; int idx =3D vpn & DTLB_MASK; @@ -87,8 +82,7 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu, if (!(cpu->env.tlb.dtlb[0][idx].mr & 1)) { return TLBRET_INVALID; } - - if (cpu->env.sr & SR_SM) { /* supervisor mode */ + if (supervisor) { if (cpu->env.tlb.dtlb[0][idx].tr & SRE) { right |=3D PAGE_READ; } @@ -117,20 +111,24 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu, return TLBRET_MATCH; } =20 -static int cpu_openrisc_get_phys_addr(OpenRISCCPU *cpu, - hwaddr *physical, - int *prot, target_ulong address, - int rw) +static int get_phys_addr(OpenRISCCPU *cpu, hwaddr *physical, + int *prot, target_ulong address, int rw) { - int ret =3D TLBRET_MATCH; + bool supervisor =3D (cpu->env.sr & SR_SM) !=3D 0; + int ret; =20 - 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); - } else { /* DTLB */ - ret =3D cpu->env.tlb.cpu_openrisc_map_address_data(cpu, physical, - prot, address, r= w); + /* Assume nommu results for a moment. */ + ret =3D get_phys_nommu(physical, prot, address); + + /* Overwrite with TLB lookup if enabled. */ + if (rw =3D=3D MMU_INST_FETCH) { + if (cpu->env.sr & SR_IME) { + ret =3D get_phys_code(cpu, physical, prot, address, rw, superv= isor); + } + } else { + if (cpu->env.sr & SR_DME) { + ret =3D get_phys_data(cpu, physical, prot, address, rw, superv= isor); + } } =20 return ret; @@ -186,8 +184,7 @@ int openrisc_cpu_handle_mmu_fault(CPUState *cs, vaddr a= ddress, int size, hwaddr physical =3D 0; int prot =3D 0; =20 - ret =3D cpu_openrisc_get_phys_addr(cpu, &physical, &prot, - address, rw); + ret =3D get_phys_addr(cpu, &physical, &prot, address, rw); =20 if (ret =3D=3D TLBRET_MATCH) { tlb_set_page(cs, address & TARGET_PAGE_MASK, @@ -225,17 +222,16 @@ hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cs,= vaddr addr) =20 /* 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); + miss =3D get_phys_addr(cpu, &phys_addr, &prot, addr, 0); =20 /* Check instruction tlb */ if (miss) { - miss =3D cpu_openrisc_get_phys_addr(cpu, &phys_addr, &prot, addr, - MMU_INST_FETCH); + miss =3D get_phys_addr(cpu, &phys_addr, &prot, addr, MMU_INST_FETC= H); } =20 /* Last, fall back to a plain address */ if (miss) { - miss =3D cpu_openrisc_get_phys_nommu(cpu, &phys_addr, &prot, addr,= 0); + miss =3D get_phys_nommu(&phys_addr, &prot, addr); } =20 if (miss) { @@ -244,10 +240,4 @@ hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cs, = vaddr addr) return phys_addr; } } - -void cpu_openrisc_mmu_init(OpenRISCCPU *cpu) -{ - cpu->env.tlb.cpu_openrisc_map_address_code =3D &cpu_openrisc_get_phys_= nommu; - cpu->env.tlb.cpu_openrisc_map_address_data =3D &cpu_openrisc_get_phys_= nommu; -} #endif diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index f26c688df6..a1285894ad 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -60,21 +60,6 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong s= pr, target_ulong rb) tlb_flush(cs); } cpu_set_sr(env, rb); - 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; - } break; =20 case TO_SPR(0, 18): /* PPC */ --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15293481518291003.7586790704411; Mon, 18 Jun 2018 11:55:51 -0700 (PDT) Received: from localhost ([::1]:36536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzJf-0006l9-59 for importer@patchew.org; Mon, 18 Jun 2018 14:55:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5T-0003Te-5q for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5S-0004lw-2S for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:11 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:38652) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5R-0004lL-S8 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:09 -0400 Received: by mail-pf0-x243.google.com with SMTP id b74-v6so8603233pfl.5 for ; Mon, 18 Jun 2018 11:41:09 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s2fWIvcIapxwY3FyUL2rUhGsGMtdyQRgSzCCYuc2ilU=; b=f3W4Ys4a382wVFMjBvgkRzUQH3/4Q5yZCwk7D0qKaYAxm+bsfDsPd0NfKeC5gf+yFC lRu4tr5n+idEhDyepxwAKdVoF4Gfq4/MFlszPNtotja3vvkOcOIDUhXATQWeQXKIx28K +p75mrnKD7Dl0sttc4hxmYaePjEBiVP1A9BCk= 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:mime-version:content-transfer-encoding; bh=s2fWIvcIapxwY3FyUL2rUhGsGMtdyQRgSzCCYuc2ilU=; b=NMxehxUezcKSwbmwNZCh49luJd5H2NCSJMljvHAx6yh0INwdojfXmGoV+a3saYaFpf G6Zh6uThqfyojpdbDfL0ekxXk/0gK28R6FjdAtMqyIXKD/gBEgkJ00nf4IqZHp2sCMzK 5bYb8gxfARNZsJ/e5YFo0VI1+k9/jhsKamJo0zH5FGIEqkwLwkGi5kG0gCZxEw/WHZjg meeLgTkkIG0YhBsrlgEngOnFbxbO5H3Yxo9KG0Ke7rVKMbJki+lcNBXAMelz4W4a5crH N8xNz8YwHVLHgvoaMUV6GkgC9xYSCCKQfJzCoRa3PwePkiqe9rl3TXAhngCQEi7nZ4fa kt8A== X-Gm-Message-State: APt69E2pTd/1pb6u+g1qItlO3Qa8ZqL8we2cuX5B/kYxub7Kc2Y2vHVH JiVui3GmyVX0SnUN0qvNvYrwmy/cbFw= X-Google-Smtp-Source: ADUXVKLe6dssfRrjedMQAuyazRa15LzIH2RE89ZwXj3jFeft103r2b8gq9Vip7jf2gJDgioxz3ChMw== X-Received: by 2002:a63:6ac5:: with SMTP id f188-v6mr11868438pgc.195.1529347268598; Mon, 18 Jun 2018 11:41:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:34 -1000 Message-Id: <20180618184046.6270-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v2 10/22] target/openrisc: Merge mmu_helper.c into mmu.c 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: shorne@gmail.com 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 With tlb_fill in mmu.c, we can simplify things further. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/openrisc/mmu.c | 11 ++++++++++ target/openrisc/mmu_helper.c | 40 ----------------------------------- target/openrisc/Makefile.objs | 2 +- 3 files changed, 12 insertions(+), 41 deletions(-) delete mode 100644 target/openrisc/mmu_helper.c diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c index b2effaa6d7..9b4b5cf04f 100644 --- a/target/openrisc/mmu.c +++ b/target/openrisc/mmu.c @@ -240,4 +240,15 @@ hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cs, = vaddr addr) return phys_addr; } } + +void tlb_fill(CPUState *cs, target_ulong addr, int size, + MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) +{ + int ret =3D openrisc_cpu_handle_mmu_fault(cs, addr, size, + access_type, mmu_idx); + if (ret) { + /* Raise Exception. */ + cpu_loop_exit_restore(cs, retaddr); + } +} #endif diff --git a/target/openrisc/mmu_helper.c b/target/openrisc/mmu_helper.c deleted file mode 100644 index 97e1d17b5a..0000000000 --- a/target/openrisc/mmu_helper.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * OpenRISC MMU helper routines - * - * Copyright (c) 2011-2012 Jia Liu - * Zhizhou Zhang - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#include "qemu/osdep.h" -#include "cpu.h" -#include "exec/exec-all.h" -#include "exec/cpu_ldst.h" - -#ifndef CONFIG_USER_ONLY - -void tlb_fill(CPUState *cs, target_ulong addr, int size, - MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) -{ - int ret; - - ret =3D openrisc_cpu_handle_mmu_fault(cs, addr, size, access_type, mmu= _idx); - - if (ret) { - /* Raise Exception. */ - cpu_loop_exit_restore(cs, retaddr); - } -} -#endif diff --git a/target/openrisc/Makefile.objs b/target/openrisc/Makefile.objs index 1b98a911ea..957ce02199 100644 --- a/target/openrisc/Makefile.objs +++ b/target/openrisc/Makefile.objs @@ -1,7 +1,7 @@ obj-$(CONFIG_SOFTMMU) +=3D machine.o obj-y +=3D cpu.o exception.o interrupt.o mmu.o translate.o obj-y +=3D exception_helper.o fpu_helper.o \ - interrupt_helper.o mmu_helper.o sys_helper.o + interrupt_helper.o sys_helper.o obj-y +=3D gdbstub.o =20 DECODETREE =3D $(SRC_PATH)/scripts/decodetree.py --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529348290819403.5855189604539; Mon, 18 Jun 2018 11:58:10 -0700 (PDT) Received: from localhost ([::1]:36551 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzLu-00005P-3q for importer@patchew.org; Mon, 18 Jun 2018 14:58:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5W-0003VL-EV for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5T-0004o6-P9 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:14 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:44676) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5T-0004n7-Gw for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:11 -0400 Received: by mail-pf0-x241.google.com with SMTP id h12-v6so8601783pfk.11 for ; Mon, 18 Jun 2018 11:41:11 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MGPS5mMTvNmY0ddKxeDKt9fH9pqi2zSjNfROgeBG/vw=; b=kbT70YTpmKRsg/uLEtQLh21bOoxJ3muF89NVaFKoFPgsQTn5ZoVBFnqERYlY9V74L/ ZL69P6NbP9YTDEU2cEj4khS73K+WGzp4vynWx1mKymzjavplXETcvRXzMRzqa9m7KSKO Rj8NxCmxggjs4K4d1g/JrEe56pGOYCWha+F20= 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:mime-version:content-transfer-encoding; bh=MGPS5mMTvNmY0ddKxeDKt9fH9pqi2zSjNfROgeBG/vw=; b=qfKdFoKl4q4S/O/mgvqHR4e+3giUT8aPOr+L5ousWdVDcpOP6pT6BB4vQu9oRXNIdv 5DfxV/l/kyBYspVPQq91cclV52VOf7i2k8yTm00u6hB/koxiTrhkBLfSQBH1moWAfEUJ kzh6zaDqGM1b6wm7H+/36+ZB0/Hj0ev3gq4fRDsc7TrjxlCzentEm0kjiLihIqgJknji zsbcgZ456yUJJGO9pqwuYgBmO7LjIOySIkm9HW3xgx+ZSSxALHnpHIy2tLa4mj21ntWf uj+IGE6J92hpjxYKijulY0KfYIDWY4a44o4GJbdU5dVS0/3Ra3bRcgWlqb9iEMT0g6Es pMjw== X-Gm-Message-State: APt69E3sSVUo2dlgmI5BU5ZSgs4cCKiqpSQhbxs2pEGtnzM/U3kzqfet 01+PIDELy4jr8Db61zr/revkeXhGcB4= X-Google-Smtp-Source: ADUXVKJWIAsfulXfh03HcxGQmIvf+E/3Pc2LQfpi8HIhv3sjHgnYw1KZNtTTfTLLlIKvtJGDoEcXWw== X-Received: by 2002:a63:9e42:: with SMTP id r2-v6mr12008884pgo.436.1529347270221; Mon, 18 Jun 2018 11:41:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:35 -1000 Message-Id: <20180618184046.6270-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2 11/22] target/openrisc: Reduce tlb to a single dimension 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: shorne@gmail.com 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 While we had defines for *_WAYS, we didn't define more than 1. Reduce the complexity by eliminating this unused dimension. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/openrisc/cpu.h | 6 ++---- target/openrisc/machine.c | 6 ++---- target/openrisc/mmu.c | 30 ++++++++++++++++-------------- target/openrisc/sys_helper.c | 20 ++++++++++---------- 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 13107058cb..947ca00d8d 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -222,10 +222,8 @@ enum { =20 /* TLB size */ enum { - DTLB_WAYS =3D 1, DTLB_SIZE =3D 64, DTLB_MASK =3D (DTLB_SIZE-1), - ITLB_WAYS =3D 1, ITLB_SIZE =3D 64, ITLB_MASK =3D (ITLB_SIZE-1), }; @@ -256,8 +254,8 @@ typedef struct OpenRISCTLBEntry { =20 #ifndef CONFIG_USER_ONLY typedef struct CPUOpenRISCTLBContext { - OpenRISCTLBEntry itlb[ITLB_WAYS][ITLB_SIZE]; - OpenRISCTLBEntry dtlb[DTLB_WAYS][DTLB_SIZE]; + OpenRISCTLBEntry itlb[ITLB_SIZE]; + OpenRISCTLBEntry dtlb[DTLB_SIZE]; =20 int (*cpu_openrisc_map_address_code)(struct OpenRISCCPU *cpu, hwaddr *physical, diff --git a/target/openrisc/machine.c b/target/openrisc/machine.c index 73e0abcfd7..b795b56dc6 100644 --- a/target/openrisc/machine.c +++ b/target/openrisc/machine.c @@ -42,11 +42,9 @@ static const VMStateDescription vmstate_cpu_tlb =3D { .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_STRUCT_ARRAY(itlb, CPUOpenRISCTLBContext, ITLB_SIZE, 0, vmstate_tlb_entry, OpenRISCTLBEntry), - VMSTATE_STRUCT_2DARRAY(dtlb, CPUOpenRISCTLBContext, - DTLB_WAYS, DTLB_SIZE, 0, + VMSTATE_STRUCT_ARRAY(dtlb, CPUOpenRISCTLBContext, DTLB_SIZE, 0, vmstate_tlb_entry, OpenRISCTLBEntry), VMSTATE_END_OF_LIST() } diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c index 9b4b5cf04f..856969a7f2 100644 --- a/target/openrisc/mmu.c +++ b/target/openrisc/mmu.c @@ -43,19 +43,21 @@ static int get_phys_code(OpenRISCCPU *cpu, hwaddr *phys= ical, int *prot, int vpn =3D address >> TARGET_PAGE_BITS; int idx =3D vpn & ITLB_MASK; int right =3D 0; + uint32_t mr =3D cpu->env.tlb.itlb[idx].mr; + uint32_t tr =3D cpu->env.tlb.itlb[idx].tr; =20 - if ((cpu->env.tlb.itlb[0][idx].mr >> TARGET_PAGE_BITS) !=3D vpn) { + if ((mr >> TARGET_PAGE_BITS) !=3D vpn) { return TLBRET_NOMATCH; } - if (!(cpu->env.tlb.itlb[0][idx].mr & 1)) { + if (!(mr & 1)) { return TLBRET_INVALID; } if (supervisor) { - if (cpu->env.tlb.itlb[0][idx].tr & SXE) { + if (tr & SXE) { right |=3D PAGE_EXEC; } } else { - if (cpu->env.tlb.itlb[0][idx].tr & UXE) { + if (tr & UXE) { right |=3D PAGE_EXEC; } } @@ -63,8 +65,7 @@ static int get_phys_code(OpenRISCCPU *cpu, hwaddr *physic= al, int *prot, return TLBRET_BADADDR; } =20 - *physical =3D (cpu->env.tlb.itlb[0][idx].tr & TARGET_PAGE_MASK) | - (address & (TARGET_PAGE_SIZE-1)); + *physical =3D (tr & TARGET_PAGE_MASK) | (address & ~TARGET_PAGE_MASK); *prot =3D right; return TLBRET_MATCH; } @@ -75,25 +76,27 @@ static int get_phys_data(OpenRISCCPU *cpu, hwaddr *phys= ical, int *prot, int vpn =3D address >> TARGET_PAGE_BITS; int idx =3D vpn & DTLB_MASK; int right =3D 0; + uint32_t mr =3D cpu->env.tlb.dtlb[idx].mr; + uint32_t tr =3D cpu->env.tlb.dtlb[idx].tr; =20 - if ((cpu->env.tlb.dtlb[0][idx].mr >> TARGET_PAGE_BITS) !=3D vpn) { + if ((mr >> TARGET_PAGE_BITS) !=3D vpn) { return TLBRET_NOMATCH; } - if (!(cpu->env.tlb.dtlb[0][idx].mr & 1)) { + if (!(mr & 1)) { return TLBRET_INVALID; } if (supervisor) { - if (cpu->env.tlb.dtlb[0][idx].tr & SRE) { + if (tr & SRE) { right |=3D PAGE_READ; } - if (cpu->env.tlb.dtlb[0][idx].tr & SWE) { + if (tr & SWE) { right |=3D PAGE_WRITE; } } else { - if (cpu->env.tlb.dtlb[0][idx].tr & URE) { + if (tr & URE) { right |=3D PAGE_READ; } - if (cpu->env.tlb.dtlb[0][idx].tr & UWE) { + if (tr & UWE) { right |=3D PAGE_WRITE; } } @@ -105,8 +108,7 @@ static int get_phys_data(OpenRISCCPU *cpu, hwaddr *phys= ical, int *prot, return TLBRET_BADADDR; } =20 - *physical =3D (cpu->env.tlb.dtlb[0][idx].tr & TARGET_PAGE_MASK) | - (address & (TARGET_PAGE_SIZE-1)); + *physical =3D (tr & TARGET_PAGE_MASK) | (address & ~TARGET_PAGE_MASK); *prot =3D right; return TLBRET_MATCH; } diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index a1285894ad..8ad7a7d898 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -85,14 +85,14 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong = spr, target_ulong 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)) { - tlb_flush_page(cs, env->tlb.dtlb[0][idx].mr & TARGET_PAGE_MASK= ); + tlb_flush_page(cs, env->tlb.dtlb[idx].mr & TARGET_PAGE_MASK); } - env->tlb.dtlb[0][idx].mr =3D rb; + env->tlb.dtlb[idx].mr =3D rb; break; =20 case TO_SPR(1, 640) ... TO_SPR(1, 640+DTLB_SIZE-1): /* DTLBW0TR 0-127 = */ idx =3D spr - TO_SPR(1, 640); - env->tlb.dtlb[0][idx].tr =3D rb; + env->tlb.dtlb[idx].tr =3D rb; break; case TO_SPR(1, 768) ... TO_SPR(1, 895): /* DTLBW1MR 0-127 */ case TO_SPR(1, 896) ... TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ @@ -104,14 +104,14 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulon= g spr, target_ulong rb) case TO_SPR(2, 512) ... TO_SPR(2, 512+ITLB_SIZE-1): /* ITLBW0MR 0-12= 7 */ idx =3D spr - TO_SPR(2, 512); if (!(rb & 1)) { - tlb_flush_page(cs, env->tlb.itlb[0][idx].mr & TARGET_PAGE_MASK= ); + tlb_flush_page(cs, env->tlb.itlb[idx].mr & TARGET_PAGE_MASK); } - env->tlb.itlb[0][idx].mr =3D rb; + env->tlb.itlb[idx].mr =3D rb; break; =20 case TO_SPR(2, 640) ... TO_SPR(2, 640+ITLB_SIZE-1): /* ITLBW0TR 0-127 = */ idx =3D spr - TO_SPR(2, 640); - env->tlb.itlb[0][idx].tr =3D rb; + env->tlb.itlb[idx].tr =3D rb; break; case TO_SPR(2, 768) ... TO_SPR(2, 895): /* ITLBW1MR 0-127 */ case TO_SPR(2, 896) ... TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ @@ -243,11 +243,11 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, tar= get_ulong rd, =20 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; + return env->tlb.dtlb[idx].mr; =20 case TO_SPR(1, 640) ... TO_SPR(1, 640+DTLB_SIZE-1): /* DTLBW0TR 0-127 = */ idx =3D spr - TO_SPR(1, 640); - return env->tlb.dtlb[0][idx].tr; + return env->tlb.dtlb[idx].tr; =20 case TO_SPR(1, 768) ... TO_SPR(1, 895): /* DTLBW1MR 0-127 */ case TO_SPR(1, 896) ... TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ @@ -259,11 +259,11 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, tar= get_ulong rd, =20 case TO_SPR(2, 512) ... TO_SPR(2, 512+ITLB_SIZE-1): /* ITLBW0MR 0-127 = */ idx =3D spr - TO_SPR(2, 512); - return env->tlb.itlb[0][idx].mr; + return env->tlb.itlb[idx].mr; =20 case TO_SPR(2, 640) ... TO_SPR(2, 640+ITLB_SIZE-1): /* ITLBW0TR 0-127 = */ idx =3D spr - TO_SPR(2, 640); - return env->tlb.itlb[0][idx].tr; + return env->tlb.itlb[idx].tr; =20 case TO_SPR(2, 768) ... TO_SPR(2, 895): /* ITLBW1MR 0-127 */ case TO_SPR(2, 896) ... TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529347593302857.3897058619415; Mon, 18 Jun 2018 11:46:33 -0700 (PDT) Received: from localhost ([::1]:36490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzAe-0007BR-Kb for importer@patchew.org; Mon, 18 Jun 2018 14:46:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5W-0003VQ-FJ for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5V-0004qI-EN for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:14 -0400 Received: from mail-pl0-x233.google.com ([2607:f8b0:400e:c01::233]:35869) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5V-0004pW-8t for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:13 -0400 Received: by mail-pl0-x233.google.com with SMTP id a7-v6so9500246plp.3 for ; Mon, 18 Jun 2018 11:41:13 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5z97SVwjEk4sNEX969oQIopbF5FDZsjnXfc9pzcx1EA=; b=Vr311plRX3TPKnnVInCjrFVf38k55izZuRJGEMcpiUwohS30IMoZiErXwym1xaZcRm r0jFdao+3f2n8FyzSBVXnRVbdT2bdb/uMS1CuIQqokxStsx0lzS6KjN6MfIFN0ZqNEha +vk6GkuCqfH3Otz3Isbg+vCYaXdlCM6W1VjvU= 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=5z97SVwjEk4sNEX969oQIopbF5FDZsjnXfc9pzcx1EA=; b=Q6N8jQUV8/sO4sOUCYoK3MT1HB4qHJaYY1cK398fd9YcXKKCPfWVEgPqvR3E6WfjAM R6krVkMR0RKfEi8j+RSWXjM04ehVE6XKDyWjD65t4gfPq0Fh8I2U/FgBabhvKy1gRLc6 W/h4nHqXLLLPu8Vb90rlASPu7Q1kad2PHVVXh8oA3B1+qY05/0XtrL1OhVzpje7rFmQj jWUnydWUMePIUHS527pNIpngr1CaJv46DgR0lhZQgKS+fekKWfKUpPaIufO73ZinN3q9 myPpj+qs2/+AUTB8M7PWm9xvhCmYX77KVcFiTk87pbCE86tA/OTMNyfwrwzYe6D0S7aI bXkg== X-Gm-Message-State: APt69E3pTc+lP5Bz2v7g/MME6yJ7qV4MN0mfeM1E6Qr5QWj3RIxp+IVa cft4OW5caGqoB/16gHLTVeXoVhhd5M8= X-Google-Smtp-Source: ADUXVKL6mAsST7zSJwMDyunba6cjlQWh0lhRv/CY0ocNwaFnXqR7Hg0qpZgKvYNFXplLoWnV7KOAIg== X-Received: by 2002:a17:902:70ca:: with SMTP id l10-v6mr2332822plt.174.1529347272034; Mon, 18 Jun 2018 11:41:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:36 -1000 Message-Id: <20180618184046.6270-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::233 Subject: [Qemu-devel] [PATCH v2 12/22] target/openrisc: Fix tlb flushing in mtspr 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: shorne@gmail.com 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" The previous code was confused, avoiding the flush of the old entry if the new entry is invalid. We need to flush the old page if the old entry is valid and the new page if the new entry is valid. This bug was masked by over-flushing elsewhere. Signed-off-by: Richard Henderson --- target/openrisc/sys_helper.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index 8ad7a7d898..e00aaa332e 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -32,6 +32,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong sp= r, target_ulong rb) #ifndef CONFIG_USER_ONLY OpenRISCCPU *cpu =3D openrisc_env_get_cpu(env); CPUState *cs =3D CPU(cpu); + target_ulong mr; int idx; =20 switch (spr) { @@ -84,12 +85,15 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong = spr, target_ulong rb) =20 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)) { - tlb_flush_page(cs, env->tlb.dtlb[idx].mr & TARGET_PAGE_MASK); + mr =3D env->tlb.dtlb[idx].mr; + if (mr & 1) { + tlb_flush_page(cs, mr & TARGET_PAGE_MASK); + } + if (rb & 1) { + tlb_flush_page(cs, rb & TARGET_PAGE_MASK); } env->tlb.dtlb[idx].mr =3D rb; break; - case TO_SPR(1, 640) ... TO_SPR(1, 640+DTLB_SIZE-1): /* DTLBW0TR 0-127 = */ idx =3D spr - TO_SPR(1, 640); env->tlb.dtlb[idx].tr =3D rb; @@ -101,14 +105,18 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulon= g spr, target_ulong rb) case TO_SPR(1, 1280) ... TO_SPR(1, 1407): /* DTLBW3MR 0-127 */ case TO_SPR(1, 1408) ... TO_SPR(1, 1535): /* DTLBW3TR 0-127 */ break; + case TO_SPR(2, 512) ... TO_SPR(2, 512+ITLB_SIZE-1): /* ITLBW0MR 0-12= 7 */ idx =3D spr - TO_SPR(2, 512); - if (!(rb & 1)) { - tlb_flush_page(cs, env->tlb.itlb[idx].mr & TARGET_PAGE_MASK); + mr =3D env->tlb.itlb[idx].mr; + if (mr & 1) { + tlb_flush_page(cs, mr & TARGET_PAGE_MASK); + } + if (rb & 1) { + tlb_flush_page(cs, rb & TARGET_PAGE_MASK); } env->tlb.itlb[idx].mr =3D rb; break; - case TO_SPR(2, 640) ... TO_SPR(2, 640+ITLB_SIZE-1): /* ITLBW0TR 0-127 = */ idx =3D spr - TO_SPR(2, 640); env->tlb.itlb[idx].tr =3D rb; @@ -120,6 +128,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong = spr, target_ulong rb) case TO_SPR(2, 1280) ... TO_SPR(2, 1407): /* ITLBW3MR 0-127 */ case TO_SPR(2, 1408) ... TO_SPR(2, 1535): /* ITLBW3TR 0-127 */ break; + case TO_SPR(5, 1): /* MACLO */ env->mac =3D deposit64(env->mac, 0, 32, rb); break; --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529348121135476.5939746229452; Mon, 18 Jun 2018 11:55:21 -0700 (PDT) Received: from localhost ([::1]:36531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzJ0-0006DX-D8 for importer@patchew.org; Mon, 18 Jun 2018 14:55:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57392) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5Y-0003WO-FX for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5X-0004ry-6e for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:16 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:41688) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5W-0004rZ-Uw for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:15 -0400 Received: by mail-pf0-x241.google.com with SMTP id a11-v6so8596941pff.8 for ; Mon, 18 Jun 2018 11:41:14 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FwHCXPAknYlMFR4FRB8q6D+1KAe105t+S830j5eMmYA=; b=Oo6HHrP/R6WCYLc3dXK7BhMVR7/T+u7/M1Bqp9d79QheYbwhznzI20ZG/m6qLmzo7k juztqrqHyIKMR9PvQ8fVTwhkfN+FCao91sRnefRlVF+d1m559nMa/nPo+FvkEpopj56M TzsJgB1p2NRAwvd7osGb9g1gN80IjNF8SkWA8= 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=FwHCXPAknYlMFR4FRB8q6D+1KAe105t+S830j5eMmYA=; b=tAScYpRKY7IaZj7gGLvIcnb3KDsv1RKPdWz9+CTSMuvj+XwQhX81mi9LPO+33XTAkV QLLBkbloBrfa/or+anOnqnOG8UATipB+E39mEbdn7pjbYBtPsg+Q5fRhr98RAX/tdEcP bO/eoXR52OqwHP4i6hm47iZQpKun3ZirLZwEGSuQJt8SdioRL9VZ3my/h4Sad2mRnPhT ztBhatWYtzVU3olxUrx0yxsLcri1a8movYPOvCPwmlWuYICxH0kxDqKGhWznGv7vH5u0 Fzpn0toLMhZNuM+EIdNIARtMROnfN88soGiGOeVNB2Ni/i1lWZp0nYvZ6xM/uFO2h+hp K6tg== X-Gm-Message-State: APt69E0iJ7L2e96J5PjxtJgso8nMK1Jk4qBdxuIsFaNGFrfXBr7LTp4g cKaF34TnROaKzQfhJz//4vk1uLCBTbo= X-Google-Smtp-Source: ADUXVKIr1lae97LXHylddJUUo5VzIHYmbGK7Cl7WfhAKV/hOqDGs1uRsIRn1cgeM+yF3EPdwljQALg== X-Received: by 2002:a62:9f16:: with SMTP id g22-v6mr14422092pfe.207.1529347273734; Mon, 18 Jun 2018 11:41:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:37 -1000 Message-Id: <20180618184046.6270-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2 13/22] target/openrisc: Fix cpu_mmu_index 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: shorne@gmail.com 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" The code in cpu_mmu_index does not properly honor SR_DME. This bug has workarounds elsewhere in that we flush the tlb more often than necessary, on the state changes that should be reflected in a change of mmu_index. Fixing this means that we can respect the mmu_index that is given to tlb_flush. Signed-off-by: Richard Henderson --- target/openrisc/cpu.h | 23 +++++++++++++-------- target/openrisc/interrupt.c | 4 ---- target/openrisc/interrupt_helper.c | 15 +++----------- target/openrisc/mmu.c | 33 +++++++++++++++++++++++++++--- target/openrisc/sys_helper.c | 4 ---- target/openrisc/translate.c | 2 +- 6 files changed, 49 insertions(+), 32 deletions(-) diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 947ca00d8d..c48802ad8f 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -384,9 +384,12 @@ void cpu_openrisc_count_stop(OpenRISCCPU *cpu); =20 #include "exec/cpu-all.h" =20 -#define TB_FLAGS_DFLAG 1 -#define TB_FLAGS_R0_0 2 +#define TB_FLAGS_SM SR_SM +#define TB_FLAGS_DME SR_DME +#define TB_FLAGS_IME SR_IME #define TB_FLAGS_OVE SR_OVE +#define TB_FLAGS_DFLAG 2 /* reuse SR_TEE */ +#define TB_FLAGS_R0_0 4 /* reuse SR_IEE */ =20 static inline uint32_t cpu_get_gpr(const CPUOpenRISCState *env, int i) { @@ -404,17 +407,21 @@ static inline void cpu_get_tb_cpu_state(CPUOpenRISCSt= ate *env, { *pc =3D env->pc; *cs_base =3D 0; - *flags =3D (env->dflag - | (cpu_get_gpr(env, 0) =3D=3D 0 ? TB_FLAGS_R0_0 : 0) - | (env->sr & SR_OVE)); + *flags =3D (env->dflag ? TB_FLAGS_DFLAG : 0) + | (cpu_get_gpr(env, 0) ? 0 : TB_FLAGS_R0_0) + | (env->sr & (SR_SM | SR_DME | SR_IME | SR_OVE)); } =20 static inline int cpu_mmu_index(CPUOpenRISCState *env, bool ifetch) { - if (!(env->sr & SR_IME)) { - return MMU_NOMMU_IDX; + int ret =3D MMU_NOMMU_IDX; /* mmu is disabled */ + + if (env->sr & (ifetch ? SR_IME : SR_DME)) { + /* The mmu is enabled; test supervisor state. */ + ret =3D env->sr & SR_SM ? MMU_SUPERVISOR_IDX : MMU_USER_IDX; } - return (env->sr & SR_SM) =3D=3D 0 ? MMU_USER_IDX : MMU_SUPERVISOR_IDX; + + return ret; } =20 static inline uint32_t cpu_get_sr(const CPUOpenRISCState *env) diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index d9cb363fea..e28042856a 100644 --- a/target/openrisc/interrupt.c +++ b/target/openrisc/interrupt.c @@ -50,10 +50,6 @@ void openrisc_cpu_do_interrupt(CPUState *cs) env->eear =3D env->pc; } =20 - /* For machine-state changed between user-mode and supervisor mode, - we need flush TLB when we enter&exit EXCP. */ - tlb_flush(cs); - env->esr =3D cpu_get_sr(env); env->sr &=3D ~SR_DME; env->sr &=3D ~SR_IME; diff --git a/target/openrisc/interrupt_helper.c b/target/openrisc/interrupt= _helper.c index a2e9003969..9c5489f5f7 100644 --- a/target/openrisc/interrupt_helper.c +++ b/target/openrisc/interrupt_helper.c @@ -25,16 +25,7 @@ =20 void HELPER(rfe)(CPUOpenRISCState *env) { - OpenRISCCPU *cpu =3D openrisc_env_get_cpu(env); -#ifndef CONFIG_USER_ONLY - int need_flush_tlb =3D (cpu->env.sr & (SR_SM | SR_IME | SR_DME)) ^ - (cpu->env.esr & (SR_SM | SR_IME | SR_DME)); - if (need_flush_tlb) { - CPUState *cs =3D CPU(cpu); - tlb_flush(cs); - } -#endif - cpu->env.pc =3D cpu->env.epcr; - cpu->env.lock_addr =3D -1; - cpu_set_sr(&cpu->env, cpu->env.esr); + env->pc =3D env->epcr; + env->lock_addr =3D -1; + cpu_set_sr(env, env->esr); } diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c index 856969a7f2..b293b64e98 100644 --- a/target/openrisc/mmu.c +++ b/target/openrisc/mmu.c @@ -246,9 +246,36 @@ hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cs, = vaddr addr) void tlb_fill(CPUState *cs, target_ulong addr, int size, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - int ret =3D openrisc_cpu_handle_mmu_fault(cs, addr, size, - access_type, mmu_idx); - if (ret) { + OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); + int ret, prot =3D 0; + hwaddr physical =3D 0; + + if (mmu_idx =3D=3D MMU_NOMMU_IDX) { + ret =3D get_phys_nommu(&physical, &prot, addr); + } else { + bool super =3D mmu_idx =3D=3D MMU_SUPERVISOR_IDX; + if (access_type =3D=3D MMU_INST_FETCH) { + ret =3D get_phys_code(cpu, &physical, &prot, addr, 2, super); + } else { + ret =3D get_phys_data(cpu, &physical, &prot, addr, + access_type =3D=3D MMU_DATA_STORE, super); + } + } + + if (ret =3D=3D TLBRET_MATCH) { + tlb_set_page(cs, addr & TARGET_PAGE_MASK, + physical & TARGET_PAGE_MASK, prot, + mmu_idx, TARGET_PAGE_SIZE); + } else if (ret < 0) { + int rw; + if (access_type =3D=3D MMU_INST_FETCH) { + rw =3D 2; + } else if (access_type =3D=3D MMU_DATA_STORE) { + rw =3D 1; + } else { + rw =3D 0; + } + cpu_openrisc_raise_mmu_exception(cpu, addr, rw, ret); /* Raise Exception. */ cpu_loop_exit_restore(cs, retaddr); } diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index e00aaa332e..0a74c9522f 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -56,10 +56,6 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong s= pr, target_ulong rb) break; =20 case TO_SPR(0, 17): /* SR */ - if ((env->sr & (SR_IME | SR_DME | SR_SM)) ^ - (rb & (SR_IME | SR_DME | SR_SM))) { - tlb_flush(cs); - } cpu_set_sr(env, rb); break; =20 diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index f19f0d257b..60c6e19f4b 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -59,7 +59,7 @@ static inline bool is_user(DisasContext *dc) #ifdef CONFIG_USER_ONLY return true; #else - return dc->mem_idx =3D=3D MMU_USER_IDX; + return !(dc->tb_flags & TB_FLAGS_SM); #endif } =20 --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529347787440324.5570449598832; Mon, 18 Jun 2018 11:49:47 -0700 (PDT) Received: from localhost ([::1]:36502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzDm-0001Wf-Mp for importer@patchew.org; Mon, 18 Jun 2018 14:49:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5a-0003Wx-9J for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5Y-0004sz-SN for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:18 -0400 Received: from mail-pg0-x235.google.com ([2607:f8b0:400e:c05::235]:35781) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5Y-0004sS-Jc for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:16 -0400 Received: by mail-pg0-x235.google.com with SMTP id 15-v6so7928396pge.2 for ; Mon, 18 Jun 2018 11:41:16 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S79sZyivBkNyL4H4hbuunUzlbblK48JMQIvgdjiIie8=; b=i8Af3oZGml6nYFyGmIT1kpMRDc2XovuLKUbvFdHG8nc+IlNeNZbZuecNTIQNX0G/XG xLVJUSV4ILU+Y2bFdBK4TPFPvRfEK8RaCOb3ljSGZWOnUEf8VRAiRFV8+tFJFuxx3RvN ATwvYDR1kCHLjGyT4ZnOhfYeFMTR2G8eVb4fo= 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:mime-version:content-transfer-encoding; bh=S79sZyivBkNyL4H4hbuunUzlbblK48JMQIvgdjiIie8=; b=ZC29pvjMhC9KjcyRsafD5S0KItJUO8Hx8qbGB8sb3MxZigyI8AZOL9J5B+OsXkkfwG TBMxzCjNabU/kfoB/wPPToB4bGphhcv8y+WZD9P+U0VrboK9mjncw/R/BysrIt81EP/6 REGD1SlluIEtwJ6Vs1bEHJunuGOM1XvORkCUCczwi+/VIeKTpX4PcexoUGeppkYu2kZo 2mqGdRN5cgW6Z3cKF0vV9eR5GWB/lMb3OI3ds3HmSquXbkd6n5Rkz0JbFOZVpTOXY5D+ BnIV7ARBOKV1thjL1wTitXCUsalNrXuS3qia7Tk64DDxbT5lj3V+TsfLoVTn2eSp7M1Y +j9Q== X-Gm-Message-State: APt69E1YPXYj1M3uk8KqBD3kRqDnVmjboPh8SuVDD+0bZpXu+tJYQZza ZZtS6LtX/HBR3mHGfwslwV/c7KySJpw= X-Google-Smtp-Source: ADUXVKKv8nvctFl6HNYF6o4nXOwlkB1dQx2BT4U/J9Lmvv1/vJkZ+VY8TpwPUUPFksgEZ4edsCYfOg== X-Received: by 2002:a62:993:: with SMTP id 19-v6mr3338238pfj.105.1529347275324; Mon, 18 Jun 2018 11:41:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:38 -1000 Message-Id: <20180618184046.6270-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::235 Subject: [Qemu-devel] [PATCH v2 14/22] target/openrisc: Use identical sizes for ITLB and DTLB 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: shorne@gmail.com 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 The sizes are already the same, however, we can improve things if they are identical by design. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/openrisc/cpu.h | 10 ++++------ target/openrisc/machine.c | 4 ++-- target/openrisc/mmu.c | 4 ++-- target/openrisc/sys_helper.c | 16 ++++++++-------- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index c48802ad8f..53abe965e8 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -222,10 +222,8 @@ enum { =20 /* TLB size */ enum { - DTLB_SIZE =3D 64, - DTLB_MASK =3D (DTLB_SIZE-1), - ITLB_SIZE =3D 64, - ITLB_MASK =3D (ITLB_SIZE-1), + TLB_SIZE =3D 64, + TLB_MASK =3D TLB_SIZE - 1, }; =20 /* TLB prot */ @@ -254,8 +252,8 @@ typedef struct OpenRISCTLBEntry { =20 #ifndef CONFIG_USER_ONLY typedef struct CPUOpenRISCTLBContext { - OpenRISCTLBEntry itlb[ITLB_SIZE]; - OpenRISCTLBEntry dtlb[DTLB_SIZE]; + OpenRISCTLBEntry itlb[TLB_SIZE]; + OpenRISCTLBEntry dtlb[TLB_SIZE]; =20 int (*cpu_openrisc_map_address_code)(struct OpenRISCCPU *cpu, hwaddr *physical, diff --git a/target/openrisc/machine.c b/target/openrisc/machine.c index b795b56dc6..3fc837b925 100644 --- a/target/openrisc/machine.c +++ b/target/openrisc/machine.c @@ -42,9 +42,9 @@ static const VMStateDescription vmstate_cpu_tlb =3D { .minimum_version_id =3D 1, .minimum_version_id_old =3D 1, .fields =3D (VMStateField[]) { - VMSTATE_STRUCT_ARRAY(itlb, CPUOpenRISCTLBContext, ITLB_SIZE, 0, + VMSTATE_STRUCT_ARRAY(itlb, CPUOpenRISCTLBContext, TLB_SIZE, 0, vmstate_tlb_entry, OpenRISCTLBEntry), - VMSTATE_STRUCT_ARRAY(dtlb, CPUOpenRISCTLBContext, DTLB_SIZE, 0, + VMSTATE_STRUCT_ARRAY(dtlb, CPUOpenRISCTLBContext, TLB_SIZE, 0, vmstate_tlb_entry, OpenRISCTLBEntry), VMSTATE_END_OF_LIST() } diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c index b293b64e98..a4613e9ae4 100644 --- a/target/openrisc/mmu.c +++ b/target/openrisc/mmu.c @@ -41,7 +41,7 @@ static int get_phys_code(OpenRISCCPU *cpu, hwaddr *physic= al, int *prot, target_ulong address, int rw, bool supervisor) { int vpn =3D address >> TARGET_PAGE_BITS; - int idx =3D vpn & ITLB_MASK; + int idx =3D vpn & TLB_MASK; int right =3D 0; uint32_t mr =3D cpu->env.tlb.itlb[idx].mr; uint32_t tr =3D cpu->env.tlb.itlb[idx].tr; @@ -74,7 +74,7 @@ static int get_phys_data(OpenRISCCPU *cpu, hwaddr *physic= al, int *prot, target_ulong address, int rw, bool supervisor) { int vpn =3D address >> TARGET_PAGE_BITS; - int idx =3D vpn & DTLB_MASK; + int idx =3D vpn & TLB_MASK; int right =3D 0; uint32_t mr =3D cpu->env.tlb.dtlb[idx].mr; uint32_t tr =3D cpu->env.tlb.dtlb[idx].tr; diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index 0a74c9522f..7254aa9830 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -79,7 +79,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong sp= r, target_ulong rb) idx =3D (spr - 1024); env->shadow_gpr[idx / 32][idx % 32] =3D rb; =20 - case TO_SPR(1, 512) ... TO_SPR(1, 512+DTLB_SIZE-1): /* DTLBW0MR 0-127 = */ + case TO_SPR(1, 512) ... TO_SPR(1, 512 + TLB_SIZE - 1): /* DTLBW0MR 0-1= 27 */ idx =3D spr - TO_SPR(1, 512); mr =3D env->tlb.dtlb[idx].mr; if (mr & 1) { @@ -90,7 +90,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong sp= r, target_ulong rb) } env->tlb.dtlb[idx].mr =3D rb; break; - case TO_SPR(1, 640) ... TO_SPR(1, 640+DTLB_SIZE-1): /* DTLBW0TR 0-127 = */ + case TO_SPR(1, 640) ... TO_SPR(1, 640 + TLB_SIZE - 1): /* DTLBW0TR 0-1= 27 */ idx =3D spr - TO_SPR(1, 640); env->tlb.dtlb[idx].tr =3D rb; break; @@ -102,7 +102,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong = spr, target_ulong rb) case TO_SPR(1, 1408) ... TO_SPR(1, 1535): /* DTLBW3TR 0-127 */ break; =20 - case TO_SPR(2, 512) ... TO_SPR(2, 512+ITLB_SIZE-1): /* ITLBW0MR 0-12= 7 */ + case TO_SPR(2, 512) ... TO_SPR(2, 512 + TLB_SIZE - 1): /* ITLBW0MR 0-1= 27 */ idx =3D spr - TO_SPR(2, 512); mr =3D env->tlb.itlb[idx].mr; if (mr & 1) { @@ -113,7 +113,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong = spr, target_ulong rb) } env->tlb.itlb[idx].mr =3D rb; break; - case TO_SPR(2, 640) ... TO_SPR(2, 640+ITLB_SIZE-1): /* ITLBW0TR 0-127 = */ + case TO_SPR(2, 640) ... TO_SPR(2, 640 + TLB_SIZE - 1): /* ITLBW0TR 0-1= 27 */ idx =3D spr - TO_SPR(2, 640); env->tlb.itlb[idx].tr =3D rb; break; @@ -246,11 +246,11 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, tar= get_ulong rd, idx =3D (spr - 1024); return env->shadow_gpr[idx / 32][idx % 32]; =20 - case TO_SPR(1, 512) ... TO_SPR(1, 512+DTLB_SIZE-1): /* DTLBW0MR 0-127 = */ + case TO_SPR(1, 512) ... TO_SPR(1, 512 + TLB_SIZE - 1): /* DTLBW0MR 0-1= 27 */ idx =3D spr - TO_SPR(1, 512); return env->tlb.dtlb[idx].mr; =20 - case TO_SPR(1, 640) ... TO_SPR(1, 640+DTLB_SIZE-1): /* DTLBW0TR 0-127 = */ + case TO_SPR(1, 640) ... TO_SPR(1, 640 + TLB_SIZE - 1): /* DTLBW0TR 0-1= 27 */ idx =3D spr - TO_SPR(1, 640); return env->tlb.dtlb[idx].tr; =20 @@ -262,11 +262,11 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, tar= get_ulong rd, case TO_SPR(1, 1408) ... TO_SPR(1, 1535): /* DTLBW3TR 0-127 */ break; =20 - case TO_SPR(2, 512) ... TO_SPR(2, 512+ITLB_SIZE-1): /* ITLBW0MR 0-127 = */ + case TO_SPR(2, 512) ... TO_SPR(2, 512 + TLB_SIZE - 1): /* ITLBW0MR 0-1= 27 */ idx =3D spr - TO_SPR(2, 512); return env->tlb.itlb[idx].mr; =20 - case TO_SPR(2, 640) ... TO_SPR(2, 640+ITLB_SIZE-1): /* ITLBW0TR 0-127 = */ + case TO_SPR(2, 640) ... TO_SPR(2, 640 + TLB_SIZE - 1): /* ITLBW0TR 0-1= 27 */ idx =3D spr - TO_SPR(2, 640); return env->tlb.itlb[idx].tr; =20 --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529347570760741.252201645316; Mon, 18 Jun 2018 11:46:10 -0700 (PDT) Received: from localhost ([::1]:36488 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzAI-0006ur-0y for importer@patchew.org; Mon, 18 Jun 2018 14:46:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5b-0003Xx-8p for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5a-0004ue-EW for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:19 -0400 Received: from mail-pg0-x22f.google.com ([2607:f8b0:400e:c05::22f]:34482) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5a-0004th-8M for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:18 -0400 Received: by mail-pg0-x22f.google.com with SMTP id q4-v6so7935204pgr.1 for ; Mon, 18 Jun 2018 11:41:18 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xQ7MuAb0CMxAlY812ETLA9j5/iyPIirofg3K3ekSZ3o=; b=XYRkmP5MymnpTloEpD2cjCs8uhz5jUctDdu9t+twTVDOdIo7dO3YGbvXplSSU8zD0v pVKUJYw3cy2rvTjKh306roiadChb86L59RvOkmS+VkglVUp3aVYWdS/qhBYc6UIZDPJm K3IoKQloMwbN5fnRgdCVtU/YCzxD53qQhnknM= 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=xQ7MuAb0CMxAlY812ETLA9j5/iyPIirofg3K3ekSZ3o=; b=o89ZHWkKa3mrIRUYqKcts2HTgJ1JkbebQpboYrSSUk55LqKG36Iwrlt2FM34uZAv9J Cv+0W2U2IU5VCJmmoW9vazdu+bTno/MSlHJ1WMLEl+aGR2I9B+qq2YmeT6lmTPS7giZa A58hTD3h2v8qANhNL7Gt9LELRdPQh9yhap9s7D7dcdum7VGoXnT++v4B+ymzlYsKN13Z lKdxplbz6HRW8ASB84zZqbNWZU9Vcd5j5XA/vxYt3MQk2B6B8l7X+jMwUqXUFetpry1i I2supmWulGGxPzRrsVThNwZ8S0CPk/z0kXpSvf5cV5sd88hY3v5FpdDzHrdUAh1a78xQ doFw== X-Gm-Message-State: APt69E3e4f6myU4HANyZpgsz9eQPTDAx8RTBKb8e/1oukKgY4KtQ3V30 yU4OaRoIa1hk4gH2OjMEPLcvnopEEBI= X-Google-Smtp-Source: ADUXVKLuNY63UGGik0fPa0Xyi9VEZ6fuTdToCn7krIKrF0pNY23IindAGVoV8XrwMDXVGP46Ud9nOw== X-Received: by 2002:a63:af50:: with SMTP id s16-v6mr12232101pgo.263.1529347277026; Mon, 18 Jun 2018 11:41:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:39 -1000 Message-Id: <20180618184046.6270-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22f Subject: [Qemu-devel] [PATCH v2 15/22] target/openrisc: Stub out handle_mmu_fault for softmmu 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: shorne@gmail.com 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" This hook is only used by CONFIG_USER_ONLY. Signed-off-by: Richard Henderson --- target/openrisc/mmu.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c index a4613e9ae4..f4c0a3e217 100644 --- a/target/openrisc/mmu.c +++ b/target/openrisc/mmu.c @@ -177,42 +177,17 @@ static void cpu_openrisc_raise_mmu_exception(OpenRISC= CPU *cpu, cpu->env.lock_addr =3D -1; } =20 -#ifndef CONFIG_USER_ONLY int openrisc_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, int mmu_idx) { +#ifdef CONFIG_USER_ONLY OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); - int ret =3D 0; - hwaddr physical =3D 0; - int prot =3D 0; - - ret =3D get_phys_addr(cpu, &physical, &prot, address, rw); - - if (ret =3D=3D TLBRET_MATCH) { - tlb_set_page(cs, address & TARGET_PAGE_MASK, - physical & TARGET_PAGE_MASK, prot, - mmu_idx, TARGET_PAGE_SIZE); - ret =3D 0; - } else if (ret < 0) { - cpu_openrisc_raise_mmu_exception(cpu, address, rw, ret); - ret =3D 1; - } - - return ret; -} + cpu_openrisc_raise_mmu_exception(cpu, address, rw, 0); + return 1; #else -int openrisc_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, - int rw, int mmu_idx) -{ - OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); - int ret =3D 0; - - cpu_openrisc_raise_mmu_exception(cpu, address, rw, ret); - ret =3D 1; - - return ret; -} + g_assert_not_reached(); #endif +} =20 #ifndef CONFIG_USER_ONLY hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529348402215464.89482529703014; Mon, 18 Jun 2018 12:00:02 -0700 (PDT) Received: from localhost ([::1]:36561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzNh-0001Wc-J1 for importer@patchew.org; Mon, 18 Jun 2018 15:00:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5f-0003ZI-CX for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5c-0004wE-7V for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:23 -0400 Received: from mail-pl0-x234.google.com ([2607:f8b0:400e:c01::234]:45151) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5c-0004vS-1J for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:20 -0400 Received: by mail-pl0-x234.google.com with SMTP id c23-v6so9486822plz.12 for ; Mon, 18 Jun 2018 11:41:19 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZBFXVHb8oEn5W3bnIqvhmT0QND9o29BCX1TtsvICkS0=; b=c9qdcke3dvmYy1K9qFBdbpRHj7ch8lUZC0i5uq/XmVaDWwqqlI0DLJS2SjQbUJIHCn bV2Ve0wtEHma+p6FczvnP1uiAV30dD97YlYAy8R6nYuPs/3HBFxWw9gVbzFrRE8TqO8y md3Q417q+YSq42eYQHnlF0da8RPHypNWrklIQ= 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:mime-version:content-transfer-encoding; bh=ZBFXVHb8oEn5W3bnIqvhmT0QND9o29BCX1TtsvICkS0=; b=g8GyV7tL8bpnyhafX5kWLWTpK71dTqgf9Sdg+sVrEGg8lZakMRN8o3zpmrgF53s+D+ FfADy6vbjaHGgOGoej3Mo6e98Pkxxi3AWizhd+P8qsupPzplys17Q/Ot4WI9c5776aSh zjmzaBb2Za/FTRy/Mjq4d2JysBplU58IEdFGnth8F4gWhqkxkWVxycfFKiQOPGpKxNAw C6nwP5nuj6X899lFRVtOi2tWHNXuoXJeKoMT0G3sZo4pa+CbbECfeO67DkSowEvKlG59 qm3CQwnEF0P3y5H8bD6K3A3kK+FboXTCb1Gng13tQBRBTQHYNpK3QjJMlCzAe+mqRAbs TtvQ== X-Gm-Message-State: APt69E0D9GvLkZzIugtqYMrB2u0odMcCSmIBfjlneIB2EWzYl+p+oeyY +Vz0XtcTcw7yVBDSDT8vftmZyOeaalM= X-Google-Smtp-Source: ADUXVKKJeqPetFt22rjJRljrMYDiEoQl/7QO8BJYOCNyYaZ0ggxPEzPRVYoC9fy/c4MtV1AfkR6XVg== X-Received: by 2002:a17:902:6bc7:: with SMTP id m7-v6mr15591274plt.162.1529347278797; Mon, 18 Jun 2018 11:41:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:40 -1000 Message-Id: <20180618184046.6270-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::234 Subject: [Qemu-devel] [PATCH v2 16/22] target/openrisc: Log interrupts 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: shorne@gmail.com 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/openrisc/interrupt.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index e28042856a..138ad17f00 100644 --- a/target/openrisc/interrupt.c +++ b/target/openrisc/interrupt.c @@ -32,6 +32,7 @@ void openrisc_cpu_do_interrupt(CPUState *cs) #ifndef CONFIG_USER_ONLY OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); CPUOpenRISCState *env =3D &cpu->env; + int exception =3D cs->exception_index; =20 env->epcr =3D env->pc; if (env->dflag) { @@ -41,12 +42,12 @@ void openrisc_cpu_do_interrupt(CPUState *cs) } else { env->sr &=3D ~SR_DSX; } - if (cs->exception_index =3D=3D EXCP_SYSCALL) { + if (exception =3D=3D EXCP_SYSCALL) { env->epcr +=3D 4; } /* When we have an illegal instruction the error effective address shall be set to the illegal instruction address. */ - if (cs->exception_index =3D=3D EXCP_ILLEGAL) { + if (exception =3D=3D EXCP_ILLEGAL) { env->eear =3D env->pc; } =20 @@ -60,8 +61,27 @@ void openrisc_cpu_do_interrupt(CPUState *cs) env->pmr &=3D ~PMR_SME; env->lock_addr =3D -1; =20 - if (cs->exception_index > 0 && cs->exception_index < EXCP_NR) { - hwaddr vect_pc =3D cs->exception_index << 8; + if (exception > 0 && exception < EXCP_NR) { + static const char * const int_name[EXCP_NR] =3D { + [EXCP_RESET] =3D "RESET", + [EXCP_BUSERR] =3D "BUSERR (bus error)", + [EXCP_DPF] =3D "DFP (data protection fault)", + [EXCP_IPF] =3D "IPF (code protection fault)", + [EXCP_TICK] =3D "TICK (timer interrupt)", + [EXCP_ALIGN] =3D "ALIGN", + [EXCP_ILLEGAL] =3D "ILLEGAL", + [EXCP_INT] =3D "INT (device interrupt)", + [EXCP_DTLBMISS] =3D "DTLBMISS (data tlb miss)", + [EXCP_ITLBMISS] =3D "ITLBMISS (code tlb miss)", + [EXCP_RANGE] =3D "RANGE", + [EXCP_SYSCALL] =3D "SYSCALL", + [EXCP_FPE] =3D "FPE", + [EXCP_TRAP] =3D "TRAP", + }; + + qemu_log_mask(CPU_LOG_INT, "INT: %s\n", int_name[exception]); + + hwaddr vect_pc =3D exception << 8; if (env->cpucfgr & CPUCFGR_EVBARP) { vect_pc |=3D env->evbar; } @@ -70,7 +90,7 @@ void openrisc_cpu_do_interrupt(CPUState *cs) } env->pc =3D vect_pc; } else { - cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index); + cpu_abort(cs, "Unhandled exception 0x%x\n", exception); } #endif =20 --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529347968520359.6151838745251; Mon, 18 Jun 2018 11:52:48 -0700 (PDT) Received: from localhost ([::1]:36521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzGh-00049z-PT for importer@patchew.org; Mon, 18 Jun 2018 14:52:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57453) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5f-0003ZG-Bx for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5d-0004yO-VI for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:23 -0400 Received: from mail-pf0-x231.google.com ([2607:f8b0:400e:c00::231]:34540) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5d-0004xK-Pj for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:21 -0400 Received: by mail-pf0-x231.google.com with SMTP id a63-v6so8613279pfl.1 for ; Mon, 18 Jun 2018 11:41:21 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V/jeWmFGQVVeKWPcvaBSAlQuL/FGCb4V1yNp9F8huX4=; b=jf5r+Wejt3mGA9xulBqhI0KH04CstPoTbBHq72G2R/EjBTx2Keg7JBfjQV/1pBcPVa fq3Ce9jLVb81bY2/nRyIpBjJTCvOw1XioqmeRlAvm7SKIQevh59XudMJIGFbvjyfN5/O J2yfGuV4byHOZ2hQixMMFrHcFQ0tqzA9L6LI8= 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=V/jeWmFGQVVeKWPcvaBSAlQuL/FGCb4V1yNp9F8huX4=; b=etpoHGEgGorwLue1PxPF4ByJ8WtppHCLvvqasZdvJbXcrv21h4tYNvsJD4Tiz/F2Zj RDiX1TxF6v9Rj/QzQea6yqJqb7WIArTxtRX8p6fj4aNO1xr07M2NuNFbHfY216yQWC2Y 0GCtmk2JDVcVgKYFSeWqOUB526dZlfbvUm00LxvH88601aflFs4HIubDaSNgOFl7EmAj sw2AXBbxqf0WKyuKLi7O2J+lZI+ma9w/TAcUGBmeJhVDkjvDKXtdMIwS027+rTx5XeqJ Ah3/TiZFMovCft3JlGoTL4y/pGNdvgV3WsOwcmvFUzru6qa5mnnBNGMbqOZebz8bb0DT DIAQ== X-Gm-Message-State: APt69E2hEu079c9wIF1S4I44gHjLnyDrTQMmJnUN3Nxt5JrVnAUHc8pc Ai77d3/vse8kXIDVtr7wFRJRPptqHQQ= X-Google-Smtp-Source: ADUXVKImShD46e0rLRyakzkYqlX2npO1cTgn3ajP+PG+F+a+g3HjuZ1Df0OYthlIQ+8AsTspr4+uxw== X-Received: by 2002:a65:660a:: with SMTP id w10-v6mr11765294pgv.366.1529347280560; Mon, 18 Jun 2018 11:41:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:41 -1000 Message-Id: <20180618184046.6270-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::231 Subject: [Qemu-devel] [PATCH v2 17/22] target/openrisc: Increase the TLB size 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: shorne@gmail.com 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" The architecture supports 128 TLB entries. There is no reason not to provide all of them. In the process we need to fix a bug that failed to parameterize the configuration register that tells the operating system the number of entries. Signed-off-by: Richard Henderson --- v2: - Change VMState version. --- target/openrisc/cpu.h | 2 +- target/openrisc/cpu.c | 6 ++++-- target/openrisc/machine.c | 5 ++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 53abe965e8..8035654087 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -222,7 +222,7 @@ enum { =20 /* TLB size */ enum { - TLB_SIZE =3D 64, + TLB_SIZE =3D 128, TLB_MASK =3D TLB_SIZE - 1, }; =20 diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index 4c166c6329..677f02efa4 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -52,8 +52,10 @@ static void openrisc_cpu_reset(CPUState *s) =20 cpu->env.upr =3D UPR_UP | UPR_DMP | UPR_IMP | UPR_PICP | UPR_TTP | UPR_PMP; - cpu->env.dmmucfgr =3D (DMMUCFGR_NTW & (0 << 2)) | (DMMUCFGR_NTS & (6 <= < 2)); - cpu->env.immucfgr =3D (IMMUCFGR_NTW & (0 << 2)) | (IMMUCFGR_NTS & (6 <= < 2)); + cpu->env.dmmucfgr =3D (DMMUCFGR_NTW & (0 << 2)) + | (DMMUCFGR_NTS & (ctz32(TLB_SIZE) << 2)); + cpu->env.immucfgr =3D (IMMUCFGR_NTW & (0 << 2)) + | (IMMUCFGR_NTS & (ctz32(TLB_SIZE) << 2)); =20 #ifndef CONFIG_USER_ONLY cpu->env.picmr =3D 0x00000000; diff --git a/target/openrisc/machine.c b/target/openrisc/machine.c index 3fc837b925..1eedbf3dbe 100644 --- a/target/openrisc/machine.c +++ b/target/openrisc/machine.c @@ -38,9 +38,8 @@ static const VMStateDescription vmstate_tlb_entry =3D { =20 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, + .version_id =3D 2, + .minimum_version_id =3D 2, .fields =3D (VMStateField[]) { VMSTATE_STRUCT_ARRAY(itlb, CPUOpenRISCTLBContext, TLB_SIZE, 0, vmstate_tlb_entry, OpenRISCTLBEntry), --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529347784839108.8246519601646; Mon, 18 Jun 2018 11:49:44 -0700 (PDT) Received: from localhost ([::1]:36500 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzDX-0001Kh-E2 for importer@patchew.org; Mon, 18 Jun 2018 14:49:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5h-0003ba-G6 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5f-00050O-UD for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:25 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:39683) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5f-0004zN-L8 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:23 -0400 Received: by mail-pf0-x244.google.com with SMTP id r11-v6so8605587pfl.6 for ; Mon, 18 Jun 2018 11:41:23 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aa/SHG/LxURCrjFybFC++2LSNmmhU6rlmBikxJvyPmI=; b=cHJOV70vdK/XEuWa7snnFuTGEfwlgQ5AEJtxIzVxXCIk3gGvRAwj9dgQCggovAEAnU UX9DQ6p+TfvosjYQ0vROdicl3jhq5wpS4Iwbn9BC4JLXI+AhHbbbZMAFgA5FOXdFoSDq 3+Oex2n/0sEZh9cfP+uuVW33Ikflpmrtk72yY= 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=aa/SHG/LxURCrjFybFC++2LSNmmhU6rlmBikxJvyPmI=; b=nKTjvK0UIK3YGtgrD9ZcRkrloLNwuSqX2pCcS1wxny3WAJiBj1GwOOgvlutLAWYD0x +DAwDUChDAz/fmastP89MSavi1XXvpej+f2NA4Pk5HCy93JCv5fgdliGPuX8byz7dLFU eyOQcZnRwxtJSi9e08oxTLASi9sLRwIUp2vq0NDsZhjzlCkrpWGayqAaOQLz9l6S+hnt KQ89MjVSHMeNMpDvY6uO25ANOBC0wkKMKadXohrT1DVgvN4bQS9eG+/CuZodcpGYpJbX lCyGdZ8dEiAEJPhdXzMlRO6P8QsExJick7pgfGSSfDtZnZkRz1cNCBUsaLw2n2RlFV3F YHcg== X-Gm-Message-State: APt69E0qdDs531hwSbk1alAE88YNRt8nktFFILUsFv8M6UBfFr8fUH/G 3G9tSU8E7d6oyc+82w9L5EqksTbs3ss= X-Google-Smtp-Source: ADUXVKKyKz6hUTXkLpETvDl0HyWAD7aD/6Ge31NcXLnHiZCEBZccVLMMc+s7cDwViAevMvaqQwBz2A== X-Received: by 2002:a62:904c:: with SMTP id a73-v6mr14695788pfe.145.1529347282434; Mon, 18 Jun 2018 11:41:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:42 -1000 Message-Id: <20180618184046.6270-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> 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 v2 18/22] target/openrisc: Reorg tlb lookup 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: shorne@gmail.com 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" While openrisc has a split i/d tlb, qemu does not. Perform a lookup on both i & d tlbs in parallel and put the composite rights into qemu's tlb. This avoids ping-ponging the qemu tlb between EXEC and READ. Signed-off-by: Richard Henderson --- target/openrisc/cpu.h | 8 -- target/openrisc/mmu.c | 254 +++++++++++++++--------------------------- 2 files changed, 90 insertions(+), 172 deletions(-) diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 8035654087..1efffa5269 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -237,14 +237,6 @@ enum { UXE =3D (1 << 7), }; =20 -/* check if tlb available */ -enum { - TLBRET_INVALID =3D -3, - TLBRET_NOMATCH =3D -2, - TLBRET_BADADDR =3D -1, - TLBRET_MATCH =3D 0 -}; - typedef struct OpenRISCTLBEntry { uint32_t mr; uint32_t tr; diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c index f4c0a3e217..d3796ae41e 100644 --- a/target/openrisc/mmu.c +++ b/target/openrisc/mmu.c @@ -29,148 +29,78 @@ #endif =20 #ifndef CONFIG_USER_ONLY -static inline int get_phys_nommu(hwaddr *physical, int *prot, - target_ulong address) +static inline void get_phys_nommu(hwaddr *phys_addr, int *prot, + target_ulong address) { - *physical =3D address; + *phys_addr =3D address; *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; - return TLBRET_MATCH; } =20 -static int get_phys_code(OpenRISCCPU *cpu, hwaddr *physical, int *prot, - target_ulong address, int rw, bool supervisor) +static int get_phys_mmu(OpenRISCCPU *cpu, hwaddr *phys_addr, int *prot, + target_ulong addr, int need, bool super) { - int vpn =3D address >> TARGET_PAGE_BITS; - int idx =3D vpn & TLB_MASK; - int right =3D 0; - uint32_t mr =3D cpu->env.tlb.itlb[idx].mr; - uint32_t tr =3D cpu->env.tlb.itlb[idx].tr; + int idx =3D (addr >> TARGET_PAGE_BITS) & TLB_MASK; + uint32_t imr =3D cpu->env.tlb.itlb[idx].mr; + uint32_t itr =3D cpu->env.tlb.itlb[idx].tr; + uint32_t dmr =3D cpu->env.tlb.dtlb[idx].mr; + uint32_t dtr =3D cpu->env.tlb.dtlb[idx].tr; + int right, match, valid; =20 - if ((mr >> TARGET_PAGE_BITS) !=3D vpn) { - return TLBRET_NOMATCH; - } - if (!(mr & 1)) { - return TLBRET_INVALID; - } - if (supervisor) { - if (tr & SXE) { - right |=3D PAGE_EXEC; - } - } else { - if (tr & UXE) { - right |=3D PAGE_EXEC; + /* If the ITLB and DTLB indexes map to the same page, we want to + load all permissions all at once. If the destination pages do + not match, zap the one we don't need. */ + if (unlikely((itr ^ dtr) & TARGET_PAGE_MASK)) { + if (need & PAGE_EXEC) { + dmr =3D dtr =3D 0; + } else { + imr =3D itr =3D 0; } } - if ((rw & 2) && ((right & PAGE_EXEC) =3D=3D 0)) { - return TLBRET_BADADDR; - } =20 - *physical =3D (tr & TARGET_PAGE_MASK) | (address & ~TARGET_PAGE_MASK); + /* Check if either of the entries matches the source address. */ + match =3D (imr ^ addr) & TARGET_PAGE_MASK ? 0 : PAGE_EXEC; + match |=3D (dmr ^ addr) & TARGET_PAGE_MASK ? 0 : PAGE_READ | PAGE_WRIT= E; + + /* Check if either of the entries is valid. */ + valid =3D imr & 1 ? PAGE_EXEC : 0; + valid |=3D dmr & 1 ? PAGE_READ | PAGE_WRITE : 0; + valid &=3D match; + + /* Collect the permissions from the entries. */ + right =3D itr & (super ? SXE : UXE) ? PAGE_EXEC : 0; + right |=3D dtr & (super ? SRE : URE) ? PAGE_READ : 0; + right |=3D dtr & (super ? SWE : UWE) ? PAGE_WRITE : 0; + right &=3D valid; + + /* Note that above we validated that itr and dtr match on page. + So oring them together changes nothing without having to + check which one we needed. We also want to store to these + variables even on failure, as it avoids compiler warnings. */ + *phys_addr =3D ((itr | dtr) & TARGET_PAGE_MASK) | (addr & ~TARGET_PAGE= _MASK); *prot =3D right; - return TLBRET_MATCH; -} =20 -static int get_phys_data(OpenRISCCPU *cpu, hwaddr *physical, int *prot, - target_ulong address, int rw, bool supervisor) -{ - int vpn =3D address >> TARGET_PAGE_BITS; - int idx =3D vpn & TLB_MASK; - int right =3D 0; - uint32_t mr =3D cpu->env.tlb.dtlb[idx].mr; - uint32_t tr =3D cpu->env.tlb.dtlb[idx].tr; + qemu_log_mask(CPU_LOG_MMU, + "MMU lookup: need %d match %d valid %d right %d -> %s\n", + need, match, valid, right, (need & right) ? "OK" : "FAIL= "); =20 - if ((mr >> TARGET_PAGE_BITS) !=3D vpn) { - return TLBRET_NOMATCH; + /* Check the collective permissions are present. */ + if (likely(need & right)) { + return 0; /* success! */ } - if (!(mr & 1)) { - return TLBRET_INVALID; - } - if (supervisor) { - if (tr & SRE) { - right |=3D PAGE_READ; - } - if (tr & SWE) { - right |=3D PAGE_WRITE; - } + + /* Determine what kind of failure we have. */ + if (need & valid) { + return need & PAGE_EXEC ? EXCP_IPF : EXCP_DPF; } else { - if (tr & URE) { - right |=3D PAGE_READ; - } - if (tr & UWE) { - right |=3D PAGE_WRITE; - } + return need & PAGE_EXEC ? EXCP_ITLBMISS : EXCP_DTLBMISS; } - - if (!(rw & 1) && ((right & PAGE_READ) =3D=3D 0)) { - return TLBRET_BADADDR; - } - if ((rw & 1) && ((right & PAGE_WRITE) =3D=3D 0)) { - return TLBRET_BADADDR; - } - - *physical =3D (tr & TARGET_PAGE_MASK) | (address & ~TARGET_PAGE_MASK); - *prot =3D right; - return TLBRET_MATCH; -} - -static int get_phys_addr(OpenRISCCPU *cpu, hwaddr *physical, - int *prot, target_ulong address, int rw) -{ - bool supervisor =3D (cpu->env.sr & SR_SM) !=3D 0; - int ret; - - /* Assume nommu results for a moment. */ - ret =3D get_phys_nommu(physical, prot, address); - - /* Overwrite with TLB lookup if enabled. */ - if (rw =3D=3D MMU_INST_FETCH) { - if (cpu->env.sr & SR_IME) { - ret =3D get_phys_code(cpu, physical, prot, address, rw, superv= isor); - } - } else { - if (cpu->env.sr & SR_DME) { - ret =3D get_phys_data(cpu, physical, prot, address, rw, superv= isor); - } - } - - return ret; } #endif =20 -static void cpu_openrisc_raise_mmu_exception(OpenRISCCPU *cpu, - target_ulong address, - int rw, int tlb_error) +static void raise_mmu_exception(OpenRISCCPU *cpu, target_ulong address, + int exception) { CPUState *cs =3D CPU(cpu); - int exception =3D 0; - - switch (tlb_error) { - default: - if (rw =3D=3D 2) { - exception =3D EXCP_IPF; - } else { - exception =3D EXCP_DPF; - } - break; -#ifndef CONFIG_USER_ONLY - case TLBRET_BADADDR: - if (rw =3D=3D 2) { - exception =3D EXCP_IPF; - } else { - exception =3D EXCP_DPF; - } - break; - case TLBRET_INVALID: - case TLBRET_NOMATCH: - /* No TLB match for a mapped address */ - if (rw =3D=3D 2) { - exception =3D EXCP_ITLBMISS; - } else { - exception =3D EXCP_DTLBMISS; - } - break; -#endif - } =20 cs->exception_index =3D exception; cpu->env.eear =3D address; @@ -182,7 +112,7 @@ int openrisc_cpu_handle_mmu_fault(CPUState *cs, vaddr a= ddress, int size, { #ifdef CONFIG_USER_ONLY OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); - cpu_openrisc_raise_mmu_exception(cpu, address, rw, 0); + raise_mmu_exception(cpu, address, EXCP_DPF); return 1; #else g_assert_not_reached(); @@ -193,27 +123,32 @@ int openrisc_cpu_handle_mmu_fault(CPUState *cs, vaddr= address, int size, hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) { OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); + int prot, excp, sr =3D cpu->env.sr; hwaddr phys_addr; - int prot; - int miss; =20 - /* Check memory for any kind of address, since during debug the - gdb can ask for anything, check data tlb for address */ - miss =3D get_phys_addr(cpu, &phys_addr, &prot, addr, 0); + switch (sr & (SR_DME | SR_IME)) { + case SR_DME | SR_IME: + /* The mmu is definitely enabled. */ + excp =3D get_phys_mmu(cpu, &phys_addr, &prot, addr, + PROT_EXEC | PROT_READ | PROT_WRITE, + (sr & SR_SM) !=3D 0); + return excp ? -1 : phys_addr; =20 - /* Check instruction tlb */ - if (miss) { - miss =3D get_phys_addr(cpu, &phys_addr, &prot, addr, MMU_INST_FETC= H); - } + default: + /* The mmu is partially enabled, and we don't really have + a "real" access type. Begin by trying the mmu, but if + that fails try again without. */ + excp =3D get_phys_mmu(cpu, &phys_addr, &prot, addr, + PROT_EXEC | PROT_READ | PROT_WRITE, + (sr & SR_SM) !=3D 0); + if (!excp) { + return phys_addr; + } + /* fallthru */ =20 - /* Last, fall back to a plain address */ - if (miss) { - miss =3D get_phys_nommu(&phys_addr, &prot, addr); - } - - if (miss) { - return -1; - } else { + case 0: + /* The mmu is definitely disabled; lookups never fail. */ + get_phys_nommu(&phys_addr, &prot, addr); return phys_addr; } } @@ -222,37 +157,28 @@ void tlb_fill(CPUState *cs, target_ulong addr, int si= ze, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); - int ret, prot =3D 0; - hwaddr physical =3D 0; + int prot, excp; + hwaddr phys_addr; =20 if (mmu_idx =3D=3D MMU_NOMMU_IDX) { - ret =3D get_phys_nommu(&physical, &prot, addr); + /* The mmu is disabled; lookups never fail. */ + get_phys_nommu(&phys_addr, &prot, addr); + excp =3D 0; } else { bool super =3D mmu_idx =3D=3D MMU_SUPERVISOR_IDX; - if (access_type =3D=3D MMU_INST_FETCH) { - ret =3D get_phys_code(cpu, &physical, &prot, addr, 2, super); - } else { - ret =3D get_phys_data(cpu, &physical, &prot, addr, - access_type =3D=3D MMU_DATA_STORE, super); - } + int need =3D (access_type =3D=3D MMU_INST_FETCH ? PROT_EXEC + : access_type =3D=3D MMU_DATA_STORE ? PROT_WRITE + : PROT_READ); + excp =3D get_phys_mmu(cpu, &phys_addr, &prot, addr, need, super); } =20 - if (ret =3D=3D TLBRET_MATCH) { - tlb_set_page(cs, addr & TARGET_PAGE_MASK, - physical & TARGET_PAGE_MASK, prot, - mmu_idx, TARGET_PAGE_SIZE); - } else if (ret < 0) { - int rw; - if (access_type =3D=3D MMU_INST_FETCH) { - rw =3D 2; - } else if (access_type =3D=3D MMU_DATA_STORE) { - rw =3D 1; - } else { - rw =3D 0; - } - cpu_openrisc_raise_mmu_exception(cpu, addr, rw, ret); - /* Raise Exception. */ + if (unlikely(excp)) { + raise_mmu_exception(cpu, addr, excp); cpu_loop_exit_restore(cs, retaddr); } + + tlb_set_page(cs, addr & TARGET_PAGE_MASK, + phys_addr & TARGET_PAGE_MASK, prot, + mmu_idx, TARGET_PAGE_SIZE); } #endif --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529348264818300.2771877081701; Mon, 18 Jun 2018 11:57:44 -0700 (PDT) Received: from localhost ([::1]:36550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzLU-0008Br-15 for importer@patchew.org; Mon, 18 Jun 2018 14:57:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5n-0003i1-46 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5i-00053n-Hn for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:31 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:37977) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5i-00052Z-6q for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:26 -0400 Received: by mail-pg0-x242.google.com with SMTP id c9-v6so7927721pgf.5 for ; Mon, 18 Jun 2018 11:41:26 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=J3QJdJXu3oppYhtD6iNUwKJpeotcEanwJq8pBURkYxk=; b=PLeCpg3rnkb9qffmZefIa4R4rM+Bq3T4JCl6BkHy3kcXWSAgYOlmMXZzkt0BMrgEPC +sxsGkoCQ1z4OTTn/Z27Zo9OJiH8r6UXnQEcVyPUDBn0fmD+LStiJvTqtSAjvgfm4m2+ tWH2kFTSteWwgC26wj+K3hyX7n2B8emQZRvgc= 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=J3QJdJXu3oppYhtD6iNUwKJpeotcEanwJq8pBURkYxk=; b=naJGZW3BNFGzn/MnfMJFP4OSzj8JwLDmCRD2TtFWtB1ci9DHZh+EpUI90Tn4zshlDe WbjIjT13cbj8xEAVyMQAwZA2sjNknUqP/ZeaNAPvRXlKF6MbZ3oqkLDE5P+3jyAwLXUP nXrJdumxtG62yrObNMI640mlYt/EKsyI6xSbytcOGT5pNgVmK12NQyB5GPTI+aDX05BU EotdiLUEZ1/R//1V/pC5YY5BOkYksSqQy+9PIC9aEPn28Arkyk191MTcNWjvIvGjkWbq fnVf6wJD7oPqhhjJJMcmVU2+EmqADl76RjTMjKd6RT+s5IyWxu3/17LSBAJaciOnU05p veGg== X-Gm-Message-State: APt69E0GbWNrl8vA+/9AKYsaCSh4MOXB6v0qWzEqVKJO4MxAgd2jpUfX MYHAYW+nHti8rZN6QCanWnOO1+b6uqI= X-Google-Smtp-Source: ADUXVKL2sJRyTe/Lid3BWiw1TGqvsEXllw6chJcbtj0IlE1h43xsPmMBGfLLm7QKcnQrV455v25KRg== X-Received: by 2002:a62:de03:: with SMTP id h3-v6mr14785895pfg.46.1529347284432; Mon, 18 Jun 2018 11:41:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:43 -1000 Message-Id: <20180618184046.6270-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v2 19/22] target/openrisc: Add print_insn_or1k 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: shorne@gmail.com 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" Rather than emit disassembly while translating, reuse the generated decoder to build a separate disassembler. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/openrisc/cpu.h | 1 + target/openrisc/cpu.c | 6 ++ target/openrisc/disas.c | 170 ++++++++++++++++++++++++++++++++++ target/openrisc/translate.c | 114 ----------------------- target/openrisc/Makefile.objs | 3 +- 5 files changed, 179 insertions(+), 115 deletions(-) create mode 100644 target/openrisc/disas.c diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 1efffa5269..f1b31bc24a 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -348,6 +348,7 @@ void openrisc_translate_init(void); int openrisc_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int rw, int mmu_idx); int cpu_openrisc_signal_handler(int host_signum, void *pinfo, void *puc); +int print_insn_or1k(bfd_vma addr, disassemble_info *info); =20 #define cpu_list cpu_openrisc_list #define cpu_signal_handler cpu_openrisc_signal_handler diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index 677f02efa4..e01ce9ed1c 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -35,6 +35,11 @@ static bool openrisc_cpu_has_work(CPUState *cs) CPU_INTERRUPT_TIMER); } =20 +static void openrisc_disas_set_info(CPUState *cpu, disassemble_info *info) +{ + info->print_insn =3D print_insn_or1k; +} + /* CPUClass::reset() */ static void openrisc_cpu_reset(CPUState *s) { @@ -150,6 +155,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, vo= id *data) #endif cc->gdb_num_core_regs =3D 32 + 3; cc->tcg_initialize =3D openrisc_translate_init; + cc->disas_set_info =3D openrisc_disas_set_info; } =20 /* Sort alphabetically by type name, except for "any". */ diff --git a/target/openrisc/disas.c b/target/openrisc/disas.c new file mode 100644 index 0000000000..5acf4f4744 --- /dev/null +++ b/target/openrisc/disas.c @@ -0,0 +1,170 @@ +/* + * OpenRISC disassembler + * + * Copyright (c) 2018 Richard Henderson + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "disas/bfd.h" +#include "qemu/bitops.h" +#include "cpu.h" + +typedef disassemble_info DisasContext; + +/* Include the auto-generated decoder. */ +#include "decode.inc.c" + +#define output(mnemonic, format, ...) \ + info->fprintf_func(info->stream, "%-9s " format, \ + mnemonic, ##__VA_ARGS__) + +int print_insn_or1k(bfd_vma addr, disassemble_info *info) +{ + bfd_byte buffer[4]; + uint32_t insn; + int status; + + status =3D info->read_memory_func(addr, buffer, 4, info); + if (status !=3D 0) { + info->memory_error_func(status, addr, info); + return -1; + } + insn =3D bfd_getb32(buffer); + + if (!decode(info, insn)) { + output(".long", "%#08x", insn); + } + return 4; +} + +#define INSN(opcode, format, ...) \ +static bool trans_l_##opcode(disassemble_info *info, \ + arg_l_##opcode *a, uint32_t insn) \ +{ \ + output("l." #opcode, format, ##__VA_ARGS__); \ + return true; \ +} + +INSN(add, "r%d, r%d, r%d", a->d, a->a, a->b) +INSN(addc, "r%d, r%d, r%d", a->d, a->a, a->b) +INSN(sub, "r%d, r%d, r%d", a->d, a->a, a->b) +INSN(and, "r%d, r%d, r%d", a->d, a->a, a->b) +INSN(or, "r%d, r%d, r%d", a->d, a->a, a->b) +INSN(xor, "r%d, r%d, r%d", a->d, a->a, a->b) +INSN(sll, "r%d, r%d, r%d", a->d, a->a, a->b) +INSN(srl, "r%d, r%d, r%d", a->d, a->a, a->b) +INSN(sra, "r%d, r%d, r%d", a->d, a->a, a->b) +INSN(ror, "r%d, r%d, r%d", a->d, a->a, a->b) +INSN(exths, "r%d, r%d", a->d, a->a) +INSN(extbs, "r%d, r%d", a->d, a->a) +INSN(exthz, "r%d, r%d", a->d, a->a) +INSN(extbz, "r%d, r%d", a->d, a->a) +INSN(cmov, "r%d, r%d, r%d", a->d, a->a, a->b) +INSN(ff1, "r%d, r%d", a->d, a->a) +INSN(fl1, "r%d, r%d", a->d, a->a) +INSN(mul, "r%d, r%d, r%d", a->d, a->a, a->b) +INSN(mulu, "r%d, r%d, r%d", a->d, a->a, a->b) +INSN(div, "r%d, r%d, r%d", a->d, a->a, a->b) +INSN(divu, "r%d, r%d, r%d", a->d, a->a, a->b) +INSN(muld, "r%d, r%d", a->a, a->b) +INSN(muldu, "r%d, r%d", a->a, a->b) +INSN(j, "%d", a->n) +INSN(jal, "%d", a->n) +INSN(bf, "%d", a->n) +INSN(bnf, "%d", a->n) +INSN(jr, "r%d", a->b) +INSN(jalr, "r%d", a->b) +INSN(lwa, "r%d, %d(r%d)", a->d, a->i, a->a) +INSN(lwz, "r%d, %d(r%d)", a->d, a->i, a->a) +INSN(lws, "r%d, %d(r%d)", a->d, a->i, a->a) +INSN(lbz, "r%d, %d(r%d)", a->d, a->i, a->a) +INSN(lbs, "r%d, %d(r%d)", a->d, a->i, a->a) +INSN(lhz, "r%d, %d(r%d)", a->d, a->i, a->a) +INSN(lhs, "r%d, %d(r%d)", a->d, a->i, a->a) +INSN(swa, "%d(r%d), r%d", a->i, a->a, a->b) +INSN(sw, "%d(r%d), r%d", a->i, a->a, a->b) +INSN(sb, "%d(r%d), r%d", a->i, a->a, a->b) +INSN(sh, "%d(r%d), r%d", a->i, a->a, a->b) +INSN(nop, "") +INSN(addi, "r%d, r%d, %d", a->d, a->a, a->i) +INSN(addic, "r%d, r%d, %d", a->d, a->a, a->i) +INSN(muli, "r%d, r%d, %d", a->d, a->a, a->i) +INSN(maci, "r%d, %d", a->a, a->i) +INSN(andi, "r%d, r%d, %d", a->d, a->a, a->k) +INSN(ori, "r%d, r%d, %d", a->d, a->a, a->k) +INSN(xori, "r%d, r%d, %d", a->d, a->a, a->i) +INSN(mfspr, "r%d, r%d, %d", a->d, a->a, a->k) +INSN(mtspr, "r%d, r%d, %d", a->a, a->b, a->k) +INSN(mac, "r%d, r%d", a->a, a->b) +INSN(msb, "r%d, r%d", a->a, a->b) +INSN(macu, "r%d, r%d", a->a, a->b) +INSN(msbu, "r%d, r%d", a->a, a->b) +INSN(slli, "r%d, r%d, %d", a->d, a->a, a->l) +INSN(srli, "r%d, r%d, %d", a->d, a->a, a->l) +INSN(srai, "r%d, r%d, %d", a->d, a->a, a->l) +INSN(rori, "r%d, r%d, %d", a->d, a->a, a->l) +INSN(movhi, "r%d, %d", a->d, a->k) +INSN(macrc, "r%d", a->d) +INSN(sfeq, "r%d, r%d", a->a, a->b) +INSN(sfne, "r%d, r%d", a->a, a->b) +INSN(sfgtu, "r%d, r%d", a->a, a->b) +INSN(sfgeu, "r%d, r%d", a->a, a->b) +INSN(sfltu, "r%d, r%d", a->a, a->b) +INSN(sfleu, "r%d, r%d", a->a, a->b) +INSN(sfgts, "r%d, r%d", a->a, a->b) +INSN(sfges, "r%d, r%d", a->a, a->b) +INSN(sflts, "r%d, r%d", a->a, a->b) +INSN(sfles, "r%d, r%d", a->a, a->b) +INSN(sfeqi, "r%d, %d", a->a, a->i) +INSN(sfnei, "r%d, %d", a->a, a->i) +INSN(sfgtui, "r%d, %d", a->a, a->i) +INSN(sfgeui, "r%d, %d", a->a, a->i) +INSN(sfltui, "r%d, %d", a->a, a->i) +INSN(sfleui, "r%d, %d", a->a, a->i) +INSN(sfgtsi, "r%d, %d", a->a, a->i) +INSN(sfgesi, "r%d, %d", a->a, a->i) +INSN(sfltsi, "r%d, %d", a->a, a->i) +INSN(sflesi, "r%d, %d", a->a, a->i) +INSN(sys, "%d", a->k) +INSN(trap, "%d", a->k) +INSN(msync, "") +INSN(psync, "") +INSN(csync, "") +INSN(rfe, "") + +#define FP_INSN(opcode, suffix, format, ...) \ +static bool trans_lf_##opcode##_##suffix(disassemble_info *info, \ + arg_lf_##opcode##_##suffix *a, uint32_t insn) \ +{ \ + output("lf." #opcode "." #suffix, format, ##__VA_ARGS__); \ + return true; \ +} + +FP_INSN(add, s, "r%d, r%d, r%d", a->d, a->a, a->b) +FP_INSN(sub, s, "r%d, r%d, r%d", a->d, a->a, a->b) +FP_INSN(mul, s, "r%d, r%d, r%d", a->d, a->a, a->b) +FP_INSN(div, s, "r%d, r%d, r%d", a->d, a->a, a->b) +FP_INSN(rem, s, "r%d, r%d, r%d", a->d, a->a, a->b) +FP_INSN(itof, s, "r%d, r%d", a->d, a->a) +FP_INSN(ftoi, s, "r%d, r%d", a->d, a->a) +FP_INSN(madd, s, "r%d, r%d, r%d", a->d, a->a, a->b) +FP_INSN(sfeq, s, "r%d, r%d", a->a, a->b) +FP_INSN(sfne, s, "r%d, r%d", a->a, a->b) +FP_INSN(sfgt, s, "r%d, r%d", a->a, a->b) +FP_INSN(sfge, s, "r%d, r%d", a->a, a->b) +FP_INSN(sflt, s, "r%d, r%d", a->a, a->b) +FP_INSN(sfle, s, "r%d, r%d", a->a, a->b) diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 60c6e19f4b..d0662f38c6 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -36,10 +36,6 @@ #include "trace-tcg.h" #include "exec/log.h" =20 -#define LOG_DIS(str, ...) \ - qemu_log_mask(CPU_LOG_TB_IN_ASM, "%08x: " str, dc->base.pc_next, \ - ## __VA_ARGS__) - /* is_jmp field values */ #define DISAS_EXIT DISAS_TARGET_0 /* force exit to main loop */ #define DISAS_JUMP DISAS_TARGET_1 /* exit via jmp_pc/jmp_pc_imm */ @@ -440,7 +436,6 @@ static void gen_msbu(DisasContext *dc, TCGv srca, TCGv = srcb) =20 static bool trans_l_add(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("l.add r%d, r%d, r%d\n", a->d, a->a, a->b); check_r0_write(a->d); gen_add(dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); return true; @@ -448,7 +443,6 @@ static bool trans_l_add(DisasContext *dc, arg_dab *a, u= int32_t insn) =20 static bool trans_l_addc(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("l.addc r%d, r%d, r%d\n", a->d, a->a, a->b); check_r0_write(a->d); gen_addc(dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); return true; @@ -456,7 +450,6 @@ static bool trans_l_addc(DisasContext *dc, arg_dab *a, = uint32_t insn) =20 static bool trans_l_sub(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("l.sub r%d, r%d, r%d\n", a->d, a->a, a->b); check_r0_write(a->d); gen_sub(dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); return true; @@ -464,7 +457,6 @@ static bool trans_l_sub(DisasContext *dc, arg_dab *a, u= int32_t insn) =20 static bool trans_l_and(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("l.and r%d, r%d, r%d\n", a->d, a->a, a->b); check_r0_write(a->d); tcg_gen_and_tl(cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); return true; @@ -472,7 +464,6 @@ static bool trans_l_and(DisasContext *dc, arg_dab *a, u= int32_t insn) =20 static bool trans_l_or(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("l.or r%d, r%d, r%d\n", a->d, a->a, a->b); check_r0_write(a->d); tcg_gen_or_tl(cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); return true; @@ -480,7 +471,6 @@ static bool trans_l_or(DisasContext *dc, arg_dab *a, ui= nt32_t insn) =20 static bool trans_l_xor(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("l.xor r%d, r%d, r%d\n", a->d, a->a, a->b); check_r0_write(a->d); tcg_gen_xor_tl(cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); return true; @@ -488,7 +478,6 @@ static bool trans_l_xor(DisasContext *dc, arg_dab *a, u= int32_t insn) =20 static bool trans_l_sll(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("l.sll r%d, r%d, r%d\n", a->d, a->a, a->b); check_r0_write(a->d); tcg_gen_shl_tl(cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); return true; @@ -496,7 +485,6 @@ static bool trans_l_sll(DisasContext *dc, arg_dab *a, u= int32_t insn) =20 static bool trans_l_srl(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("l.srl r%d, r%d, r%d\n", a->d, a->a, a->b); check_r0_write(a->d); tcg_gen_shr_tl(cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); return true; @@ -504,7 +492,6 @@ static bool trans_l_srl(DisasContext *dc, arg_dab *a, u= int32_t insn) =20 static bool trans_l_sra(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("l.sra r%d, r%d, r%d\n", a->d, a->a, a->b); check_r0_write(a->d); tcg_gen_sar_tl(cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); return true; @@ -512,7 +499,6 @@ static bool trans_l_sra(DisasContext *dc, arg_dab *a, u= int32_t insn) =20 static bool trans_l_ror(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("l.ror r%d, r%d, r%d\n", a->d, a->a, a->b); check_r0_write(a->d); tcg_gen_rotr_tl(cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); return true; @@ -520,7 +506,6 @@ static bool trans_l_ror(DisasContext *dc, arg_dab *a, u= int32_t insn) =20 static bool trans_l_exths(DisasContext *dc, arg_da *a, uint32_t insn) { - LOG_DIS("l.exths r%d, r%d\n", a->d, a->a); check_r0_write(a->d); tcg_gen_ext16s_tl(cpu_R[a->d], cpu_R[a->a]); return true; @@ -528,7 +513,6 @@ static bool trans_l_exths(DisasContext *dc, arg_da *a, = uint32_t insn) =20 static bool trans_l_extbs(DisasContext *dc, arg_da *a, uint32_t insn) { - LOG_DIS("l.extbs r%d, r%d\n", a->d, a->a); check_r0_write(a->d); tcg_gen_ext8s_tl(cpu_R[a->d], cpu_R[a->a]); return true; @@ -536,7 +520,6 @@ static bool trans_l_extbs(DisasContext *dc, arg_da *a, = uint32_t insn) =20 static bool trans_l_exthz(DisasContext *dc, arg_da *a, uint32_t insn) { - LOG_DIS("l.exthz r%d, r%d\n", a->d, a->a); check_r0_write(a->d); tcg_gen_ext16u_tl(cpu_R[a->d], cpu_R[a->a]); return true; @@ -544,7 +527,6 @@ static bool trans_l_exthz(DisasContext *dc, arg_da *a, = uint32_t insn) =20 static bool trans_l_extbz(DisasContext *dc, arg_da *a, uint32_t insn) { - LOG_DIS("l.extbz r%d, r%d\n", a->d, a->a); check_r0_write(a->d); tcg_gen_ext8u_tl(cpu_R[a->d], cpu_R[a->a]); return true; @@ -553,7 +535,6 @@ static bool trans_l_extbz(DisasContext *dc, arg_da *a, = uint32_t insn) static bool trans_l_cmov(DisasContext *dc, arg_dab *a, uint32_t insn) { TCGv zero; - LOG_DIS("l.cmov r%d, r%d, r%d\n", a->d, a->a, a->b); =20 check_r0_write(a->d); zero =3D tcg_const_tl(0); @@ -565,8 +546,6 @@ static bool trans_l_cmov(DisasContext *dc, arg_dab *a, = uint32_t insn) =20 static bool trans_l_ff1(DisasContext *dc, arg_da *a, uint32_t insn) { - LOG_DIS("l.ff1 r%d, r%d\n", a->d, a->a); - check_r0_write(a->d); tcg_gen_ctzi_tl(cpu_R[a->d], cpu_R[a->a], -1); tcg_gen_addi_tl(cpu_R[a->d], cpu_R[a->d], 1); @@ -575,8 +554,6 @@ static bool trans_l_ff1(DisasContext *dc, arg_da *a, ui= nt32_t insn) =20 static bool trans_l_fl1(DisasContext *dc, arg_da *a, uint32_t insn) { - LOG_DIS("l.fl1 r%d, r%d\n", a->d, a->a); - check_r0_write(a->d); tcg_gen_clzi_tl(cpu_R[a->d], cpu_R[a->a], TARGET_LONG_BITS); tcg_gen_subfi_tl(cpu_R[a->d], TARGET_LONG_BITS, cpu_R[a->d]); @@ -585,8 +562,6 @@ static bool trans_l_fl1(DisasContext *dc, arg_da *a, ui= nt32_t insn) =20 static bool trans_l_mul(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("l.mul r%d, r%d, r%d\n", a->d, a->a, a->b); - check_r0_write(a->d); gen_mul(dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); return true; @@ -594,8 +569,6 @@ static bool trans_l_mul(DisasContext *dc, arg_dab *a, u= int32_t insn) =20 static bool trans_l_mulu(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("l.mulu r%d, r%d, r%d\n", a->d, a->a, a->b); - check_r0_write(a->d); gen_mulu(dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); return true; @@ -603,8 +576,6 @@ static bool trans_l_mulu(DisasContext *dc, arg_dab *a, = uint32_t insn) =20 static bool trans_l_div(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("l.div r%d, r%d, r%d\n", a->d, a->a, a->b); - check_r0_write(a->d); gen_div(dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); return true; @@ -612,8 +583,6 @@ static bool trans_l_div(DisasContext *dc, arg_dab *a, u= int32_t insn) =20 static bool trans_l_divu(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("l.divu r%d, r%d, r%d\n", a->d, a->a, a->b); - check_r0_write(a->d); gen_divu(dc, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); return true; @@ -621,14 +590,12 @@ static bool trans_l_divu(DisasContext *dc, arg_dab *a= , uint32_t insn) =20 static bool trans_l_muld(DisasContext *dc, arg_ab *a, uint32_t insn) { - LOG_DIS("l.muld r%d, r%d\n", a->a, a->b); gen_muld(dc, cpu_R[a->a], cpu_R[a->b]); return true; } =20 static bool trans_l_muldu(DisasContext *dc, arg_ab *a, uint32_t insn) { - LOG_DIS("l.muldu r%d, r%d\n", a->a, a->b); gen_muldu(dc, cpu_R[a->a], cpu_R[a->b]); return true; } @@ -637,7 +604,6 @@ static bool trans_l_j(DisasContext *dc, arg_l_j *a, uin= t32_t insn) { target_ulong tmp_pc =3D dc->base.pc_next + a->n * 4; =20 - LOG_DIS("l.j %d\n", a->n); tcg_gen_movi_tl(jmp_pc, tmp_pc); dc->jmp_pc_imm =3D tmp_pc; dc->delayed_branch =3D 2; @@ -649,7 +615,6 @@ static bool trans_l_jal(DisasContext *dc, arg_l_jal *a,= uint32_t insn) target_ulong tmp_pc =3D dc->base.pc_next + a->n * 4; target_ulong ret_pc =3D dc->base.pc_next + 8; =20 - LOG_DIS("l.jal %d\n", a->n); tcg_gen_movi_tl(cpu_R[9], ret_pc); /* Optimize jal being used to load the PC for PIC. */ if (tmp_pc !=3D ret_pc) { @@ -677,21 +642,18 @@ static void do_bf(DisasContext *dc, arg_l_bf *a, TCGC= ond cond) =20 static bool trans_l_bf(DisasContext *dc, arg_l_bf *a, uint32_t insn) { - LOG_DIS("l.bf %d\n", a->n); do_bf(dc, a, TCG_COND_NE); return true; } =20 static bool trans_l_bnf(DisasContext *dc, arg_l_bf *a, uint32_t insn) { - LOG_DIS("l.bnf %d\n", a->n); do_bf(dc, a, TCG_COND_EQ); return true; } =20 static bool trans_l_jr(DisasContext *dc, arg_l_jr *a, uint32_t insn) { - LOG_DIS("l.jr r%d\n", a->b); tcg_gen_mov_tl(jmp_pc, cpu_R[a->b]); dc->delayed_branch =3D 2; return true; @@ -699,7 +661,6 @@ static bool trans_l_jr(DisasContext *dc, arg_l_jr *a, u= int32_t insn) =20 static bool trans_l_jalr(DisasContext *dc, arg_l_jalr *a, uint32_t insn) { - LOG_DIS("l.jalr r%d\n", a->b); tcg_gen_mov_tl(jmp_pc, cpu_R[a->b]); tcg_gen_movi_tl(cpu_R[9], dc->base.pc_next + 8); dc->delayed_branch =3D 2; @@ -710,8 +671,6 @@ static bool trans_l_lwa(DisasContext *dc, arg_load *a, = uint32_t insn) { TCGv ea; =20 - LOG_DIS("l.lwa r%d, r%d, %d\n", a->d, a->a, a->i); - check_r0_write(a->d); ea =3D tcg_temp_new(); tcg_gen_addi_tl(ea, cpu_R[a->a], a->i); @@ -735,42 +694,36 @@ static void do_load(DisasContext *dc, arg_load *a, TC= GMemOp mop) =20 static bool trans_l_lwz(DisasContext *dc, arg_load *a, uint32_t insn) { - LOG_DIS("l.lwz r%d, r%d, %d\n", a->d, a->a, a->i); do_load(dc, a, MO_TEUL); return true; } =20 static bool trans_l_lws(DisasContext *dc, arg_load *a, uint32_t insn) { - LOG_DIS("l.lws r%d, r%d, %d\n", a->d, a->a, a->i); do_load(dc, a, MO_TESL); return true; } =20 static bool trans_l_lbz(DisasContext *dc, arg_load *a, uint32_t insn) { - LOG_DIS("l.lbz r%d, r%d, %d\n", a->d, a->a, a->i); do_load(dc, a, MO_UB); return true; } =20 static bool trans_l_lbs(DisasContext *dc, arg_load *a, uint32_t insn) { - LOG_DIS("l.lbs r%d, r%d, %d\n", a->d, a->a, a->i); do_load(dc, a, MO_SB); return true; } =20 static bool trans_l_lhz(DisasContext *dc, arg_load *a, uint32_t insn) { - LOG_DIS("l.lhz r%d, r%d, %d\n", a->d, a->a, a->i); do_load(dc, a, MO_TEUW); return true; } =20 static bool trans_l_lhs(DisasContext *dc, arg_load *a, uint32_t insn) { - LOG_DIS("l.lhs r%d, r%d, %d\n", a->d, a->a, a->i); do_load(dc, a, MO_TESW); return true; } @@ -780,8 +733,6 @@ static bool trans_l_swa(DisasContext *dc, arg_store *a,= uint32_t insn) TCGv ea, val; TCGLabel *lab_fail, *lab_done; =20 - LOG_DIS("l.swa r%d, r%d, %d\n", a->a, a->b, a->i); - ea =3D tcg_temp_new(); tcg_gen_addi_tl(ea, cpu_R[a->a], a->i); =20 @@ -822,28 +773,24 @@ static void do_store(DisasContext *dc, arg_store *a, = TCGMemOp mop) =20 static bool trans_l_sw(DisasContext *dc, arg_store *a, uint32_t insn) { - LOG_DIS("l.sw r%d, r%d, %d\n", a->a, a->b, a->i); do_store(dc, a, MO_TEUL); return true; } =20 static bool trans_l_sb(DisasContext *dc, arg_store *a, uint32_t insn) { - LOG_DIS("l.sb r%d, r%d, %d\n", a->a, a->b, a->i); do_store(dc, a, MO_UB); return true; } =20 static bool trans_l_sh(DisasContext *dc, arg_store *a, uint32_t insn) { - LOG_DIS("l.sh r%d, r%d, %d\n", a->a, a->b, a->i); do_store(dc, a, MO_TEUW); return true; } =20 static bool trans_l_nop(DisasContext *dc, arg_l_nop *a, uint32_t insn) { - LOG_DIS("l.nop %d\n", a->k); return true; } =20 @@ -851,7 +798,6 @@ static bool trans_l_addi(DisasContext *dc, arg_rri *a, = uint32_t insn) { TCGv t0; =20 - LOG_DIS("l.addi r%d, r%d, %d\n", a->d, a->a, a->i); check_r0_write(a->d); t0 =3D tcg_const_tl(a->i); gen_add(dc, cpu_R[a->d], cpu_R[a->a], t0); @@ -863,7 +809,6 @@ static bool trans_l_addic(DisasContext *dc, arg_rri *a,= uint32_t insn) { TCGv t0; =20 - LOG_DIS("l.addic r%d, r%d, %d\n", a->d, a->a, a->i); check_r0_write(a->d); t0 =3D tcg_const_tl(a->i); gen_addc(dc, cpu_R[a->d], cpu_R[a->a], t0); @@ -875,7 +820,6 @@ static bool trans_l_muli(DisasContext *dc, arg_rri *a, = uint32_t insn) { TCGv t0; =20 - LOG_DIS("l.muli r%d, r%d, %d\n", a->d, a->a, a->i); check_r0_write(a->d); t0 =3D tcg_const_tl(a->i); gen_mul(dc, cpu_R[a->d], cpu_R[a->a], t0); @@ -887,7 +831,6 @@ static bool trans_l_maci(DisasContext *dc, arg_l_maci *= a, uint32_t insn) { TCGv t0; =20 - LOG_DIS("l.maci r%d, %d\n", a->a, a->i); t0 =3D tcg_const_tl(a->i); gen_mac(dc, cpu_R[a->a], t0); tcg_temp_free(t0); @@ -896,7 +839,6 @@ static bool trans_l_maci(DisasContext *dc, arg_l_maci *= a, uint32_t insn) =20 static bool trans_l_andi(DisasContext *dc, arg_rrk *a, uint32_t insn) { - LOG_DIS("l.andi r%d, r%d, %d\n", a->d, a->a, a->k); check_r0_write(a->d); tcg_gen_andi_tl(cpu_R[a->d], cpu_R[a->a], a->k); return true; @@ -904,7 +846,6 @@ static bool trans_l_andi(DisasContext *dc, arg_rrk *a, = uint32_t insn) =20 static bool trans_l_ori(DisasContext *dc, arg_rrk *a, uint32_t insn) { - LOG_DIS("l.ori r%d, r%d, %d\n", a->d, a->a, a->k); check_r0_write(a->d); tcg_gen_ori_tl(cpu_R[a->d], cpu_R[a->a], a->k); return true; @@ -912,7 +853,6 @@ static bool trans_l_ori(DisasContext *dc, arg_rrk *a, u= int32_t insn) =20 static bool trans_l_xori(DisasContext *dc, arg_rri *a, uint32_t insn) { - LOG_DIS("l.xori r%d, r%d, %d\n", a->d, a->a, a->i); check_r0_write(a->d); tcg_gen_xori_tl(cpu_R[a->d], cpu_R[a->a], a->i); return true; @@ -920,7 +860,6 @@ static bool trans_l_xori(DisasContext *dc, arg_rri *a, = uint32_t insn) =20 static bool trans_l_mfspr(DisasContext *dc, arg_l_mfspr *a, uint32_t insn) { - LOG_DIS("l.mfspr r%d, r%d, %d\n", a->d, a->a, a->k); check_r0_write(a->d); =20 if (is_user(dc)) { @@ -936,8 +875,6 @@ static bool trans_l_mfspr(DisasContext *dc, arg_l_mfspr= *a, uint32_t insn) =20 static bool trans_l_mtspr(DisasContext *dc, arg_l_mtspr *a, uint32_t insn) { - LOG_DIS("l.mtspr r%d, r%d, %d\n", a->a, a->b, a->k); - if (is_user(dc)) { gen_illegal_exception(dc); } else { @@ -973,35 +910,30 @@ static bool trans_l_mtspr(DisasContext *dc, arg_l_mts= pr *a, uint32_t insn) =20 static bool trans_l_mac(DisasContext *dc, arg_ab *a, uint32_t insn) { - LOG_DIS("l.mac r%d, r%d\n", a->a, a->b); gen_mac(dc, cpu_R[a->a], cpu_R[a->b]); return true; } =20 static bool trans_l_msb(DisasContext *dc, arg_ab *a, uint32_t insn) { - LOG_DIS("l.msb r%d, r%d\n", a->a, a->b); gen_msb(dc, cpu_R[a->a], cpu_R[a->b]); return true; } =20 static bool trans_l_macu(DisasContext *dc, arg_ab *a, uint32_t insn) { - LOG_DIS("l.mac r%d, r%d\n", a->a, a->b); gen_macu(dc, cpu_R[a->a], cpu_R[a->b]); return true; } =20 static bool trans_l_msbu(DisasContext *dc, arg_ab *a, uint32_t insn) { - LOG_DIS("l.msb r%d, r%d\n", a->a, a->b); gen_msbu(dc, cpu_R[a->a], cpu_R[a->b]); return true; } =20 static bool trans_l_slli(DisasContext *dc, arg_dal *a, uint32_t insn) { - LOG_DIS("l.slli r%d, r%d, %d\n", a->d, a->a, a->l); check_r0_write(a->d); tcg_gen_shli_tl(cpu_R[a->d], cpu_R[a->a], a->l & (TARGET_LONG_BITS - 1= )); return true; @@ -1009,7 +941,6 @@ static bool trans_l_slli(DisasContext *dc, arg_dal *a,= uint32_t insn) =20 static bool trans_l_srli(DisasContext *dc, arg_dal *a, uint32_t insn) { - LOG_DIS("l.srli r%d, r%d, %d\n", a->d, a->a, a->l); check_r0_write(a->d); tcg_gen_shri_tl(cpu_R[a->d], cpu_R[a->a], a->l & (TARGET_LONG_BITS - 1= )); return true; @@ -1017,7 +948,6 @@ static bool trans_l_srli(DisasContext *dc, arg_dal *a,= uint32_t insn) =20 static bool trans_l_srai(DisasContext *dc, arg_dal *a, uint32_t insn) { - LOG_DIS("l.srai r%d, r%d, %d\n", a->d, a->a, a->l); check_r0_write(a->d); tcg_gen_sari_tl(cpu_R[a->d], cpu_R[a->a], a->l & (TARGET_LONG_BITS - 1= )); return true; @@ -1025,7 +955,6 @@ static bool trans_l_srai(DisasContext *dc, arg_dal *a,= uint32_t insn) =20 static bool trans_l_rori(DisasContext *dc, arg_dal *a, uint32_t insn) { - LOG_DIS("l.rori r%d, r%d, %d\n", a->d, a->a, a->l); check_r0_write(a->d); tcg_gen_rotri_tl(cpu_R[a->d], cpu_R[a->a], a->l & (TARGET_LONG_BITS - = 1)); return true; @@ -1033,7 +962,6 @@ static bool trans_l_rori(DisasContext *dc, arg_dal *a,= uint32_t insn) =20 static bool trans_l_movhi(DisasContext *dc, arg_l_movhi *a, uint32_t insn) { - LOG_DIS("l.movhi r%d, %d\n", a->d, a->k); check_r0_write(a->d); tcg_gen_movi_tl(cpu_R[a->d], a->k << 16); return true; @@ -1041,7 +969,6 @@ static bool trans_l_movhi(DisasContext *dc, arg_l_movh= i *a, uint32_t insn) =20 static bool trans_l_macrc(DisasContext *dc, arg_l_macrc *a, uint32_t insn) { - LOG_DIS("l.macrc r%d\n", a->d); check_r0_write(a->d); tcg_gen_trunc_i64_tl(cpu_R[a->d], cpu_mac); tcg_gen_movi_i64(cpu_mac, 0); @@ -1050,147 +977,126 @@ static bool trans_l_macrc(DisasContext *dc, arg_l_= macrc *a, uint32_t insn) =20 static bool trans_l_sfeq(DisasContext *dc, arg_ab *a, TCGCond cond) { - LOG_DIS("l.sfeq r%d, r%d\n", a->a, a->b); tcg_gen_setcond_tl(TCG_COND_EQ, cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); return true; } =20 static bool trans_l_sfne(DisasContext *dc, arg_ab *a, TCGCond cond) { - LOG_DIS("l.sfne r%d, r%d\n", a->a, a->b); tcg_gen_setcond_tl(TCG_COND_NE, cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); return true; } =20 static bool trans_l_sfgtu(DisasContext *dc, arg_ab *a, TCGCond cond) { - LOG_DIS("l.sfgtu r%d, r%d\n", a->a, a->b); tcg_gen_setcond_tl(TCG_COND_GTU, cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); return true; } =20 static bool trans_l_sfgeu(DisasContext *dc, arg_ab *a, TCGCond cond) { - LOG_DIS("l.sfgeu r%d, r%d\n", a->a, a->b); tcg_gen_setcond_tl(TCG_COND_GEU, cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); return true; } =20 static bool trans_l_sfltu(DisasContext *dc, arg_ab *a, TCGCond cond) { - LOG_DIS("l.sfltu r%d, r%d\n", a->a, a->b); tcg_gen_setcond_tl(TCG_COND_LTU, cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); return true; } =20 static bool trans_l_sfleu(DisasContext *dc, arg_ab *a, TCGCond cond) { - LOG_DIS("l.sfleu r%d, r%d\n", a->a, a->b); tcg_gen_setcond_tl(TCG_COND_LEU, cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); return true; } =20 static bool trans_l_sfgts(DisasContext *dc, arg_ab *a, TCGCond cond) { - LOG_DIS("l.sfgts r%d, r%d\n", a->a, a->b); tcg_gen_setcond_tl(TCG_COND_GT, cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); return true; } =20 static bool trans_l_sfges(DisasContext *dc, arg_ab *a, TCGCond cond) { - LOG_DIS("l.sfges r%d, r%d\n", a->a, a->b); tcg_gen_setcond_tl(TCG_COND_GE, cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); return true; } =20 static bool trans_l_sflts(DisasContext *dc, arg_ab *a, TCGCond cond) { - LOG_DIS("l.sflts r%d, r%d\n", a->a, a->b); tcg_gen_setcond_tl(TCG_COND_LT, cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); return true; } =20 static bool trans_l_sfles(DisasContext *dc, arg_ab *a, TCGCond cond) { - LOG_DIS("l.sfles r%d, r%d\n", a->a, a->b); tcg_gen_setcond_tl(TCG_COND_LE, cpu_sr_f, cpu_R[a->a], cpu_R[a->b]); return true; } =20 static bool trans_l_sfeqi(DisasContext *dc, arg_ai *a, TCGCond cond) { - LOG_DIS("l.sfeqi r%d, %d\n", a->a, a->i); tcg_gen_setcondi_tl(TCG_COND_EQ, cpu_sr_f, cpu_R[a->a], a->i); return true; } =20 static bool trans_l_sfnei(DisasContext *dc, arg_ai *a, TCGCond cond) { - LOG_DIS("l.sfnei r%d, %d\n", a->a, a->i); tcg_gen_setcondi_tl(TCG_COND_NE, cpu_sr_f, cpu_R[a->a], a->i); return true; } =20 static bool trans_l_sfgtui(DisasContext *dc, arg_ai *a, TCGCond cond) { - LOG_DIS("l.sfgtui r%d, %d\n", a->a, a->i); tcg_gen_setcondi_tl(TCG_COND_GTU, cpu_sr_f, cpu_R[a->a], a->i); return true; } =20 static bool trans_l_sfgeui(DisasContext *dc, arg_ai *a, TCGCond cond) { - LOG_DIS("l.sfgeui r%d, %d\n", a->a, a->i); tcg_gen_setcondi_tl(TCG_COND_GEU, cpu_sr_f, cpu_R[a->a], a->i); return true; } =20 static bool trans_l_sfltui(DisasContext *dc, arg_ai *a, TCGCond cond) { - LOG_DIS("l.sfltui r%d, %d\n", a->a, a->i); tcg_gen_setcondi_tl(TCG_COND_LTU, cpu_sr_f, cpu_R[a->a], a->i); return true; } =20 static bool trans_l_sfleui(DisasContext *dc, arg_ai *a, TCGCond cond) { - LOG_DIS("l.sfleui r%d, %d\n", a->a, a->i); tcg_gen_setcondi_tl(TCG_COND_LEU, cpu_sr_f, cpu_R[a->a], a->i); return true; } =20 static bool trans_l_sfgtsi(DisasContext *dc, arg_ai *a, TCGCond cond) { - LOG_DIS("l.sfgtsi r%d, %d\n", a->a, a->i); tcg_gen_setcondi_tl(TCG_COND_GT, cpu_sr_f, cpu_R[a->a], a->i); return true; } =20 static bool trans_l_sfgesi(DisasContext *dc, arg_ai *a, TCGCond cond) { - LOG_DIS("l.sfgesi r%d, %d\n", a->a, a->i); tcg_gen_setcondi_tl(TCG_COND_GE, cpu_sr_f, cpu_R[a->a], a->i); return true; } =20 static bool trans_l_sfltsi(DisasContext *dc, arg_ai *a, TCGCond cond) { - LOG_DIS("l.sfltsi r%d, %d\n", a->a, a->i); tcg_gen_setcondi_tl(TCG_COND_LT, cpu_sr_f, cpu_R[a->a], a->i); return true; } =20 static bool trans_l_sflesi(DisasContext *dc, arg_ai *a, TCGCond cond) { - LOG_DIS("l.sflesi r%d, %d\n", a->a, a->i); tcg_gen_setcondi_tl(TCG_COND_LE, cpu_sr_f, cpu_R[a->a], a->i); return true; } =20 static bool trans_l_sys(DisasContext *dc, arg_l_sys *a, uint32_t insn) { - LOG_DIS("l.sys %d\n", a->k); tcg_gen_movi_tl(cpu_pc, dc->base.pc_next); gen_exception(dc, EXCP_SYSCALL); dc->base.is_jmp =3D DISAS_NORETURN; @@ -1199,7 +1105,6 @@ static bool trans_l_sys(DisasContext *dc, arg_l_sys *= a, uint32_t insn) =20 static bool trans_l_trap(DisasContext *dc, arg_l_trap *a, uint32_t insn) { - LOG_DIS("l.trap %d\n", a->k); tcg_gen_movi_tl(cpu_pc, dc->base.pc_next); gen_exception(dc, EXCP_TRAP); dc->base.is_jmp =3D DISAS_NORETURN; @@ -1208,27 +1113,22 @@ static bool trans_l_trap(DisasContext *dc, arg_l_tr= ap *a, uint32_t insn) =20 static bool trans_l_msync(DisasContext *dc, arg_l_msync *a, uint32_t insn) { - LOG_DIS("l.msync\n"); tcg_gen_mb(TCG_MO_ALL); return true; } =20 static bool trans_l_psync(DisasContext *dc, arg_l_psync *a, uint32_t insn) { - LOG_DIS("l.psync\n"); return true; } =20 static bool trans_l_csync(DisasContext *dc, arg_l_csync *a, uint32_t insn) { - LOG_DIS("l.csync\n"); return true; } =20 static bool trans_l_rfe(DisasContext *dc, arg_l_rfe *a, uint32_t insn) { - LOG_DIS("l.rfe\n"); - if (is_user(dc)) { gen_illegal_exception(dc); } else { @@ -1271,56 +1171,48 @@ static void do_fpcmp(DisasContext *dc, arg_ab *a, =20 static bool trans_lf_add_s(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("lf.add.s r%d, r%d, r%d\n", a->d, a->a, a->b); do_fp3(dc, a, gen_helper_float_add_s); return true; } =20 static bool trans_lf_sub_s(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("lf.sub.s r%d, r%d, r%d\n", a->d, a->a, a->b); do_fp3(dc, a, gen_helper_float_sub_s); return true; } =20 static bool trans_lf_mul_s(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("lf.mul.s r%d, r%d, r%d\n", a->d, a->a, a->b); do_fp3(dc, a, gen_helper_float_mul_s); return true; } =20 static bool trans_lf_div_s(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("lf.div.s r%d, r%d, r%d\n", a->d, a->a, a->b); do_fp3(dc, a, gen_helper_float_div_s); return true; } =20 static bool trans_lf_rem_s(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("lf.rem.s r%d, r%d, r%d\n", a->d, a->a, a->b); do_fp3(dc, a, gen_helper_float_rem_s); return true; } =20 static bool trans_lf_itof_s(DisasContext *dc, arg_da *a, uint32_t insn) { - LOG_DIS("lf.itof.s r%d, r%d\n", a->d, a->a); do_fp2(dc, a, gen_helper_itofs); return true; } =20 static bool trans_lf_ftoi_s(DisasContext *dc, arg_da *a, uint32_t insn) { - LOG_DIS("lf.ftoi.s r%d, r%d\n", a->d, a->a); do_fp2(dc, a, gen_helper_ftois); return true; } =20 static bool trans_lf_madd_s(DisasContext *dc, arg_dab *a, uint32_t insn) { - LOG_DIS("lf.madd.s r%d, r%d, r%d\n", a->d, a->a, a->b); check_r0_write(a->d); gen_helper_float_madd_s(cpu_R[a->d], cpu_env, cpu_R[a->d], cpu_R[a->a], cpu_R[a->b]); @@ -1330,42 +1222,36 @@ static bool trans_lf_madd_s(DisasContext *dc, arg_d= ab *a, uint32_t insn) =20 static bool trans_lf_sfeq_s(DisasContext *dc, arg_ab *a, uint32_t insn) { - LOG_DIS("lf.sfeq.s r%d, r%d\n", a->a, a->b); do_fpcmp(dc, a, gen_helper_float_eq_s, false, false); return true; } =20 static bool trans_lf_sfne_s(DisasContext *dc, arg_ab *a, uint32_t insn) { - LOG_DIS("lf.sfne.s r%d, r%d\n", a->a, a->b); do_fpcmp(dc, a, gen_helper_float_eq_s, true, false); return true; } =20 static bool trans_lf_sfgt_s(DisasContext *dc, arg_ab *a, uint32_t insn) { - LOG_DIS("lf.sfgt.s r%d, r%d\n", a->a, a->b); do_fpcmp(dc, a, gen_helper_float_lt_s, false, true); return true; } =20 static bool trans_lf_sfge_s(DisasContext *dc, arg_ab *a, uint32_t insn) { - LOG_DIS("lf.sfge.s r%d, r%d\n", a->a, a->b); do_fpcmp(dc, a, gen_helper_float_le_s, false, true); return true; } =20 static bool trans_lf_sflt_s(DisasContext *dc, arg_ab *a, uint32_t insn) { - LOG_DIS("lf.sflt.s r%d, r%d\n", a->a, a->b); do_fpcmp(dc, a, gen_helper_float_lt_s, false, false); return true; } =20 static bool trans_lf_sfle_s(DisasContext *dc, arg_ab *a, uint32_t insn) { - LOG_DIS("lf.sfle.s r%d, r%d\n", a->a, a->b); do_fpcmp(dc, a, gen_helper_float_le_s, false, false); return true; } diff --git a/target/openrisc/Makefile.objs b/target/openrisc/Makefile.objs index 957ce02199..b5432f4684 100644 --- a/target/openrisc/Makefile.objs +++ b/target/openrisc/Makefile.objs @@ -1,5 +1,5 @@ obj-$(CONFIG_SOFTMMU) +=3D machine.o -obj-y +=3D cpu.o exception.o interrupt.o mmu.o translate.o +obj-y +=3D cpu.o exception.o interrupt.o mmu.o translate.o disas.o obj-y +=3D exception_helper.o fpu_helper.o \ interrupt_helper.o sys_helper.o obj-y +=3D gdbstub.o @@ -12,3 +12,4 @@ target/openrisc/decode.inc.c: \ $(PYTHON) $(DECODETREE) -o $@ $<, "GEN", $(TARGET_DIR)$@) =20 target/openrisc/translate.o: target/openrisc/decode.inc.c +target/openrisc/disas.o: target/openrisc/decode.inc.c --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529348129337668.4572406722314; Mon, 18 Jun 2018 11:55:29 -0700 (PDT) Received: from localhost ([::1]:36532 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzJ9-0006Lo-2S for importer@patchew.org; Mon, 18 Jun 2018 14:55:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57526) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5k-0003f1-Bt for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5j-00054s-HB for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:28 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:47076) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5j-00054E-B0 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:27 -0400 Received: by mail-pf0-x243.google.com with SMTP id q1-v6so8602309pff.13 for ; Mon, 18 Jun 2018 11:41:27 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iTILNdw0hnTGA/3RfV2xAFyT61IwjcHouXiNyX/Bhc4=; b=GEMUsYZNSwm9O8q+LXI1zXLjfsCFWE2rN2pHy909/hHrFvHMxpmnKpzqBps+oUm0HN G84KGF59uuQohHK0fm9BrbiQEKa3N7QGkDJ5Npi4c6lVrAQVAR0Wgul2hDcS7OVkN0BM /6gi0gSJALD1WBHTUCGY7NJFzlZ3uDW5ItQ5Q= 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=iTILNdw0hnTGA/3RfV2xAFyT61IwjcHouXiNyX/Bhc4=; b=egBpMuigK6HU/4e/noYOkD36BtBICLeCXW8auoaWOQ41BPbQQTT9hlFmFUBMKZnPY0 TIsZeB4iEKj1d3DPgpTK9wJebEVSAqYC75A04Re9udo8If7BXSm03qXOZ/dw7JluWsjL a8bKm+L9/UB82hoXl//o1iT0TaPiqXFNnimeYAIPhMYllEQYr5c8H+4zzeCz+mQEJjjw cAtMjGR0sDZhKSiv+8wB2DPS0ARpwa/KQjTN1B3V4UoMbV1wBumhd29shP/HyRLB/GvM tPIIr0FJNkGnD45bdse+/Fj5QZGNZF4mXj8P2CJoopShaWSLYd701lEhQwJHzs2/XGcC CleQ== X-Gm-Message-State: APt69E3JT5FbbgNNI+KQEi0xfHdfcg0zRYPA0JPPBEaTDKIKKyYH5PTr VqlpOqIbeGbCLjai1yg/ia2f680wX0Y= X-Google-Smtp-Source: ADUXVKIfHei5Q2+Jsd5NfplPVTT7fZlLmj3HxZc0o52fcc9V6jgbhuOv0uPebMka5A++I+y4B5W5uQ== X-Received: by 2002:a62:6710:: with SMTP id b16-v6mr14835755pfc.37.1529347286154; Mon, 18 Jun 2018 11:41:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:44 -1000 Message-Id: <20180618184046.6270-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> 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 v2 20/22] target/openrisc: Add support in scripts/qemu-binfmt-conf.sh 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: shorne@gmail.com 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" Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier --- scripts/qemu-binfmt-conf.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index d7eefda0b8..a5cb96d79a 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -1,10 +1,10 @@ #!/bin/sh -# enable automatic i386/ARM/M68K/MIPS/SPARC/PPC/s390/HPPA/Xtensa/microblaze -# program execution by the kernel +# Enable automatic program execution by the kernel. =20 qemu_target_list=3D"i386 i486 alpha arm armeb sparc32plus ppc ppc64 ppc64l= e m68k \ mips mipsel mipsn32 mipsn32el mips64 mips64el \ -sh4 sh4eb s390x aarch64 aarch64_be hppa riscv32 riscv64 xtensa xtensaeb mi= croblaze microblazeel" +sh4 sh4eb s390x aarch64 aarch64_be hppa riscv32 riscv64 xtensa xtensaeb \ +microblaze microblazeel or1k" =20 i386_magic=3D'\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\= x00\x03\x00' i386_mask=3D'\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\= xff\xfe\xff\xff\xff' @@ -124,6 +124,10 @@ microblazeel_magic=3D'\x7fELF\x01\x01\x01\x00\x00\x00\= x00\x00\x00\x00\x00\x00\x02\ microblazeel_mask=3D'\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\= xff\xff\xff\xfe\xff\xff\xff' microblazeel_family=3Dmicroblazeel =20 +or1k_magic=3D'\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\= x02\x00\x5c' +or1k_mask=3D'\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\= xff\xff\xfe\xff\xff' +or1k_family=3Dor1k + qemu_get_family() { cpu=3D${HOST_ARCH:-$(uname -m)} case "$cpu" in --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529348658653472.57866273540424; Mon, 18 Jun 2018 12:04:18 -0700 (PDT) Received: from localhost ([::1]:36589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzRm-000464-RP for importer@patchew.org; Mon, 18 Jun 2018 15:04:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5o-0003jN-MV for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5l-000567-Gf for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:32 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:41436) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5l-00055o-8W for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:29 -0400 Received: by mail-pg0-x244.google.com with SMTP id l65-v6so7927567pgl.8 for ; Mon, 18 Jun 2018 11:41:29 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LurpDsWRdGxV/79+3SZ1vQla0wCVu0GI31+av9dMieM=; b=bpq/vWL6ZGqyZBkOhXRO73GzuobgNzfcNUi9W7JQQVpTbgj4qNOajNVBC/RikEuf68 aHuIMeruZUsaWVG0hPwmcGQ0tJigMOxhAcKSd/dGpB5h5yJ5Y612yLNXDf0GPhz+5wc4 cblIWCYtzzWA0KjN41KcZ/37BXfhNtzirAc2I= 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=LurpDsWRdGxV/79+3SZ1vQla0wCVu0GI31+av9dMieM=; b=uc4ZzRKh2EInZ+SqR9XOMJjaFDLYFk/2ABsR5K79McGD8ASY3FniRlO6LuahjtXzY0 /naeQrj7JTBbK3j/rvhEXnHb5MLCPgGv6nbvumFl9kBcT0xkX0AMPCVogNFevr2jGTBv vV5tBCFMZ0Mu09QvmjWjbqQzwITwOap9DSQ6WtAjFcoZMqoL9Zfolut+LAF9FaErPZGU Td1WZaHAX6NLMr5FdyaYeKntjLbyqiYYo2YzBlu25BTqOccljHPSMx4OWxu9RUMfn8Qv E5Y2zDvzyjTZgf4HlCLXOlfvpz2B4/97FjQ9ysDQxPjizPT/Pz3uC/ERENZ/oWnM+Mj1 kazw== X-Gm-Message-State: APt69E3cPKb0fdA1Qt59MaSAeC7fm7m9+1pLw2VXwegCaTkmpCXH5FiM uK+ajeS+CKnbS8U4U45iz6L1kpv7utw= X-Google-Smtp-Source: ADUXVKLGHkXywzFdhl/6LjTU/pSPBnx7AASFfYaVb5zsj/Pvt6pGV4gYQAvP248HtHMnaW88VJ88Bw== X-Received: by 2002:a62:ab0e:: with SMTP id p14-v6mr14574377pff.211.1529347287979; Mon, 18 Jun 2018 11:41:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:45 -1000 Message-Id: <20180618184046.6270-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH v2 21/22] linux-user: Implement signals for openrisc 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: shorne@gmail.com 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" All of the existing code was boilerplate from elsewhere, and would crash the guest upon the first signal. Signed-off-by: Richard Henderson --- v2: Add a comment to the new definition of target_pt_regs. Install the signal mask into the ucontext. --- linux-user/openrisc/target_syscall.h | 28 +--- linux-user/openrisc/signal.c | 212 +++++++++++---------------- linux-user/signal.c | 2 +- target/openrisc/cpu.c | 1 + 4 files changed, 95 insertions(+), 148 deletions(-) diff --git a/linux-user/openrisc/target_syscall.h b/linux-user/openrisc/tar= get_syscall.h index 03104f80af..d586d2a018 100644 --- a/linux-user/openrisc/target_syscall.h +++ b/linux-user/openrisc/target_syscall.h @@ -1,27 +1,15 @@ #ifndef OPENRISC_TARGET_SYSCALL_H #define OPENRISC_TARGET_SYSCALL_H =20 +/* Note that in linux/arch/openrisc/include/uapi/asm/ptrace.h, + * this is called user_regs_struct. Given that this is what + * is used within struct sigcontext we need this definition. + * However, elfload.c wants this name. + */ struct target_pt_regs { - union { - struct { - /* Named registers */ - uint32_t sr; /* Stored in place of r0 */ - target_ulong sp; /* r1 */ - }; - struct { - /* Old style */ - target_ulong offset[2]; - target_ulong gprs[30]; - }; - struct { - /* New style */ - target_ulong gpr[32]; - }; - }; - target_ulong pc; - target_ulong orig_gpr11; /* For restarting system calls */ - uint32_t syscallno; /* Syscall number (used by strace) */ - target_ulong dummy; /* Cheap alignment fix */ + abi_ulong gpr[32]; + abi_ulong pc; + abi_ulong sr; }; =20 #define UNAME_MACHINE "openrisc" diff --git a/linux-user/openrisc/signal.c b/linux-user/openrisc/signal.c index 8be0b74001..ea083ef15e 100644 --- a/linux-user/openrisc/signal.c +++ b/linux-user/openrisc/signal.c @@ -21,125 +21,79 @@ #include "signal-common.h" #include "linux-user/trace.h" =20 -struct target_sigcontext { +typedef struct target_sigcontext { struct target_pt_regs regs; abi_ulong oldmask; - abi_ulong usp; -}; +} target_sigcontext; =20 -struct target_ucontext { +typedef struct target_ucontext { abi_ulong tuc_flags; abi_ulong tuc_link; target_stack_t tuc_stack; - struct target_sigcontext tuc_mcontext; + target_sigcontext tuc_mcontext; target_sigset_t tuc_sigmask; /* mask last for extensibility */ -}; +} target_ucontext; =20 -struct target_rt_sigframe { - abi_ulong pinfo; - uint64_t puc; +typedef struct target_rt_sigframe { struct target_siginfo info; - struct target_sigcontext sc; - struct target_ucontext uc; - unsigned char retcode[16]; /* trampoline code */ -}; + target_ucontext uc; + uint32_t retcode[4]; /* trampoline code */ +} target_rt_sigframe; =20 -/* This is the asm-generic/ucontext.h version */ -#if 0 -static int restore_sigcontext(CPUOpenRISCState *regs, - struct target_sigcontext *sc) +static void restore_sigcontext(CPUOpenRISCState *env, target_sigcontext *s= c) { - unsigned int err =3D 0; - unsigned long old_usp; + int i; + abi_ulong v; =20 - /* Alwys make any pending restarted system call return -EINTR */ - current_thread_info()->restart_block.fn =3D do_no_restart_syscall; - - /* restore the regs from &sc->regs (same as sc, since regs is first) - * (sc is already checked for VERIFY_READ since the sigframe was - * checked in sys_sigreturn previously) - */ - - if (copy_from_user(regs, &sc, sizeof(struct target_pt_regs))) { - goto badframe; + for (i =3D 0; i < 32; ++i) { + __get_user(v, &sc->regs.gpr[i]); + cpu_set_gpr(env, i, v); } + __get_user(env->pc, &sc->regs.pc); =20 - /* make sure the U-flag is set so user-mode cannot fool us */ - - regs->sr &=3D ~SR_SM; - - /* restore the old USP as it was before we stacked the sc etc. - * (we cannot just pop the sigcontext since we aligned the sp and - * stuff after pushing it) - */ - - __get_user(old_usp, &sc->usp); - phx_signal("old_usp 0x%lx", old_usp); - - __PHX__ REALLY /* ??? */ - wrusp(old_usp); - regs->gpr[1] =3D old_usp; - - /* TODO: the other ports use regs->orig_XX to disable syscall checks - * after this completes, but we don't use that mechanism. maybe we can - * use it now ? - */ - - return err; - -badframe: - return 1; + /* Make sure the supervisor flag is clear. */ + __get_user(v, &sc->regs.sr); + cpu_set_sr(env, v & ~SR_SM); } -#endif =20 /* Set up a signal frame. */ =20 -static void setup_sigcontext(struct target_sigcontext *sc, - CPUOpenRISCState *regs, - unsigned long mask) +static void setup_sigcontext(target_sigcontext *sc, CPUOpenRISCState *env) { - unsigned long usp =3D cpu_get_gpr(regs, 1); + int i; =20 - /* copy the regs. they are first in sc so we can use sc directly */ + for (i =3D 0; i < 32; ++i) { + __put_user(cpu_get_gpr(env, i), &sc->regs.gpr[i]); + } =20 - /*copy_to_user(&sc, regs, sizeof(struct target_pt_regs));*/ - - /* Set the frametype to CRIS_FRAME_NORMAL for the execution of - the signal handler. The frametype will be restored to its previous - value in restore_sigcontext. */ - /*regs->frametype =3D CRIS_FRAME_NORMAL;*/ - - /* then some other stuff */ - __put_user(mask, &sc->oldmask); - __put_user(usp, &sc->usp); + __put_user(env->pc, &sc->regs.pc); + __put_user(cpu_get_sr(env), &sc->regs.sr); } =20 -static inline unsigned long align_sigframe(unsigned long sp) +static inline target_ulong align_sigframe(target_ulong sp) { - return sp & ~3UL; + return QEMU_ALIGN_DOWN(sp, 4); } =20 static inline abi_ulong get_sigframe(struct target_sigaction *ka, - CPUOpenRISCState *regs, + CPUOpenRISCState *env, size_t frame_size) { - unsigned long sp =3D get_sp_from_cpustate(regs); + target_ulong sp =3D get_sp_from_cpustate(env); int onsigstack =3D on_sig_stack(sp); =20 - /* redzone */ - sp =3D target_sigsp(sp, ka); - + /* Honor redzone now. If we swap to signal stack, no need to waste + * the 128 bytes by subtracting afterward. + */ + sp =3D target_sigsp(sp - 128, ka); sp =3D align_sigframe(sp - frame_size); =20 - /* - * If we are on the alternate signal stack and would overflow it, don'= t. + /* If we are on the alternate signal stack and would overflow it, don'= t. * Return an always-bogus address instead so we will die with SIGSEGV. */ - - if (onsigstack && !likely(on_sig_stack(sp))) { + if (onsigstack && !on_sig_stack(sp)) { return -1L; } - return sp; } =20 @@ -147,11 +101,9 @@ void setup_rt_frame(int sig, struct target_sigaction *= ka, target_siginfo_t *info, target_sigset_t *set, CPUOpenRISCState *env) { - int err =3D 0; abi_ulong frame_addr; - unsigned long return_ip; - struct target_rt_sigframe *frame; - abi_ulong info_addr, uc_addr; + target_rt_sigframe *frame; + int i; =20 frame_addr =3D get_sigframe(ka, env, sizeof(*frame)); trace_user_setup_rt_frame(env, frame_addr); @@ -159,47 +111,35 @@ void setup_rt_frame(int sig, struct target_sigaction = *ka, goto give_sigsegv; } =20 - info_addr =3D frame_addr + offsetof(struct target_rt_sigframe, info); - __put_user(info_addr, &frame->pinfo); - uc_addr =3D frame_addr + offsetof(struct target_rt_sigframe, uc); - __put_user(uc_addr, &frame->puc); + tswap_siginfo(&frame->info, info); =20 - if (ka->sa_flags & SA_SIGINFO) { - tswap_siginfo(&frame->info, info); - } - - /*err |=3D __clear_user(&frame->uc, offsetof(ucontext_t, uc_mcontext))= ;*/ __put_user(0, &frame->uc.tuc_flags); __put_user(0, &frame->uc.tuc_link); + target_save_altstack(&frame->uc.tuc_stack, env); - setup_sigcontext(&frame->sc, env, set->sig[0]); - - /*err |=3D copy_to_user(frame->uc.tuc_sigmask, set, sizeof(*set));*/ - - /* trampoline - the desired return ip is the retcode itself */ - return_ip =3D (unsigned long)&frame->retcode; - /* This is l.ori r11,r0,__NR_sigreturn, l.sys 1 */ - __put_user(0xa960, (short *)(frame->retcode + 0)); - __put_user(TARGET_NR_rt_sigreturn, (short *)(frame->retcode + 2)); - __put_user(0x20000001, (unsigned long *)(frame->retcode + 4)); - __put_user(0x15000000, (unsigned long *)(frame->retcode + 8)); - - if (err) { - goto give_sigsegv; + setup_sigcontext(&frame->uc.tuc_mcontext, env); + for (i =3D 0; i < TARGET_NSIG_WORDS; ++i) { + __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } =20 - /* TODO what is the current->exec_domain stuff and invmap ? */ + /* This is l.ori r11,r0,__NR_sigreturn; l.sys 1; l.nop; l.nop */ + __put_user(0xa9600000 | TARGET_NR_rt_sigreturn, frame->retcode + 0); + __put_user(0x20000001, frame->retcode + 1); + __put_user(0x15000000, frame->retcode + 2); + __put_user(0x15000000, frame->retcode + 3); =20 /* Set up registers for signal handler */ - env->pc =3D (unsigned long)ka->_sa_handler; /* what we enter NOW */ - cpu_set_gpr(env, 9, (unsigned long)return_ip); /* what we enter LA= TER */ - cpu_set_gpr(env, 3, (unsigned long)sig); /* arg 1: signo */ - cpu_set_gpr(env, 4, (unsigned long)&frame->info); /* arg 2: (siginfo_= t*) */ - cpu_set_gpr(env, 5, (unsigned long)&frame->uc); /* arg 3: ucontext = */ - - /* actually move the usp to reflect the stacked frame */ - cpu_set_gpr(env, 1, (unsigned long)frame); + cpu_set_gpr(env, 9, frame_addr + offsetof(target_rt_sigframe, retcode)= ); + cpu_set_gpr(env, 3, sig); + cpu_set_gpr(env, 4, frame_addr + offsetof(target_rt_sigframe, info)); + cpu_set_gpr(env, 5, frame_addr + offsetof(target_rt_sigframe, uc)); + cpu_set_gpr(env, 1, frame_addr); =20 + /* For debugging convenience, set ppc to the insn that faulted. */ + env->ppc =3D env->pc; + /* When setting the PC for the signal handler, exit delay slot. */ + env->pc =3D ka->_sa_handler; + env->dflag =3D 0; return; =20 give_sigsegv: @@ -207,16 +147,34 @@ give_sigsegv: force_sigsegv(sig); } =20 -long do_sigreturn(CPUOpenRISCState *env) -{ - trace_user_do_sigreturn(env, 0); - fprintf(stderr, "do_sigreturn: not implemented\n"); - return -TARGET_ENOSYS; -} - long do_rt_sigreturn(CPUOpenRISCState *env) { + abi_ulong frame_addr =3D cpu_get_gpr(env, 1); + target_rt_sigframe *frame; + sigset_t set; + trace_user_do_rt_sigreturn(env, 0); - fprintf(stderr, "do_rt_sigreturn: not implemented\n"); - return -TARGET_ENOSYS; + if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { + goto badframe; + } + if (frame_addr & 3) { + goto badframe; + } + + target_to_host_sigset(&set, &frame->uc.tuc_sigmask); + set_sigmask(&set); + + restore_sigcontext(env, &frame->uc.tuc_mcontext); + if (do_sigaltstack(frame_addr + offsetof(target_rt_sigframe, uc.tuc_st= ack), + 0, frame_addr) =3D=3D -EFAULT) { + goto badframe; + } + + unlock_user_struct(frame, frame_addr, 0); + return cpu_get_gpr(env, 11); + + badframe: + unlock_user_struct(frame, frame_addr, 0); + force_sig(TARGET_SIGSEGV); + return 0; } diff --git a/linux-user/signal.c b/linux-user/signal.c index be2815b45d..602b631b92 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -236,7 +236,7 @@ int do_sigprocmask(int how, const sigset_t *set, sigset= _t *oldset) return 0; } =20 -#if !defined(TARGET_OPENRISC) && !defined(TARGET_NIOS2) +#if !defined(TARGET_NIOS2) /* Just set the guest's signal mask to the specified value; the * caller is assumed to have called block_signals() already. */ diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index e01ce9ed1c..fb7cb5c507 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -27,6 +27,7 @@ static void openrisc_cpu_set_pc(CPUState *cs, vaddr value) OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); =20 cpu->env.pc =3D value; + cpu->env.dflag =3D 0; } =20 static bool openrisc_cpu_has_work(CPUState *cs) --=20 2.17.1 From nobody Tue Apr 30 11:36:42 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529348550299631.746088938974; Mon, 18 Jun 2018 12:02:30 -0700 (PDT) Received: from localhost ([::1]:36582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzQ0-0002wr-Il for importer@patchew.org; Mon, 18 Jun 2018 15:02:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5o-0003jQ-Mq for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5n-00056a-0Y for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:32 -0400 Received: from mail-pg0-x231.google.com ([2607:f8b0:400e:c05::231]:41571) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5m-00056M-Qa for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:30 -0400 Received: by mail-pg0-x231.google.com with SMTP id l65-v6so7927596pgl.8 for ; Mon, 18 Jun 2018 11:41:30 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZmODOKqYsNcEx2b/NPWMK/4BN92xnKbEXaSmAIQDQA8=; b=hGUjXmjXDXSi4BdUwoZOrLD9QIzOOdyWcsnxXACEVJEYbBr08SyQm9AKWCxbPxMu6G ctcQ+mieyXHnsc942o5H2SwYfdvleJM45gOsOugFGbjNd/6AdS3n4Sq1XYxEtuBmfU20 32h+3IBulM1SssY/TEc9v7waiRkY1KUdYMG4Q= 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=ZmODOKqYsNcEx2b/NPWMK/4BN92xnKbEXaSmAIQDQA8=; b=XPMWZoxfAW6mtibBOO5633TPKwvz2tWI3V5uUdprDHYOXvx0kQ7XnALLrBAYNGxh8y L6xnt9emCfWZaabqfqQrNA2NEipaHSgvOG8JnvR3IqXH6SOq4hLA+rQ6hy7d7dh/KXU8 vKIVpg9Se9B8j+d9E7AlIM9A2RwG9adif1Utzti0U7j1xAKewsSd4Wq3TELdKt7N6X+P YX1q3xfMhvBbJs1N8byCm0UsGHsWqCsbdO5KHwG3kPKXju48NNhx9O7+ycgAU4714n+X LgIUhxKlVWia0/tr1BziQMbB31nXGeEJ6Rz0gRo1/2JE1+adtwvxZd4xbFu69HWlSLrB cXVQ== X-Gm-Message-State: APt69E0L5hDBvFZioh/bEB/Wdofqxi4xYnXempCY6kzRhlleZ3avSu9O bjc/Ku7W9dL4wjqUhVC49SzXxZ7Ew8g= X-Google-Smtp-Source: ADUXVKJRtQysMMB6Z0r37H70ijMrp0rumxQlkOVDDMaVUWt0j5MfodDEPd44lroc7JAE3/ii48m9mw== X-Received: by 2002:a63:2c94:: with SMTP id s142-v6mr11696084pgs.39.1529347289687; Mon, 18 Jun 2018 11:41:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:46 -1000 Message-Id: <20180618184046.6270-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::231 Subject: [Qemu-devel] [PATCH v2 22/22] linux-user: Fix struct sigaltstack for openrisc 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: shorne@gmail.com 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" Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson --- linux-user/openrisc/target_signal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/openrisc/target_signal.h b/linux-user/openrisc/targ= et_signal.h index c352a8b333..8283eaf544 100644 --- a/linux-user/openrisc/target_signal.h +++ b/linux-user/openrisc/target_signal.h @@ -5,8 +5,8 @@ =20 typedef struct target_sigaltstack { abi_long ss_sp; + abi_int ss_flags; abi_ulong ss_size; - abi_long ss_flags; } target_stack_t; =20 /* sigaltstack controls */ --=20 2.17.1