From patchwork Sat Mar 23 19:08:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160996 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2201650jan; Sat, 23 Mar 2019 12:52:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdWM/0tTgt/CWzgNjdhOqM/z5s2Wxos6/w7qCNHX7GKrenpcJNt8By9NBiNqsluR+496S3 X-Received: by 2002:a25:938f:: with SMTP id a15mr13209626ybm.19.1553370777265; Sat, 23 Mar 2019 12:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553370777; cv=none; d=google.com; s=arc-20160816; b=rg3XonM9H6H8kxgajV7j5n1gZGmTrMx6pNXkDZbBMszbscoM/PFaRE0M7DrttTI9Ox /3pii86NW18IE7NCM4mf3lllYzoaYdrmKtyxm+KXKw0y90JJuZU/fvifv564V77PdVJ3 OXO6iYe6t1vJe0m34j5rxH4hrHxHAmULbxdQDTc6t/9rF+hOgwMwCGZK4O1Ok1NVcbpl ER1IYgAi61SiJmfJa2QfRkPf2sDm9UnisUoNyCYXS86r97pceDZw1HC5tOXgDrpEJ9Zt B6JQmweRRhMM+nqoT9FQnKmhn1aFqcO/3haODXTcwp1nS+tXdZV0zLdcURBKdhZBHtLw tDkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:message-id:date:to:from :dkim-signature; bh=AX3saUASTaFcbAzfODlP7iUxHWFv63027uwNqqWaT8Q=; b=lxaBRB+viOALCHy3xJM5ZtmtwIRa1dwztQZmDGE/FuaGUIccQBgLSofG2KnUc77u0A 4jOkl44eu+60Ex76QlVortobhEVqv28gfstLH3xcHgRuzGMZZXA/ZgQ6o2PSlmcBh2CC yRCBmA0ZFVov+PRO10m/2C8VuM7Qwh4f91v40aI/2L0OS/8ipA7juSLyzWkI7wCWqeEu qt04N7vhqD94zfHYfpLZfcC0sJK+6rQXOtws73MSxQIUMa8r6SVu0Jjm89Nw3ntoUtd7 YjtFTTvXk6+UK4qN1nX6BVRsE/PFnHSc21vRA3vXuj8I4+2XDuG9h98rVVDpfwQkrkH4 PtUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qo1romUo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p5si7240660ybg.218.2019.03.23.12.52.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 23 Mar 2019 12:52:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qo1romUo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:47348 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7mhM-0007PM-Qb for patch@linaro.org; Sat, 23 Mar 2019 15:52:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7mGI-0008Km-8w for qemu-devel@nongnu.org; Sat, 23 Mar 2019 15:25:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h7m1K-0006ko-ST for qemu-devel@nongnu.org; Sat, 23 Mar 2019 15:09:32 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:45721) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h7m1K-0006k7-8s for qemu-devel@nongnu.org; Sat, 23 Mar 2019 15:09:30 -0400 Received: by mail-pg1-x536.google.com with SMTP id y3so3683239pgk.12 for ; Sat, 23 Mar 2019 12:09:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id; bh=AX3saUASTaFcbAzfODlP7iUxHWFv63027uwNqqWaT8Q=; b=qo1romUo+fzzJKgRa7DaXmC2jLCdCVjQZoHT5/HMHb1vwG0RoUpb4uEpJgSeKmLKxV +UvYxrMADOjihQFsrk88PVdT3yY3k0RM/dxl/ou4R3Sn2ssigFF09bIPm1VMEE+/GLUr NSNKnnlFEW7PQeklyQst6Vm+uScm03XAHB1ByXbCc1HNpubsANi+CsI8zC/2sAoGcuDC erv0Y2BxsgvT0T8LBTMaN9ylobS5mHHzKsvRE/1jrIqa+KvNAzQ5kkYLtGRX5+NTfM2s MMjewzITwxz3aWdlI1MwDuY3NDT4BwZIg7jugjbVR1bJFWF2bSCpz1o0WJQqgZweKZU3 VKPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=AX3saUASTaFcbAzfODlP7iUxHWFv63027uwNqqWaT8Q=; b=uQ1X9BIJeCqdyX8DOOP4rSLDHKqeijY4MkaSMF7TAn+lzdgL/1EbdeiewTZAwG/nwa kkrLzkkomyDsVFgrTNI4+GgqVC/qju07Q+yS6u0SWrX2NEGLWWWBIru/sESvdabthpOj BhTgkJY7XEwre3w8GjHytMqsokJkx7Hfq3ju/bvEGqYXnrXePdAlBXXcP+tOkeU/EnYm nX8LBNXC8WKo+OWX+WJY5Um0S5yH3lPVXbGaxeDsn4t/QEpfmefJO0OIZpcSLD8d0Bf/ r2Zqh8a+srjGJnGP5jQDfbt6sTDxPQ0fo7rnhUnWDam6sy5BXlAbVXxCf4oGHxyX9A0n Ko9Q== X-Gm-Message-State: APjAAAUONmJYVqPE74I1mtSognsNCyrE0vcrcUrfoa0inrCnAZljUe0G 3hrhG+aChdSu002dT3G6W4GNG3XOVCk= X-Received: by 2002:aa7:8b12:: with SMTP id f18mr16169722pfd.240.1553368168043; Sat, 23 Mar 2019 12:09:28 -0700 (PDT) Received: from localhost.localdomain (174-21-5-201.tukw.qwest.net. [174.21.5.201]) by smtp.gmail.com with ESMTPSA id h184sm25990703pfc.78.2019.03.23.12.09.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Mar 2019 12:09:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 23 Mar 2019 12:08:50 -0700 Message-Id: <20190323190925.21324-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::536 Subject: [Qemu-devel] [PATCH for-4.1 00/35] tcg: Move the softmmu tlb to CPUNegativeOffsetState 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This started merely as an attempt to reduce the size of each softmmu lookup by using smaller offsets from env. But in the end it also represents a significant cleanup in the boilerplate that each target must define. With respect to the initial goal, here are the relevant code snips generated for loading the mask & table fields for a qemu_ld from an aarch64 guest on the indicated host. BEFORE: x86_64: 0x7f9698c5f73b: 48 23 bd 98 32 00 00 andq 0x3298(%rbp), %rdi 0x7f9698c5f742: 48 03 bd d8 32 00 00 addq 0x32d8(%rbp), %rdi aarch64: 0xffff9e001e28: 91400e61 add x1, x19, #3, lsl #12 0xffff9e001e2c: f9414c20 ldr x0, [x1, #0x298] 0xffff9e001e30: f9416c21 ldr x1, [x1, #0x2d8] aarch32: 0xa2b7f0d4: e2862a03 add r2, r6, #0x3000 0xa2b7f0d8: e592c20c ldr ip, [r2, #0x20c] 0xa2b7f0dc: e592222c ldr r2, [r2, #0x22c] AFTER: x86_64: 0x7fa40a000154: 48 23 7d e0 andq -0x20(%rbp), %rdi 0x7fa40a000158: 48 03 7d e8 addq -0x18(%rbp), %rdi aarch64: 0xffffa20001b4: a97e0660 ldp x0, x1, [x19, #-0x20] aarch32: 0xa2c7f0d4: e14604d8 ldrd r0, r1, [r6, #-0x48] The other tcg hosts do not see as significant difference. PPC and mips have 16-bit signed offsets, and have no load-pair/multiple. S390x has 20-bit signed offsets and, like x86, uses a read-operate instruction form. Sparc and RISC-V have 13 and 12-bit signed offsets respectively, and so do avoid an extra add insn in this case, but do not have load-pair/multiple. All that said, in the end I'm most happy with the diffstat result. r~ Richard Henderson (35): tcg: Fold CPUTLBWindow into CPUTLBDesc tcg: Split out target/arch/cpu-param.h tcg: Create struct CPUTLB cpu: Define CPUArchState with typedef cpu: Define ArchCPU cpu: Replace ENV_GET_CPU with env_cpu cpu: Introduce env_archcpu target/alpha: Use env_cpu, env_archcpu target/arm: Use env_cpu, env_archcpu target/cris: Use env_cpu, env_archcpu target/hppa: Use env_cpu, env_archcpu target/i386: Use env_cpu, env_archcpu target/lm32: Use env_cpu, env_archcpu target/m68k: Use env_cpu, env_archcpu target/microblaze: Use env_cpu, env_archcpu target/mips: Use env_cpu, env_archcpu target/moxie: Use env_cpu, env_archcpu target/nios2: Use env_cpu, env_archcpu target/openrisc: Use env_cpu, env_archcpu target/ppc: Use env_cpu, env_archcpu target/riscv: Use env_cpu, env_archcpu target/s390x: Use env_cpu, env_archcpu target/sh4: Use env_cpu, env_archcpu target/sparc: Use env_cpu, env_archcpu target/tilegx: Use env_cpu target/tricore: Use env_cpu target/unicore32: Use env_cpu, env_archcpu target/xtensa: Use env_cpu, env_archcpu cpu: Move ENV_OFFSET to exec/gen-icount.h cpu: Introduce CPUNegativeOffsetState cpu: Move icount_decr to CPUNegativeOffsetState cpu: Move the softmmu tlb to CPUNegativeOffsetState cpu: Remove CPU_COMMON tcg/aarch64: Use LDP to load tlb mask+table tcg/arm: Use LDRD to load tlb mask+table Makefile.target | 1 + accel/tcg/atomic_template.h | 8 +- accel/tcg/softmmu_template.h | 24 +- include/exec/cpu-all.h | 46 +++ include/exec/cpu-defs.h | 113 ++++-- include/exec/cpu_ldst.h | 6 +- include/exec/cpu_ldst_template.h | 6 +- include/exec/cpu_ldst_useronly_template.h | 6 +- include/exec/gen-icount.h | 14 +- include/exec/softmmu-semi.h | 16 +- include/qom/cpu.h | 28 +- linux-user/cpu_loop-common.h | 2 +- linux-user/m68k/target_cpu.h | 2 +- target/alpha/cpu-param.h | 19 + target/alpha/cpu.h | 40 +- target/arm/cpu-param.h | 22 ++ target/arm/cpu.h | 52 +-- target/cris/cpu-param.h | 5 + target/cris/cpu.h | 25 +- target/hppa/cpu-param.h | 22 ++ target/hppa/cpu.h | 38 +- target/i386/cpu-param.h | 14 + target/i386/cpu.h | 40 +- target/lm32/cpu-param.h | 5 + target/lm32/cpu.h | 25 +- target/m68k/cpu-param.h | 9 + target/m68k/cpu.h | 28 +- target/microblaze/cpu-param.h | 6 + target/microblaze/cpu.h | 63 ++-- target/mips/cpu-param.h | 18 + target/mips/cpu.h | 21 +- target/mips/mips-defs.h | 15 - target/moxie/cpu-param.h | 5 + target/moxie/cpu.h | 29 +- target/nios2/cpu-param.h | 9 + target/nios2/cpu.h | 33 +- target/openrisc/cpu-param.h | 5 + target/openrisc/cpu.h | 31 +- target/ppc/cpu-param.h | 25 ++ target/ppc/cpu.h | 54 +-- target/ppc/helper_regs.h | 4 +- target/riscv/cpu-param.h | 11 + target/riscv/cpu.h | 35 +- target/s390x/cpu-param.h | 5 + target/s390x/cpu.h | 31 +- target/sh4/cpu-param.h | 9 + target/sh4/cpu.h | 30 +- target/sparc/cpu-param.h | 17 + target/sparc/cpu.h | 36 +- target/tilegx/cpu-param.h | 5 + target/tilegx/cpu.h | 23 +- target/tricore/cpu-param.h | 5 + target/tricore/cpu.h | 22 +- target/tricore/tricore-defs.h | 5 - target/unicore32/cpu-param.h | 5 + target/unicore32/cpu.h | 24 +- target/xtensa/cpu-param.h | 9 + target/xtensa/cpu.h | 40 +- accel/tcg/cpu-exec.c | 23 +- accel/tcg/cputlb.c | 193 +++++----- accel/tcg/tcg-all.c | 6 +- accel/tcg/tcg-runtime.c | 4 +- accel/tcg/translate-all.c | 10 +- accel/tcg/user-exec.c | 2 +- bsd-user/main.c | 5 +- bsd-user/syscall.c | 6 +- cpus.c | 9 +- hw/i386/kvmvapic.c | 4 +- hw/i386/pc.c | 2 +- hw/intc/mips_gic.c | 2 +- hw/mips/mips_int.c | 2 +- hw/nios2/cpu_pic.c | 5 +- hw/ppc/ppc.c | 18 +- hw/ppc/ppc405_uc.c | 2 +- hw/ppc/ppc_booke.c | 4 +- hw/sparc/leon3.c | 4 +- hw/sparc/sun4m.c | 4 +- hw/sparc64/sparc64.c | 2 +- hw/unicore32/puv3.c | 2 +- hw/xtensa/pic_cpu.c | 2 +- linux-user/aarch64/cpu_loop.c | 6 +- linux-user/aarch64/signal.c | 4 +- linux-user/alpha/cpu_loop.c | 2 +- linux-user/arm/cpu_loop.c | 4 +- linux-user/cris/cpu_loop.c | 4 +- linux-user/elfload.c | 6 +- linux-user/hppa/cpu_loop.c | 2 +- linux-user/i386/cpu_loop.c | 2 +- linux-user/i386/signal.c | 2 +- linux-user/m68k-sim.c | 3 +- linux-user/m68k/cpu_loop.c | 4 +- linux-user/main.c | 2 +- linux-user/microblaze/cpu_loop.c | 2 +- linux-user/mips/cpu_loop.c | 4 +- linux-user/nios2/cpu_loop.c | 2 +- linux-user/openrisc/cpu_loop.c | 2 +- linux-user/ppc/cpu_loop.c | 2 +- linux-user/riscv/cpu_loop.c | 4 +- linux-user/s390x/cpu_loop.c | 2 +- linux-user/sh4/cpu_loop.c | 2 +- linux-user/signal.c | 8 +- linux-user/sparc/cpu_loop.c | 2 +- linux-user/syscall.c | 26 +- linux-user/tilegx/cpu_loop.c | 2 +- linux-user/uname.c | 2 +- linux-user/vm86.c | 18 +- linux-user/xtensa/cpu_loop.c | 2 +- qom/cpu-common.c | 425 ++++++++++++++++++++++ qom/cpu.c | 408 +-------------------- target/alpha/helper.c | 8 +- target/alpha/sys_helper.c | 8 +- target/arm/arm-semi.c | 4 +- target/arm/cpu64.c | 2 +- target/arm/helper-a64.c | 4 +- target/arm/helper.c | 160 ++++---- target/arm/op_helper.c | 21 +- target/arm/translate-a64.c | 4 +- target/arm/translate.c | 2 +- target/arm/vfp_helper.c | 2 +- target/cris/mmu.c | 3 +- target/cris/op_helper.c | 10 +- target/cris/translate.c | 2 +- target/hppa/helper.c | 3 +- target/hppa/int_helper.c | 4 +- target/hppa/mem_helper.c | 10 +- target/hppa/op_helper.c | 10 +- target/i386/bpt_helper.c | 4 +- target/i386/cpu.c | 4 +- target/i386/excp_helper.c | 2 +- target/i386/fpu_helper.c | 2 +- target/i386/hax-all.c | 6 +- target/i386/helper.c | 16 +- target/i386/hvf/x86_decode.c | 22 +- target/i386/hvf/x86_emu.c | 48 +-- target/i386/mem_helper.c | 4 +- target/i386/misc_helper.c | 24 +- target/i386/seg_helper.c | 14 +- target/i386/smm_helper.c | 4 +- target/i386/svm_helper.c | 22 +- target/lm32/helper.c | 19 +- target/lm32/op_helper.c | 6 +- target/lm32/translate.c | 2 +- target/m68k/helper.c | 33 +- target/m68k/m68k-semi.c | 4 +- target/m68k/op_helper.c | 14 +- target/m68k/translate.c | 4 +- target/microblaze/mmu.c | 5 +- target/microblaze/op_helper.c | 2 +- target/microblaze/translate.c | 2 +- target/mips/helper.c | 15 +- target/mips/op_helper.c | 25 +- target/mips/translate.c | 3 +- target/mips/translate_init.inc.c | 4 +- target/moxie/helper.c | 6 +- target/moxie/translate.c | 2 +- target/nios2/mmu.c | 14 +- target/nios2/op_helper.c | 2 +- target/openrisc/exception_helper.c | 5 +- target/openrisc/sys_helper.c | 8 +- target/ppc/excp_helper.c | 14 +- target/ppc/fpu_helper.c | 14 +- target/ppc/kvm.c | 5 +- target/ppc/misc_helper.c | 22 +- target/ppc/mmu-hash64.c | 14 +- target/ppc/mmu_helper.c | 116 +++--- target/ppc/translate_init.inc.c | 85 +++-- target/riscv/cpu_helper.c | 4 +- target/riscv/csr.c | 12 +- target/riscv/op_helper.c | 8 +- target/s390x/cc_helper.c | 5 +- target/s390x/diag.c | 2 +- target/s390x/excp_helper.c | 6 +- target/s390x/fpu_helper.c | 4 +- target/s390x/gdbstub.c | 24 +- target/s390x/helper.c | 7 +- target/s390x/int_helper.c | 3 +- target/s390x/interrupt.c | 6 +- target/s390x/mem_helper.c | 30 +- target/s390x/misc_helper.c | 50 +-- target/s390x/mmu_helper.c | 8 +- target/s390x/sigp.c | 4 +- target/sh4/helper.c | 26 +- target/sh4/op_helper.c | 11 +- target/sparc/fop_helper.c | 2 +- target/sparc/helper.c | 8 +- target/sparc/ldst_helper.c | 33 +- target/sparc/mmu_helper.c | 10 +- target/tilegx/helper.c | 2 +- target/tricore/op_helper.c | 4 +- target/unicore32/helper.c | 8 +- target/unicore32/op_helper.c | 2 +- target/unicore32/softmmu.c | 11 +- target/unicore32/translate.c | 26 +- target/unicore32/ucf64_helper.c | 2 +- target/xtensa/dbg_helper.c | 4 +- target/xtensa/exc_helper.c | 9 +- target/xtensa/helper.c | 2 +- target/xtensa/mmu_helper.c | 11 +- target/xtensa/xtensa-semi.c | 2 +- tcg/aarch64/tcg-target.inc.c | 36 +- tcg/arm/tcg-target.inc.c | 149 +++----- tcg/i386/tcg-target.inc.c | 6 +- tcg/mips/tcg-target.inc.c | 45 +-- tcg/ppc/tcg-target.inc.c | 32 +- tcg/riscv/tcg-target.inc.c | 37 +- tcg/s390/tcg-target.inc.c | 13 +- tcg/sparc/tcg-target.inc.c | 40 +- docs/devel/tracing.txt | 4 +- qom/Makefile.objs | 2 +- scripts/tracetool/format/tcg_helper_c.py | 2 +- 210 files changed, 1841 insertions(+), 2256 deletions(-) create mode 100644 target/alpha/cpu-param.h create mode 100644 target/arm/cpu-param.h create mode 100644 target/cris/cpu-param.h create mode 100644 target/hppa/cpu-param.h create mode 100644 target/i386/cpu-param.h create mode 100644 target/lm32/cpu-param.h create mode 100644 target/m68k/cpu-param.h create mode 100644 target/microblaze/cpu-param.h create mode 100644 target/mips/cpu-param.h create mode 100644 target/moxie/cpu-param.h create mode 100644 target/nios2/cpu-param.h create mode 100644 target/openrisc/cpu-param.h create mode 100644 target/ppc/cpu-param.h create mode 100644 target/riscv/cpu-param.h create mode 100644 target/s390x/cpu-param.h create mode 100644 target/sh4/cpu-param.h create mode 100644 target/sparc/cpu-param.h create mode 100644 target/tilegx/cpu-param.h create mode 100644 target/tricore/cpu-param.h create mode 100644 target/unicore32/cpu-param.h create mode 100644 target/xtensa/cpu-param.h create mode 100644 qom/cpu-common.c -- 2.17.1