From patchwork Mon Jul 2 15:09:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140796 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp67687ljj; Mon, 2 Jul 2018 08:12:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd40qSPVa3zJ+n6Ln8vZflJelrNc57zN8z7yQkJ/o5Mok8sKQqXP++IP/Owao/6+hbnhDAP X-Received: by 2002:ac8:33c2:: with SMTP id d2-v6mr8430092qtb.323.1530544319926; Mon, 02 Jul 2018 08:11:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530544319; cv=none; d=google.com; s=arc-20160816; b=bADkvQ+q8tUD23+9kjMwKZyrWoiZKdufv1qMub++G3b9EIhD25jOxsd0eJ+i1ajwOn cEUNFmBa/zMR1KXHl/AFAP/hux/ZQLpJFGwkpr1ugRbrUTKQYgNKiBHTmffqyoKK3Rrc 41uuoPAbfWOcrKZpSlAyZlkaWPa7Z4tIYS9XoUNsyRswRh5k7WjmNry8UczpDmQL0P9l 93CYySJDYB8Or3ny68CWDGCWmUCG0y4jwqAOQeGEoynAZc+O9vYFYweO/SrKc+NTxllO icldtCqTOH5ePL1tDaG+xBuuwJfGXtLItxk/SajnG8gU45q6l8gc9Y0tBwCygqzt1hbA LXZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=4kKcrKeV9F/Qdu736T7k95sF9L6dvtl4xdV9jCWRIzA=; b=mpdp+G9RTY/Dedz976eW9txDa3SOmnsHFjQZu8eBxCkB/lZ+jvGxHo4Ad5yTxoJyJt xrEw2TcgFQOKIkmgqHCYUXUqaWWJJC4Bs4uhZyPmhRzYYex7lvPxA6Gfj8MFPQjXJP3o mcfoOJV8P9yf7D+s9z1rmiiar4Vu52ruIr0QWRZ0x47fnIxW/7PaSK2dSNnYf+5dEq3r HAXvFzKaIlkzrNWiJbr0M9IVLSxyzF5h800qdwNVbs7QP9M2DPGcbVcq+97TLV+Cn1qf 5yieOagEax4C4aX7S1wTOJGxzHUxzfUJ9aScqrLn7WyLK0+NcsuUbBX70bv0xNUwS1Cf bzQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mkZZzp2Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y126-v6si5239878qke.6.2018.07.02.08.11.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:11:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mkZZzp2Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33440 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0Uh-0004Yk-2t for patch@linaro.org; Mon, 02 Jul 2018 11:11:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0TV-0003pF-D1 for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0TS-0007h0-Ux for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:45 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:44243) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0TS-0007fw-7b for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:42 -0400 Received: by mail-pf0-x241.google.com with SMTP id j3-v6so7649652pfh.11 for ; Mon, 02 Jul 2018 08:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4kKcrKeV9F/Qdu736T7k95sF9L6dvtl4xdV9jCWRIzA=; b=mkZZzp2QMR4H1414eG/tss32R32uqpmxVJ01FqgwqnpukfWqeO6qTLCMw5/f1FMIV4 pkuWXy8GgvaNmc7rV9PODdvHzB8Nes7yDXzQCutPbPDTTqWLz4KOXo642zmGzSO6Q1fI GLu0dJ3W6dU2OhVI1m8X0w7gSs/H2OdTY6WR1Fku2OGc36wuk4KMRFQzsujOjwimDCUR MCLaP9SIvghwIOPpHvmREfGoWr92HMR30zmlOcK/SQbeO29NXhhoT91yzP2U8Zc7Ard5 DPq9Tv8Iez0qsGvGHQrvwEIrf7M6Ftjc+TnMH/iYLh1BCIBvF+BqZM/gicHOhXvrCA8K 47bA== 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=4kKcrKeV9F/Qdu736T7k95sF9L6dvtl4xdV9jCWRIzA=; b=A5s11o0+GbB9Qz18sHomht1086TwgrbmzLwx7hlbjtnJV90+/hZUxmhnmCLOYrEDog RliNA9V+rsoRJtirrhMp7n12CeFvJlBnvgxIhdqqHy6frj43B0We55rfjcqcAGqthB26 BGnOzM6ovqDU+d6jCx16lemPtTS7omo89jjevfbn79BCEFHup4iKN7d6/dOFQBv/Bqv5 eaHnZVSyKMfSaqGGqlAoKelNVmk7Rbb/uyFbikk7IMcEyxTU9Qm0cfVxPDneQcEGocry 5bm9rHHDMXD3EuZOwiVe4KDnOuPWOvq+x1muAexx9Yc8Gw+hSNXNsQr/T79+2dEPVszn wubQ== X-Gm-Message-State: APt69E3JBEsp7fu1Km5/X+JDdz8Jy98RFKrX/SmkLbvsyPk4EjZxNzdF 9RqqG+fKplrGN2/Jk4QvSRI= X-Received: by 2002:a62:57dc:: with SMTP id i89-v6mr13777076pfj.65.1530544241199; Mon, 02 Jul 2018 08:10:41 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id r77-v6sm10576728pfr.117.2018.07.02.08.10.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:10:40 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:09:59 +0900 Message-Id: <20180702151023.24532-2-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> MIME-Version: 1.0 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] [PULL v2 01/25] target/openrisc: Fix mtspr shadow gprs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Missing break when this feature was added in 89e71e873d ("target/openrisc: implement shadow registers"). This was causing strange issues as we get writes into the translation block jump cache and other bits of state. Fixes: 89e71e873d ("target/openrisc: implement shadow registers") Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- target/openrisc/sys_helper.c | 1 + 1 file changed, 1 insertion(+) -- 2.17.0 diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index b284064381..2f337363ec 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -98,6 +98,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, case TO_SPR(0, 1024) ... TO_SPR(0, 1024 + (16 * 32)): /* Shadow GPRs */ idx = (spr - 1024); env->shadow_gpr[idx / 32][idx % 32] = rb; + break; case TO_SPR(1, 512) ... TO_SPR(1, 512+DTLB_SIZE-1): /* DTLBW0MR 0-127 */ idx = spr - TO_SPR(1, 512); From patchwork Mon Jul 2 15:10:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140799 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp71510ljj; Mon, 2 Jul 2018 08:15:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfykk3TZ8N5kVyPlu5gFwyL6F7AWuuWG1Z2o3WpGNzuAa1NioIHaJ1j3OpC7mt8JoTFuDQE X-Received: by 2002:a37:ad07:: with SMTP id f7-v6mr6571483qkm.114.1530544526590; Mon, 02 Jul 2018 08:15:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530544526; cv=none; d=google.com; s=arc-20160816; b=lXj/VluaiBwhLV/MGxQ5mwFe1zQiMpgMv40Qzh1sd5vnNLznB4cCeJQq7RxKa3E3t3 uVKiQR2bssU5ThvswPmDRh6V8HSY+fdxOj1kKos1A9/wKJEQn0TjFO/dLJsENNUSGMNz ItS+LK1tLKtkPjSPuM3u2+4JfyzG//athWiVwoJNOKJVN6yqHOHmOmMlySzM7NDuwVyy /qjXCSAgnIns8p2pz6LeVKUyCCo0Lt+v+/4OEGrvo7l6WjOEls20yFttHkQAbIr/cSdL xseMM3hkzG2YhCMeyfXJRRURD2ozAmwzdxUweLxn8ouQqSzNxKbuKhgt33dYJlOYULqN yhnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=HBXdVMeMatlFxsh6nhSErqq102Qvtozl4ABc9n6oyhY=; b=KxQ+HU0akqGjLxEj8m4F52LTQ/Df/KePmUg14rnbovmom9wa6Yv3f3ch+53n7Yc3G9 i7gJJ16QnleBDFozsUq1H4U+iFc0YHCIOjo1C1sLZvOhBgmWc7wViT2QPqSADoywDLMf ofMA2ugEeqeA9eZbaFm9UdtZQddNi6MPFt0a3JOOffEQCyCHBkacAcQFGuZ187ja0MTo Ij4oLPihabGhjLSEJBCCW9HrcyqO4rmW2PS6RhOUAJ3V/p7m4YO27a0+qt0Hy+ZOWf8D UK6DtVZoW0PkGF2yyKXkH/TJC5HZCjkPKaBJz4dddZUhpw2W+9JntBD7vll8oAvfR6v2 FPvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=YX1IbwDV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n79-v6si58991qkh.309.2018.07.02.08.15.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:15:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=YX1IbwDV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0Y1-0007St-UX for patch@linaro.org; Mon, 02 Jul 2018 11:15:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0Ta-0003u7-Uy for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0TW-0007jJ-7H for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:50 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:34005) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0TV-0007iZ-PQ for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:46 -0400 Received: by mail-pl0-x243.google.com with SMTP id z9-v6so8098219plo.1 for ; Mon, 02 Jul 2018 08:10:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HBXdVMeMatlFxsh6nhSErqq102Qvtozl4ABc9n6oyhY=; b=YX1IbwDVdNY26yxAm2Ygco+7JNRG6UeFQ15ZTv9uhQI59ore6N9ShkT4tuTKjETtt0 eZnU8hQgbDYwn8ddsgFtgpXP2HWWJSxw87C8cM/8wFnz0x92cuiiKXgM9BbJqqJwQY1M +CA2YkPiInw9Fz/9FMELyrDeGgyfUHwjXPIjbtzaIdIXmnVtBifb8WtvmuyWRsmwcKo/ mJZW72NdbjmMXI1pJCcokfWxcUWAT0BaZyIjnrmvCWcF4852iedvBiBBgfhIny2A5LRX hz5D/s3zz9vAp0tlPU4GcknMLtsQV8KLQ0Zkiw0Nr0EIiZfjIsCI8477Htxa/752GoBh luEw== 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=HBXdVMeMatlFxsh6nhSErqq102Qvtozl4ABc9n6oyhY=; b=disa/Fd3iygFX/mHYnAbnJ3fbd39DGlmbSI5P1s+GynHJkqwGqVs6vJo/MUl7Ze5KP EynNdyrB3j3CGl58PV6/lK4Y+rCIFtsMpn+16giU07UIJxQSA15WnqbJkTrYxRLt2uVx aXLT9kPVu8RvBOmZ5o77v2LzXiOTtG6RYv71f63dggXxDHcu7k4yXGR3kvzbK/+uYYLg XUcFMgrcPBtWG6vBJV6J8EAV+r6gUrG+BGI8UBfz2N3DbMJksoKIPbygQf8+KaGVT45V S3rbmiifjstGOhFYEe854cKwQnx0yhgMf2WufwHWwJJb0+wXPlJo83tXl6//oLD3YAH7 9m/g== X-Gm-Message-State: APt69E2GXM7lmaTvL09ooZL0/lJ43QQ16SrmIObtC/hACizepKPbRqii tnh4OeJiLoFxeMEptF3th2E= X-Received: by 2002:a17:902:2864:: with SMTP id e91-v6mr25644137plb.240.1530544244460; Mon, 02 Jul 2018 08:10:44 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id b22-v6sm24558319pfi.144.2018.07.02.08.10.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:10:43 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:00 +0900 Message-Id: <20180702151023.24532-3-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PULL v2 02/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Rather than emit disassembly while translating, reuse the generated decoder to build a separate disassembler. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- target/openrisc/Makefile.objs | 3 +- target/openrisc/cpu.c | 6 ++ target/openrisc/cpu.h | 1 + target/openrisc/disas.c | 170 ++++++++++++++++++++++++++++++++++ target/openrisc/translate.c | 114 ----------------------- 5 files changed, 179 insertions(+), 115 deletions(-) create mode 100644 target/openrisc/disas.c -- 2.17.0 diff --git a/target/openrisc/Makefile.objs b/target/openrisc/Makefile.objs index 1b98a911ea..8b8a890c59 100644 --- a/target/openrisc/Makefile.objs +++ b/target/openrisc/Makefile.objs @@ -1,5 +1,5 @@ obj-$(CONFIG_SOFTMMU) += machine.o -obj-y += cpu.o exception.o interrupt.o mmu.o translate.o +obj-y += cpu.o exception.o interrupt.o mmu.o translate.o disas.o obj-y += exception_helper.o fpu_helper.o \ interrupt_helper.o mmu_helper.o sys_helper.o obj-y += gdbstub.o @@ -12,3 +12,4 @@ target/openrisc/decode.inc.c: \ $(PYTHON) $(DECODETREE) -o $@ $<, "GEN", $(TARGET_DIR)$@) target/openrisc/translate.o: target/openrisc/decode.inc.c +target/openrisc/disas.o: target/openrisc/decode.inc.c diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index a692a98ec0..fa8e342ff7 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); } +static void openrisc_disas_set_info(CPUState *cpu, disassemble_info *info) +{ + info->print_insn = print_insn_or1k; +} + /* CPUClass::reset() */ static void openrisc_cpu_reset(CPUState *s) { @@ -152,6 +157,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) #endif cc->gdb_num_core_regs = 32 + 3; cc->tcg_initialize = openrisc_translate_init; + cc->disas_set_info = openrisc_disas_set_info; } /* Sort alphabetically by type name, except for "any". */ diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 35cab65f11..c871d6bfe1 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -358,6 +358,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); #define cpu_list cpu_openrisc_list #define cpu_signal_handler cpu_openrisc_signal_handler diff --git a/target/openrisc/disas.c b/target/openrisc/disas.c new file mode 100644 index 0000000000..4bfd2dd8a6 --- /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 = info->read_memory_func(addr, buffer, 4, info); + if (status != 0) { + info->memory_error_func(status, addr, info); + return -1; + } + insn = 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 d69f8d0422..fbdc2058dc 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -36,10 +36,6 @@ #include "trace-tcg.h" #include "exec/log.h" -#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_JUMP DISAS_TARGET_0 /* only pc was modified dynamically */ #define DISAS_UPDATE DISAS_TARGET_1 /* cpu state was modified dynamically */ @@ -457,7 +453,6 @@ static void gen_msbu(DisasContext *dc, TCGv srca, TCGv srcb) 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; @@ -465,7 +460,6 @@ static bool trans_l_add(DisasContext *dc, arg_dab *a, uint32_t insn) 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; @@ -473,7 +467,6 @@ static bool trans_l_addc(DisasContext *dc, arg_dab *a, uint32_t insn) 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; @@ -481,7 +474,6 @@ static bool trans_l_sub(DisasContext *dc, arg_dab *a, uint32_t insn) 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; @@ -489,7 +481,6 @@ static bool trans_l_and(DisasContext *dc, arg_dab *a, uint32_t insn) 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; @@ -497,7 +488,6 @@ static bool trans_l_or(DisasContext *dc, arg_dab *a, uint32_t insn) 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; @@ -505,7 +495,6 @@ static bool trans_l_xor(DisasContext *dc, arg_dab *a, uint32_t insn) 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; @@ -513,7 +502,6 @@ static bool trans_l_sll(DisasContext *dc, arg_dab *a, uint32_t insn) 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; @@ -521,7 +509,6 @@ static bool trans_l_srl(DisasContext *dc, arg_dab *a, uint32_t insn) 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; @@ -529,7 +516,6 @@ static bool trans_l_sra(DisasContext *dc, arg_dab *a, uint32_t insn) 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; @@ -537,7 +523,6 @@ static bool trans_l_ror(DisasContext *dc, arg_dab *a, uint32_t insn) 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; @@ -545,7 +530,6 @@ static bool trans_l_exths(DisasContext *dc, arg_da *a, uint32_t insn) 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; @@ -553,7 +537,6 @@ static bool trans_l_extbs(DisasContext *dc, arg_da *a, uint32_t insn) 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; @@ -561,7 +544,6 @@ static bool trans_l_exthz(DisasContext *dc, arg_da *a, uint32_t insn) 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; @@ -570,7 +552,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); check_r0_write(a->d); zero = tcg_const_tl(0); @@ -582,8 +563,6 @@ static bool trans_l_cmov(DisasContext *dc, arg_dab *a, uint32_t insn) 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); @@ -592,8 +571,6 @@ static bool trans_l_ff1(DisasContext *dc, arg_da *a, uint32_t insn) 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]); @@ -602,8 +579,6 @@ static bool trans_l_fl1(DisasContext *dc, arg_da *a, uint32_t insn) 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; @@ -611,8 +586,6 @@ static bool trans_l_mul(DisasContext *dc, arg_dab *a, uint32_t insn) 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; @@ -620,8 +593,6 @@ static bool trans_l_mulu(DisasContext *dc, arg_dab *a, uint32_t insn) 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; @@ -629,8 +600,6 @@ static bool trans_l_div(DisasContext *dc, arg_dab *a, uint32_t insn) 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; @@ -638,14 +607,12 @@ static bool trans_l_divu(DisasContext *dc, arg_dab *a, uint32_t insn) 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; } 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; } @@ -654,7 +621,6 @@ static bool trans_l_j(DisasContext *dc, arg_l_j *a, uint32_t insn) { target_ulong tmp_pc = dc->base.pc_next + a->n * 4; - LOG_DIS("l.j %d\n", a->n); tcg_gen_movi_tl(jmp_pc, tmp_pc); dc->delayed_branch = 2; return true; @@ -665,7 +631,6 @@ static bool trans_l_jal(DisasContext *dc, arg_l_jal *a, uint32_t insn) target_ulong tmp_pc = dc->base.pc_next + a->n * 4; target_ulong ret_pc = dc->base.pc_next + 8; - 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 != ret_pc) { @@ -692,21 +657,18 @@ static void do_bf(DisasContext *dc, arg_l_bf *a, TCGCond cond) 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; } 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; } 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 = 2; return true; @@ -714,7 +676,6 @@ static bool trans_l_jr(DisasContext *dc, arg_l_jr *a, uint32_t insn) 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 = 2; @@ -725,8 +686,6 @@ static bool trans_l_lwa(DisasContext *dc, arg_load *a, uint32_t insn) { TCGv ea; - LOG_DIS("l.lwa r%d, r%d, %d\n", a->d, a->a, a->i); - check_r0_write(a->d); ea = tcg_temp_new(); tcg_gen_addi_tl(ea, cpu_R[a->a], a->i); @@ -750,42 +709,36 @@ static void do_load(DisasContext *dc, arg_load *a, TCGMemOp mop) 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; } 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; } 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; } 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; } 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; } 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; } @@ -795,8 +748,6 @@ static bool trans_l_swa(DisasContext *dc, arg_store *a, uint32_t insn) TCGv ea, val; TCGLabel *lab_fail, *lab_done; - LOG_DIS("l.swa r%d, r%d, %d\n", a->a, a->b, a->i); - ea = tcg_temp_new(); tcg_gen_addi_tl(ea, cpu_R[a->a], a->i); @@ -837,28 +788,24 @@ static void do_store(DisasContext *dc, arg_store *a, TCGMemOp mop) 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; } 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; } 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; } static bool trans_l_nop(DisasContext *dc, arg_l_nop *a, uint32_t insn) { - LOG_DIS("l.nop %d\n", a->k); return true; } @@ -866,7 +813,6 @@ static bool trans_l_addi(DisasContext *dc, arg_rri *a, uint32_t insn) { TCGv t0; - LOG_DIS("l.addi r%d, r%d, %d\n", a->d, a->a, a->i); check_r0_write(a->d); t0 = tcg_const_tl(a->i); gen_add(dc, cpu_R[a->d], cpu_R[a->a], t0); @@ -878,7 +824,6 @@ static bool trans_l_addic(DisasContext *dc, arg_rri *a, uint32_t insn) { TCGv t0; - LOG_DIS("l.addic r%d, r%d, %d\n", a->d, a->a, a->i); check_r0_write(a->d); t0 = tcg_const_tl(a->i); gen_addc(dc, cpu_R[a->d], cpu_R[a->a], t0); @@ -890,7 +835,6 @@ static bool trans_l_muli(DisasContext *dc, arg_rri *a, uint32_t insn) { TCGv t0; - LOG_DIS("l.muli r%d, r%d, %d\n", a->d, a->a, a->i); check_r0_write(a->d); t0 = tcg_const_tl(a->i); gen_mul(dc, cpu_R[a->d], cpu_R[a->a], t0); @@ -902,7 +846,6 @@ static bool trans_l_maci(DisasContext *dc, arg_l_maci *a, uint32_t insn) { TCGv t0; - LOG_DIS("l.maci r%d, %d\n", a->a, a->i); t0 = tcg_const_tl(a->i); gen_mac(dc, cpu_R[a->a], t0); tcg_temp_free(t0); @@ -911,7 +854,6 @@ static bool trans_l_maci(DisasContext *dc, arg_l_maci *a, uint32_t insn) 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; @@ -919,7 +861,6 @@ static bool trans_l_andi(DisasContext *dc, arg_rrk *a, uint32_t insn) 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; @@ -927,7 +868,6 @@ static bool trans_l_ori(DisasContext *dc, arg_rrk *a, uint32_t insn) 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; @@ -935,7 +875,6 @@ static bool trans_l_xori(DisasContext *dc, arg_rri *a, uint32_t insn) 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); #ifdef CONFIG_USER_ONLY @@ -954,8 +893,6 @@ static bool trans_l_mfspr(DisasContext *dc, arg_l_mfspr *a, uint32_t insn) 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); - #ifdef CONFIG_USER_ONLY gen_illegal_exception(dc); #else @@ -972,35 +909,30 @@ static bool trans_l_mtspr(DisasContext *dc, arg_l_mtspr *a, uint32_t insn) 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; } 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; } 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; } 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; } 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; @@ -1008,7 +940,6 @@ static bool trans_l_slli(DisasContext *dc, arg_dal *a, uint32_t insn) 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; @@ -1016,7 +947,6 @@ static bool trans_l_srli(DisasContext *dc, arg_dal *a, uint32_t insn) 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; @@ -1024,7 +954,6 @@ static bool trans_l_srai(DisasContext *dc, arg_dal *a, uint32_t insn) 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; @@ -1032,7 +961,6 @@ static bool trans_l_rori(DisasContext *dc, arg_dal *a, uint32_t insn) 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; @@ -1040,7 +968,6 @@ static bool trans_l_movhi(DisasContext *dc, arg_l_movhi *a, uint32_t insn) 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); @@ -1049,147 +976,126 @@ static bool trans_l_macrc(DisasContext *dc, arg_l_macrc *a, uint32_t insn) 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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 = DISAS_NORETURN; @@ -1198,7 +1104,6 @@ static bool trans_l_sys(DisasContext *dc, arg_l_sys *a, uint32_t insn) 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 = DISAS_NORETURN; @@ -1207,27 +1112,22 @@ static bool trans_l_trap(DisasContext *dc, arg_l_trap *a, uint32_t insn) 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; } static bool trans_l_psync(DisasContext *dc, arg_l_psync *a, uint32_t insn) { - LOG_DIS("l.psync\n"); return true; } static bool trans_l_csync(DisasContext *dc, arg_l_csync *a, uint32_t insn) { - LOG_DIS("l.csync\n"); return true; } static bool trans_l_rfe(DisasContext *dc, arg_l_rfe *a, uint32_t insn) { - LOG_DIS("l.rfe\n"); - #ifdef CONFIG_USER_ONLY gen_illegal_exception(dc); #else @@ -1274,56 +1174,48 @@ static void do_fpcmp(DisasContext *dc, arg_ab *a, 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; } 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; } 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; } 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; } 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; } 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; } 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; } 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]); @@ -1333,42 +1225,36 @@ static bool trans_lf_madd_s(DisasContext *dc, arg_dab *a, uint32_t insn) 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; } 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; } 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; } 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; } 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; } 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; } From patchwork Mon Jul 2 15:10:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140797 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp68501ljj; Mon, 2 Jul 2018 08:12:40 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcV/DfNlXxZMDn85kkDj6gD+ssLXzqp/Czo9d/NCEFqHjpe0nkQelMDeYSj1HaDNVZsykTO X-Received: by 2002:a37:a4d:: with SMTP id 74-v6mr23224574qkk.148.1530544360542; Mon, 02 Jul 2018 08:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530544360; cv=none; d=google.com; s=arc-20160816; b=suzKzUVux4U8qndR8kxKavHQi1l+fp9k9fPcUtit0FeOWkq21texvuukatiCVTM4C+ lK6vDXdzIQfh8rGx3cYhslu4XW5AgCrSW30BLEYVxT+kwqkHomBfDOeVnIgUhcEJATGJ Fg3j3mLa/5ziRYx7A/6eNy4B4E2cm/y3K7P/LddV9EzkLLioTllbxXZ9MTw/hddeRGcX 4fnssHvkacAGFtBxlRxldjWnXIsuJbmjHGjPsWHOLNXxJFu/kkeMoTNb29t5/TOIWbvz DmQYHnLN+goWHFVG61d0TESiKDLRYv0+/p5w+tH+M6qNTaPWmiSthalLuAhN+hd/aaM6 8urA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Zf+D1raeWsoWAsHnT7ef46EOTupNmWqr70cskO2ieC0=; b=uFBb2i4GME+htblZcVh3jh+DVAgHfuPAOrY3mcoIU6mWpbNzUReJsA6GwvqPrSS4zF sUU1cBYiUEHlYvOjm+xQGqwk3F0dcV8610mCPvx7u7LfLZ40k7RmbMxhBdTzD2FoUo7O eTiRpC6O3KehqcDb74bBPXVoZD77UnTCV0zZBPoGEhxMDVngUC7ywwTX+5ynBzhlpzmh uYQk3Wcd3pDvWC4hn+uyW4ih0Sfr5qasSla6K26uMBtNku+QyG+FogVbJVNZ4BWeTTK5 WGyW3y+0EQ5WLCrPCBoCXebqgxn7oInQAIlgkT3I8XhLfi42A54vVo7go0DmThjkZt0H gMQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=MpTQSJNY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 22-v6si1138016qvg.68.2018.07.02.08.12.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:12:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=MpTQSJNY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0VL-0005Ae-MQ for patch@linaro.org; Mon, 02 Jul 2018 11:12:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0TY-0003sQ-Vh for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0TX-0007kM-SB for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:48 -0400 Received: from mail-pl0-x22d.google.com ([2607:f8b0:400e:c01::22d]:36633) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0TX-0007jy-LR for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:47 -0400 Received: by mail-pl0-x22d.google.com with SMTP id a7-v6so8094534plp.3 for ; Mon, 02 Jul 2018 08:10:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zf+D1raeWsoWAsHnT7ef46EOTupNmWqr70cskO2ieC0=; b=MpTQSJNYf34jcHrb8f56udGO6qYca7vW47nUe7DacLY9g0VUzMFi3F52ZnaOBGBM0G JY0470xOkuxnhB8wjY1TO5D5lY9XsiCAD43+XNGo4LV2tGkGjZGN7bZKnaz3i1MAqMsX pO0MRbA+WOdld4wGhV+h786rAwsp1iDIvjBard35/JPj3HwDl6enaRNdOLD8RkkeonOU d0hhGBkQ5UvIRxSExqQFJIojAxyiY0a69k/kIpHA9vv+cBhStRSMtFxKoHqujOk2lQnK JhAZm7Bc8Ebzg+m998HaGNVeE/1DWb+b1RKUTPWsfzcmyzmwgjO0M6eAjksE4R/eRENP FGvA== 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=Zf+D1raeWsoWAsHnT7ef46EOTupNmWqr70cskO2ieC0=; b=BsbEvxe12laeZkto1qg4vkrpWGULbBepAgX1A+iQ64teuEg5dFL2vDOZap7AUqkh15 XMc5JFYAf/cwJ2oyTYagJecYvujwhE9Q5uk6sv7Y5nE7sdpyKUWE2l0Xx87/jwGD9QSG 52TOXbuNDwgp8nK8XjQNzSswVqpNyoSHJ8tDxYip+t1Mm1pounN0X8oTLxRHPxRoWZ2V FlLtnsKoaAlSHqqcOa6duYIigV9wcqVFXrLl6I0yr5rQm4vqrrPrRmu6FTW+cnZ4bkk4 cKvMfCVBUu/EUxylmSb0dO4cemdxDSV1nKz9bP3nwGh+hVajJMywE+430WWOQFuMtmjl iaFw== X-Gm-Message-State: APt69E2lzycOVkHRkChA7vbX7OSfLRnznqJg4VdWHxriFW0uMr5kSOLi eb7gEhmcvHGGNqFne2u+qVE= X-Received: by 2002:a17:902:8f94:: with SMTP id z20-v6mr25952109plo.337.1530544246831; Mon, 02 Jul 2018 08:10:46 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id t76-v6sm4073052pfe.109.2018.07.02.08.10.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:10:46 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:01 +0900 Message-Id: <20180702151023.24532-4-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::22d Subject: [Qemu-devel] [PULL v2 03/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- target/openrisc/interrupt.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) -- 2.17.0 diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index 3959671c59..25351d5de3 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 = OPENRISC_CPU(cs); CPUOpenRISCState *env = &cpu->env; + int exception = cs->exception_index; env->epcr = env->pc; if (env->dflag) { @@ -41,12 +42,12 @@ void openrisc_cpu_do_interrupt(CPUState *cs) } else { env->sr &= ~SR_DSX; } - if (cs->exception_index == EXCP_SYSCALL) { + if (exception == EXCP_SYSCALL) { env->epcr += 4; } /* When we have an illegal instruction the error effective address shall be set to the illegal instruction address. */ - if (cs->exception_index == EXCP_ILLEGAL) { + if (exception == EXCP_ILLEGAL) { env->eear = env->pc; } @@ -66,8 +67,27 @@ void openrisc_cpu_do_interrupt(CPUState *cs) env->tlb->cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_nommu; env->lock_addr = -1; - if (cs->exception_index > 0 && cs->exception_index < EXCP_NR) { - hwaddr vect_pc = cs->exception_index << 8; + if (exception > 0 && exception < EXCP_NR) { + static const char * const int_name[EXCP_NR] = { + [EXCP_RESET] = "RESET", + [EXCP_BUSERR] = "BUSERR (bus error)", + [EXCP_DPF] = "DFP (data protection fault)", + [EXCP_IPF] = "IPF (code protection fault)", + [EXCP_TICK] = "TICK (timer interrupt)", + [EXCP_ALIGN] = "ALIGN", + [EXCP_ILLEGAL] = "ILLEGAL", + [EXCP_INT] = "INT (device interrupt)", + [EXCP_DTLBMISS] = "DTLBMISS (data tlb miss)", + [EXCP_ITLBMISS] = "ITLBMISS (code tlb miss)", + [EXCP_RANGE] = "RANGE", + [EXCP_SYSCALL] = "SYSCALL", + [EXCP_FPE] = "FPE", + [EXCP_TRAP] = "TRAP", + }; + + qemu_log_mask(CPU_LOG_INT, "INT: %s\n", int_name[exception]); + + hwaddr vect_pc = exception << 8; if (env->cpucfgr & CPUCFGR_EVBARP) { vect_pc |= env->evbar; } @@ -76,7 +96,7 @@ void openrisc_cpu_do_interrupt(CPUState *cs) } env->pc = vect_pc; } else { - cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index); + cpu_abort(cs, "Unhandled exception 0x%x\n", exception); } #endif From patchwork Mon Jul 2 15:10:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140804 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp75227ljj; Mon, 2 Jul 2018 08:18:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf3bogAbqoI1dm0LWNW02TMkoDbbmLO22t0wtHeNKos/AVYMxO9gUJtGWlK0Ar3lqjg9qTn X-Received: by 2002:ac8:3226:: with SMTP id x35-v6mr23956980qta.21.1530544733459; Mon, 02 Jul 2018 08:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530544733; cv=none; d=google.com; s=arc-20160816; b=jxb+m6ZruFtRTufnCvz+LZgZW7U5xhsoV7AjK5N3EmHKAd6RCqQYMlnATKzL6mLcJV sN0aWAXfkJYzpv5yMWJGYyBIcUV1CabD+KQF3mC9uF4CGpS0AarylU3/fCpxnsBRoWa/ 6P3Tlatbr/N8Z/6YXKm1m2pVLv3olqXNNr82MFaX13/v3EHCZZ3sJ8BGzjYvC06C1+m5 ZawnGXJnhs9l5Qw0hNmAnIOXkRneAGavTMo5JCdwgcdLGMbF6wiN6pBR9i4PgB7jiCII oCeFB7f5uVPs44aHK+X3IhAhrDTeKQCR2VRKiOsA4xfHyZeKD+d7B/K1b5yqDwdEx0/d 20nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=g6Mduc7hQU9gsvBLzpISCXQ7Roi6dd1EE1YPoIP0Pc4=; b=SIl9BluHfo1q+txVj0/bcOv92cLkc+XBJdDKaX1k3ULvM4kV9A4lS8hq0xU/qcTL00 MI6QNL7AKIezRc+Y6s+qiaYf4Ycm/4BdZZD9plUqIXPI1xiE7iNSNNPaaNXXGSYox0rM /pOiXaDQnvXAG+fgtY7iLk4ZdW74MGAfCxZpXJYuaIhl1X4q9eGWwzpKPmzW3EH/sqW4 KkXhnm1ehRWU6O8IcoPJmqXStsnDiFrO3nbb0cYjr/P5fcEbVikms09fmXd11QY4K5B6 MiY5yG/JBJvqhOn8JfSuQCA8wA7CzVy6/+t4kYxZ0Zay3vJfVCjFNkKoQmCkg57/ceWW azGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=sKv13lv5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e185-v6si2178220qkb.291.2018.07.02.08.18.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:18:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=sKv13lv5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33484 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0bM-0001hI-P9 for patch@linaro.org; Mon, 02 Jul 2018 11:18:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0Tb-0003uS-Bl for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0Ta-0007mq-JD for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:51 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:33624) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0Ta-0007mD-Dm for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:50 -0400 Received: by mail-pf0-x243.google.com with SMTP id b17-v6so7660480pfi.0 for ; Mon, 02 Jul 2018 08:10:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g6Mduc7hQU9gsvBLzpISCXQ7Roi6dd1EE1YPoIP0Pc4=; b=sKv13lv5Nb8KaJoevHQfF6HAuQ5PFBFTkympYDC+VXcmWlrkUoE4BThYKc4t5NItE6 z/eLp9ixwP3yQCz9FkQ+oeT8klj4EBI0XALShnPQiITyipZ6L9zJyRWoo2uQnxIo1+AX a8nsZ64WZK6lY+6TG5ifC+LUZlgSnOywPwAf0k/NlTJkd2yS1OV2q+AJzXHgF+mVM9z3 gF8eGsZx5ToNQSqhTTLO97N2WTgKlI8SVvynSzSy6/RxNNk1zCYTkIKjWNOcfbkAF7Rc Hfs523EbIYYsHBVa+40dblxl3fOQrsxSO2+iNL7TJ16HBatgUWLNwcz8E0uo080PwUCe LnQw== 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=g6Mduc7hQU9gsvBLzpISCXQ7Roi6dd1EE1YPoIP0Pc4=; b=P1SzFKAEXezVaxCU8CAIfWcHZtCcoCUv1D1oO0psv583B74b6keRLziuLKthSdcSi+ TQmSS4rEy4/SdraFEPPrBNz9L6Kz7dSp54cZXBkyJ4SL+1zBpvEfcd5nATdYsd2z23vl XPhAlmEO1gnPTQCd33kIjgmptYHyRR+yIdad3oSlYcNeKam2YAYGO5Fo94cWCd9v2RXY jJO52nLC8+3YN+RdceOR02HHUy3OR+ravAs7PrRh6kOuai3gcG7rSNhH0x5DDQOcRp75 WLn8sNeTd84028+Q9gdc4+hFY1NVt2NcOrYUGaQadFk7spGTwQa3dl791zifzUEQippY eaig== X-Gm-Message-State: APt69E3uGBcFEueBexSzn49sR18C7AYVC+T68VQVnIxKNlAPmjGrlZtz qlnUeBSAU0sJjytdyjlRck/lInTD X-Received: by 2002:a65:6210:: with SMTP id d16-v6mr21727888pgv.272.1530544249612; Mon, 02 Jul 2018 08:10:49 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id l85-v6sm31641136pfk.79.2018.07.02.08.10.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:10:49 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:02 +0900 Message-Id: <20180702151023.24532-5-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> MIME-Version: 1.0 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] [PULL v2 04/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson These values are unused. Reviewed-by: Stafford Horne Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- target/openrisc/translate.c | 4 ---- 1 file changed, 4 deletions(-) -- 2.17.0 diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index fbdc2058dc..f5af515979 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -37,9 +37,7 @@ #include "exec/log.h" /* 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 */ typedef struct DisasContext { DisasContextBase base; @@ -1353,8 +1351,6 @@ static void openrisc_tr_tb_stop(DisasContextBase *dcbase, 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 From patchwork Mon Jul 2 15:10:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140800 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp71780ljj; Mon, 2 Jul 2018 08:15:40 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcCWgzwc5g7fRZrNVhgQz1oZsm8gZvrAlT3/Z8/rDCZXDy+tISZXBGTypvNoMfShJTQSF1E X-Received: by 2002:a0c:91d0:: with SMTP id r16-v6mr23133239qvr.38.1530544540270; Mon, 02 Jul 2018 08:15:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530544540; cv=none; d=google.com; s=arc-20160816; b=oUdjvRc235nhrVqZPOi27to1SDyivxVAvd5oWgXzF/80VPaqkS0YpqElHLuW/f3Qqh OhlW3/AnLKlQ5wjSzotXUQ03IAwkBbCQMMSWmMMUA30n0v/HiPR/do9NjoQjyfC03pYv 3WCJ+sUeigdIq13Fc51IxAvFGLUu7UmT6flks2pmoYTex3vTUtsUOhPQfqUcrr1wn/yf O/tfm/ADmcEUt7cZlpvyxU9Zy7Ko+aK1wjrj4AMSR8CeSbcGswr1jzAewrpHLb4fSHQp bjcxtQMRbL14xxa0gJAEi3DxI4htka4HZdPklgeNxC4xil9p6KSESOKgQXYk0TG6BjRD TFvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=zwROJDNO19y8L4571rd5vDDy9iKL7GFmoIWAnXAcLlA=; b=b6V/8lehfieyExiYfLNfN11veTxtOHf7MIGO3VqAEow243dPF8nf8TN5sT4PpmYrET YCTl2Q7LZmwhyv9tFqsBE31CR9Cko9Kcg38kjVenHm6Y5D3X3DJuRb7wtJey6cj+9b7f cnqNUeshJuv9eO+J4XuRyFwV8ddRc11DfZiy5dTfIRNt162auLRoobuOyWZH9HdCFCFp /b+u5WIGeCkwL9DIR9jFDdmIIHZj3hkDCdja3aln95ETEohPRHduMyw4Fbgg6VtAthW8 65kkqk8q5QVtvagn5EXzXkHMFCinymSAkvdLhel+E3Tgts60qNaS1WA8uBq9MecxeVlq QuuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=uBXka7WO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z7-v6si9587665qta.91.2018.07.02.08.15.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:15:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=uBXka7WO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0YF-0007hy-Kx for patch@linaro.org; Mon, 02 Jul 2018 11:15:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0Tg-0003wB-6k for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0Tc-0007oD-Td for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:56 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:44825) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0Tc-0007nv-Oz for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:52 -0400 Received: by mail-pl0-x241.google.com with SMTP id m16-v6so8092925pls.11 for ; Mon, 02 Jul 2018 08:10:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zwROJDNO19y8L4571rd5vDDy9iKL7GFmoIWAnXAcLlA=; b=uBXka7WOeUxYjPVDmvdAb3OdlZcnDQtBf5zCwNOCRoGsCMbLxBhBsWMcXSQ71bYGme ivHEiHoOfGTby823FH4nGyiONTzSj+8xs+3bvFG0HHFV1ug3W014B0BDBwh49TBt2qto aqTpJfg7VUdEruO/EMTkwnXjUXM9sXz7UBx5VKoqZhCJUQF1g2H3Mc/ErJT9MSEwySY1 MUVqggSdZ+/9ITzIoYzgvchKQSN/nXsoKK+60tjGqhBcZfePT9GLO1tPvgBNKimC8OJc bQfUdaI0lS9CgCDFb/HLPoBKRygLAwi5slExX+V5jA242c6kG1XrELxutbzx/0a73Szj 0Jag== 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=zwROJDNO19y8L4571rd5vDDy9iKL7GFmoIWAnXAcLlA=; b=mfJZ4E/LvpKVP7CTUdKvhvQpZLTvXwPqJk4kWLxxY+s6aclmSLYbcaWD0ridgseFwN K/zw6yUKfm9OczjMVWy22X3n+1bWHF2WL7VzUfE4zFtGGKG2fmcMh6w6nrcx/f3nDhMz ouE2+FMsgtAXnMoNXKWFmCmP+/XReAoWBi5WGiTgMY6/olSd3Ix8JvBZK19igV+3NXzN xTtF2iVkWbP4uwKKUXHfTrzupxY5Ft5ftF19sPfMjctUBFw5WA43o6rwGi+zLouv53s8 y7nB7qMuOnOYCAdo5wTLlA41FfQgY3U2IoHXrpG0IycurzFWZUZXcW2bx+xdaM4co6Ev 8axQ== X-Gm-Message-State: APt69E0vxoWdu8sGDqOYJ9K7khrFtjQvmkSTQYYV+Xz6TImSt4dA52TW WawctFG8OnxwQweJy0XaR3c= X-Received: by 2002:a17:902:a518:: with SMTP id s24-v6mr26577031plq.144.1530544251929; Mon, 02 Jul 2018 08:10:51 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id v15-v6sm24454562pff.120.2018.07.02.08.10.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:10:51 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:03 +0900 Message-Id: <20180702151023.24532-6-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> 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] [PULL v2 05/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson No need to use the interrupt mechanisms when we can simply exit the tb directly. Reviewed-by: Stafford Horne Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- target/openrisc/interrupt_helper.c | 3 +-- target/openrisc/translate.c | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) -- 2.17.0 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 = openrisc_env_get_cpu(env); - CPUState *cs = CPU(cpu); #ifndef CONFIG_USER_ONLY int need_flush_tlb = (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) } if (need_flush_tlb) { + CPUState *cs = CPU(cpu); tlb_flush(cs); } #endif - cs->interrupt_request |= CPU_INTERRUPT_EXITTB; } diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index f5af515979..43bdf378eb 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -37,6 +37,7 @@ #include "exec/log.h" /* 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 */ typedef struct DisasContext { @@ -1133,7 +1134,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 = DISAS_UPDATE; + dc->base.is_jmp = DISAS_EXIT; } #endif return true; @@ -1353,8 +1354,7 @@ static void openrisc_tr_tb_stop(DisasContextBase *dcbase, 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: From patchwork Mon Jul 2 15:10:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140802 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp75059ljj; Mon, 2 Jul 2018 08:18:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe79wE/SDA6ty2RUIYPbhxDI6zvGlgOkvW+aBPC9TbqbvYWAqY+JSCwWc7yykC5XHxjcXzZ X-Received: by 2002:ac8:701d:: with SMTP id x29-v6mr23538090qtm.98.1530544724325; Mon, 02 Jul 2018 08:18:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530544724; cv=none; d=google.com; s=arc-20160816; b=C1MA6a7aP9pOP94zv4MJSy8dl2mTd51WF3+U51x8jeH/StK1pGJ4GuagUkoXLNYOTq 4jM/cF71THaeNp3psMhYjNUO7o6uf1+yVKjgbgJSWxZJveJRB8YLeDCQsyYJOsjd8xUj l2GY/xUW/NvbS4nTMw0tKf7E9RblomtsYQRDgWcqZxUkIy/UzQ9VRGTkQsGK7smMMYtJ XyyXL3DwWKqH3o1e8LKyJpj1tU8EyTAfKJ+nMQdajIDykzjvPVFuF5FH35JuIeyJiBeL QwKmirZyJ1VRlp+DbuUxrGc2vR54Tbo+1+A3xg787dGmahuVCs0NcH6ex1VwIBzS4v6D MlnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=egPnLBVgtP7NhsuuXtIHrGJQwyDZe26xfhEhEduYjIY=; b=Ppv/xNK5fQy9V/Lqo36mmOWieWFJ0T013HHH3VdEgNYRGuIsb2c9B2o/DwqqXJJDlV ajOFWqOL+DH1aWIyqTJZNea48pIKyuZ3ahdHRuCqh/w2pTizLh99bK0+nr1buXiQfmuR RWsgxtsw6U0jZKSs6atg0VLrOAeBrOOek4B4osu0D3CHGOqLeM7NSYoEGxPIk//2rA/k V6eg7Qt9j45SNKotTHMu31vGnNDcfWEQOV46k5HxN/6lcfDtvj9m44rEkCC8TxB1bdZO ZM7hpLjeypzzey5i2McM5wxTfLo/9Zr7G84V1r+DLUv7HPlZzAqxcsg5SS4XhXO+QTIl 0tyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=e4pm6DSz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m82-v6si9459438qki.213.2018.07.02.08.18.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:18:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=e4pm6DSz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33479 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0bD-0001aU-Lk for patch@linaro.org; Mon, 02 Jul 2018 11:18:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0Tg-0003wJ-BI for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0Tf-0007pP-8S for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:56 -0400 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]:40443) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0Tf-0007pF-2R for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:55 -0400 Received: by mail-pf0-x22c.google.com with SMTP id z24-v6so7656123pfe.7 for ; Mon, 02 Jul 2018 08:10:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=egPnLBVgtP7NhsuuXtIHrGJQwyDZe26xfhEhEduYjIY=; b=e4pm6DSzkfHdk/TR2CU8+/bP9WYycKetJu5llGfPfLcIAlS/gBUafIg5GLf/+AzTL0 IxrFC3BJ2tS+lr0KApvjJYOKdJNnyxPNW7ohE85OF196WbPv4Nns3uYOy/mqZ6eWKX7D DQGum9Pp6dP8L8vEM+dnslh2xeocudPL7aY8I7hqLu0cQveZah67Si49Mj87ZkvklMtx AE/UMiZKarX+9ERoeio+Ab68g7WqT8DtFJ2HNmZ6fTLMvhnKKmU1OjS4zKXlkHo+rfNe Kqak99ntHm6EfP3fHsHayx4gd6xg1fNmFHZ/lvPBYxuIuRmQ322uYQQlsXet++BvV6dg EicQ== 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=egPnLBVgtP7NhsuuXtIHrGJQwyDZe26xfhEhEduYjIY=; b=gCP9jfWZkMIcsz6EGTwrvuUdn3g7lbZ12EAVqnBnf2OgTRRaQFmqkrqkvhPIupE5gW USgsnRvXG68Hl0RBHKMiQSZMxM7MHBTI/iItCH1k7a1NZM9o6q8v4QHVKboJYnDLvu/5 r5PGFKCHIVA4VjRJ6G3JZKolzlV/83FJSj1WyIeh3x+LoMg3hy9i5yB47WcZgyBLmH1/ C05OwQzxYPljmgDy+23ejd4uNaFa4BWGYaDAirFSgGuyv/RsYq4cVSfNN+h1U3Ynq8X3 HOQYC8XLEWVCgifCRV25d1WNBFc2W/SWfxxda8yALQJl1xOmXDHb4eUMYZ5rxDM3/9Nm 5Fow== X-Gm-Message-State: APt69E3BPjsYiIxebQITGqb8Oqo6U4mtGxq/QRYxm7I9pAAaJY98Vn/f eiPhDPRIYkVJN3ZsgxbdvoU7es0G X-Received: by 2002:a62:2ec1:: with SMTP id u184-v6mr25972153pfu.184.1530544254247; Mon, 02 Jul 2018 08:10:54 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id 15-v6sm28346424pfq.81.2018.07.02.08.10.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:10:53 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:04 +0900 Message-Id: <20180702151023.24532-7-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22c Subject: [Qemu-devel] [PULL v2 06/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson 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 Signed-off-by: Stafford Horne --- target/openrisc/translate.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) -- 2.17.0 diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 43bdf378eb..22848b17ad 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -1335,31 +1335,30 @@ static void openrisc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) { DisasContext *dc = container_of(dcbase, DisasContext, base); + /* If we have already exited the TB, nothing following has effect. */ + if (dc->base.is_jmp == DISAS_NORETURN) { + return; + } + if ((dc->tb_flags & TB_FLAGS_DFLAG ? 1 : 0) != (dc->delayed_branch != 0)) { tcg_gen_movi_i32(cpu_dflag, dc->delayed_branch != 0); } tcg_gen_movi_tl(cpu_ppc, dc->base.pc_next - 4); - if (dc->base.is_jmp == DISAS_NEXT) { - dc->base.is_jmp = 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(); } } From patchwork Mon Jul 2 15:10:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140795 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp67080ljj; Mon, 2 Jul 2018 08:11:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpflpt+Up1zpyQl4WdGXXmxiOblOyp4EsEoxWmlkZfF4LYrbrfad4VGOoYb2ER4diueiIR7w X-Received: by 2002:a37:99c3:: with SMTP id b186-v6mr22211136qke.261.1530544287295; Mon, 02 Jul 2018 08:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530544287; cv=none; d=google.com; s=arc-20160816; b=jTeMajNcKfv/zqI+MUIwIAa8J9DN9Y9kGxLQaKa9eJ96gDM55vab5kVI7W8ZhA/MUu 1DncTa/KCxogz//1pi7kHwI4COpVsKxoJIWOVx9nypl6TLgBWv/sEP+oo6i1I/wP8pdH YCdpv6GntQRy6RG69YXGE7tAXZlITlpqv0OSjF4ke7m4/N2R3xzL/KKi4yN4GdiJ+btY 69f30jRol6NmdQmt31oJ4UiLqcMJXe+tNrh1yo7QaDitIJP2KySiERqwtwnd/xu7e0IL waL4JHKLiIAaaRTek0VgmdTFYIO2VQoGSsXuFnJz/gxoLD687rj/au9puVlyTzzgBwga bnUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=0AwTJ+88ZGHtSYhFlyrIVloh3Xf4GpNuS/w+tenewKg=; b=RlwjQEqQJzoGB0L3fR8NtRJEEq0HWCRztcA3+tfPcDNqTc6cJY5B2bgo8OVGT//67P V9WeU5xET+pxpp90L6ZbqTP0GWDKIyh8ZKaj70/AXZlVNjamVB0SLXRcbECFlQJAVzrT YGK/QSxQCM7Ope0Fp2bdi9HlkYF6jpLXWaiC/dZEwWT3Xr+MO+gokq/ikEpP5rL7+ZQZ uJPtEhk7xO9rbSnxIrNYUe3z7VjPDcWH25c92NgId+bFS7X3J73NeSEb7E30U/gfEjgA F+57Z58htgxaBlNUfIqys433bAzCVJAWHIBkNad6w6fv7O+0ssM/JsqTqfMpS755Q7mp 1NnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=rwhCa7IM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p84-v6si4071473qkp.268.2018.07.02.08.11.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:11:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=rwhCa7IM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33436 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0UA-00042R-J5 for patch@linaro.org; Mon, 02 Jul 2018 11:11:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0Tj-0003zD-2S for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0Th-0007rC-P3 for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:59 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:38682) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0Th-0007qh-Hf for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:57 -0400 Received: by mail-pg0-x241.google.com with SMTP id c9-v6so7282794pgf.5 for ; Mon, 02 Jul 2018 08:10:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0AwTJ+88ZGHtSYhFlyrIVloh3Xf4GpNuS/w+tenewKg=; b=rwhCa7IMCP7NCLTb3vb4upyPyhr6HwejkLvltYsEargOiiJmOYiHIhQI1Y4wpIe8Dd 1KHFFud5wSD0t2KXkYXM75aGmJox9WG+qvdqcG+UDtBXhAGfKaYP25sxvYDrUF5Tvwhv uFJdiPKCmjeYqfp1VTuojsnB9LM8IGrfk0pxwMzubTIo2D95R9OIc5aSSslsj8AYiI/q CK8VNidupFyh+SZAxuB/U9IvIxzItPnHoB4iL3r5TfqBKQDuYqUs+sD4L4yQb+Cqx+oC jNDM7GbO8YUsmnMfMshSxDv/2KK0p+9cmcPNcvPs5PoY7X+aUKgmt4hWjsmGcSv4Q721 QOsQ== 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=0AwTJ+88ZGHtSYhFlyrIVloh3Xf4GpNuS/w+tenewKg=; b=oKAs9GjR/YC21HxZXrrFt1vWrQOKW1pXQQSzL/dba+UpYBX25r48Eqf/iSKAWAL9J1 w+R8iG7hGKmI0Q3kDYzr2pke4qH8XKZAw9CVADDcz69zXj0E7+lc6B8YotSNXKv/BN7h PIRqkg2KNHropPijYNafh2svAiL07Kx6OxjcdqGar26dXnEsaYrJDpcB15vIrtbdXcS8 mgdGJY5TaNpcPUnDQcFaQukra6Zb/yl4t8Nrkthoq0JVtKgMvdBOOKBwka8KHmqm9ZbM UmKaLUdAbLrAJv1/jNHbhCqAwSzOZmXmkyu72XvmH5ILkguesxXzCrRcqQntYieM/3kj Iq4w== X-Gm-Message-State: APt69E1w0MVbxkbCwh914uKOqz4mUweRFD/vp064Set8kBG6nGNInxXi /t0qZVVTvt1yLrY8gcRkTMs= X-Received: by 2002:a63:2c94:: with SMTP id s142-v6mr21598450pgs.39.1530544256683; Mon, 02 Jul 2018 08:10:56 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id a11-v6sm22187754pgq.32.2018.07.02.08.10.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:10:56 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:05 +0900 Message-Id: <20180702151023.24532-8-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PULL v2 07/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson 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 Signed-off-by: Stafford Horne --- target/openrisc/translate.c | 96 +++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 41 deletions(-) -- 2.17.0 diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 22848b17ad..a618d39242 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -38,13 +38,16 @@ /* 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 */ 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; /* Include the auto-generated decoder. */ @@ -160,34 +163,6 @@ static void check_ov64s(DisasContext *dc) } \ } while (0) -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) == (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) { @@ -621,6 +596,7 @@ static bool trans_l_j(DisasContext *dc, arg_l_j *a, uint32_t insn) target_ulong tmp_pc = dc->base.pc_next + a->n * 4; tcg_gen_movi_tl(jmp_pc, tmp_pc); + dc->jmp_pc_imm = tmp_pc; dc->delayed_branch = 2; return true; } @@ -634,6 +610,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 != ret_pc) { tcg_gen_movi_tl(jmp_pc, tmp_pc); + dc->jmp_pc_imm = tmp_pc; dc->delayed_branch = 2; } return true; @@ -1267,6 +1244,8 @@ static void openrisc_tr_init_disas_context(DisasContextBase *dcb, CPUState *cs) dc->mem_idx = cpu_mmu_index(env, false); dc->tb_flags = dc->base.tb->flags; dc->delayed_branch = (dc->tb_flags & TB_FLAGS_DFLAG) != 0; + dc->jmp_pc_imm = -1; + bound = -(dc->base.pc_first | TARGET_PAGE_MASK) / 4; dc->base.max_insns = MIN(dc->base.max_insns, bound); } @@ -1319,37 +1298,72 @@ static void openrisc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) } dc->base.pc_next += 4; - /* delay slot */ - 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 = DISAS_UPDATE; - return; - } + /* When exiting the delay slot normally, exit via jmp_pc. + * For DISAS_NORETURN, we have raised an exception and already exited. + * For DISAS_EXIT, we found l.rfe in a delay slot. There's nothing + * in the manual saying this is illegal, but it surely it should. + * At least or1ksim overrides pcnext and ignores the branch. + */ + if (dc->delayed_branch + && --dc->delayed_branch == 0 + && dc->base.is_jmp == DISAS_NEXT) { + dc->base.is_jmp = DISAS_JUMP; } } static void openrisc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) { DisasContext *dc = container_of(dcbase, DisasContext, base); + target_ulong jmp_dest; /* If we have already exited the TB, nothing following has effect. */ if (dc->base.is_jmp == DISAS_NORETURN) { return; } + /* Adjust the delayed branch state for the next TB. */ if ((dc->tb_flags & TB_FLAGS_DFLAG ? 1 : 0) != (dc->delayed_branch != 0)) { tcg_gen_movi_i32(cpu_dflag, dc->delayed_branch != 0); } - tcg_gen_movi_tl(cpu_ppc, dc->base.pc_next - 4); + /* For DISAS_TOO_MANY, jump to the next insn. */ + jmp_dest = dc->base.pc_next; + tcg_gen_movi_tl(cpu_ppc, jmp_dest - 4); + switch (dc->base.is_jmp) { + case DISAS_JUMP: + jmp_dest = dc->jmp_pc_imm; + if (jmp_dest == -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); From patchwork Mon Jul 2 15:10:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140803 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp75122ljj; Mon, 2 Jul 2018 08:18:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcrX1O1Sq7Sk82jXjKkUKVd5DzAuvR30rgMW/fKhikx41ABWUpmAlDZaPsAR5Po9JHVlM3R X-Received: by 2002:ac8:2f42:: with SMTP id k2-v6mr18860360qta.169.1530544728268; Mon, 02 Jul 2018 08:18:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530544728; cv=none; d=google.com; s=arc-20160816; b=Iam9uLWDSQEw3JMl5Vvehtzn46nvpeP8VSn509XS66zEYt8qQ+g2uJJ3A2pwjamy4X mvcmpWPu3qWUDbMsnagCCr80bk8ev1ZnVTy4AgrWvImxIyl4Rlrsw2Rf2XFaXdlxacAa IruwLIiamJjLE6r7ex2cbprUiuu5xPFyLtcO6bbp2Fq9Czts2kPCYkKTLz/256N7ygbT vGnFCUNoRK4Y6v6WOqibeFGpusm9txvd5b68nL23RhYayoqL1YaxxskYA3Qa42LY1rQ+ deU0Z6Fs/5wi2YVrAJ+icv2IlkYxbv2+z7Mj/cGFs4gsTZ0zPPPq+SeEHnPBZjBUm2E3 L0Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Yixh9gBbGs/L/HsYKBIMiny0gxQr3xXkYWn48J9gsi0=; b=ruLhLVlAa8wFdU9oM0ib9K5XlfwTahdaQxV3eA7zLVXOxhsPeA2hW0Cu+CulnCHwU6 y+YmbPNodoH2cIvNSGflUO048EUwe0L0O/xD3XEGfjzNq09JG3uO/GV8F0MAqEaPQ8Nn tw1NKRS+BSALM4BN0mSWKShRml7WMopPWN+KEk3kcAg819ead7GbarfXInEuQKnfxiIH x+vcn01JS4mzfG3M1BzfL/QoAhh4gin4iPCxgnL0k/Bv2Sy9VVt/U3FDdcfpLN1LdeTe 26PYC8HOoR6pqU1PDBY9RWA5nx17j+Mk6XMhGWN5NKjiNz0y2vFhgOaTfOE8oDHto/w3 9C0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=udu5eby0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d47-v6si2515896qvd.46.2018.07.02.08.18.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:18:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=udu5eby0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0bH-0001dd-IJ for patch@linaro.org; Mon, 02 Jul 2018 11:18:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0Tl-00041Q-9I for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0Tj-0007rt-Uo for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:01 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:33271) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0Tj-0007ri-Oo for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:10:59 -0400 Received: by mail-pg0-x244.google.com with SMTP id e11-v6so7285956pgq.0 for ; Mon, 02 Jul 2018 08:10:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Yixh9gBbGs/L/HsYKBIMiny0gxQr3xXkYWn48J9gsi0=; b=udu5eby0qJwFDT5Ye7sl8WFXXbMK2Tx2qKpb3b+/tyhewtgkj7SSWdYIySiN5MEnhs HzzQOuLWs1LLzCdKz21QhmFG56t77N8t6DVCIaoZNhgG9+7ZynxmxLpF6E0YeXdxizOu VLcSOAvKfKf2zwaodg3soHQmK3Zc4SHTtPX+KjS7xh5zQMpwyY3SnI0w9r6ioVD8Bmz2 n7N582h//l1A2VZuwSptE/n8Azwo3kkKZsnvtIicOPN06hxXINu5skOi41vpAcFG6Q+o EeNpLHUbJwC0+nmzFN4vE6VxRa6Cxk44D6AvN7Z3oLjeREaAZ03hV4BnWJ7vWXfys2sy TdvQ== 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=Yixh9gBbGs/L/HsYKBIMiny0gxQr3xXkYWn48J9gsi0=; b=rF4APYId4uDFWB4dCQ0JKWHLXiR/N/240Kkjh/otbr+UmMKIBOQQv3E8ndl3qceBdl JWMyazim4a5T4oWULOHWqgCa4h5VIEe4no3tB5+w1yFpeffxP5wMVLF2esklyf/47GOg x4D4p0epa+N84LFB9rh67YYrgurx/ONe48WZUsBOryeFVeKDXwOI9JGbMddUgfAQzWGZ Jbn+WchxdIHXNl2OpEmQcmqJUyj7uVbhqywnbrcC8qmPmNqXw0IIbeWmQ49NfWdD+Lu9 lX3t7J328L7KodN1+SF9CACtit9U+xFKqycOlNiTCxd7/rbNzISWkMWMsXPg2zNtTwn8 gJGw== X-Gm-Message-State: APt69E1NQIQV/wWZPmFWwmRbngfA+y0EveJt7hR04T7Gs6GMlgnJmG0K ApQIQ1pR9GwiSEzrGWRitk0= X-Received: by 2002:a63:64c2:: with SMTP id y185-v6mr21922531pgb.126.1530544258956; Mon, 02 Jul 2018 08:10:58 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id v14-v6sm13846096pfi.55.2018.07.02.08.10.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:10:58 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:06 +0900 Message-Id: <20180702151023.24532-9-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> MIME-Version: 1.0 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] [PULL v2 08/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson This allows us to limit the amount of ifdefs and isolate the test for usermode. Reviewed-by: Stafford Horne Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- target/openrisc/translate.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) -- 2.17.0 diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index a618d39242..db149986af 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -50,6 +50,15 @@ typedef struct DisasContext { target_ulong jmp_pc_imm; } DisasContext; +static inline bool is_user(DisasContext *dc) +{ +#ifdef CONFIG_USER_ONLY + return true; +#else + return dc->mem_idx == MMU_USER_IDX; +#endif +} + /* Include the auto-generated decoder. */ #include "decode.inc.c" @@ -853,33 +862,25 @@ static bool trans_l_mfspr(DisasContext *dc, arg_l_mfspr *a, uint32_t insn) { check_r0_write(a->d); -#ifdef CONFIG_USER_ONLY - gen_illegal_exception(dc); -#else - if (dc->mem_idx == MMU_USER_IDX) { + if (is_user(dc)) { gen_illegal_exception(dc); } else { TCGv_i32 ti = tcg_const_i32(a->k); gen_helper_mfspr(cpu_R[a->d], cpu_env, cpu_R[a->d], cpu_R[a->a], ti); tcg_temp_free_i32(ti); } -#endif return true; } static bool trans_l_mtspr(DisasContext *dc, arg_l_mtspr *a, uint32_t insn) { -#ifdef CONFIG_USER_ONLY - gen_illegal_exception(dc); -#else - if (dc->mem_idx == MMU_USER_IDX) { + if (is_user(dc)) { gen_illegal_exception(dc); } else { TCGv_i32 ti = 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; } @@ -1104,16 +1105,12 @@ static bool trans_l_csync(DisasContext *dc, arg_l_csync *a, uint32_t insn) static bool trans_l_rfe(DisasContext *dc, arg_l_rfe *a, uint32_t insn) { -#ifdef CONFIG_USER_ONLY - gen_illegal_exception(dc); -#else - if (dc->mem_idx == MMU_USER_IDX) { + if (is_user(dc)) { gen_illegal_exception(dc); } else { gen_helper_rfe(cpu_env); dc->base.is_jmp = DISAS_EXIT; } -#endif return true; } From patchwork Mon Jul 2 15:10:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140801 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp72755ljj; Mon, 2 Jul 2018 08:16:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe5eW2ILiGnSUSZae5fGpfVVBe6tlva+4mGACKyD2KVydgkf9tzFBIsQNFkGZILtc5bE45Q X-Received: by 2002:a0c:e60e:: with SMTP id z14-v6mr11816897qvm.244.1530544594898; Mon, 02 Jul 2018 08:16:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530544594; cv=none; d=google.com; s=arc-20160816; b=GmcWx+TbCuj/pk2ZcBX45COAHggbOhzulX6/iN0ULk6cIYBWb8ZBk3LRIwVwjr61dv 6csD88QLgM8VgE3H1rZDhu6qVY/Khq9cfOsQscvV6eYCZ7YmPC7gkIbXO5Qr1b35OLjq 3CjGV4vQPYx/hjHm1+jnDdtHMv5Z02lhEU8j8aCVSyaYVA7AwKdFvFhVF8xaS35UFXVB UhCSO7ooEXPdBFvlC1FH7KIig5civ365dfQCXD8yG/YZ68D8wHYYvlfRJ/PKv2c/7pB0 YH669Mitw/b2u2c9BnHgubXLNb3w5DfK60yWpjwd2n00NS3Ef/rjn0rzt3AO0ajAlMFd 58BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=/JZVefHUUHKkgVlCuUjnyf/d1zk468BKGk0xxZUY1uE=; b=WLL+XAV/HkWleOVCz3hOmkitn/hWwJIm3nlC1dtyS8wfuwvB6SDGx/lDpmyRG03r0g zdXpbbGCOnd/eGFK0D+hVouIG4Ve1Pt0gjeVdi7s48Qq/nbf0axq3vL1y1ScnZLQc6Vw H1ybdf4x4uYP87ltmV1FBe/M1/ZnS3xxB3lxWQy1J5FWLMMNLi0iTDUVvKrZUhmbGss5 iC3HeS8oa+BVimk4s8nSnx62Na6xKdvgCeG+1yMbqBuwwZbUAlS+tQVQV3p6rlPsr8qV NxIE7f46PKQSp9e6ZWRgS5IVLJ0ziJW3QthePLNtRMBTMw/C0ERn6wGBa7pZOvEZzu3i AHlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=XbaEK4q2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m38-v6si4694476qtb.84.2018.07.02.08.16.34 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:16:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=XbaEK4q2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33461 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0Z8-0007ZN-AE for patch@linaro.org; Mon, 02 Jul 2018 11:16:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0Tr-00047K-7P for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0Tm-0007tH-AD for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:07 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:41670) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0Tm-0007sn-4E for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:02 -0400 Received: by mail-pl0-x242.google.com with SMTP id w8-v6so8106837ply.8 for ; Mon, 02 Jul 2018 08:11:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/JZVefHUUHKkgVlCuUjnyf/d1zk468BKGk0xxZUY1uE=; b=XbaEK4q2kgaq6Gz7+BgDFAZVMMcpSYUy9/kbsO3LcTrg4zn5jhhQjDSd5AuoCaHOGU E5ka4P14F6wfOYbkwsOY6p/yN1C8lMv0uAaYO0x5z1txFspCfkue0OGAfSh8xCDzNcqs 1gX+tlCINNVk2o0kGeYvxoLUKznwwVEoPakAdwX85fqt8C//C1VAR9r7OTQw1N2pUOp7 Dt1L4Z9MBlqxv/w5/kJvVnZ0rC3NLcWDFRBywB5Vu+0I/VrQ16HZYwaFvmsygswwoIQO jzs7oQfzMFEdpQ1conw4IXsxrVtOfugL4ZKsZIfTLjy+xEhUSaQzcBJzI0lJzksovp6C mvvQ== 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=/JZVefHUUHKkgVlCuUjnyf/d1zk468BKGk0xxZUY1uE=; b=icsTvLAJSQK7iT22RePq6WeCzpbjaqTDa/EgXg7qVeb+M6CkZwsVN+6P+dJFm1kaIr G2RtqhE59LAhHhzX0laqVomgQYG8jVvs0ooEAG92ZvFg9+Xm3CQZhq7lDcUQxEBGlnJO esJ4VPSPFMej1PzoRWqswWJcbzzbwEdKPwD0CxEbmpVQpT0CHu9qX/OyaKxAhrdxUA7l J9sMPvXPgFAdDeRwwKr6/n6yNCZbqlGFVoM+va1Kf6JC8o8UdEx67YBbDtSFUA3Mg27p WKO4Oms8vhpoPFnwCe1bumyp09JDppSmSx7iep7vEnKcKo2zV4Uiizjs1Z2t+dEjXc1B VjRw== X-Gm-Message-State: APt69E3QPecjUmvg4T8l4OLAfVdyDGrLgkYSq/QPTiUiNt5sCTlYFGuQ MEWb1naatUch8/HRACgKN3k= X-Received: by 2002:a17:902:9a06:: with SMTP id v6-v6mr26211447plp.21.1530544261296; Mon, 02 Jul 2018 08:11:01 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id w10-v6sm4658053pfg.187.2018.07.02.08.11.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:11:00 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:07 +0900 Message-Id: <20180702151023.24532-10-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PULL v2 09/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson A store to SR changes interrupt state, which should return to the main loop to recognize that state. Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- target/openrisc/translate.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) -- 2.17.0 diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index db149986af..59605aacca 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -877,7 +877,22 @@ 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 = 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->delayed_branch) { + tcg_gen_mov_tl(cpu_pc, jmp_pc); + tcg_gen_discard_tl(jmp_pc); + } else { + tcg_gen_movi_tl(cpu_pc, dc->base.pc_next + 4); + } + dc->base.is_jmp = DISAS_EXIT; + + ti = tcg_const_i32(a->k); gen_helper_mtspr(cpu_env, cpu_R[a->a], cpu_R[a->b], ti); tcg_temp_free_i32(ti); } From patchwork Mon Jul 2 15:10:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140809 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp81383ljj; Mon, 2 Jul 2018 08:24:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcfjxdaKzY9oBNndSz83EYYwx4RRJlDg7ZWFId573ZddmWdvgc8tJU37ewVmJafaVNRf8U+ X-Received: by 2002:aed:3fc8:: with SMTP id w8-v6mr23744636qth.262.1530545088214; Mon, 02 Jul 2018 08:24:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530545088; cv=none; d=google.com; s=arc-20160816; b=oGDxUOCmE43K6eisVzLof36q7xktdv52AR+Z6QSyYcfTWzg4DLq9zLiHLErVOJX51z p7RQOvWOXg5u8g8t/Vvuy+xNJiP3o2g0mdJhh5tDp/YysMsTW4pLNI9zP2of9EIxqwbr 9yehskFj9/l9AH59fqi0WQ0sMcmiyxiJt+WQmeiPtCKmkcDuhKFe9n8TZ3RBFTdLzQL7 PvYX4zDl6vWN5GLDqStPIr0/XXP91xhL22rj87gG1g8VCHuQLMdgEo4Q5Y2TN1KS4G74 kD1ca5kT5AauIabVaLTWLyGGPtmuPBBA7MfTolqD9sHbTcgQ7ryy+EDHyCkGBW1SSBTZ aB/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=BpXhKplcmVzaEgYPHqOAQOcTQDA7dzSkA3kbaZ3R+rw=; b=CL/rslBssXKocBKBR9FPK112+7+fy9Bh+qpC0BlFxY2WWINa15lmyrGFTv1veHqoHo LC4GGt//JdJj6tjW30iKadXYdjF+4hvouuDgMeh9vTnOfy8Q9dq1SqfHMGyjl5QgFZPU qoSbvM5OO3AmqfLuGWmv6Tmk+7VGiqix/ydnT1tFqrBj/KVh6X7ccefXdobE4sGlANaZ T8cv652a3rIs3PvIV1hHJmX9a4W5khWzDz4d21b1u1nyhzpfRl/uOai5m5Nxzyix+zLH 85LGH890bM0ufAoMQj504ZSUqKI7wncR7ZYPK5HmfOT2MliF2Un7QBxdWyXf3mynhVMc X/Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=pzzVBlXN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m188-v6si5750498qkd.89.2018.07.02.08.24.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:24:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=pzzVBlXN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33511 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0h5-0005Qq-Ar for patch@linaro.org; Mon, 02 Jul 2018 11:24:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0Tr-00047L-8Q for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0To-0007ve-Gb for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:07 -0400 Received: from mail-pl0-x22d.google.com ([2607:f8b0:400e:c01::22d]:35517) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0To-0007v2-An for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:04 -0400 Received: by mail-pl0-x22d.google.com with SMTP id k1-v6so8099958plt.2 for ; Mon, 02 Jul 2018 08:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BpXhKplcmVzaEgYPHqOAQOcTQDA7dzSkA3kbaZ3R+rw=; b=pzzVBlXNg9ATc2Q/woK5UySSDlCXcOgBBnUmhvZuTuIwdQl5ix1qP32zleCmJbxBNC w0G1rhW60Y1nHXkasW6bKQjrev/9Suy4jsYeW8G95me7W05gyZuwcxhpWUvgRaEDB4dP IOGcle1ceRlgpR20qdW1VhTTAwScg6EuVkd2nUlYH07iRSL3bG6dSr5UM8G1bSOCRCWN hXLPVnw4WmMuEHMphBZuQNeHLQ7vLD55aTjOWtvoujJjNJFP4f6QmBUi+V21bUu2vAeD m/Ma2dCrsQ3fbZ9ZyW5nQcDcr1oBg3vcT7BwlONT07ydCjhvDMR3X5tCGfwFJLwPLxeo 20IA== 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=BpXhKplcmVzaEgYPHqOAQOcTQDA7dzSkA3kbaZ3R+rw=; b=g8mpOFI6+RknFd6gAFZulJZS+hhU9AkjQmLLRQHjB0NiPYsWJXg19ihYn9lax9VG9i rsdxRNjkry6Pas97jbSOfbA2PNKNjXUofpljrPfqCrASoexOiifRGyvSbQaPMrkMqSCI kSoo0kSOQcGbMsdQ00lYMSV8XVhXCxNK2UZKVDnvgUbgTUuHPPaA7HO221c1E9tKswAt jITjdOk0RG924hHQ6JXDuczZYZvunBsA0gei5jxUK+Ry+dB5elaDyAB+3fpCj7ejMpw5 9d7SdbjhqG8uZkZvhEFwFmSmTvSc0/xn25eMOU3vQqkYiGYCM4zLY56m0+DF0+eN5SMx zlgw== X-Gm-Message-State: APt69E1LBnUACKrp7GpIKJQf0S/TarFg1hFb86idGvVeeMv0k2KJn/D1 FsFYmFDUkxafj1cSIDEIGF0igDus X-Received: by 2002:a17:902:7e43:: with SMTP id a3-v6mr25495382pln.151.1530544263594; Mon, 02 Jul 2018 08:11:03 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id q77-v6sm44327351pfk.152.2018.07.02.08.11.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:11:03 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:08 +0900 Message-Id: <20180702151023.24532-11-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::22d Subject: [Qemu-devel] [PULL v2 10/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson 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é Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- target/openrisc/helper.h | 4 ++-- target/openrisc/sys_helper.c | 9 +++------ target/openrisc/translate.c | 16 +++++++++------- 3 files changed, 14 insertions(+), 15 deletions(-) -- 2.17.0 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) /* 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 2f337363ec..2c959f63f4 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -27,13 +27,11 @@ #define TO_SPR(group, number) (((group) << 11) + (number)) -void HELPER(mtspr)(CPUOpenRISCState *env, - target_ulong ra, target_ulong rb, target_ulong offset) +void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) { #ifndef CONFIG_USER_ONLY OpenRISCCPU *cpu = openrisc_env_get_cpu(env); CPUState *cs = CPU(cpu); - int spr = (ra | offset); int idx; switch (spr) { @@ -202,13 +200,12 @@ void HELPER(mtspr)(CPUOpenRISCState *env, #endif } -target_ulong HELPER(mfspr)(CPUOpenRISCState *env, - target_ulong rd, target_ulong ra, uint32_t offset) +target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd, + target_ulong spr) { #ifndef CONFIG_USER_ONLY OpenRISCCPU *cpu = openrisc_env_get_cpu(env); CPUState *cs = CPU(cpu); - int spr = (ra | offset); int idx; switch (spr) { diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 59605aacca..64b5e84630 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -865,9 +865,10 @@ static bool trans_l_mfspr(DisasContext *dc, arg_l_mfspr *a, uint32_t insn) if (is_user(dc)) { gen_illegal_exception(dc); } else { - TCGv_i32 ti = tcg_const_i32(a->k); - gen_helper_mfspr(cpu_R[a->d], cpu_env, cpu_R[a->d], cpu_R[a->a], ti); - tcg_temp_free_i32(ti); + TCGv spr = 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; } @@ -877,7 +878,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; /* For SR, we will need to exit the TB to recognize the new * exception state. For NPC, in theory this counts as a branch @@ -892,9 +893,10 @@ static bool trans_l_mtspr(DisasContext *dc, arg_l_mtspr *a, uint32_t insn) } dc->base.is_jmp = DISAS_EXIT; - ti = 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 = 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); } return true; } From patchwork Mon Jul 2 15:10:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140811 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp81821ljj; Mon, 2 Jul 2018 08:25:18 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeK+k81k3I3OP6N5D5QPev4HjexAuW1zMf1C2nYoOV+1lsFp2F2b2G5YelX2fq0dl74N5mf X-Received: by 2002:ac8:30cd:: with SMTP id w13-v6mr22660970qta.247.1530545118656; Mon, 02 Jul 2018 08:25:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530545118; cv=none; d=google.com; s=arc-20160816; b=SPJKKgoot5GUKis/xTfxgxdG8xTfwhlLnzP1srvrX+v/7nuJUEpnAODPGXsl7UW/KD iYORafm+RXUAjxguhpyl3HOjQhX/OGKHBMpOTA6jomP17+2P7c0FTu4IAeYAm1RHnQMB kHuA9cTEEvyMUezgQlAHzBG6c6Lfuaq1yyiTmPFf1QhRUbsVhVDd1oAG7IGulzeTSqLX BEze4Q7eyF4gFDt7WSJ4ayZUclYOCc7ShEQG/V5/36dCtoP8ki9JYm77D+ROnfxpfHVm H5FH5oBtAjkSIB00cAMyjn2f+k5HsQQUm8jn3Ope+lF2IO7e5XRD8t2DnaN7b73ZEQmO xgCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=v5FrLyXryFF/bWUCf/i79zoVM08Dt+CkMsrtY9ZC8PQ=; b=LONwpaGUTxgZ52mWtRwudntvUjEvxNTi+MQt94nZn8sYUvOKYLfwWRHA+bQDgYS/sx 0RtO5z04BRqnqOciFHx2cZ/qe8/LQUvhZnWavXYZQDNZWDA0cdLtiEdfVe/7A2P5MtCg TqexnnO/SYYeYfUwYPudvcmN3+HCrrK2Litg8zF85a1TXRVN8+9m5cl3jtL/6P6KX6ha rlsNmtqXmw6NIw1biNZB74WPC6ojQcndeUgpHXDhK8Lp0UnfsG8LF0ddXm/VYHY/oa8q u+e7R2stL1S9Fl9Uwvj6L8bXIVX8tPvW2ESie0/qtuVLmgZ+2em41DjX+ZgB40aE00aT TQaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Psy5FoIp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m188-v6si5751376qkd.89.2018.07.02.08.25.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:25:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Psy5FoIp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0hZ-0006gQ-SY for patch@linaro.org; Mon, 02 Jul 2018 11:25:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0Tt-0004B9-EF for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0Tr-0007xH-7W for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:09 -0400 Received: from mail-pf0-x235.google.com ([2607:f8b0:400e:c00::235]:43777) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0Tq-0007wo-Ui for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:07 -0400 Received: by mail-pf0-x235.google.com with SMTP id y8-v6so7653415pfm.10 for ; Mon, 02 Jul 2018 08:11:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v5FrLyXryFF/bWUCf/i79zoVM08Dt+CkMsrtY9ZC8PQ=; b=Psy5FoIpGZ3KsUt+fBi2VFkm8Ohzb4FEx+T5Z9Bj67u6WDH+ETTxJTVGWbtZWajIGX qo66sLd62jBesnteRFvRrodAFhOjCBxIVt4iWHRoHDKQp5T9rfI4ILPRSh3/va154115 i04a4Lvq3qEg+qfuhhcT/ApvMVYyusUYWeIhmEU7f9Jnh1R2bpSd/mw+BqfJ8Nw0npNV 1qM5pZjqd3aL15iOPCkrd0swYmsowSuiK+9mSsLK8tAxek2/KA7m5AR/a5oh6DU4GV4n SOJwteFj/MeM22p/2pTHHrgmpxHBGu7puVm19scIHUopaawLJSJ+Bz/eMignQNq4pED3 bM+A== 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=v5FrLyXryFF/bWUCf/i79zoVM08Dt+CkMsrtY9ZC8PQ=; b=AD/mFKh7pMZYDB7mNvoNoHlDqEQzyi4oBb1bXapYsZrVE/vUPMua5rXNLGt3pgcD4E SwKdOVSZmZaFQEizVeN31FK1ps0U57BpWHG3ZCDO3PbKWae/ZB22YSDLbkjMCiSmNX87 1xAGfo1TO03/XIHp6bBOicaQnsyfs9Lynt+dV4YOoGtXzgKdhJq2fjVcjgr8K4kCQEih 11E1aHMplYwh7sjJLboqTTvgV+KataahJ40fowJOm7mCN0wF1sSDgqeFhd1vT7/n7obc y/V4DEDHmBNHQmOZ+/MdHP40Oupf2Ds0GVJF/KZyiOyJl+xx15DnWVtD3cKuKfiD3irI h0Ag== X-Gm-Message-State: APt69E3yGe4wigZ7AXLBLA2S5c8XedOb7lEzDwIPm460srnZB0Yzgf+z 9P2DOKtdOPB+Gf1fQuTNrng= X-Received: by 2002:a65:52cc:: with SMTP id z12-v6mr12837234pgp.69.1530544266044; Mon, 02 Jul 2018 08:11:06 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id i188-v6sm17250167pfc.3.2018.07.02.08.11.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:11:05 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:09 +0900 Message-Id: <20180702151023.24532-12-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::235 Subject: [Qemu-devel] [PULL v2 11/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson 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 Signed-off-by: Stafford Horne --- 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(-) -- 2.17.0 diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index c871d6bfe1..96b7f58659 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -301,6 +301,10 @@ typedef struct CPUOpenRISCState { uint32_t dflag; /* In delay slot (boolean) */ +#ifndef CONFIG_USER_ONLY + CPUOpenRISCTLBContext tlb; +#endif + /* Fields up to this point are cleared by a CPU reset */ struct {} end_reset_fields; @@ -310,8 +314,6 @@ typedef struct CPUOpenRISCState { uint32_t cpucfgr; /* CPU configure register */ #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 25351d5de3..2d0b55afa9 100644 --- a/target/openrisc/interrupt.c +++ b/target/openrisc/interrupt.c @@ -63,8 +63,8 @@ void openrisc_cpu_do_interrupt(CPUState *cs) env->sr &= ~SR_TEE; env->pmr &= ~PMR_DME; env->pmr &= ~PMR_SME; - env->tlb->cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_nommu; - env->tlb->cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_nommu; + env->tlb.cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_nommu; + env->tlb.cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_nommu; env->lock_addr = -1; if (exception > 0 && exception < 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) #ifndef CONFIG_USER_ONLY if (cpu->env.sr & SR_DME) { - cpu->env.tlb->cpu_openrisc_map_address_data = + cpu->env.tlb.cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_data; } else { - cpu->env.tlb->cpu_openrisc_map_address_data = + cpu->env.tlb.cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_nommu; } if (cpu->env.sr & SR_IME) { - cpu->env.tlb->cpu_openrisc_map_address_code = + cpu->env.tlb.cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_code; } else { - cpu->env.tlb->cpu_openrisc_map_address_code = + cpu->env.tlb.cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_nommu; } 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) /* Restore MMU handlers */ if (env->sr & SR_DME) { - env->tlb->cpu_openrisc_map_address_data = + env->tlb.cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_data; } else { - env->tlb->cpu_openrisc_map_address_data = + env->tlb.cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_nommu; } if (env->sr & SR_IME) { - env->tlb->cpu_openrisc_map_address_code = + env->tlb.cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_code; } else { - env->tlb->cpu_openrisc_map_address_code = + env->tlb.cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_nommu; } @@ -77,10 +77,6 @@ static const VMStateDescription vmstate_cpu_tlb = { } }; -#define VMSTATE_CPU_TLB(_f, _s) \ - VMSTATE_STRUCT_POINTER(_f, _s, vmstate_cpu_tlb, CPUOpenRISCTLBContext) - - static int get_sr(QEMUFile *f, void *opaque, size_t size, VMStateField *field) { CPUOpenRISCState *env = opaque; @@ -143,7 +139,8 @@ static const VMStateDescription vmstate_env = { VMSTATE_UINT32(fpcsr, CPUOpenRISCState), VMSTATE_UINT64(mac, CPUOpenRISCState), - VMSTATE_CPU_TLB(tlb, CPUOpenRISCState), + VMSTATE_STRUCT(tlb, CPUOpenRISCState, 1, + vmstate_cpu_tlb, CPUOpenRISCTLBContext), 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 = vpn & ITLB_MASK; int right = 0; - if ((cpu->env.tlb->itlb[0][idx].mr >> TARGET_PAGE_BITS) != vpn) { + if ((cpu->env.tlb.itlb[0][idx].mr >> TARGET_PAGE_BITS) != 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; } 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 |= PAGE_EXEC; } } else { - if (cpu->env.tlb->itlb[0][idx].tr & UXE) { + if (cpu->env.tlb.itlb[0][idx].tr & UXE) { right |= PAGE_EXEC; } } @@ -67,7 +67,7 @@ int cpu_openrisc_get_phys_code(OpenRISCCPU *cpu, return TLBRET_BADADDR; } - *physical = (cpu->env.tlb->itlb[0][idx].tr & TARGET_PAGE_MASK) | + *physical = (cpu->env.tlb.itlb[0][idx].tr & TARGET_PAGE_MASK) | (address & (TARGET_PAGE_SIZE-1)); *prot = right; return TLBRET_MATCH; @@ -81,25 +81,25 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu, int idx = vpn & DTLB_MASK; int right = 0; - if ((cpu->env.tlb->dtlb[0][idx].mr >> TARGET_PAGE_BITS) != vpn) { + if ((cpu->env.tlb.dtlb[0][idx].mr >> TARGET_PAGE_BITS) != 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; } 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 |= PAGE_READ; } - if (cpu->env.tlb->dtlb[0][idx].tr & SWE) { + if (cpu->env.tlb.dtlb[0][idx].tr & SWE) { right |= PAGE_WRITE; } } else { - if (cpu->env.tlb->dtlb[0][idx].tr & URE) { + if (cpu->env.tlb.dtlb[0][idx].tr & URE) { right |= PAGE_READ; } - if (cpu->env.tlb->dtlb[0][idx].tr & UWE) { + if (cpu->env.tlb.dtlb[0][idx].tr & UWE) { right |= PAGE_WRITE; } } @@ -111,7 +111,7 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu, return TLBRET_BADADDR; } - *physical = (cpu->env.tlb->dtlb[0][idx].tr & TARGET_PAGE_MASK) | + *physical = (cpu->env.tlb.dtlb[0][idx].tr & TARGET_PAGE_MASK) | (address & (TARGET_PAGE_SIZE-1)); *prot = right; return TLBRET_MATCH; @@ -126,10 +126,10 @@ static int cpu_openrisc_get_phys_addr(OpenRISCCPU *cpu, if (rw == MMU_INST_FETCH) { /* ITLB */ *physical = 0; - ret = cpu->env.tlb->cpu_openrisc_map_address_code(cpu, physical, + ret = cpu->env.tlb.cpu_openrisc_map_address_code(cpu, physical, prot, address, rw); } else { /* DTLB */ - ret = cpu->env.tlb->cpu_openrisc_map_address_data(cpu, physical, + ret = cpu->env.tlb.cpu_openrisc_map_address_data(cpu, physical, prot, address, rw); } @@ -247,9 +247,7 @@ hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) void cpu_openrisc_mmu_init(OpenRISCCPU *cpu) { - cpu->env.tlb = g_malloc0(sizeof(CPUOpenRISCTLBContext)); - - cpu->env.tlb->cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_nommu; - cpu->env.tlb->cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_nommu; + cpu->env.tlb.cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_nommu; + cpu->env.tlb.cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_nommu; } #endif diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index 2c959f63f4..ff315f6f1a 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 = + env->tlb.cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_data; } else { - env->tlb->cpu_openrisc_map_address_data = + env->tlb.cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_nommu; } if (env->sr & SR_IME) { - env->tlb->cpu_openrisc_map_address_code = + env->tlb.cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_code; } else { - env->tlb->cpu_openrisc_map_address_code = + env->tlb.cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_nommu; } break; @@ -101,14 +101,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 = 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[0][idx].mr & TARGET_PAGE_MASK); } - env->tlb->dtlb[0][idx].mr = rb; + env->tlb.dtlb[0][idx].mr = rb; break; case TO_SPR(1, 640) ... TO_SPR(1, 640+DTLB_SIZE-1): /* DTLBW0TR 0-127 */ idx = spr - TO_SPR(1, 640); - env->tlb->dtlb[0][idx].tr = rb; + env->tlb.dtlb[0][idx].tr = 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 */ @@ -120,14 +120,14 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) case TO_SPR(2, 512) ... TO_SPR(2, 512+ITLB_SIZE-1): /* ITLBW0MR 0-127 */ idx = 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[0][idx].mr & TARGET_PAGE_MASK); } - env->tlb->itlb[0][idx].mr = rb; + env->tlb.itlb[0][idx].mr = rb; break; case TO_SPR(2, 640) ... TO_SPR(2, 640+ITLB_SIZE-1): /* ITLBW0TR 0-127 */ idx = spr - TO_SPR(2, 640); - env->tlb->itlb[0][idx].tr = rb; + env->tlb.itlb[0][idx].tr = 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 */ @@ -259,11 +259,11 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd, case TO_SPR(1, 512) ... TO_SPR(1, 512+DTLB_SIZE-1): /* DTLBW0MR 0-127 */ idx = spr - TO_SPR(1, 512); - return env->tlb->dtlb[0][idx].mr; + return env->tlb.dtlb[0][idx].mr; case TO_SPR(1, 640) ... TO_SPR(1, 640+DTLB_SIZE-1): /* DTLBW0TR 0-127 */ idx = spr - TO_SPR(1, 640); - return env->tlb->dtlb[0][idx].tr; + return env->tlb.dtlb[0][idx].tr; case TO_SPR(1, 768) ... TO_SPR(1, 895): /* DTLBW1MR 0-127 */ case TO_SPR(1, 896) ... TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ @@ -275,11 +275,11 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd, case TO_SPR(2, 512) ... TO_SPR(2, 512+ITLB_SIZE-1): /* ITLBW0MR 0-127 */ idx = spr - TO_SPR(2, 512); - return env->tlb->itlb[0][idx].mr; + return env->tlb.itlb[0][idx].mr; case TO_SPR(2, 640) ... TO_SPR(2, 640+ITLB_SIZE-1): /* ITLBW0TR 0-127 */ idx = spr - TO_SPR(2, 640); - return env->tlb->itlb[0][idx].tr; + return env->tlb.itlb[0][idx].tr; case TO_SPR(2, 768) ... TO_SPR(2, 895): /* ITLBW1MR 0-127 */ case TO_SPR(2, 896) ... TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ From patchwork Mon Jul 2 15:10:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140806 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp78633ljj; Mon, 2 Jul 2018 08:22:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc3JzxLg+XFoEri/VF1nnBWYzg6KJbOGp28V9CwyCkB71g+MNCzmJRYdhGQRZknJTJ8gH/i X-Received: by 2002:ac8:30e3:: with SMTP id w32-v6mr24309917qta.280.1530544921378; Mon, 02 Jul 2018 08:22:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530544921; cv=none; d=google.com; s=arc-20160816; b=z34Sav7/ZI2yan3cxEdmlt6YcBzQpOW/5jzemNl/MvclRYWUNsUK3HugNJGLnv9zc+ zXKHfV1ELp3pXbT/7+eg3H6iQrMY2HBfGfOeCPJ3r2tHdCQhxLLVFlrm527lm9xf3J0d XcxviSfXaURKOjq4T+vkSofsErXjaTy65Y8dIct3Ktu4tKVbCYwcGPLyvrL8KmgB+mTX n9KJ1PAd47BkiYKLcpj/VpNSQekFbt3PK1ueEAHwF9lnHGoL3PdMjhN5v93Gj5ggJq/R z7O/hQ7frZkZf4zroOM55eU8mjGrD/I7UT8a0vuiNPc6arvLuvjx7FgIAiIr1O96GIg+ yboQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=u+YJliszgwkY8rbcE/JLOHssHRTMCNlXvsTX0k06qok=; b=ZpzKWxZxf8hETSEk5eWlMXmRnx3uZN6ciT8B12DSBzfqiZ83B9Zhvjrm0P1VryqAMk RdzBl4l1WuHKE+nxsvShwAoGB3vVw7JJhnA13wDSp79MuQwIknKhK85B4bms4BG9ob+l nAOZbLxXjEndRvnkcuvI8rzkwA38joV4Aax6HwFzHAY55a4FiAEAGQggY1bVTeT62i2r hQnblbBotdWoX3IKsVIMMAmMygHGpbTqU92ipANHn9sIFjQA6W13hvGgfZwOwa4HV5UR lgSr+W7/duomRS9KJ5cCXGNkJbJE13pDpPynSbOumn1LGbgvu7Sp40r85JhFrvxE4zfe bbaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="lJCbrC/+"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l1-v6si668858qvm.176.2018.07.02.08.22.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:22:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="lJCbrC/+"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33501 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0eO-00046R-OC for patch@linaro.org; Mon, 02 Jul 2018 11:22:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0Tv-0004Dj-Tg for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0Tu-00081J-0I for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:11 -0400 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]:42895) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0Tt-000807-Nv for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:09 -0400 Received: by mail-pf0-x234.google.com with SMTP id v9-v6so6527625pff.9 for ; Mon, 02 Jul 2018 08:11:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=u+YJliszgwkY8rbcE/JLOHssHRTMCNlXvsTX0k06qok=; b=lJCbrC/+lgH/VLUeUnBSe8bMPOxC6ZWqNwijnWw8xt3ADsP2Cch6b/tA+Kn4ljs/ty oQ0xyMV8i6zQ4nvU5THRsX6nK7sS5/w8uznJNRC3wOQ/lKxijVbuXsayc49RxdTc+Fz8 XLjVqQvyraNYJjCFZBb07expaoshjyxvn0VTcISgSZROhLmQ+4a9H5a5kOZBAbl+nAOU 1gR7UrgfHs1xb76O9IssLO5oVue9euYh68oQrzzNIPmdhuTUKneCh5F9FZufwIzP4m6o lwloZcGCYQ0mcZJ0QwSBfrTpRir2taky4FbjocJTIrXekd2vUPzwT3G/APEU8PhG90rY lx3w== 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=u+YJliszgwkY8rbcE/JLOHssHRTMCNlXvsTX0k06qok=; b=F0a9F/UXE4uFztJuDfrcfVXkEK4cMt0B16eCGbfDqV484sc1Lh5Q5VKHSjVxDAHck0 XSbye1PMiOkRh5pGebcKTdJvINWDKirICg36LsjIvdEc9fix3+9ehC2KMcsUNyj4Ya7m RgC5y+eRbzyhAtD/dnhbIVSh9msS6QQPlFlWkJPp1J89sphopD14H04DB39ZiZQT0d1w eY98QAZs83ZMj8JQZsgTjrE8IsRUFzk3JGGhVnD5vs0ei1unanoyCLqXLLKxZXWQAIMG roxQtvXCXyiuIJN+9k8FEywr+DjEdaD9urCazjppCmumzqZxU8hMYH3Gda83EGKLdWic LKbg== X-Gm-Message-State: APt69E0SoP1aIVvpZE+Xu3BKbvHH88ydYc+az64CtRwKWO6i95b6sTA1 d8Hp+qIeCLwFoh564zYTv+s= X-Received: by 2002:a62:3a9d:: with SMTP id v29-v6mr16544037pfj.215.1530544268920; Mon, 02 Jul 2018 08:11:08 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id y3-v6sm37429549pge.29.2018.07.02.08.11.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:11:08 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:10 +0900 Message-Id: <20180702151023.24532-13-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> 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] [PULL v2 12/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson 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 Signed-off-by: Stafford Horne --- target/openrisc/cpu.c | 4 -- target/openrisc/cpu.h | 11 ----- target/openrisc/interrupt.c | 2 - target/openrisc/interrupt_helper.c | 25 ++--------- target/openrisc/machine.c | 26 ------------ target/openrisc/mmu.c | 68 +++++++++++++----------------- target/openrisc/sys_helper.c | 15 ------- 7 files changed, 32 insertions(+), 119 deletions(-) -- 2.17.0 diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index fa8e342ff7..b92de51ecf 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -92,10 +92,6 @@ static void openrisc_cpu_initfn(Object *obj) OpenRISCCPU *cpu = OPENRISC_CPU(obj); cs->env_ptr = &cpu->env; - -#ifndef CONFIG_USER_ONLY - cpu_openrisc_mmu_init(cpu); -#endif } /* CPU models */ diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 96b7f58659..a27adad085 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -379,17 +379,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 #define OPENRISC_CPU_TYPE_SUFFIX "-" TYPE_OPENRISC_CPU diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index 2d0b55afa9..23abcf29ed 100644 --- a/target/openrisc/interrupt.c +++ b/target/openrisc/interrupt.c @@ -63,8 +63,6 @@ void openrisc_cpu_do_interrupt(CPUState *cs) env->sr &= ~SR_TEE; env->pmr &= ~PMR_DME; env->pmr &= ~PMR_SME; - env->tlb.cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_nommu; - env->tlb.cpu_openrisc_map_address_code = &cpu_openrisc_get_phys_nommu; env->lock_addr = -1; if (exception > 0 && exception < 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 = (cpu->env.sr & (SR_SM | SR_IME | SR_DME)) ^ (cpu->env.esr & (SR_SM | SR_IME | SR_DME)); -#endif - cpu->env.pc = cpu->env.epcr; - cpu_set_sr(&cpu->env, cpu->env.esr); - cpu->env.lock_addr = -1; - -#ifndef CONFIG_USER_ONLY - if (cpu->env.sr & SR_DME) { - cpu->env.tlb.cpu_openrisc_map_address_data = - &cpu_openrisc_get_phys_data; - } else { - cpu->env.tlb.cpu_openrisc_map_address_data = - &cpu_openrisc_get_phys_nommu; - } - - if (cpu->env.sr & SR_IME) { - cpu->env.tlb.cpu_openrisc_map_address_code = - &cpu_openrisc_get_phys_code; - } else { - cpu->env.tlb.cpu_openrisc_map_address_code = - &cpu_openrisc_get_phys_nommu; - } - if (need_flush_tlb) { CPUState *cs = CPU(cpu); tlb_flush(cs); } #endif + cpu->env.pc = cpu->env.epcr; + cpu->env.lock_addr = -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" -static int env_post_load(void *opaque, int version_id) -{ - CPUOpenRISCState *env = opaque; - - /* Restore MMU handlers */ - if (env->sr & SR_DME) { - env->tlb.cpu_openrisc_map_address_data = - &cpu_openrisc_get_phys_data; - } else { - env->tlb.cpu_openrisc_map_address_data = - &cpu_openrisc_get_phys_nommu; - } - - if (env->sr & SR_IME) { - env->tlb.cpu_openrisc_map_address_code = - &cpu_openrisc_get_phys_code; - } else { - env->tlb.cpu_openrisc_map_address_code = - &cpu_openrisc_get_phys_nommu; - } - - - return 0; -} - static const VMStateDescription vmstate_tlb_entry = { .name = "tlb_entry", .version_id = 1, @@ -102,7 +77,6 @@ static const VMStateDescription vmstate_env = { .name = "env", .version_id = 6, .minimum_version_id = 6, - .post_load = env_post_load, .fields = (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 #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 = address; *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; return TLBRET_MATCH; } -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 = address >> TARGET_PAGE_BITS; int idx = 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 |= PAGE_EXEC; } @@ -62,7 +59,6 @@ int cpu_openrisc_get_phys_code(OpenRISCCPU *cpu, right |= PAGE_EXEC; } } - if ((rw & 2) && ((right & PAGE_EXEC) == 0)) { return TLBRET_BADADDR; } @@ -73,9 +69,8 @@ int cpu_openrisc_get_phys_code(OpenRISCCPU *cpu, return TLBRET_MATCH; } -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 = address >> TARGET_PAGE_BITS; int idx = 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 |= PAGE_READ; } @@ -117,20 +111,24 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu, return TLBRET_MATCH; } -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 = TLBRET_MATCH; - - if (rw == MMU_INST_FETCH) { /* ITLB */ - *physical = 0; - ret = cpu->env.tlb.cpu_openrisc_map_address_code(cpu, physical, - prot, address, rw); - } else { /* DTLB */ - ret = cpu->env.tlb.cpu_openrisc_map_address_data(cpu, physical, - prot, address, rw); + bool supervisor = (cpu->env.sr & SR_SM) != 0; + int ret; + + /* Assume nommu results for a moment. */ + ret = get_phys_nommu(physical, prot, address); + + /* Overwrite with TLB lookup if enabled. */ + if (rw == MMU_INST_FETCH) { + if (cpu->env.sr & SR_IME) { + ret = get_phys_code(cpu, physical, prot, address, rw, supervisor); + } + } else { + if (cpu->env.sr & SR_DME) { + ret = get_phys_data(cpu, physical, prot, address, rw, supervisor); + } } return ret; @@ -186,8 +184,7 @@ int openrisc_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, hwaddr physical = 0; int prot = 0; - ret = cpu_openrisc_get_phys_addr(cpu, &physical, &prot, - address, rw); + ret = get_phys_addr(cpu, &physical, &prot, address, rw); if (ret == 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) /* Check memory for any kind of address, since during debug the gdb can ask for anything, check data tlb for address */ - miss = cpu_openrisc_get_phys_addr(cpu, &phys_addr, &prot, addr, 0); + miss = get_phys_addr(cpu, &phys_addr, &prot, addr, 0); /* Check instruction tlb */ if (miss) { - miss = cpu_openrisc_get_phys_addr(cpu, &phys_addr, &prot, addr, - MMU_INST_FETCH); + miss = get_phys_addr(cpu, &phys_addr, &prot, addr, MMU_INST_FETCH); } /* Last, fall back to a plain address */ if (miss) { - miss = cpu_openrisc_get_phys_nommu(cpu, &phys_addr, &prot, addr, 0); + miss = get_phys_nommu(&phys_addr, &prot, addr); } 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 = &cpu_openrisc_get_phys_nommu; - cpu->env.tlb.cpu_openrisc_map_address_data = &cpu_openrisc_get_phys_nommu; -} #endif diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index ff315f6f1a..9b4339b34e 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -60,21 +60,6 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) tlb_flush(cs); } cpu_set_sr(env, rb); - if (env->sr & SR_DME) { - env->tlb.cpu_openrisc_map_address_data = - &cpu_openrisc_get_phys_data; - } else { - env->tlb.cpu_openrisc_map_address_data = - &cpu_openrisc_get_phys_nommu; - } - - if (env->sr & SR_IME) { - env->tlb.cpu_openrisc_map_address_code = - &cpu_openrisc_get_phys_code; - } else { - env->tlb.cpu_openrisc_map_address_code = - &cpu_openrisc_get_phys_nommu; - } break; case TO_SPR(0, 18): /* PPC */ From patchwork Mon Jul 2 15:10:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140807 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp78744ljj; Mon, 2 Jul 2018 08:22:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcqr7o4zt04c6bpw7NDU3fJcVQdyvAOxNWN/0ts1A8lRKcb5ZMqvC6y/X5P64XFqnkOfG1G X-Received: by 2002:ac8:b45:: with SMTP id m5-v6mr24327122qti.335.1530544927292; Mon, 02 Jul 2018 08:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530544927; cv=none; d=google.com; s=arc-20160816; b=bHLZsTmMg8GfGyV/t4XhRQtG8Ga2sCvgRoZt4Ek5cfvV/zIQsxWM0SRkfWfkby3OKn Z+Yr9My7G59XOW5G2zVqfkLKIFuvqhPKkkl4j2wpgY1AnX3837/D+lDmvm6G8b9LmTKk xL2dEo3/EZDCx0vbzUNVtKsxeC+fWDEUBsq9O6Wqi9ygTyY5Y7FyXLPOjpYMPBfXr3ig sF8111EpDYRgoZxvetdIQp/X0ZMfkGqLSUKCVEz2wYrXNLBBjfoCFaR5cjNq7oQwQPBI tX0xZodaVdMabs7w1xGw8f5cPnNWdA2nHhYZXK0e170JG5G+g2mEQIN9nbT5KYDAaCQI 1DnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=MjW6dn4TOEFg6KjmG/SOXMb8i7HIhfULuWj/uo0zFYU=; b=0j37h1iuz+BOb5Swo4ME1wk7f8jhjy1XxRn69VAsmE9FKjrAw3H3Sox+yTNzkPWuUC 1HWE4AuKa4sO+DpiCT0kU5E0WvHrSsT8DBi6S5+CPgFA4904MhLWp4bf6mjZL+QVrUb+ Xgl1w16mmq9spvhokEo6FvIzeUXIWyPpMfRziEEdV4PzW277djfhmkOW/fwhWOil5Ooa OnhUX6txf4tl1zgotQD0Pa3YQxxbW3ShD6YstqrFfk8Oo9mj2OMkzXw5XrlN7ZtNoiv4 IiF20R/CV/c55TmjjvF9qnIkRnwtr4+fss32Q9sULHApKR/xBZ9a56U9XEElWq7VmD1Y Fu+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VZVKf5UI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 18-v6si3138994qtz.397.2018.07.02.08.22.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:22:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VZVKf5UI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0eS-0004AY-Kl for patch@linaro.org; Mon, 02 Jul 2018 11:22:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48840) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0Tx-0004FF-FL for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0Tw-00083T-91 for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:13 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:38333) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0Tw-00082k-32 for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:12 -0400 Received: by mail-pl0-x244.google.com with SMTP id d10-v6so8094179plo.5 for ; Mon, 02 Jul 2018 08:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MjW6dn4TOEFg6KjmG/SOXMb8i7HIhfULuWj/uo0zFYU=; b=VZVKf5UIgmQ9pycl07y5QsWkQDPsibcVrKUglpl6iLEXyYoLej5JPZbZaE5VjX8dEo 0AUuKYjo6I5jaF6lu1VbnOMJkHyMKC1NFNq37d1RRdODozcx8Q/vIChcoNWordY+kLUt rtTroHfat9fIo/DGA2c1/5sTyKN/KM3N//baoi4oAGdJOGAey2lyjziBS86tmwTHcxu6 xHPm2WlZa55bmRFJxq7KRwCvtTtW3Kqyy5RwIHvCAUwJxQEvKhwFy9w4+g53//NROhfS e+QegHk3rGBuGz7QS1HHc6SfUMjpu3KKjuXb5gQrmVfC3YtGWhC/AJgpgoGqI/IZEb8d SR8A== 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=MjW6dn4TOEFg6KjmG/SOXMb8i7HIhfULuWj/uo0zFYU=; b=Y7Vge5Wql2u0CT3EezIMobRRYil/hXu8ZkhOc4rCVZPtKL3Ga6swG9HuoiS4FGlUWf kWziNDZQCz7inCqw+HGMJexjNbNtmSxWZYT96l2zoRdhxjfoUVBQ399zmtEdP8oWqbNY thI7A6laJCm4a+Jio1vBTu2fjh6BUeKLIzpfUXB3NDRyYDJ281Bm8rsSXgmAcDpgFRug PSARvQTZSOt2C+KvXUXxpw3AKCrzJSpwB2FS6qaqB+tYXfdA4p/DYosJvP113ALFszFz Y1tz4AdmhiQW6K8lVbK1Zlq42UEMjH+3cwk5vc2reDr7w2QxTx0RWTDy+GkstxuGhddV cRfw== X-Gm-Message-State: APt69E3p+zRgrqjv9g2Ztajh4voSeKtU6t1MqxWxl2+DmGFPZO+CbDLr iRQRwMI9F7K7OMVbCBLSQhI= X-Received: by 2002:a17:902:6802:: with SMTP id h2-v6mr25920355plk.113.1530544271267; Mon, 02 Jul 2018 08:11:11 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id n5-v6sm32664439pgd.7.2018.07.02.08.11.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:11:10 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:11 +0900 Message-Id: <20180702151023.24532-14-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::244 Subject: [Qemu-devel] [PULL v2 13/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson With tlb_fill in mmu.c, we can simplify things further. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- target/openrisc/Makefile.objs | 2 +- target/openrisc/mmu.c | 11 ++++++++++ target/openrisc/mmu_helper.c | 40 ----------------------------------- 3 files changed, 12 insertions(+), 41 deletions(-) delete mode 100644 target/openrisc/mmu_helper.c -- 2.17.0 diff --git a/target/openrisc/Makefile.objs b/target/openrisc/Makefile.objs index 8b8a890c59..b5432f4684 100644 --- a/target/openrisc/Makefile.objs +++ b/target/openrisc/Makefile.objs @@ -1,7 +1,7 @@ obj-$(CONFIG_SOFTMMU) += machine.o obj-y += cpu.o exception.o interrupt.o mmu.o translate.o disas.o obj-y += exception_helper.o fpu_helper.o \ - interrupt_helper.o mmu_helper.o sys_helper.o + interrupt_helper.o sys_helper.o obj-y += gdbstub.o DECODETREE = $(SRC_PATH)/scripts/decodetree.py 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 = 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 = openrisc_cpu_handle_mmu_fault(cs, addr, size, access_type, mmu_idx); - - if (ret) { - /* Raise Exception. */ - cpu_loop_exit_restore(cs, retaddr); - } -} -#endif From patchwork Mon Jul 2 15:10:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140812 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp83930ljj; Mon, 2 Jul 2018 08:27:30 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdN8XOHndPWrNSWbruztktjOIdWNsWxNRUoDKBEuEwWKnqJYts4VoHMrtfLdc8gZ1yzUSFJ X-Received: by 2002:a37:9d58:: with SMTP id g85-v6mr21915548qke.230.1530545250785; Mon, 02 Jul 2018 08:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530545250; cv=none; d=google.com; s=arc-20160816; b=jihLoRV8BjiB4w03r5aWV+YaVaq4zKEBp1IBLcma+N4iYZ/RWnOY/qE6eSL7sY2cUz 1/O4xV5F1Eij2P5hxya1VyzrKbG0hD7VISMpLPqrKnvcsRe/624FFxBJEsd65RSx/HEx sxgIXeWKiTs10D+Ee1nsfAkrV3kcN4ZnowZyQmaezmMGEImLYMnk6m/TmmfbL+f0OFy4 Yxe7jGLIluDSC1LVERqixE20pOLE43cq+zvdTd659Pa4tMXavINFpwvFaFQ1hYy2Kue7 YEmwIaLkZPJoWnIjnSl7PlVwMSsJr0YABEfI+TEibOQGPys/LWgTXO94mvP+glV2KFTK 3Qmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=uw6bwresnlFax+lm1Y0j99UCglnsMaf1UI+tOn5Xj+c=; b=aM9jeonrVgrYZy9IocHm6frVHMyMAJFDMmUg4N0SNevO+LzhmsItUjN6fdlojif6NL XjwA8rdJxS9m1G+5Ege2++5/bGX1E7SDrXKVg63/zBKE4xG8iHL9dE32wUtZvNJk6Pw2 Y5NnxDXXQQgYZDMuUCi0v+icEAscoKBArW3KhHIrZyObbrQvzPTQIzzIwFmFiw2HOBW5 8hhZZg+IhTTocifbSSInsV6ZrfugXePwO8yVyDdoMTgzMUiruNGR2ZMaqWs4nCO3pc2z oYuOBpPWvAvBqXWh5fGWtuuXXPA03J8Uk2ue+CYJWugaX+0IXfBQdxYDK5qqrIbg0+zi ouiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZrPoKc2b; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 5-v6si216748qvq.156.2018.07.02.08.27.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:27:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZrPoKc2b; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33528 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0ji-0007nm-2C for patch@linaro.org; Mon, 02 Jul 2018 11:27:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0U2-0004Js-Gp for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0Ty-00085I-Nl for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:18 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:35151) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0Ty-00084m-FR for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:14 -0400 Received: by mail-pf0-x242.google.com with SMTP id a24-v6so4003893pfo.2 for ; Mon, 02 Jul 2018 08:11:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uw6bwresnlFax+lm1Y0j99UCglnsMaf1UI+tOn5Xj+c=; b=ZrPoKc2b4nN494LULbiSNpRBUODBTYdkvewelJENQpPzKr03+mtf7eJ45xvPRjyvHr F29Hl61bofP2MrtQr5nzCOJLjvA2Z8zexncjqWQXCQ+vUztUK6Ums5Xeh432V35juEz3 XOpXhtYdEpQTKpM1JDo6g/LkxJ0HFctfI1jk17bohR39ii9H0IoYrQWSkWpWVpsBXwvX X37QMQIXYmKrWDmr7bKaN8UaQaHsQ2AfCsNyklZoim+hVclxQ5+0IZojoHeTwotVodBw aznju8ld8pAXhCT5fTyqx4xEWhtiTBU9rlAKtJirZxf/+B5i/t/GDw4XaoHmKEVp+08x eCfw== 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=uw6bwresnlFax+lm1Y0j99UCglnsMaf1UI+tOn5Xj+c=; b=tD59DFgrnOmZpuPYxo31LIfK13tfDgpNV56KgCIBKjR1WJqAo9sRkrGeziVPmEA1DL iDJQKkwqAFbdCBzIw8yN3qj3NSmm56+N00deh1Ez0YNITdLzIv5tLoRx08xmE0Tyf9LL kfPQxOCT2Of3n2fpWkJosxRLLKQXNRYMxKUl2ODjhscDSVYieJqBB4fsN5o1swS30r82 SounQ/eoAp76u1pHVILfyz3U1mtdDvjBtx6dG7fHvkGaU/gKETYRlhDNoiWLJC/2hVAE cjNTJyy7wbSAZYNvsmHKTOzx30FndXDgiAgw24Pq/FUR4fJZDpKsMYNh/epye0X7l4xn AOww== X-Gm-Message-State: APt69E2eiuZ4QqN7r9GR7T6h/cTB+/uNoRrBC4SMMJTosOOBjubGCDJO fN6Oxg/JMFDyALqkaHRKRoWT+wii X-Received: by 2002:a63:614d:: with SMTP id v74-v6mr16193129pgb.328.1530544273594; Mon, 02 Jul 2018 08:11:13 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id c19-v6sm25380521pfn.182.2018.07.02.08.11.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:11:13 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:12 +0900 Message-Id: <20180702151023.24532-15-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PULL v2 14/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson 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é Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- 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(-) -- 2.17.0 diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index a27adad085..eaf6cdd40e 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -222,10 +222,8 @@ enum { /* TLB size */ enum { - DTLB_WAYS = 1, DTLB_SIZE = 64, DTLB_MASK = (DTLB_SIZE-1), - ITLB_WAYS = 1, ITLB_SIZE = 64, ITLB_MASK = (ITLB_SIZE-1), }; @@ -256,8 +254,8 @@ typedef struct OpenRISCTLBEntry { #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]; 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 = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (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 *physical, int *prot, int vpn = address >> TARGET_PAGE_BITS; int idx = vpn & ITLB_MASK; int right = 0; + uint32_t mr = cpu->env.tlb.itlb[idx].mr; + uint32_t tr = cpu->env.tlb.itlb[idx].tr; - if ((cpu->env.tlb.itlb[0][idx].mr >> TARGET_PAGE_BITS) != vpn) { + if ((mr >> TARGET_PAGE_BITS) != 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 |= PAGE_EXEC; } } else { - if (cpu->env.tlb.itlb[0][idx].tr & UXE) { + if (tr & UXE) { right |= PAGE_EXEC; } } @@ -63,8 +65,7 @@ static int get_phys_code(OpenRISCCPU *cpu, hwaddr *physical, int *prot, return TLBRET_BADADDR; } - *physical = (cpu->env.tlb.itlb[0][idx].tr & TARGET_PAGE_MASK) | - (address & (TARGET_PAGE_SIZE-1)); + *physical = (tr & TARGET_PAGE_MASK) | (address & ~TARGET_PAGE_MASK); *prot = right; return TLBRET_MATCH; } @@ -75,25 +76,27 @@ static int get_phys_data(OpenRISCCPU *cpu, hwaddr *physical, int *prot, int vpn = address >> TARGET_PAGE_BITS; int idx = vpn & DTLB_MASK; int right = 0; + uint32_t mr = cpu->env.tlb.dtlb[idx].mr; + uint32_t tr = cpu->env.tlb.dtlb[idx].tr; - if ((cpu->env.tlb.dtlb[0][idx].mr >> TARGET_PAGE_BITS) != vpn) { + if ((mr >> TARGET_PAGE_BITS) != 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 |= PAGE_READ; } - if (cpu->env.tlb.dtlb[0][idx].tr & SWE) { + if (tr & SWE) { right |= PAGE_WRITE; } } else { - if (cpu->env.tlb.dtlb[0][idx].tr & URE) { + if (tr & URE) { right |= PAGE_READ; } - if (cpu->env.tlb.dtlb[0][idx].tr & UWE) { + if (tr & UWE) { right |= PAGE_WRITE; } } @@ -105,8 +108,7 @@ static int get_phys_data(OpenRISCCPU *cpu, hwaddr *physical, int *prot, return TLBRET_BADADDR; } - *physical = (cpu->env.tlb.dtlb[0][idx].tr & TARGET_PAGE_MASK) | - (address & (TARGET_PAGE_SIZE-1)); + *physical = (tr & TARGET_PAGE_MASK) | (address & ~TARGET_PAGE_MASK); *prot = right; return TLBRET_MATCH; } diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index 9b4339b34e..7f458b0d17 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -86,14 +86,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 = 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 = rb; + env->tlb.dtlb[idx].mr = rb; break; case TO_SPR(1, 640) ... TO_SPR(1, 640+DTLB_SIZE-1): /* DTLBW0TR 0-127 */ idx = spr - TO_SPR(1, 640); - env->tlb.dtlb[0][idx].tr = rb; + env->tlb.dtlb[idx].tr = 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 */ @@ -105,14 +105,14 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) case TO_SPR(2, 512) ... TO_SPR(2, 512+ITLB_SIZE-1): /* ITLBW0MR 0-127 */ idx = 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 = rb; + env->tlb.itlb[idx].mr = rb; break; case TO_SPR(2, 640) ... TO_SPR(2, 640+ITLB_SIZE-1): /* ITLBW0TR 0-127 */ idx = spr - TO_SPR(2, 640); - env->tlb.itlb[0][idx].tr = rb; + env->tlb.itlb[idx].tr = 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 */ @@ -244,11 +244,11 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd, case TO_SPR(1, 512) ... TO_SPR(1, 512+DTLB_SIZE-1): /* DTLBW0MR 0-127 */ idx = spr - TO_SPR(1, 512); - return env->tlb.dtlb[0][idx].mr; + return env->tlb.dtlb[idx].mr; case TO_SPR(1, 640) ... TO_SPR(1, 640+DTLB_SIZE-1): /* DTLBW0TR 0-127 */ idx = spr - TO_SPR(1, 640); - return env->tlb.dtlb[0][idx].tr; + return env->tlb.dtlb[idx].tr; case TO_SPR(1, 768) ... TO_SPR(1, 895): /* DTLBW1MR 0-127 */ case TO_SPR(1, 896) ... TO_SPR(1, 1023): /* DTLBW1TR 0-127 */ @@ -260,11 +260,11 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd, case TO_SPR(2, 512) ... TO_SPR(2, 512+ITLB_SIZE-1): /* ITLBW0MR 0-127 */ idx = spr - TO_SPR(2, 512); - return env->tlb.itlb[0][idx].mr; + return env->tlb.itlb[idx].mr; case TO_SPR(2, 640) ... TO_SPR(2, 640+ITLB_SIZE-1): /* ITLBW0TR 0-127 */ idx = spr - TO_SPR(2, 640); - return env->tlb.itlb[0][idx].tr; + return env->tlb.itlb[idx].tr; case TO_SPR(2, 768) ... TO_SPR(2, 895): /* ITLBW1MR 0-127 */ case TO_SPR(2, 896) ... TO_SPR(2, 1023): /* ITLBW1TR 0-127 */ From patchwork Mon Jul 2 15:10:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140815 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp85552ljj; Mon, 2 Jul 2018 08:29:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfcC/jFX70fm7VuFJDXW6pu0tGhEKnsRDKuFz/RjsAOH+OtvnJ/FmfL5ngNLh9RvgK36LHA X-Received: by 2002:a37:1f87:: with SMTP id n7-v6mr18442279qkh.308.1530545356300; Mon, 02 Jul 2018 08:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530545356; cv=none; d=google.com; s=arc-20160816; b=vynjUqJY0jNQ+Exfm8vB1yE9pm2V68+jWZW3mEDSqokg3ox5wMI4P4zxs46TYjsI8O fB3sKXxSnZyHO6+P58MjCH3Gy2kEZUSf+/LDJb+yP+LYjCd1QRlrZL+ioHuSFCWzNduP khA1JnI+JWEOxevRC4b2rJKS6odbtE2X+epDOjXxwBOIP6C6JhROnmYKCR/z6ZHKLjk4 W5NvsGPj+CcXvsL6KVV1ztAyqxfVGovvf+rhOhSXSo2EQfsbUfsLYXmdHntmmjPYRK6E CIJT/cPkFMHBRqFakmRWgWrabro5fT+tMT80uPvTLNx8gLSODLveRPLndx51iXAVI5M2 EoNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=XP26Su5f4Z0Z60ApQh47OEXkTrqSOl00r2acJz/P8YI=; b=QdRpD4z2s9dgwbq+tBmJYs++7B2OEw6YpIRjez+pcMzfGqr9GDv0EiwzzNcUwfJb/W 2xIX8Z9SC6ON0InDG8ZdWdgV9T9q6JdyVYFVt1MKWr5F/KIY0BKkCUPsCS1/mXZPSce7 3h9dtt/ZgdXCFTU9W2TRdpjLUHRc7czTsb7L6mVXiLRd4pnHwmpYP6Ss28fGbb3YupGo WyARMhI4m44kUeZUDO5cW3vaXioEUpvxuPco1IE4ddquWOhGBOW0JuptF0Qyb6gn3B/j VeAopbjAvmu+a0Hr1SVdlD8neRYcVoj8lyOUeACdOfRExyWMcD95/oMfp2CbXgNLVf9j Rd3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Ypqt1811; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k90-v6si4886987qkl.224.2018.07.02.08.29.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:29:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Ypqt1811; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0lP-0001bG-7h for patch@linaro.org; Mon, 02 Jul 2018 11:29:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0U2-0004Jq-G9 for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0U0-00086d-SU for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:18 -0400 Received: from mail-pl0-x22c.google.com ([2607:f8b0:400e:c01::22c]:40263) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0U0-000865-MA for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:16 -0400 Received: by mail-pl0-x22c.google.com with SMTP id t6-v6so8097754plo.7 for ; Mon, 02 Jul 2018 08:11:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XP26Su5f4Z0Z60ApQh47OEXkTrqSOl00r2acJz/P8YI=; b=Ypqt1811Yk498sRu7vWSZSManDzBCd+9PVMTttDhGlWLhXX3YnUQviyNV2APaC7r0y 6+fBkFLvmhtZM1kdwOKPSet7y3hZvVKp2+FPyNnrLe3POQvPY2YAExKR14EaVH02dseC Nf4VdDQb8cd/kG8UprcJNYLkJlmyY5hjlUSLgRfWRG9JSX4LCE0LWzTi3C1isKHIwEOs EWn2lUmtp0zOCykxVbraB4o45kVszT79L22xk7PzX9C7K+ZcgoZc2yHv/AJLyS6blCxR Ljl7V+9ZetKmRFAVdg/c7bDhavJ2Y3BevnAcayw8lO/j9QFL3X28pLkO3fA1yLZNvqSR d4fA== 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=XP26Su5f4Z0Z60ApQh47OEXkTrqSOl00r2acJz/P8YI=; b=EY2aBtwd5nJtPkytTN3AshJ/BaZCCf6ovBwofr96mlvzdjdgP5dhfgKSmlBiuhh4Ha nR+CdrR2EtbbeyLhzXXiyz2k95JYx8//3ZISKjKSl9xsqn0gwNl3VWTpjfLkHj723Gvz HB1KUu/IQvdcFD88RoYnt3UvkGvkuIZzYQw+3puG50im+R4XpfXdob2wrdTM7A0p9jmS wY48vLWXBIj34X2CiFCo3rweO81+EqlBoaC2YjJwABISuPhIL42eJWNPOD7UQA9Efxs0 ux2T9nH1HdupAPz+TeF+Fkc93L23lKnWwQsLYn8+jQ9xTw+st9inFiAmOBmICfkm37qu nMiQ== X-Gm-Message-State: APt69E0oInxpDhAXv9lmxwL4REaWIcuItlkksyYWehKRhA9UeBi8dqdm I481K9F8eN7BhPd0hNRO0h8= X-Received: by 2002:a17:902:7798:: with SMTP id o24-v6mr9252570pll.165.1530544275877; Mon, 02 Jul 2018 08:11:15 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id x63-v6sm7858171pfi.40.2018.07.02.08.11.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:11:15 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:13 +0900 Message-Id: <20180702151023.24532-16-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::22c Subject: [Qemu-devel] [PULL v2 15/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson 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 Signed-off-by: Stafford Horne --- target/openrisc/sys_helper.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) -- 2.17.0 diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index 7f458b0d17..c9702cd26c 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -32,6 +32,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) #ifndef CONFIG_USER_ONLY OpenRISCCPU *cpu = openrisc_env_get_cpu(env); CPUState *cs = CPU(cpu); + target_ulong mr; int idx; switch (spr) { @@ -85,12 +86,15 @@ 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 = spr - TO_SPR(1, 512); - if (!(rb & 1)) { - tlb_flush_page(cs, env->tlb.dtlb[idx].mr & TARGET_PAGE_MASK); + mr = 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 = rb; break; - case TO_SPR(1, 640) ... TO_SPR(1, 640+DTLB_SIZE-1): /* DTLBW0TR 0-127 */ idx = spr - TO_SPR(1, 640); env->tlb.dtlb[idx].tr = rb; @@ -102,14 +106,18 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong 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-127 */ idx = spr - TO_SPR(2, 512); - if (!(rb & 1)) { - tlb_flush_page(cs, env->tlb.itlb[idx].mr & TARGET_PAGE_MASK); + mr = 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 = rb; break; - case TO_SPR(2, 640) ... TO_SPR(2, 640+ITLB_SIZE-1): /* ITLBW0TR 0-127 */ idx = spr - TO_SPR(2, 640); env->tlb.itlb[idx].tr = rb; @@ -121,6 +129,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 = deposit64(env->mac, 0, 32, rb); break; From patchwork Mon Jul 2 15:10:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140814 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp84402ljj; Mon, 2 Jul 2018 08:28:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpduPy2EbUjjpJLKiY3jfog1aqSsbSwqmToN8QplWUl+ohcEiAzfFNOXsBQfovUjrOxmgsVj X-Received: by 2002:ac8:2a8f:: with SMTP id b15-v6mr14629378qta.405.1530545280218; Mon, 02 Jul 2018 08:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530545280; cv=none; d=google.com; s=arc-20160816; b=qPy5lOEa7bcfkeB79YJljk0QpxjYHg7SLwZISbFnJzMv/dlhbWNUP8pYbvDmS99wpj qhY2IwVAIhrxcFCEHqVCyV1lA9BIkOGCvZW6BXYJMTtrY+Drs7T3CNg0xDwSQ9/Qih+H vpqszeJmX43fSqi2HDeMaaFZffg7/Kj40aWqE6W5Sf9kUL3qq8L8y5/L3AEBmuDRyU6q 4cvf4O/E6RDjrgFoJCiZGGxmpjn6AM78L1ZflBwQEBbFX3Us7R3a54Zo1CPCaX0eo85M FadMxAU/30hEugtdjWhpf5Z3ikKRwKCfaSFEiUlqHpUQODsY7zQCrTh6fUNtMJuLQYml odpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=GZeiyhs9RzYP4jMrD0QM9E/kmwQr0SWmgpdpIiEqRpY=; b=aKFO7CVAAivpDr6oONKGFVnpZF39Dsdpbc3hZUEnZdUlTfxeuGv/+UYZvupy4iS6c+ deBvyHDKJcrparX18sVROtGvqnCW5oFklI/sqkSTuL4GkmXGaFK/ByVPwHCHoF2pKRs5 +3f1h+9EQ+tlKBlFHZ18XdRS6dIriXHSYywjBZkP+AkjQnCwT8ZMozhqG1ij5h7Nl6TM SwtOYAGekAtl5DaSKROwahK0QJe95OV1P4RkgQXXFzKjqjNwBDxooEjd2DtITWjiPPcY QhTNs+b11UH2YDz48fBbGrb3hLeKWhGGCakOoa2+JBHdu2oexbQklJz+WJN1Iqqs4Akj Kv1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GHtC2UWh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h67-v6si2230978qkc.137.2018.07.02.08.27.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:28:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GHtC2UWh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0kB-0000bO-CE for patch@linaro.org; Mon, 02 Jul 2018 11:27:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48901) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0U4-0004M5-W9 for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0U3-00089B-AB for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:20 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:39149) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0U3-00088r-32 for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:19 -0400 Received: by mail-pl0-x242.google.com with SMTP id s24-v6so8094256plq.6 for ; Mon, 02 Jul 2018 08:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GZeiyhs9RzYP4jMrD0QM9E/kmwQr0SWmgpdpIiEqRpY=; b=GHtC2UWhHGHkk6ny+7K0Q+LG8tSIFTyi6SPwcFvFjoXVOLY3hH+9MmHHbwpoqSmmEx ODYpsROO+mhtmV0vACf2rcp5zoOzJYUgvqLWg1ahACP6iW6BnikzlmBMpRH/tG1nSAPv vJEgyEYfflSb6uHzrhMNLNao1pbVwWu5sqMk/Kv2DYFEU6f3B2eExveR9fgq0TnZ2gw/ QssqE/V8+AygoJrFq+dYr5twrEOtEwyga09BvRphGbVROb+/mpt80TrMlihFiGkdnEng 5tmDx9b0DZF7030eQsh3wYQ7vgQaoOo708znASZMw3HjAi1Bhv8cKhbX3+48RLLeMIIx JwNg== 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=GZeiyhs9RzYP4jMrD0QM9E/kmwQr0SWmgpdpIiEqRpY=; b=PMGoapNAhkpWfQ1eRk8BIzkODj0IIG/djL4ahsdqUNwCzEaxveUIT/UejV44eFMcrR EJgUusahN+3nS5saqWxqSLWjjMBRifhuAHTTHOUXMrqVKfIu68ymhMAW4ug+HdEy9ivA xUS81kSUB+9gOKZeGCtJunOSSfYtPU0r+ZT/xmg23MSsHBTTaJtq7DaHcvZhHBQb144U HmRb89nkNHwagE/aCYlG8G4Ai2/5+Fn0XFrf8d8Q+Xxsc9NbcatLdxfJPCKAOMN2RdVT ZlFrmcOc0kejnuOi6rvsYSXVRaV1bi/B0USZH3HRmZGXQfCNl5xsNKmLN8bPTBdkw6iQ /cxQ== X-Gm-Message-State: APt69E0IY3WHbjSdO8glYI/Ss96cmr47h0GT7HHDEWbbW1E8hpNzIVbg 8KNqaXaFudpWqfLwTlKjgM0= X-Received: by 2002:a17:902:543:: with SMTP id 61-v6mr26327408plf.47.1530544278269; Mon, 02 Jul 2018 08:11:18 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id t3-v6sm25611314pgf.43.2018.07.02.08.11.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:11:17 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:14 +0900 Message-Id: <20180702151023.24532-17-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PULL v2 16/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson 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 Signed-off-by: Stafford Horne --- 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(-) -- 2.17.0 diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index eaf6cdd40e..c3a968ec4d 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -385,9 +385,12 @@ void cpu_openrisc_count_stop(OpenRISCCPU *cpu); #include "exec/cpu-all.h" -#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 */ static inline uint32_t cpu_get_gpr(const CPUOpenRISCState *env, int i) { @@ -405,17 +408,21 @@ static inline void cpu_get_tb_cpu_state(CPUOpenRISCState *env, { *pc = env->pc; *cs_base = 0; - *flags = (env->dflag - | (cpu_get_gpr(env, 0) == 0 ? TB_FLAGS_R0_0 : 0) - | (env->sr & SR_OVE)); + *flags = (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)); } static inline int cpu_mmu_index(CPUOpenRISCState *env, bool ifetch) { - if (!(env->sr & SR_IME)) { - return MMU_NOMMU_IDX; + int ret = MMU_NOMMU_IDX; /* mmu is disabled */ + + if (env->sr & (ifetch ? SR_IME : SR_DME)) { + /* The mmu is enabled; test supervisor state. */ + ret = env->sr & SR_SM ? MMU_SUPERVISOR_IDX : MMU_USER_IDX; } - return (env->sr & SR_SM) == 0 ? MMU_USER_IDX : MMU_SUPERVISOR_IDX; + + return ret; } static inline uint32_t cpu_get_sr(const CPUOpenRISCState *env) diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index 23abcf29ed..138ad17f00 100644 --- a/target/openrisc/interrupt.c +++ b/target/openrisc/interrupt.c @@ -51,10 +51,6 @@ void openrisc_cpu_do_interrupt(CPUState *cs) env->eear = env->pc; } - /* For machine-state changed between user-mode and supervisor mode, - we need flush TLB when we enter&exit EXCP. */ - tlb_flush(cs); - env->esr = cpu_get_sr(env); env->sr &= ~SR_DME; env->sr &= ~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 @@ void HELPER(rfe)(CPUOpenRISCState *env) { - OpenRISCCPU *cpu = openrisc_env_get_cpu(env); -#ifndef CONFIG_USER_ONLY - int need_flush_tlb = (cpu->env.sr & (SR_SM | SR_IME | SR_DME)) ^ - (cpu->env.esr & (SR_SM | SR_IME | SR_DME)); - if (need_flush_tlb) { - CPUState *cs = CPU(cpu); - tlb_flush(cs); - } -#endif - cpu->env.pc = cpu->env.epcr; - cpu->env.lock_addr = -1; - cpu_set_sr(&cpu->env, cpu->env.esr); + env->pc = env->epcr; + env->lock_addr = -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 = openrisc_cpu_handle_mmu_fault(cs, addr, size, - access_type, mmu_idx); - if (ret) { + OpenRISCCPU *cpu = OPENRISC_CPU(cs); + int ret, prot = 0; + hwaddr physical = 0; + + if (mmu_idx == MMU_NOMMU_IDX) { + ret = get_phys_nommu(&physical, &prot, addr); + } else { + bool super = mmu_idx == MMU_SUPERVISOR_IDX; + if (access_type == MMU_INST_FETCH) { + ret = get_phys_code(cpu, &physical, &prot, addr, 2, super); + } else { + ret = get_phys_data(cpu, &physical, &prot, addr, + access_type == MMU_DATA_STORE, super); + } + } + + if (ret == 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 == MMU_INST_FETCH) { + rw = 2; + } else if (access_type == MMU_DATA_STORE) { + rw = 1; + } else { + rw = 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 c9702cd26c..852b219f9b 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -56,10 +56,6 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) break; 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; diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 64b5e84630..a271cd3903 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -55,7 +55,7 @@ static inline bool is_user(DisasContext *dc) #ifdef CONFIG_USER_ONLY return true; #else - return dc->mem_idx == MMU_USER_IDX; + return !(dc->tb_flags & TB_FLAGS_SM); #endif } From patchwork Mon Jul 2 15:10:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140810 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp81661ljj; Mon, 2 Jul 2018 08:25:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeRkYrr6HFEOMVWoE1GtGR0LfVgiygdbDDvKWDBsasSwzkoBJK4CykbgsRLuGyG2hTo46zD X-Received: by 2002:a0c:c252:: with SMTP id w18-v6mr11990861qvh.93.1530545106939; Mon, 02 Jul 2018 08:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530545106; cv=none; d=google.com; s=arc-20160816; b=tjagDCkijFTSRW0qkBFBD/lDELFYEjB6nTUA+VX/9opXN4ih6bTfFPoxo9Eog9MKi7 FPhDkh1uQ79J3LAhiBmIBk112b8PV9L/E+uf1/iUe6aJmP9vvMTpvgxfO6aQXpDnfpbp NPbe9U6/7oYhlfbFTG9fYgh6knImX8Gz4gkae3JCiTH4zjapWLXExbwHsw9sUKzNSY/h npi1ok0+tCJI8dtGTUt2rurWvMsStPogAyI0fUA/m175L7Wkb9cIXYXqbbY2VAMnvhH/ kWgkbhCaZy4YfbZV2w6FwCaMnXyzGvgVib+BeAN19WMKTgRMRjC+1wRJoT+rGdw9H7/Y TNAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=4Ug/yP3+QhvO8U2zdB+6CUD01N1sEYbfPEJw4NI2TCk=; b=qsAAgYiElGQVlghryDTmpE+uHtv1GgzNibU1XxCtBZaOiG2SfqgM180A/SuxZVIewH oUa9Bu32hDgW28w452lPhXtV4blEEBH1lPloexbxTgZ+UNkta6fb1md48lViMG8LHLdA tjhNh62Q7HMIJF4b2moC7t40mGra8AaRVM0ylSXyuCLwjKaHwE0yLdKmD8hY6DOUmDZI 9+d0FXOKdsGFQx/bcRb304g2BDFijt9ZlgOMAv/Kx4GZMjhyeH1vA9lDWC15eUiVPpC6 wJ8etPVJ9gYlNqSqxPlYwc/frKHrxbJNLDP8ZVDHzP4YkZYJJWkkCaTLbWBggxSOyNCy xthg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=YDxuzGuA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u27-v6si585360qku.90.2018.07.02.08.25.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:25:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=YDxuzGuA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0hO-0006UY-36 for patch@linaro.org; Mon, 02 Jul 2018 11:25:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0U7-0004Np-Gn for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0U6-0008CR-5n for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:23 -0400 Received: from mail-pg0-x229.google.com ([2607:f8b0:400e:c05::229]:43654) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0U5-0008Bi-Tx for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:22 -0400 Received: by mail-pg0-x229.google.com with SMTP id v13-v6so1650433pgr.10 for ; Mon, 02 Jul 2018 08:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4Ug/yP3+QhvO8U2zdB+6CUD01N1sEYbfPEJw4NI2TCk=; b=YDxuzGuAKFMMcCE2g34tBi7z6OEVI5RC3GAayEFFhDXimbfHIHyy1/HGyH8/4DYiin QAHOAxpBoVWwlTL+W2ckpsWh8CYCh5mBilq8mNndCbqTsVFkyvbxSPyaHrHfUtaHRhpA ZhRFKWs9vramm0k09IWu15+ge+JOa7R1RqeTfeYqvj3yHNa5pRdQp++aAW+lYSc/lyQH JpvzTn+Q5Xd9m43nibXjTsPrvDRT+j1X8+EfPCYh0wn6RXHvj41NLLbTQt4VwYQh+dl5 pmUamI7/GSnF7hEFnTkl9/SPKNF4vEtjwDt2gEfWKVg4ZSdGkEU4Fc4xlnf8iqk2vrUK sa3A== 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=4Ug/yP3+QhvO8U2zdB+6CUD01N1sEYbfPEJw4NI2TCk=; b=pROpOiNl9RCq15Cx5j/klWyLaudBhXyKoOn3NTIcTF1TfQtbFrGsSki7eJlj+X1JEu +xIcjzNmo9HaoTJ8SpTfF5Et215uwcwRc9xNHqMaqODdALOMhYJCErhq4RgleRHkXCHe pdIFAoqCLGsNL197nYW4qBS9UAuurPTqEsRH5tB1JT7oSSr+EjtTnaYU84NOtHwTHkLl /ti83MdICmK31F58fT1WX1Acv8rVmfCyG4TOp9qIVF9fEHOesMR9G1lZ3yI1y7TsvN0E THdNhoR6wD4xYeYOdlhUYP5FM19Q85FErkOTQF1LV1NrlyOnnpg1ICXIkpVFG6gA1Rkx 07kg== X-Gm-Message-State: APt69E0G1UQqiCJz763Dmlj09OoCe3KRuOQT4HiW0tzFWvmqVh6kg+pT ZXI98dlMFIyKAZSokaPoeZQ= X-Received: by 2002:a65:6397:: with SMTP id h23-v6mr22210732pgv.380.1530544281075; Mon, 02 Jul 2018 08:11:21 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id i9-v6sm16705126pgt.47.2018.07.02.08.11.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:11:20 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:15 +0900 Message-Id: <20180702151023.24532-18-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::229 Subject: [Qemu-devel] [PULL v2 17/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The sizes are already the same, however, we can improve things if they are identical by design. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- 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(-) -- 2.17.0 diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index c3a968ec4d..47e94659e1 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -222,10 +222,8 @@ enum { /* TLB size */ enum { - DTLB_SIZE = 64, - DTLB_MASK = (DTLB_SIZE-1), - ITLB_SIZE = 64, - ITLB_MASK = (ITLB_SIZE-1), + TLB_SIZE = 64, + TLB_MASK = TLB_SIZE - 1, }; /* TLB prot */ @@ -254,8 +252,8 @@ typedef struct OpenRISCTLBEntry { #ifndef CONFIG_USER_ONLY typedef struct CPUOpenRISCTLBContext { - OpenRISCTLBEntry itlb[ITLB_SIZE]; - OpenRISCTLBEntry dtlb[DTLB_SIZE]; + OpenRISCTLBEntry itlb[TLB_SIZE]; + OpenRISCTLBEntry dtlb[TLB_SIZE]; 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 = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (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 *physical, int *prot, target_ulong address, int rw, bool supervisor) { int vpn = address >> TARGET_PAGE_BITS; - int idx = vpn & ITLB_MASK; + int idx = vpn & TLB_MASK; int right = 0; uint32_t mr = cpu->env.tlb.itlb[idx].mr; uint32_t tr = cpu->env.tlb.itlb[idx].tr; @@ -74,7 +74,7 @@ static int get_phys_data(OpenRISCCPU *cpu, hwaddr *physical, int *prot, target_ulong address, int rw, bool supervisor) { int vpn = address >> TARGET_PAGE_BITS; - int idx = vpn & DTLB_MASK; + int idx = vpn & TLB_MASK; int right = 0; uint32_t mr = cpu->env.tlb.dtlb[idx].mr; uint32_t tr = cpu->env.tlb.dtlb[idx].tr; diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index 852b219f9b..541615bfb3 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -80,7 +80,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) env->shadow_gpr[idx / 32][idx % 32] = rb; break; - 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-127 */ idx = spr - TO_SPR(1, 512); mr = env->tlb.dtlb[idx].mr; if (mr & 1) { @@ -91,7 +91,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) } env->tlb.dtlb[idx].mr = 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-127 */ idx = spr - TO_SPR(1, 640); env->tlb.dtlb[idx].tr = rb; break; @@ -103,7 +103,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; - 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-127 */ idx = spr - TO_SPR(2, 512); mr = env->tlb.itlb[idx].mr; if (mr & 1) { @@ -114,7 +114,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) } env->tlb.itlb[idx].mr = 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-127 */ idx = spr - TO_SPR(2, 640); env->tlb.itlb[idx].tr = rb; break; @@ -247,11 +247,11 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd, idx = (spr - 1024); return env->shadow_gpr[idx / 32][idx % 32]; - case TO_SPR(1, 512) ... TO_SPR(1, 512+DTLB_SIZE-1): /* DTLBW0MR 0-127 */ + case TO_SPR(1, 512) ... TO_SPR(1, 512 + TLB_SIZE - 1): /* DTLBW0MR 0-127 */ idx = spr - TO_SPR(1, 512); return env->tlb.dtlb[idx].mr; - 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-127 */ idx = spr - TO_SPR(1, 640); return env->tlb.dtlb[idx].tr; @@ -263,11 +263,11 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd, 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-127 */ + case TO_SPR(2, 512) ... TO_SPR(2, 512 + TLB_SIZE - 1): /* ITLBW0MR 0-127 */ idx = spr - TO_SPR(2, 512); return env->tlb.itlb[idx].mr; - 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-127 */ idx = spr - TO_SPR(2, 640); return env->tlb.itlb[idx].tr; From patchwork Mon Jul 2 15:10:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140813 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp84350ljj; Mon, 2 Jul 2018 08:27:57 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfoBz7sFbksVDipakXa0lqRm0sNMvgyCH7CbzRWTznhrT4ehPkMSvGKp6iRLOBW8QCMY/v/ X-Received: by 2002:a37:97c4:: with SMTP id z187-v6mr22520369qkd.196.1530545277533; Mon, 02 Jul 2018 08:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530545277; cv=none; d=google.com; s=arc-20160816; b=sOF3o/O70ph+oICY7RUJY+ieprrGVJxjTKEnIo+Oru9GrvYWf+FcnldFWShkXo9tdU rh78cSpriCDJF4qW3f3mWXPfW0VpY+SWZwONPah1U+f9BJY9Lzo+0+BdSyGqE5XSE3Nu hD8DpBR13gpEFWGDRmMtc37mzp16WQigN9TVVo0s8EtYOKiRwYupCaEnq4FQG0hF65Pd evG5hcGxp81iCzMALkB49kIqHDp7Miv053Ke7gii/Jh1vU+oEybdbi3n89JwVRWzLJtA O0G1+ZF/oO8YttzEt8HaKCKGNIBlt2nlxv9RfVyJk81+USGMgLAecC9xXGI/f/lptxkr G90g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=NfAVGhkiKG5LOSRz+0cX59oYyiQyF8X1AP8p2lZ3qxA=; b=0a4NI6YFd60JoO7q2jlA5bwLbQ3MM2p+XU4FUxEJ3KS0i0846fyZe2eFQAt2YEDCRR D1OhecfuDAypMN0rZgj9wLGfBbOalwD/hljnB0DQGSpnY/e9bCGGK1z5VRd584wiACNo Dt4hms1LCI/pytvB9go8tVUmhzBtrgnayPtwFOaIX88W9gYN5/RxvBln9Rwi3/mkBh+d FhLrT2KfXhXpQgeIigaXztIbrgM2sI6bpRxwtLdXBu2oJWR9OLX8fvJrqlq/qyz6frK0 8KxVP1nmk8BJ6ikMJlLLLZm2TAHHIGeZ7GZAKotQpcSi+wsODbkOEjdssbHcsE5N3Crk 5aWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Uf2xHVj3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r37-v6si973570qvc.85.2018.07.02.08.27.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:27:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Uf2xHVj3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0k7-0000YZ-VX for patch@linaro.org; Mon, 02 Jul 2018 11:27:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0UD-0004Sm-Fp for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0U8-0008Dw-Cu for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:29 -0400 Received: from mail-pl0-x22a.google.com ([2607:f8b0:400e:c01::22a]:34288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0U8-0008DK-6r for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:24 -0400 Received: by mail-pl0-x22a.google.com with SMTP id z9-v6so8098975plo.1 for ; Mon, 02 Jul 2018 08:11:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NfAVGhkiKG5LOSRz+0cX59oYyiQyF8X1AP8p2lZ3qxA=; b=Uf2xHVj3MI6W5u/5O/QamrcdkdSwB05YQZad7+QkpegOi9xNcUptWcELDGWlxvR48B 7AAes/zbYlTlr+896FBSx4F8GJyVA7tDpDM80cHaI1+q8YCzA/Nm1tSRUC4N2TJHwxOz gFJwmHNvtuHF9zKeXV5yY8MJffx4OP5KdSn/Xd4GJ4DcV94yqDL9FRH+dwq7R23h0h9r RVn7VG8JExGxCmkYsM35wNix/bB4AGwoIzPUhcHcuPMp+wKQeGK6TDM+W72UgyVQQYJ/ s2xJgynb77b4DDdbLxd4Sj8HSMmL6Up9xBNWO5END9EdjRrAWvMSSAmS0ZfGorrhdczj u/iw== 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=NfAVGhkiKG5LOSRz+0cX59oYyiQyF8X1AP8p2lZ3qxA=; b=Op6lcViZXbIP4/pJxyaLHWcmgOYaPcIlFksulfjjr2bDzsqqSIhK3wvqRFMgs+Q6o6 Pz1FRPuafl2s/uVP6zTTD4VmFTCu4CBUaIdrVbzZ+rXKRM/ipDL5uNu+a3Ej8qc1tU/H VLPDql8akfQqU+gNZE7mi7BAOAATylP+sLUFU/WIuXKGQunoYYGKPZbz4vtWgOsDfOQ1 6Z98iTHU+p3RVQYzVf65tPZzEtA28lV0F4p59AzYniTzmRxZOEI8AhgdyiwHXdAzug02 E2nPgh547rOt7ZjMY5CZRX/tlyZieELTxnNvoGwURFsngz7A+C1jwTsgo+iEu2WFzov/ 39Jw== X-Gm-Message-State: APt69E2dwZfVJ8HnGv2YDN4ri8WNll28mRSVRaYJTnd0mK7rA9bED1aH yjDd03BSFscpMZBsjA1AvIchlRCh X-Received: by 2002:a17:902:6845:: with SMTP id f5-v6mr25982059pln.173.1530544283387; Mon, 02 Jul 2018 08:11:23 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id 125-v6sm8001766pgj.46.2018.07.02.08.11.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:11:22 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:16 +0900 Message-Id: <20180702151023.24532-19-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::22a Subject: [Qemu-devel] [PULL v2 18/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson This hook is only used by CONFIG_USER_ONLY. Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- target/openrisc/mmu.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) -- 2.17.0 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(OpenRISCCPU *cpu, cpu->env.lock_addr = -1; } -#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 = OPENRISC_CPU(cs); - int ret = 0; - hwaddr physical = 0; - int prot = 0; - - ret = get_phys_addr(cpu, &physical, &prot, address, rw); - - if (ret == TLBRET_MATCH) { - tlb_set_page(cs, address & TARGET_PAGE_MASK, - physical & TARGET_PAGE_MASK, prot, - mmu_idx, TARGET_PAGE_SIZE); - ret = 0; - } else if (ret < 0) { - cpu_openrisc_raise_mmu_exception(cpu, address, rw, ret); - ret = 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 = OPENRISC_CPU(cs); - int ret = 0; - - cpu_openrisc_raise_mmu_exception(cpu, address, rw, ret); - ret = 1; - - return ret; -} + g_assert_not_reached(); #endif +} #ifndef CONFIG_USER_ONLY hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) From patchwork Mon Jul 2 15:10:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140817 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp90228ljj; Mon, 2 Jul 2018 08:33:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpduZbOBTT0O45pM+Ov5qZKV8J4pVhocPVSU2P5WikC20LS/ykTYthyhcRGNBhx+3tQ3TvS6 X-Received: by 2002:a0c:d80f:: with SMTP id h15-v6mr12308415qvj.5.1530545602336; Mon, 02 Jul 2018 08:33:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530545602; cv=none; d=google.com; s=arc-20160816; b=0JGpvRAzmnPoPg2gSScMNLBbshvxVvXIfcE97s7AOdYcKIOsdJCKNVoGAZiWQNc/bt Eh46OWqYbIxjxQwcUlLAScqiOsVuqu746dkN53/g46tn0xXm4FdOpUrloz+bzJz5UZVJ FJkpn59eP7dd4vGCbQkDQmJB1znc9Pho6gOfhLr3IOqAmLTvAhxu2PI46EsCmSl8tGja MVEcLybXzARfJG73kdPJfvbnCkQKXSgmvZ7Mln6lnQVFrsKQLFgTYrF020I83KDwyC6T eTNfd2vRFH4kcn+zRaQ0WJKSxey0XtV+/DID/mcahPCnZAcaBXa0gBtV23vW0BJbi206 tMwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=pNLpyMH2MtrDqswU9mlulZblcEuP061D6R6k4Avg5bA=; b=G/4sWG96nsfIZvLSk652zSPpEpzgcmPpk9b8JWCqjUgbC/SORb9KloE0gX0RtsTkHg sXQ2/totYU0BHBuLw4AgdYNfly+8Zhm7WI9JH6iuyKDJcqbBWhtmdAdzSW75KVo2VnNV BM+4Dc7DGvJJAntiuUKHkM+33cZsrlEPjY8lT8gLbxLNPhhd0R0xE8gAxX82WRPFCFAI wxkb85yEYln09UucsvDrtDIcYEvOyLRDk6yASBJyvw+Jxyspydr+bO+gvlC0vCRt7OF9 szAwn35adVyOPNRj2lKPetAh6RVlp2hUMya4RuFG7r3A72OwW8DdFVMzJ7Y/weSd2RAv iG6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="s/VaV3CO"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p123-v6si3239693qkc.311.2018.07.02.08.33.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:33:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="s/VaV3CO"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0pM-0004AO-Sr for patch@linaro.org; Mon, 02 Jul 2018 11:33:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0UD-0004Sn-G9 for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0UA-0008FZ-LF for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:29 -0400 Received: from mail-pl0-x22b.google.com ([2607:f8b0:400e:c01::22b]:44643) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0UA-0008F2-Fh for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:26 -0400 Received: by mail-pl0-x22b.google.com with SMTP id m16-v6so8093629pls.11 for ; Mon, 02 Jul 2018 08:11:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pNLpyMH2MtrDqswU9mlulZblcEuP061D6R6k4Avg5bA=; b=s/VaV3COqRMvbK5zqqBMYWvpz1BIHNXfqlXWcDaRTYnq8Fi09Cf9zLTeaXJS594ptm eH7zoXNk7khxoG/kWo2H2C7J58U9tJ2OAlquI2RqdHf7XAr/abZcc3SsNRLEs3H6HeR8 cDITc7QDPn+NYsFbAjCoX9zENbRtqkS7GSxS6rfWX4JHbveZostJm6kEfmqwQoI0ZKV0 767QiqgWqlELlJevGGyfXqVcEQUOiQjRSmK1L5z+ltxG3CgUjMVre33Pf82//C3ujLRR J/nQ47BH1wOJl8b2kLa4wcfO4mUvDrouu3uY50Xh5adC7Y1tPivpLn5JbO2AKJ08DOTG PqhQ== 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=pNLpyMH2MtrDqswU9mlulZblcEuP061D6R6k4Avg5bA=; b=razTcf05FqHBr3rp7g2HQ1GiMGRdFKtqnXRQT1rsucTdl6hpGvuuu6z8pFw7gyXqjf NI+fbba5/PKsp6h5Br0lxCnY7g57Uc16+IUAkPGWsxF8GoMXe0yWiMKVV1DZKdsOnCLR EPi3Hy/4cqwh3SuthnTY3cpKSxK+0sZu3Gk81ui3VKAcEZ8OM45OXqTmKbffdwMVANRI QWXYxrotQXsAXQ0qJVtWnI4yEzkjK//j+9H/pVLYwPX2vESPxc0MXCUHRPhi/xsrSbZI KZ8lD1CWoq264drnBm0RPchqaYncnosx9Yt/Wp4vRte2Ma0hnBTr8SmlbSKtWBcF0fZF wOLg== X-Gm-Message-State: APt69E0NN1Iu/2Pb0yPKfEZ1mfCPotiB/coBHprOheDQGn3UcnXNby8g BywngUl9sPOe4/4OOKbEqGA= X-Received: by 2002:a17:902:2983:: with SMTP id h3-v6mr26365717plb.232.1530544285670; Mon, 02 Jul 2018 08:11:25 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id j133-v6sm33300282pgc.75.2018.07.02.08.11.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:11:25 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:17 +0900 Message-Id: <20180702151023.24532-20-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::22b Subject: [Qemu-devel] [PULL v2 19/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson 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 Signed-off-by: Stafford Horne --- v2: - Change VMState version. --- target/openrisc/cpu.c | 6 ++++-- target/openrisc/cpu.h | 2 +- target/openrisc/machine.c | 5 ++--- 3 files changed, 7 insertions(+), 6 deletions(-) -- 2.17.0 diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index b92de51ecf..e01ce9ed1c 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -57,8 +57,10 @@ static void openrisc_cpu_reset(CPUState *s) cpu->env.upr = UPR_UP | UPR_DMP | UPR_IMP | UPR_PICP | UPR_TTP | UPR_PMP; - cpu->env.dmmucfgr = (DMMUCFGR_NTW & (0 << 2)) | (DMMUCFGR_NTS & (6 << 2)); - cpu->env.immucfgr = (IMMUCFGR_NTW & (0 << 2)) | (IMMUCFGR_NTS & (6 << 2)); + cpu->env.dmmucfgr = (DMMUCFGR_NTW & (0 << 2)) + | (DMMUCFGR_NTS & (ctz32(TLB_SIZE) << 2)); + cpu->env.immucfgr = (IMMUCFGR_NTW & (0 << 2)) + | (IMMUCFGR_NTS & (ctz32(TLB_SIZE) << 2)); #ifndef CONFIG_USER_ONLY cpu->env.picmr = 0x00000000; diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 47e94659e1..b180e30e9e 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -222,7 +222,7 @@ enum { /* TLB size */ enum { - TLB_SIZE = 64, + TLB_SIZE = 128, TLB_MASK = TLB_SIZE - 1, }; 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 = { static const VMStateDescription vmstate_cpu_tlb = { .name = "cpu_tlb", - .version_id = 1, - .minimum_version_id = 1, - .minimum_version_id_old = 1, + .version_id = 2, + .minimum_version_id = 2, .fields = (VMStateField[]) { VMSTATE_STRUCT_ARRAY(itlb, CPUOpenRISCTLBContext, TLB_SIZE, 0, vmstate_tlb_entry, OpenRISCTLBEntry), From patchwork Mon Jul 2 15:10:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140816 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp87228ljj; Mon, 2 Jul 2018 08:30:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdYWzOCykEJHicBWdgOTQ2iRZqKRAoQGNnug12ov9buImEWt63qqfi02mHEBZYvR+1Jld+7 X-Received: by 2002:ac8:6601:: with SMTP id c1-v6mr23807920qtp.343.1530545447629; Mon, 02 Jul 2018 08:30:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530545447; cv=none; d=google.com; s=arc-20160816; b=KtDRAPgiGDWE5FnXo/LIvTn697lBChC0W66RMWKknk9gZcMp7Ei8yxajksNmJak/7P sFwPhFRgZtUGXRTwSx40NOoygBI5l68CbZjU71HECgBRM8+6jlp1+Wt0Gt5GwONSQR/H BMvyIK2vc6onC8f96KZr/NLWrRbIbukZI6WT6c4xGse86mla4hj6bLlmCy41eRsEFoes MR82aV84/Gwi41hLn8Wj6xt9RCOMPMEiEHPN924KVc7VtrN3XXEiIUKDbLwDz5oEepl2 Ygq3hfyGuItrTlfvWcFGB0gTnQK4gclRLdQbsnGl7cRqgj2WLXcx3/sy8QYiyUc7qPHV r7tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=QAqh/3eTuvXq/YfChPe5U3ubjoePgMt1L0T6W0B22sE=; b=nADtylxQKc9VhP4Xn6E+zZV0F9kn0jRrFX3e1OOflS40d2XtUVjs3KsPanMOu77oV5 /Qv5wreQw3Y2AEHS9j0A5WDtcri24EKeNVIrqMtxJiKiCQ3ZSthr5WBRWXrDEjfeGZS8 JBathiJRedOMcJM52l2QWv+LuXqeGLpJkpe2gYxGvI2W1JAvJ9x9Xder99wCPlv7eJ0g /2Zdc77oDDOqRDmODyYcy4Ed1OGotY6CvH46qYCnRXkSPIDMkQVgxyXXz2HJQ3EGp/NV CdY7TjFxyQgMPCG5ZL24CkiNLqCa/d4HEcVZgB4B63e0l6ADGsuch4PuD6IPOpYKk7mZ K3bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=NgZvkSdE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e7-v6si5932774qkb.180.2018.07.02.08.30.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:30:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=NgZvkSdE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0ms-00034j-H1 for patch@linaro.org; Mon, 02 Jul 2018 11:30:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0UE-0004U3-St for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0UD-0008Gs-3u for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:30 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:35856) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0UC-0008GT-Rx for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:29 -0400 Received: by mail-pg0-x244.google.com with SMTP id m19-v6so3747492pgv.3 for ; Mon, 02 Jul 2018 08:11:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QAqh/3eTuvXq/YfChPe5U3ubjoePgMt1L0T6W0B22sE=; b=NgZvkSdEVFhnw+4k1HzHpAdZdMtxGZkwJ9ESLCn5ro7dIKMTckLZIgA6j0JKGHTfnU qFFlZL9HytfilMOW643TVV1ddhrBB+mrRXjoC4Ui+q83WubpYVaEhUvbgej+HvmRgE+Q 3FGo47tL3hwlasV9lFbK3l3rbztnuYsisYgvIQaajgjQgPvAAd1tBfuShGDlzbnEaC7d GoDxnUMvbZRLCB6sKjlXoCCtxXF1An5QFgWb0gI38UoR/s99/He2GusPwqMzWasZAFoh hL9+KXvk2JgzSQAztpS1uUdXgfaQdZswQKDw4ICfU9UpXCC0Kyy8aIUpjSnewyoT7BpN KHSg== 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=QAqh/3eTuvXq/YfChPe5U3ubjoePgMt1L0T6W0B22sE=; b=FkRh6Gl0p5tkyy95mFkIFbgQBUwaXblE1sVFYhvJ9I1kSqfEivFF8Hsy2OgVfyGqmV iG219tmRyCTF+d/G+0TBK6V6z1fysOjmgfqIxebiDxFy05HtZAcVb5xFuFf1AE+o6t5r VBLuutl07c0bWBRF4mCdhudOBpWrECjEQ69vPAcTZAGW/5sRkiIAuJeFPZPWkOtwR4iK g2qH2vsaf5fM6RVtSt1kkPE+ImfXIplPYgcClWiZaUE3PrD4dWDsUSrisnITSkKLEtLl AWwrE/9vmC0KfHi5NNhrD7PbhiywHYzqawD9Mp5Jdqz1HyreJvQ6IfAMqFNasouHmAc4 8IMQ== X-Gm-Message-State: APt69E2qVa1kjTI2xaUOclq3GvUmNb78b6mzkZiV9ZVBQnPXrm2KzqX9 IMmexbHBFgqrCnlhui3FX8c= X-Received: by 2002:a62:190d:: with SMTP id 13-v6mr13605539pfz.103.1530544288024; Mon, 02 Jul 2018 08:11:28 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id r89-v6sm9784457pfa.75.2018.07.02.08.11.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:11:27 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:18 +0900 Message-Id: <20180702151023.24532-21-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> 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] [PULL v2 20/25] 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson 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 Signed-off-by: Stafford Horne --- target/openrisc/cpu.h | 8 -- target/openrisc/mmu.c | 250 +++++++++++++++--------------------------- 2 files changed, 88 insertions(+), 170 deletions(-) -- 2.17.0 diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index b180e30e9e..f1b31bc24a 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -237,14 +237,6 @@ enum { UXE = (1 << 7), }; -/* check if tlb available */ -enum { - TLBRET_INVALID = -3, - TLBRET_NOMATCH = -2, - TLBRET_BADADDR = -1, - TLBRET_MATCH = 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 #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 = address; + *phys_addr = address; *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; - return TLBRET_MATCH; } -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 = address >> TARGET_PAGE_BITS; - int idx = vpn & TLB_MASK; - int right = 0; - uint32_t mr = cpu->env.tlb.itlb[idx].mr; - uint32_t tr = cpu->env.tlb.itlb[idx].tr; - - if ((mr >> TARGET_PAGE_BITS) != vpn) { - return TLBRET_NOMATCH; - } - if (!(mr & 1)) { - return TLBRET_INVALID; - } - if (supervisor) { - if (tr & SXE) { - right |= PAGE_EXEC; - } - } else { - if (tr & UXE) { - right |= PAGE_EXEC; + int idx = (addr >> TARGET_PAGE_BITS) & TLB_MASK; + uint32_t imr = cpu->env.tlb.itlb[idx].mr; + uint32_t itr = cpu->env.tlb.itlb[idx].tr; + uint32_t dmr = cpu->env.tlb.dtlb[idx].mr; + uint32_t dtr = cpu->env.tlb.dtlb[idx].tr; + int right, match, valid; + + /* 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 = dtr = 0; + } else { + imr = itr = 0; } } - if ((rw & 2) && ((right & PAGE_EXEC) == 0)) { - return TLBRET_BADADDR; - } - *physical = (tr & TARGET_PAGE_MASK) | (address & ~TARGET_PAGE_MASK); - *prot = right; - return TLBRET_MATCH; -} + /* Check if either of the entries matches the source address. */ + match = (imr ^ addr) & TARGET_PAGE_MASK ? 0 : PAGE_EXEC; + match |= (dmr ^ addr) & TARGET_PAGE_MASK ? 0 : PAGE_READ | PAGE_WRITE; -static int get_phys_data(OpenRISCCPU *cpu, hwaddr *physical, int *prot, - target_ulong address, int rw, bool supervisor) -{ - int vpn = address >> TARGET_PAGE_BITS; - int idx = vpn & TLB_MASK; - int right = 0; - uint32_t mr = cpu->env.tlb.dtlb[idx].mr; - uint32_t tr = cpu->env.tlb.dtlb[idx].tr; + /* Check if either of the entries is valid. */ + valid = imr & 1 ? PAGE_EXEC : 0; + valid |= dmr & 1 ? PAGE_READ | PAGE_WRITE : 0; + valid &= match; - if ((mr >> TARGET_PAGE_BITS) != vpn) { - return TLBRET_NOMATCH; - } - if (!(mr & 1)) { - return TLBRET_INVALID; - } - if (supervisor) { - if (tr & SRE) { - right |= PAGE_READ; - } - if (tr & SWE) { - right |= PAGE_WRITE; - } - } else { - if (tr & URE) { - right |= PAGE_READ; - } - if (tr & UWE) { - right |= PAGE_WRITE; - } - } - - if (!(rw & 1) && ((right & PAGE_READ) == 0)) { - return TLBRET_BADADDR; - } - if ((rw & 1) && ((right & PAGE_WRITE) == 0)) { - return TLBRET_BADADDR; - } + /* Collect the permissions from the entries. */ + right = itr & (super ? SXE : UXE) ? PAGE_EXEC : 0; + right |= dtr & (super ? SRE : URE) ? PAGE_READ : 0; + right |= dtr & (super ? SWE : UWE) ? PAGE_WRITE : 0; + right &= valid; - *physical = (tr & TARGET_PAGE_MASK) | (address & ~TARGET_PAGE_MASK); + /* 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 = ((itr | dtr) & TARGET_PAGE_MASK) | (addr & ~TARGET_PAGE_MASK); *prot = right; - return TLBRET_MATCH; -} -static int get_phys_addr(OpenRISCCPU *cpu, hwaddr *physical, - int *prot, target_ulong address, int rw) -{ - bool supervisor = (cpu->env.sr & SR_SM) != 0; - int ret; + 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"); - /* Assume nommu results for a moment. */ - ret = get_phys_nommu(physical, prot, address); + /* Check the collective permissions are present. */ + if (likely(need & right)) { + return 0; /* success! */ + } - /* Overwrite with TLB lookup if enabled. */ - if (rw == MMU_INST_FETCH) { - if (cpu->env.sr & SR_IME) { - ret = get_phys_code(cpu, physical, prot, address, rw, supervisor); - } + /* Determine what kind of failure we have. */ + if (need & valid) { + return need & PAGE_EXEC ? EXCP_IPF : EXCP_DPF; } else { - if (cpu->env.sr & SR_DME) { - ret = get_phys_data(cpu, physical, prot, address, rw, supervisor); - } + return need & PAGE_EXEC ? EXCP_ITLBMISS : EXCP_DTLBMISS; } - - return ret; } #endif -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 = CPU(cpu); - int exception = 0; - - switch (tlb_error) { - default: - if (rw == 2) { - exception = EXCP_IPF; - } else { - exception = EXCP_DPF; - } - break; -#ifndef CONFIG_USER_ONLY - case TLBRET_BADADDR: - if (rw == 2) { - exception = EXCP_IPF; - } else { - exception = EXCP_DPF; - } - break; - case TLBRET_INVALID: - case TLBRET_NOMATCH: - /* No TLB match for a mapped address */ - if (rw == 2) { - exception = EXCP_ITLBMISS; - } else { - exception = EXCP_DTLBMISS; - } - break; -#endif - } cs->exception_index = exception; cpu->env.eear = address; @@ -182,7 +112,7 @@ int openrisc_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, { #ifdef CONFIG_USER_ONLY OpenRISCCPU *cpu = 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 = OPENRISC_CPU(cs); + int prot, excp, sr = cpu->env.sr; hwaddr phys_addr; - int prot; - int miss; - /* Check memory for any kind of address, since during debug the - gdb can ask for anything, check data tlb for address */ - miss = 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 = get_phys_mmu(cpu, &phys_addr, &prot, addr, + PROT_EXEC | PROT_READ | PROT_WRITE, + (sr & SR_SM) != 0); + return excp ? -1 : phys_addr; - /* Check instruction tlb */ - if (miss) { - miss = get_phys_addr(cpu, &phys_addr, &prot, addr, MMU_INST_FETCH); - } - - /* Last, fall back to a plain address */ - if (miss) { - miss = get_phys_nommu(&phys_addr, &prot, addr); - } + 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 = get_phys_mmu(cpu, &phys_addr, &prot, addr, + PROT_EXEC | PROT_READ | PROT_WRITE, + (sr & SR_SM) != 0); + if (!excp) { + return phys_addr; + } + /* fallthru */ - 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 size, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { OpenRISCCPU *cpu = OPENRISC_CPU(cs); - int ret, prot = 0; - hwaddr physical = 0; + int prot, excp; + hwaddr phys_addr; if (mmu_idx == MMU_NOMMU_IDX) { - ret = get_phys_nommu(&physical, &prot, addr); + /* The mmu is disabled; lookups never fail. */ + get_phys_nommu(&phys_addr, &prot, addr); + excp = 0; } else { bool super = mmu_idx == MMU_SUPERVISOR_IDX; - if (access_type == MMU_INST_FETCH) { - ret = get_phys_code(cpu, &physical, &prot, addr, 2, super); - } else { - ret = get_phys_data(cpu, &physical, &prot, addr, - access_type == MMU_DATA_STORE, super); - } + int need = (access_type == MMU_INST_FETCH ? PROT_EXEC + : access_type == MMU_DATA_STORE ? PROT_WRITE + : PROT_READ); + excp = get_phys_mmu(cpu, &phys_addr, &prot, addr, need, super); } - if (ret == 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 == MMU_INST_FETCH) { - rw = 2; - } else if (access_type == MMU_DATA_STORE) { - rw = 1; - } else { - rw = 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 From patchwork Mon Jul 2 15:10:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140818 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp90979ljj; Mon, 2 Jul 2018 08:34:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf5tsNlsitvoOT2m51qGrgTPyJ8dxBHUPakLp75bE5XEW6Dk2IeVlrerZHUkCO20JnaIOMD X-Received: by 2002:a0c:93dc:: with SMTP id g28-v6mr22731666qvg.153.1530545644956; Mon, 02 Jul 2018 08:34:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530545644; cv=none; d=google.com; s=arc-20160816; b=S0vqcv7r5icS8m8DNB/8LOly6gKV/JxA/n8m7HAMH4ePbjk8nOgjyIdOkJeAOznMZ5 6Lh6MB7wsrq6ghJhTCG4td28JQrrNiGLX91+hGgPg+Hy/finD2NsyvJbf6pe+hGdh6DT dTqMhrPwrzLFi+t0l5iIakB6KFpqSoIP3K33m4Tpo80AM+I2NndvJjlk7tKfuKwn3NSy 2nfDLvWjdqZTfNalz0lxfuHVY1EvrRHh/RgaSmrseY0cv7JDEFhBwA5jI06VBtY0jZf4 /z4ffpgze3R0jkRgOlJEIJgecf8Pe2eSZouCx9CrFLZZT+XNNTtekFWrbnszjKG9ysTS T7Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=dkOZj/ZqKz8fgp7lnx+Urncpk3L1UM+0bsh5NWkTToY=; b=WnyGMcuYIyFTSrGSFUD2ymJeMRfz6OkMI68KRoMRtvuWAdL+5kMIUgbAlaE3ZOQrLJ YhZtgkgmVoMGa8ZvTiF62c3knkcjq1KfeUtLsYD6JwvP916zQ043fhmaS/j7xd5Cob62 91A3/2I9aDoPswDxDd/br26SLqc+o6ZJAXG8YTt5/udV1D75eUhrDdA0aPo4tSJoKW6a 5dPdjwdJJoQg03BaZs2DGBgtb2kObB0aib3xZUT4KbaIz3Ca/8t4Nb9wm5dKa6sSuFNZ NftJZnM72twPeWcBSGZt1nwhzHGqKG0+rBZhcgStz2SQfZHs5fvB2ANIEtaTs5I33KnJ 5OAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="K3KHyh5/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j18-v6si140169qke.52.2018.07.02.08.34.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:34:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="K3KHyh5/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0q4-0005R6-5D for patch@linaro.org; Mon, 02 Jul 2018 11:34:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49005) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0UG-0004VG-DS for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0UF-0008Jp-Cl for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:32 -0400 Received: from mail-pl0-x22d.google.com ([2607:f8b0:400e:c01::22d]:34291) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0UF-0008JY-7P for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:31 -0400 Received: by mail-pl0-x22d.google.com with SMTP id z9-v6so8099164plo.1 for ; Mon, 02 Jul 2018 08:11:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dkOZj/ZqKz8fgp7lnx+Urncpk3L1UM+0bsh5NWkTToY=; b=K3KHyh5/otDH1//tNkZTYgd293q592W4f5pXCQeEIIQS3T1y9vXj6FkeWsxQ8DmQA7 nANYPwGyeC7AA+CglivPLiOZOIUNVDt65RDrPqnbd7SHiTY6yFTwEF7KsA1BF1L3u1py bBQ8B/1JoQT1n7MNbniOpZVgkb4N9UZel/+MiE6XFY4xG55Kny4mOsJAmRke8KFf2HC0 1ZG/JkMU2rxAMWcgpDRaRhDQnEGGmDYpK3tGzdVbgWjXzZOe/Y8EmkFm1hZi0m2b60sq W1xRpk+DBnri9qE8XI6TIrIB3bNUFcTuYV7cksuo+QU8LN3ztxSxtjvp2zzP4tJDL2Iv TCXw== 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=dkOZj/ZqKz8fgp7lnx+Urncpk3L1UM+0bsh5NWkTToY=; b=L+3LnJ1Fdg4fE6WsOuky1+fXXVJx9wvFf2SDlzqEFLIOKY9oEf6EgJ6iUKbKYg/ogz GuNjhUQDt5qG8zxwJaONVWBE3CPgDWCOSWBuFXuVRvUfb+a90efKfZ92o2NFiIRA60uw 1ZSYeFOdEJjOkRlzx98Xi42epMeOMdHHlY8c4KuNv7inq92O0co6En50HLdYivQGWScl d67FtNIsoR56//6Mx55cNcd+gTq38iLsqjyX/xRZmDR/sjLwp6yQZgPFxMGwxjz5nyw/ QaWht22IssS6ekPy9kXRnimcAjdzPj1OB6HP8Vs9rxuoT9SQ+d/lmBWO13gVv4kzCDqP xD2Q== X-Gm-Message-State: APt69E1JLe4XiSRtoRGiymKOx6RvUiiMXc5knXTVnLKlKdjAqcY6XKcI 7z/FsrfvIWS2IZebD4yCF5A= X-Received: by 2002:a17:902:650a:: with SMTP id b10-v6mr26618210plk.45.1530544290459; Mon, 02 Jul 2018 08:11:30 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id a27-v6sm28654596pfc.18.2018.07.02.08.11.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:11:29 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:19 +0900 Message-Id: <20180702151023.24532-22-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::22d Subject: [Qemu-devel] [PULL v2 21/25] 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: Stafford Horne , Riku Voipio , Richard Henderson , QEMU Development , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- scripts/qemu-binfmt-conf.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.17.0 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. qemu_target_list="i386 i486 alpha arm armeb sparc32plus ppc ppc64 ppc64le m68k \ mips mipsel mipsn32 mipsn32el mips64 mips64el \ -sh4 sh4eb s390x aarch64 aarch64_be hppa riscv32 riscv64 xtensa xtensaeb microblaze microblazeel" +sh4 sh4eb s390x aarch64 aarch64_be hppa riscv32 riscv64 xtensa xtensaeb \ +microblaze microblazeel or1k" i386_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00' i386_mask='\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='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\ microblazeel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' microblazeel_family=microblazeel +or1k_magic='\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x5c' +or1k_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff' +or1k_family=or1k + qemu_get_family() { cpu=${HOST_ARCH:-$(uname -m)} case "$cpu" in From patchwork Mon Jul 2 15:10:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140805 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp76901ljj; Mon, 2 Jul 2018 08:20:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd9/AKLi+5P/l0s4C5V117r2zvepLYnrO6Wvk1LlZbEfJAWCfDDiCN/CWwusMLfi3bKr6kt X-Received: by 2002:ac8:2825:: with SMTP id 34-v6mr24406746qtq.377.1530544823501; Mon, 02 Jul 2018 08:20:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530544823; cv=none; d=google.com; s=arc-20160816; b=ecvKmYa3aAbHIe79w8TMC3oX+dsdhC8JqfCtNng0728iTLeUWYh2iGl/NLPacSFalE kAvyzFSnPChfHey1vxxcY0NvZ3HuQ9j610In711o4PFLnJlaE6p7CSeQR6tc+lj5t28T EhKPEGwDxU2E1Qpittn1HKYwtKRzf7Imw1lwAUqJ4C1mRZrSkuL27OBBalc8W2rom9yD eVdW8W28g4VpdsgABIWoTrcEtuJlN5oRRtjulU728o2KQDi4hHL0iAIPJdLKhBVdLjuK CqVeCQWYyltBMB6mdv100+ErGaGb5mf0Th8FQ9mj4uClXgHYAuSJs6W9yQfQ6PpSCKpd Yhxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=F7rcxKazhym6fGcGabR+MBUe2uMPrZbSmGMOt1qshwg=; b=UIJ4ity2z1fB7SAr56qZRR5wlBlW8A2lF9Mj+e+ObaVgwDeH+b/3HWekoqxvQQLeNu 39fk0g0n75+Y2DincTXue+g59eOgMgnpIk61tzOtFGo4vfIyTn1URL0ShZmf5+6YqI5V GZ9tx1yeYZyGM819Ncme/aMKMAfaFPGTmpF8eSWa/Wz4qmHl1BIW6myrUh85ipaFWiGA 7GfWIP5aHZghXwNwCraP7E4qQvPQifO2qpRf8VbHPC+A1ok5p33rGr0J08MwWCI/CVaC Ho18uLJbyIJTHhV2OwOWJRZFS0TfTAHKGrMfyqj6B5V2sAGFyVPFqq0BwdcqQhc1X1vv Ojfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Q+eYbQ1H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c49-v6si1990362qtd.156.2018.07.02.08.20.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:20:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Q+eYbQ1H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33488 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0co-0002mz-O8 for patch@linaro.org; Mon, 02 Jul 2018 11:20:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0UJ-0004Yq-SJ for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0UI-0008LS-06 for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:35 -0400 Received: from mail-pg0-x22e.google.com ([2607:f8b0:400e:c05::22e]:35410) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0UH-0008Kr-OV for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:33 -0400 Received: by mail-pg0-x22e.google.com with SMTP id i7-v6so7283771pgp.2 for ; Mon, 02 Jul 2018 08:11:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F7rcxKazhym6fGcGabR+MBUe2uMPrZbSmGMOt1qshwg=; b=Q+eYbQ1HDuX6YKqCcCixkMqFktX+4EFti6TIPZPFiXSUoD11jEwE1TYW5B06I0tuoN 5YldayxJ0kMFVo7XfCS4LI72WKSaNWhDtwx1e601jYPwCw3FRBNQXtBn6DquOmbCP7jc YxBuz8hR5TaTYZeqPhyTHuBDbjmwwG2kL1Lfg8RhrXRKaCeVAHlSIO4Bm2icz/CQow4g EJJ95qlCmsV4ZbmSersXcdY0IrSNna80w9LA1D1GrbqlXBYdaS2RcQ/2R0Qzb2cvBlnh 0sIUqdNFQbDDLNDYTgqfKUrYehSuLSBAyFjiN0tpEo5waD/2gksyuN2wynLO7bZ2aX4Z xJGQ== 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=F7rcxKazhym6fGcGabR+MBUe2uMPrZbSmGMOt1qshwg=; b=mtkYhVbJIvwiTqDMaDVAvmQVUUJd5LbBRTu539IG/L4eUFdnAOiP5eLJ4pFnxHWPwP e5GBOcwIdYqsyF/KPSE7wcnFjIAacwNt/JGE2yKWKGdWrcDgAi9NCYvgE/uuqGoxYkmL 29O+CUIqBrMZgOcYnLeQ1scgsfcqArGrLfTlLznYz+GMR1j7o1s6YQ9fMuVsWUJ44Lpp oQr4Tf2IjftAVdTldViRqH1Q7exenb7uIliXdCjH23vESb9dGC9SpzEBamEX0JCyhFnY tl+5+HdnX7mXeAWeca7PiAK3o8Ko4P5sg3vv6SeFRFuL3B/wLqVpQtpb5G8FoRsxSrCC s2cQ== X-Gm-Message-State: APt69E3zvM1jWQY8tRtBiji05mhBpztG5TOCBQD3nEcLNZVqbC8rSVGw vkUvKjeTpbGQD3ifFkn/aoM= X-Received: by 2002:a62:5984:: with SMTP id k4-v6mr11261090pfj.116.1530544292852; Mon, 02 Jul 2018 08:11:32 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id d18-v6sm24357599pfn.118.2018.07.02.08.11.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:11:32 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:20 +0900 Message-Id: <20180702151023.24532-23-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22e Subject: [Qemu-devel] [PULL v2 22/25] 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: Stafford Horne , Riku Voipio , Richard Henderson , QEMU Development , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson All of the existing code was boilerplate from elsewhere, and would crash the guest upon the first signal. Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- v2: Add a comment to the new definition of target_pt_regs. Install the signal mask into the ucontext. v3: Incorporate feedback from Laurent. --- linux-user/openrisc/signal.c | 217 +++++++++++---------------- linux-user/openrisc/target_syscall.h | 28 +--- linux-user/signal.c | 2 +- target/openrisc/cpu.c | 1 + 4 files changed, 94 insertions(+), 154 deletions(-) -- 2.17.0 diff --git a/linux-user/openrisc/signal.c b/linux-user/openrisc/signal.c index 8be0b74001..232ad82b98 100644 --- a/linux-user/openrisc/signal.c +++ b/linux-user/openrisc/signal.c @@ -21,124 +21,69 @@ #include "signal-common.h" #include "linux-user/trace.h" -struct target_sigcontext { +typedef struct target_sigcontext { struct target_pt_regs regs; abi_ulong oldmask; - abi_ulong usp; -}; +} target_sigcontext; -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; -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 */ -}; - -/* This is the asm-generic/ucontext.h version */ -#if 0 -static int restore_sigcontext(CPUOpenRISCState *regs, - struct target_sigcontext *sc) -{ - unsigned int err = 0; - unsigned long old_usp; - - /* Alwys make any pending restarted system call return -EINTR */ - current_thread_info()->restart_block.fn = do_no_restart_syscall; + target_ucontext uc; + uint32_t retcode[4]; /* trampoline code */ +} target_rt_sigframe; - /* 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) - */ +static void restore_sigcontext(CPUOpenRISCState *env, target_sigcontext *sc) +{ + int i; + abi_ulong v; - if (copy_from_user(regs, &sc, sizeof(struct target_pt_regs))) { - goto badframe; + for (i = 0; i < 32; ++i) { + __get_user(v, &sc->regs.gpr[i]); + cpu_set_gpr(env, i, v); } + __get_user(env->pc, &sc->regs.pc); - /* make sure the U-flag is set so user-mode cannot fool us */ - - regs->sr &= ~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] = 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 /* Set up a signal frame. */ -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 = cpu_get_gpr(regs, 1); - - /* copy the regs. they are first in sc so we can use sc directly */ + int i; - /*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 = CRIS_FRAME_NORMAL;*/ - - /* then some other stuff */ - __put_user(mask, &sc->oldmask); - __put_user(usp, &sc->usp); -} + for (i = 0; i < 32; ++i) { + __put_user(cpu_get_gpr(env, i), &sc->regs.gpr[i]); + } -static inline unsigned long align_sigframe(unsigned long sp) -{ - return sp & ~3UL; + __put_user(env->pc, &sc->regs.pc); + __put_user(cpu_get_sr(env), &sc->regs.sr); } static inline abi_ulong get_sigframe(struct target_sigaction *ka, - CPUOpenRISCState *regs, + CPUOpenRISCState *env, size_t frame_size) { - unsigned long sp = get_sp_from_cpustate(regs); - int onsigstack = on_sig_stack(sp); - - /* redzone */ - sp = target_sigsp(sp, ka); - - sp = align_sigframe(sp - frame_size); + target_ulong sp = get_sp_from_cpustate(env); - /* - * 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. + /* Honor redzone now. If we swap to signal stack, no need to waste + * the 128 bytes by subtracting afterward. */ + sp -= 128; - if (onsigstack && !likely(on_sig_stack(sp))) { - return -1L; - } + sp = target_sigsp(sp, ka); + sp -= frame_size; + sp = QEMU_ALIGN_DOWN(sp, 4); return sp; } @@ -147,11 +92,9 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, target_siginfo_t *info, target_sigset_t *set, CPUOpenRISCState *env) { - int err = 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; frame_addr = get_sigframe(ka, env, sizeof(*frame)); trace_user_setup_rt_frame(env, frame_addr); @@ -159,47 +102,37 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, goto give_sigsegv; } - info_addr = frame_addr + offsetof(struct target_rt_sigframe, info); - __put_user(info_addr, &frame->pinfo); - uc_addr = frame_addr + offsetof(struct target_rt_sigframe, uc); - __put_user(uc_addr, &frame->puc); - if (ka->sa_flags & SA_SIGINFO) { tswap_siginfo(&frame->info, info); } - /*err |= __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 |= copy_to_user(frame->uc.tuc_sigmask, set, sizeof(*set));*/ - - /* trampoline - the desired return ip is the retcode itself */ - return_ip = (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; + target_save_altstack(&frame->uc.tuc_stack, env); + setup_sigcontext(&frame->uc.tuc_mcontext, env); + for (i = 0; i < TARGET_NSIG_WORDS; ++i) { + __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } - /* 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); /* Set up registers for signal handler */ - env->pc = (unsigned long)ka->_sa_handler; /* what we enter NOW */ - cpu_set_gpr(env, 9, (unsigned long)return_ip); /* what we enter LATER */ - 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); + + /* For debugging convenience, set ppc to the insn that faulted. */ + env->ppc = env->pc; + /* When setting the PC for the signal handler, exit delay slot. */ + env->pc = ka->_sa_handler; + env->dflag = 0; return; give_sigsegv: @@ -207,16 +140,34 @@ give_sigsegv: force_sigsegv(sig); } -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 = get_sp_from_cpustate(env); + 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_stack), + 0, frame_addr) == -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/openrisc/target_syscall.h b/linux-user/openrisc/target_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 +/* 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; }; #define UNAME_MACHINE "openrisc" 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; } -#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 = OPENRISC_CPU(cs); cpu->env.pc = value; + cpu->env.dflag = 0; } static bool openrisc_cpu_has_work(CPUState *cs) From patchwork Mon Jul 2 15:10:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140808 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp80181ljj; Mon, 2 Jul 2018 08:23:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeJ/MQCWNgjyJ37vfyHeHUtpgd9ogZOa6NruuME1Fzc1z474orb27ATSly+pO7/SQ5RskPY X-Received: by 2002:ac8:299c:: with SMTP id 28-v6mr23413149qts.37.1530545017226; Mon, 02 Jul 2018 08:23:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530545017; cv=none; d=google.com; s=arc-20160816; b=kiayZxmAkI9iPnqesBYwLvf4qrbahFpNFmddeBFNQTwcghy7CM8k+zqSCV/PWhbaWU T3vSW1IKAuOHz9wH5SBl/20S4KpPqya45CISIMbDo6XbH1oY3Ftq9FKDuVKgF3ZaULuh lLHDqVB4WB0/AELH0UhPD3JrFxARk1Q/EazVm7ayZZv+2EOVqFCQWU7qxUUcWmnVcCr0 mSuBrn7SGyreDg1JHyeKoTMpjoMkWvm3QWBHNoWJ3j4tq3cf5A90FADAJN/cIpxpWvdL ULx4pPSJP83byeMW8AaIv+CgnMTjtcGoAXs3dKEisf8aTAB6pxHg5freyTsGGns7tb4I i0MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Jg5o5O8f7NGqpFAqaMDMujT5BHfLWo7v6FNRox8NIPo=; b=rWLi+mM0PXqjy6htK3RnwR3HMo87Wk9RFSO7Dh3ADsX4qLW3ImbUwbTSeJZU2lWqFw 7ZpanEu0+5KfsOqubeYvFC1f4NTOs8857kZcdAHNFFxeYqIR5LZEkMnG0hQMXT3j0NIH xnQlUDZvKLAhuMccslWUX0GQd6o8l+1dHdT+sqRGJ+mQ+qz90ygcNX5ytG+jjpcO+mpN r9b4Mlg0nQDIl43j6V5w3e+BXOUPfHPtOmSUAGJJIiB3OWEzQVW6jTBjUMEcO/B5dmyV mjgFls1GkME8aGEE9lz0fdd/rN4qoOP06oNdJE6eWqjqg6BHEZyDhCpw/YL1Rcymeszd VBwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=EwcOS6eK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z78-v6si2774599qka.151.2018.07.02.08.23.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 08:23:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=EwcOS6eK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:33509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0fw-0005IS-Kl for patch@linaro.org; Mon, 02 Jul 2018 11:23:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa0UO-0004dW-Vn for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa0UK-0008MY-FD for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:40 -0400 Received: from mail-pg0-x22d.google.com ([2607:f8b0:400e:c05::22d]:45041) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fa0UK-0008MC-9w for qemu-devel@nongnu.org; Mon, 02 Jul 2018 11:11:36 -0400 Received: by mail-pg0-x22d.google.com with SMTP id r1-v6so1582505pgp.11 for ; Mon, 02 Jul 2018 08:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Jg5o5O8f7NGqpFAqaMDMujT5BHfLWo7v6FNRox8NIPo=; b=EwcOS6eKSOLbxWUoQDS124IewN9pvgpNlpB3WiKyAbneD81jER8gHrPZatvBimcJ2I iiOTxgGvsgR829CfRNVs1ODo5Aad/i8ALMiV6xanDNtVMtQ5T7an81YUTJjebRSag0ck B+PgzMSNkXnIWWE87KIMmDZFPl5UBdMZmZ89lfsZE9mjJRhhIO5OzcmU4bAFvaDhPu39 kafnoW8e5/22FVhK2ae8Z0mo9uzAy2f8RKg3ppCB+9A575qcACoxkvNyu5Ihujnmj82G rUZmkE6W6sUvVWaFgYjhBi716xV3foWN6o1yG0t1i6Y16GAL+B23+Y1SzF7HJGxFyfes zbQQ== 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=Jg5o5O8f7NGqpFAqaMDMujT5BHfLWo7v6FNRox8NIPo=; b=DZu4xgTnVHJIJcQ4XEGgLXK+/C4t4DGwvLtco0JDDunte763bNeA2xRPkR+LYdSMdc jphSKFiSHuvwmfNFHLqehSEwycihy/iQZQGiMgR819esVJbeY11+BMxtPmUiMVc4vQAi +pjtVug/8udw6UI5Dhl+YWe3mvqKA39ZpHx0yNao2vGJBf6tJ8GGlCufXc5mRoXCQ7R2 EsVL6Xle7uncq6m25EHRcIY2Lobq7TEzs0mkMCTb/r+omZGM0kNFu1ePnXtMgFxBJ/cn zpy7YDDR2oXwmTvNG26nazCBJPD3JwNmGGTBSQ/6/wfrz6O6otfDsYtteviLNDsIRDFQ VOuw== X-Gm-Message-State: APt69E2lh47QkdyhScBalwdAedFjEuDbHtAsAkOKYk7qabitw9ArJJaU 8+bOdFBnnKQ4Vg0j3j6N/U0= X-Received: by 2002:a63:7a43:: with SMTP id j3-v6mr5577383pgn.363.1530544295441; Mon, 02 Jul 2018 08:11:35 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id y9-v6sm3319276pgv.31.2018.07.02.08.11.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:11:34 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Tue, 3 Jul 2018 00:10:21 +0900 Message-Id: <20180702151023.24532-24-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702151023.24532-1-shorne@gmail.com> References: <20180702151023.24532-1-shorne@gmail.com> 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] [PULL v2 23/25] 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: Stafford Horne , Riku Voipio , Richard Henderson , QEMU Development , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- linux-user/openrisc/target_signal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.0 diff --git a/linux-user/openrisc/target_signal.h b/linux-user/openrisc/target_signal.h index c352a8b333..8283eaf544 100644 --- a/linux-user/openrisc/target_signal.h +++ b/linux-user/openrisc/target_signal.h @@ -5,8 +5,8 @@ typedef struct target_sigaltstack { abi_long ss_sp; + abi_int ss_flags; abi_ulong ss_size; - abi_long ss_flags; } target_stack_t; /* sigaltstack controls */