From patchwork Fri Nov 6 03:28:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885813 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C596B6A2 for ; Fri, 6 Nov 2020 03:30:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5635B2072E for ; Fri, 6 Nov 2020 03:30:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="aSLqLaHg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5635B2072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasSl-0006HB-7A for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:30:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRO-0004N2-7U for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:30 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:41395) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRL-0006ts-T2 for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:29 -0500 Received: by mail-pg1-x542.google.com with SMTP id g12so2876635pgm.8 for ; Thu, 05 Nov 2020 19:29:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lehQd8crxjGQBWeXDLJdclPmnGEfBOkk/AcImly9kNg=; b=aSLqLaHg+ymgeMLJJB1HpiICsI+QVhfqrE/p5FB1aUYwhM+uC/zIM6prxOhmqoW6dq xX8Jaz0C5wrauQ12jMeJaH/06snuOSvPCtOQUQL/YjJV7JrPTXuAmQzpCmwNlosprsAU OSShzEL9TGaxCef5XLboQ8CczW8xaceejjuveIktgRDhD9kAtQx+7yD7zS0/CRyUH6FY m6smvFkUiwS6v+XsYkl6Jeh+8t8c3wV41p6U6/BSQL/HRdgV0qJncM3J6BmZTWaC5xDn Q59nuunl8HRrDSAZpHGl8Wfv+QAPQVjnIBr6frdtWBD3K7dJOWCZNaU4x2hUc2hyIXNB iJSw== 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=lehQd8crxjGQBWeXDLJdclPmnGEfBOkk/AcImly9kNg=; b=iPVAun2+ORDusHHpN4puzQjXMdf9fPcYze+NmVLeVyQEpEVt4/aRe5n+qNBdZHvqUp y7BknUszUyZw3bBOGCbjDzQdJwyw80Wm0aU6wO4SrdVtsFf4TUzsWvebAL4P3jdkvX6z h7QMLob0t19CInPvQJr86V3vT0zhKWMaQJ/0XQCkQyHkNdBM5A3UYwzleUNbQ0XJuXFE hPbrCmVZb1R9XUSJas6tGxeZ/CnpvbOeXL+DP4lgK84xKG9U4l/Mc2j/CjXt4/hxaXMH UC/nB66fwQ5Hi8UXtUvwffoirFUHcf9l3HmvyJv4Jg3MUBwcJcqUL78wy0SlIJYhOOd3 vyAg== X-Gm-Message-State: AOAM533jIDPl1D4Iyw0fa8TIgrjoU7v7Sh8xubak/TF5aRl3gtgBH/ZG naTox0RILAf70lObykU2l2wYnPzOdZtfiA== X-Google-Smtp-Source: ABdhPJxH2K7kg4i1MIiX6ty02NQEFjhSbEWxp92q3vzQbmMfUGIFsKo92U2TCjiIaRFsJkPZ+LbwRA== X-Received: by 2002:a63:b24e:: with SMTP id t14mr5164296pgo.224.1604633364350; Thu, 05 Nov 2020 19:29:24 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 01/41] tcg: Enhance flush_icache_range with separate data pointer Date: Thu, 5 Nov 2020 19:28:41 -0800 Message-Id: <20201106032921.600200-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::542; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x542.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" We are shortly going to have a split rw/rx jit buffer. Depending on the host, we need to flush the dcache at the rw data pointer and flush the icache at the rx code pointer. For now, the two passed pointers are identical, so there is no effective change in behaviour. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- tcg/aarch64/tcg-target.h | 9 +++++++-- tcg/arm/tcg-target.h | 8 ++++++-- tcg/i386/tcg-target.h | 3 ++- tcg/mips/tcg-target.h | 8 ++++++-- tcg/ppc/tcg-target.h | 2 +- tcg/riscv/tcg-target.h | 8 ++++++-- tcg/s390/tcg-target.h | 3 ++- tcg/sparc/tcg-target.h | 8 +++++--- tcg/tci/tcg-target.h | 3 ++- softmmu/physmem.c | 9 ++++++++- tcg/tcg.c | 6 ++++-- tcg/aarch64/tcg-target.c.inc | 2 +- tcg/mips/tcg-target.c.inc | 2 +- tcg/ppc/tcg-target.c.inc | 21 +++++++++++---------- tcg/sparc/tcg-target.c.inc | 4 ++-- 15 files changed, 64 insertions(+), 32 deletions(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 663dd0b95e..d0a6a059b7 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -148,9 +148,14 @@ typedef enum { #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) +/* Flush the dcache at RW, and the icache at RX, as necessary. */ +static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { - __builtin___clear_cache((char *)start, (char *)stop); + /* TODO: Copy this from gcc to avoid 4 loops instead of 2. */ + if (rw != rx) { + __builtin___clear_cache((char *)rw, (char *)(rw + len)); + } + __builtin___clear_cache((char *)rx, (char *)(rx + len)); } void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 17e771374d..fa88b24e43 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -134,9 +134,13 @@ enum { #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) +/* Flush the dcache at RW, and the icache at RX, as necessary. */ +static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { - __builtin___clear_cache((char *) start, (char *) stop); + if (rw != rx) { + __builtin___clear_cache((char *)rw, (char *)(rw + len)); + } + __builtin___clear_cache((char *)rx, (char *)(rx + len)); } /* not defined -- call should be eliminated at compile time */ diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index abd4ac7fc0..8323e72639 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -206,7 +206,8 @@ extern bool have_avx2; #define TCG_TARGET_extract_i64_valid(ofs, len) \ (((ofs) == 8 && (len) == 8) || ((ofs) + (len)) == 32) -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) +/* Flush the dcache at RW, and the icache at RX, as necessary. */ +static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { } diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index c6b091d849..47b1226ee9 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -207,9 +207,13 @@ extern bool use_mips32r2_instructions; #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) +/* Flush the dcache at RW, and the icache at RX, as necessary. */ +static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { - cacheflush ((void *)start, stop-start, ICACHE); + if (rx != rw) { + cacheflush((void *)rw, len, DCACHE); + } + cacheflush((void *)rx, len, ICACHE); } void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index be10363956..fbb6dc1b47 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -175,7 +175,7 @@ extern bool have_vsx; #define TCG_TARGET_HAS_bitsel_vec have_vsx #define TCG_TARGET_HAS_cmpsel_vec 0 -void flush_icache_range(uintptr_t start, uintptr_t stop); +void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len); void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_DEFAULT_MO (0) diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 032439d806..0fa6ae358e 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -159,9 +159,13 @@ typedef enum { #define TCG_TARGET_HAS_mulsh_i64 1 #endif -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) +/* Flush the dcache at RW, and the icache at RX, as necessary. */ +static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { - __builtin___clear_cache((char *)start, (char *)stop); + if (rx != rw) { + __builtin___clear_cache((char *)rw, (char *)(rw + len)); + } + __builtin___clear_cache((char *)rx, (char *)(rx + len)); } /* not defined -- call should be eliminated at compile time */ diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h index 63c8797bd3..c3dc2e8938 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -145,7 +145,8 @@ enum { TCG_AREG0 = TCG_REG_R10, }; -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) +/* Flush the dcache at RW, and the icache at RX, as necessary. */ +static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { } diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h index 633841ebf2..c27c40231e 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -168,10 +168,12 @@ extern bool use_vis3_instructions; #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) +/* Flush the dcache at RW, and the icache at RX, as necessary. */ +static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { - uintptr_t p; - for (p = start & -8; p < ((stop + 7) & -8); p += 8) { + /* No additional data flush to the RW virtual address required. */ + uintptr_t p, end = (rx + len + 7) & -8; + for (p = rx & -8; p < end; p += 8) { __asm__ __volatile__("flush\t%0" : : "r" (p)); } } diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index 8c1c1d265d..6460449719 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -191,7 +191,8 @@ void tci_disas(uint8_t opc); #define HAVE_TCG_QEMU_TB_EXEC -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) +/* Flush the dcache at RW, and the icache at RX, as necessary. */ +static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { } diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 0b31be2928..d1e2da5502 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -2946,7 +2946,14 @@ static inline MemTxResult address_space_write_rom_internal(AddressSpace *as, invalidate_and_set_dirty(mr, addr1, l); break; case FLUSH_CACHE: - flush_icache_range((uintptr_t)ram_ptr, (uintptr_t)ram_ptr + l); + /* + * FIXME: This function is currently located in tcg/host/, + * but we never come here when tcg is enabled; only for + * real hardware acceleration. This can actively fail + * when TCI is configured, since that function is a nop. + * We should move this to util/ or something. + */ + flush_idcache_range((uintptr_t)ram_ptr, (uintptr_t)ram_ptr, l); break; } } diff --git a/tcg/tcg.c b/tcg/tcg.c index 43c6cf8f52..d5a72c226f 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1077,7 +1077,8 @@ void tcg_prologue_init(TCGContext *s) #endif buf1 = s->code_ptr; - flush_icache_range((uintptr_t)buf0, (uintptr_t)buf1); + flush_idcache_range((uintptr_t)buf0, (uintptr_t)buf0, + tcg_ptr_byte_diff(buf1, buf0)); /* Deduct the prologue from the buffer. */ prologue_size = tcg_current_code_size(s); @@ -4320,7 +4321,8 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) } /* flush instruction cache */ - flush_icache_range((uintptr_t)s->code_buf, (uintptr_t)s->code_ptr); + flush_idcache_range((uintptr_t)s->code_buf, (uintptr_t)s->code_buf, + tcg_ptr_byte_diff(s->code_ptr, s->code_buf)); return tcg_current_code_size(s); } diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 26f71cb599..83af3108a4 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1363,7 +1363,7 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, } pair = (uint64_t)i2 << 32 | i1; qatomic_set((uint64_t *)jmp_addr, pair); - flush_icache_range(jmp_addr, jmp_addr + 8); + flush_idcache_range(jmp_addr, jmp_addr, 8); } static inline void tcg_out_goto_label(TCGContext *s, TCGLabel *l) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 41be574e89..c255ecb444 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -2660,7 +2660,7 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t addr) { qatomic_set((uint32_t *)jmp_addr, deposit32(OPC_J, 0, 26, addr >> 2)); - flush_icache_range(jmp_addr, jmp_addr + 4); + flush_idcache_range(jmp_addr, jmp_addr, 4); } typedef struct { diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 18ee989f95..a848e98383 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -1753,12 +1753,12 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, /* As per the enclosing if, this is ppc64. Avoid the _Static_assert within qatomic_set that would fail to build a ppc32 host. */ qatomic_set__nocheck((uint64_t *)jmp_addr, pair); - flush_icache_range(jmp_addr, jmp_addr + 8); + flush_idcache_range(jmp_addr, jmp_addr, 8); } else { intptr_t diff = addr - jmp_addr; tcg_debug_assert(in_range_b(diff)); qatomic_set((uint32_t *)jmp_addr, B | (diff & 0x3fffffc)); - flush_icache_range(jmp_addr, jmp_addr + 4); + flush_idcache_range(jmp_addr, jmp_addr, 4); } } @@ -3864,22 +3864,23 @@ void tcg_register_jit(void *buf, size_t buf_size) } #endif /* __ELF__ */ -void flush_icache_range(uintptr_t start, uintptr_t stop) +/* Flush the dcache at RW, and the icache at RX, as necessary. */ +void flush_idcache_range(uintptr_t rx, uintptr_t rw, uintptr_t len) { - uintptr_t p, start1, stop1; + uintptr_t p, start, stop; size_t dsize = qemu_dcache_linesize; size_t isize = qemu_icache_linesize; - start1 = start & ~(dsize - 1); - stop1 = (stop + dsize - 1) & ~(dsize - 1); - for (p = start1; p < stop1; p += dsize) { + start = rw & ~(dsize - 1); + stop = (rw + len + dsize - 1) & ~(dsize - 1); + for (p = start; p < stop; p += dsize) { asm volatile ("dcbst 0,%0" : : "r"(p) : "memory"); } asm volatile ("sync" : : : "memory"); - start &= start & ~(isize - 1); - stop1 = (stop + isize - 1) & ~(isize - 1); - for (p = start1; p < stop1; p += isize) { + start = rx & ~(isize - 1); + stop = (rx + len + isize - 1) & ~(isize - 1); + for (p = start; p < stop; p += isize) { asm volatile ("icbi 0,%0" : : "r"(p) : "memory"); } asm volatile ("sync" : : : "memory"); diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 6775bd30fc..6e2d755f6a 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -1836,7 +1836,7 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, if (!USE_REG_TB) { qatomic_set((uint32_t *)jmp_addr, deposit32(CALL, 0, 30, br_disp >> 2)); - flush_icache_range(jmp_addr, jmp_addr + 4); + flush_idcache_range(jmp_addr, jmp_addr, 4); return; } @@ -1860,5 +1860,5 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, } qatomic_set((uint64_t *)jmp_addr, deposit64(i2, 32, 32, i1)); - flush_icache_range(jmp_addr, jmp_addr + 8); + flush_idcache_range(jmp_addr, jmp_addr, 8); } From patchwork Fri Nov 6 03:28:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885819 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB8326A2 for ; Fri, 6 Nov 2020 03:33:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9256420729 for ; Fri, 6 Nov 2020 03:33:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="bd1BKXve" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9256420729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:58016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasVI-0001HF-D1 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:33:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRP-0004N8-5S for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:31 -0500 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:37586) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRM-0006tw-2m for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:30 -0500 Received: by mail-pf1-x443.google.com with SMTP id 13so51933pfy.4 for ; Thu, 05 Nov 2020 19:29:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pAispzyuoe9bb7pX+t0JNwtc7CrjVyVvkGgTqmJ29zY=; b=bd1BKXveBuU//fHZTnIZDLyjtxcrIVGn5jr5DMLBZa95UkDPoPvw9ZG/0zqU8+ozKp Bmhu/keZnbhmWvKVtnNAum2iFCjIj99TpIVfCNubgZffGNABsaL7Pvp5pgaOUIXLnpU7 KS1dEpaJ1aeFhB7PThe+jWnKH0hWR/9Ay7DV7fHF18wEQ5XLGv4vpiSEunmv8/6yzwqg k64QnE65/5g7SgKd6Uyv0tG1X4L/Dj6n1T8llcCeu5qNmZnXyfzVL+jyxBCd05tPutGp QmUaKXxm5oxSjSaPOinyU/ra/iK6kedtmFECB/JO0bxGddCIamVZFQ9B1PyhUH5C+hOf 4Ebg== 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=pAispzyuoe9bb7pX+t0JNwtc7CrjVyVvkGgTqmJ29zY=; b=cjJMl90gCXhQFa8zXce8Dgtb5ESf9lZVmkMtqAXartM6BkCAO/La71dJI60Onc7UZz hnK/ckshWeEamog1DHIpIgl73a3QuTL5qLLrjkzm2vIjYZSBYoiN1PWalBHd5W2g7IPQ 3vxuPjcLZzjTPmEnX782N+ucwelwR+u0P0aqyVJHi3QzZp2wqugeTI58tO9Crh1JiJ75 CPMYJHJUrm1MT1gJfBGWz8cjdI0WkP2helXkIOTpyjC7FNQcrl8CllVhGnnAKnw9wnqb JlD75SWIo8RODjd+pRmP6X7o2aYjB6rsvRoV0iEvUxfaIummSDmtWOOLnIlM4V4rbsd0 HWcQ== X-Gm-Message-State: AOAM532wdFeAtOtcyaf7LO9CExyeBwT7K/JpTxV65ISBSViL3bOPYFRA 5BDNtP9scQ+yMcJLslmAg3G0qrZRrkOebQ== X-Google-Smtp-Source: ABdhPJw69TmpVG9uvQtdmOAs1bhScRAW5tQ3GFGciX6X/W3paBl1u7o7Bkv9/M3d5X+VE18Nmt6M2Q== X-Received: by 2002:aa7:9e90:0:b029:18b:a94:3498 with SMTP id p16-20020aa79e900000b029018b0a943498mr5160617pfq.54.1604633365753; Thu, 05 Nov 2020 19:29:25 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 02/41] tcg: Move tcg prologue pointer out of TCGContext Date: Thu, 5 Nov 2020 19:28:42 -0800 Message-Id: <20201106032921.600200-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::443; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This value is constant across all thread-local copies of TCGContext, so we might as well move it out of thread-local storage. Use the correct function pointer type, and name the variable tcg_qemu_tb_exec, which means that we are able to remove the macro that does the casting. Replace HAVE_TCG_QEMU_TB_EXEC with CONFIG_TCG_INTERPRETER, as this is somewhat clearer in intent. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- include/tcg/tcg.h | 9 ++++----- tcg/tci/tcg-target.h | 2 -- tcg/tcg.c | 9 ++++++++- tcg/tci.c | 3 ++- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 8ff9dad4ef..9cc412f90c 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -621,7 +621,6 @@ struct TCGContext { here, because there's too much arithmetic throughout that relies on addition and subtraction working on bytes. Rely on the GCC extension that allows arithmetic on void*. */ - void *code_gen_prologue; void *code_gen_epilogue; void *code_gen_buffer; size_t code_gen_buffer_size; @@ -1222,11 +1221,11 @@ static inline unsigned get_mmuidx(TCGMemOpIdx oi) #define TB_EXIT_IDXMAX 1 #define TB_EXIT_REQUESTED 3 -#ifdef HAVE_TCG_QEMU_TB_EXEC -uintptr_t tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr); +#ifdef CONFIG_TCG_INTERPRETER +uintptr_t tcg_qemu_tb_exec(CPUArchState *env, void *tb_ptr); #else -# define tcg_qemu_tb_exec(env, tb_ptr) \ - ((uintptr_t (*)(void *, void *))tcg_ctx->code_gen_prologue)(env, tb_ptr) +typedef uintptr_t tcg_prologue_fn(CPUArchState *env, void *tb_ptr); +extern tcg_prologue_fn *tcg_qemu_tb_exec; #endif void tcg_register_jit(void *buf, size_t buf_size); diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index 6460449719..49f3291f8a 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -189,8 +189,6 @@ typedef enum { void tci_disas(uint8_t opc); -#define HAVE_TCG_QEMU_TB_EXEC - /* Flush the dcache at RW, and the icache at RX, as necessary. */ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { diff --git a/tcg/tcg.c b/tcg/tcg.c index d5a72c226f..a6f47b033c 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -161,6 +161,10 @@ static TCGContext **tcg_ctxs; static unsigned int n_tcg_ctxs; TCGv_env cpu_env = 0; +#ifndef CONFIG_TCG_INTERPRETER +tcg_prologue_fn *tcg_qemu_tb_exec; +#endif + struct tcg_region_tree { QemuMutex lock; GTree *tree; @@ -1054,7 +1058,10 @@ void tcg_prologue_init(TCGContext *s) s->code_ptr = buf0; s->code_buf = buf0; s->data_gen_ptr = NULL; - s->code_gen_prologue = buf0; + +#ifndef CONFIG_TCG_INTERPRETER + tcg_qemu_tb_exec = (tcg_prologue_fn *)buf0; +#endif /* Compute a high-water mark, at which we voluntarily flush the buffer and start over. The size here is arbitrary, significantly larger diff --git a/tcg/tci.c b/tcg/tci.c index 82039fd163..d996eb7cf8 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -475,8 +475,9 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition) #endif /* Interpret pseudo code in tb. */ -uintptr_t tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr) +uintptr_t tcg_qemu_tb_exec(CPUArchState *env, void *v_tb_ptr) { + uint8_t *tb_ptr = v_tb_ptr; tcg_target_ulong regs[TCG_TARGET_NB_REGS]; long tcg_temps[CPU_TEMP_BUF_NLONGS]; uintptr_t sp_value = (uintptr_t)(tcg_temps + CPU_TEMP_BUF_NLONGS); From patchwork Fri Nov 6 03:28:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885823 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F1271744 for ; Fri, 6 Nov 2020 03:33:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0D2402072E for ; Fri, 6 Nov 2020 03:33:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oankWoEt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D2402072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:58248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasVO-0001Mx-0a for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:33:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRP-0004NV-Lm for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:31 -0500 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:33485) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRN-0006u7-4F for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:31 -0500 Received: by mail-pf1-x42d.google.com with SMTP id q10so66073pfn.0 for ; Thu, 05 Nov 2020 19:29:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KBY1J8V9NyIcuXYQ6Nx22ITs65VLGTs78EJG+4pWzHM=; b=oankWoEtin6BmM0CshLpdxxvliPpKUs5HN52MI3C5nF1Em9tPwKYQ+m8AuHhBz3dHw 8oQzItmK1E77IBJHTZcSia6osTP8hm9Qcjk2LphWgfhlekErYs2vLYGJ8kA4OW/IaF36 Jklz69YqksP28fnZ+rmEsu8psX6qAdc0Yb1yjdzaVi45EeESKT72l4GRxOQRxn5GmJCc BB8m6Igi4UsVM+zsJqnk96TKo+65BwQMmlshIc9QwxnL5pW8V4F8JThaP4xYgkWcHW3b jpQb05nKSzxkrecb8mTXHQirmwQ+6ibVITF8mKERoONtXhAQmXpw9eAccN5w0CT7Z97S OXrA== 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=KBY1J8V9NyIcuXYQ6Nx22ITs65VLGTs78EJG+4pWzHM=; b=baKIxhCHeQASxRCNEZ/1BIpPB9mURCSMIQO5ZlQWWuHsvSWxZ22S55iBOhHl/gxyTH 6bsCLHaGMoeTKu8eePn41sS2vUG0JJ9BxWKrp6bDODhsevuo9q4u5a+10xhT7j1iJ3lg NxRT+UZ48pqnKOEAeLLNjNh2Ur9djFKhIkhzKbQM99ecOetvXxcgQUH3OortOZSW7Ql2 vdbwlS5EJhyNBbU5XQAXZ3z/5hEtkxT7bqrD0fjCD/3Y99qBrWJ4c+t4/ixoOTl65KmU EtXwnR77u4GF4DfLhvtow3708vNQFflzOu/LqNeawhwsy5pO/7yq4JuwIamqYiM0EUrL /R3g== X-Gm-Message-State: AOAM532+GYdQQO0oBXx++O1qyZv6XhlgWe+VtusurXEg0IlX7YIcnzka bGqD4fdP30oyKJ9tre7g6QXyZV1mIVivMQ== X-Google-Smtp-Source: ABdhPJxBa7Yd/roJv8P+zK/6wARP8IA4ieuqBUt0AB35xi/IRpRB7d/ehxWmvQ1/yH8YYVX2OxAcpQ== X-Received: by 2002:a63:5650:: with SMTP id g16mr2510789pgm.353.1604633367297; Thu, 05 Nov 2020 19:29:27 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 03/41] tcg: Move tcg epilogue pointer out of TCGContext Date: Thu, 5 Nov 2020 19:28:43 -0800 Message-Id: <20201106032921.600200-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This value is constant across all thread-local copies of TCGContext, so we might as well move it out of thread-local storage. Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 2 +- accel/tcg/tcg-runtime.c | 2 +- tcg/tcg.c | 3 ++- tcg/aarch64/tcg-target.c.inc | 4 ++-- tcg/arm/tcg-target.c.inc | 2 +- tcg/i386/tcg-target.c.inc | 4 ++-- tcg/mips/tcg-target.c.inc | 2 +- tcg/ppc/tcg-target.c.inc | 2 +- tcg/riscv/tcg-target.c.inc | 4 ++-- tcg/s390/tcg-target.c.inc | 4 ++-- tcg/sparc/tcg-target.c.inc | 2 +- 11 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 9cc412f90c..bb1e97b13b 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -621,7 +621,6 @@ struct TCGContext { here, because there's too much arithmetic throughout that relies on addition and subtraction working on bytes. Rely on the GCC extension that allows arithmetic on void*. */ - void *code_gen_epilogue; void *code_gen_buffer; size_t code_gen_buffer_size; void *code_gen_ptr; @@ -678,6 +677,7 @@ struct TCGContext { extern TCGContext tcg_init_ctx; extern __thread TCGContext *tcg_ctx; +extern void *tcg_code_gen_epilogue; extern TCGv_env cpu_env; static inline size_t temp_idx(TCGTemp *ts) diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c index 446465a09a..f85dfefeab 100644 --- a/accel/tcg/tcg-runtime.c +++ b/accel/tcg/tcg-runtime.c @@ -154,7 +154,7 @@ void *HELPER(lookup_tb_ptr)(CPUArchState *env) tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, curr_cflags()); if (tb == NULL) { - return tcg_ctx->code_gen_epilogue; + return tcg_code_gen_epilogue; } qemu_log_mask_and_addr(CPU_LOG_EXEC, pc, "Chain %d: %p [" diff --git a/tcg/tcg.c b/tcg/tcg.c index a6f47b033c..1e83eed83f 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -160,6 +160,7 @@ static int tcg_out_ldst_finalize(TCGContext *s); static TCGContext **tcg_ctxs; static unsigned int n_tcg_ctxs; TCGv_env cpu_env = 0; +void *tcg_code_gen_epilogue; #ifndef CONFIG_TCG_INTERPRETER tcg_prologue_fn *tcg_qemu_tb_exec; @@ -1130,7 +1131,7 @@ void tcg_prologue_init(TCGContext *s) /* Assert that goto_ptr is implemented completely. */ if (TCG_TARGET_HAS_goto_ptr) { - tcg_debug_assert(s->code_gen_epilogue != NULL); + tcg_debug_assert(tcg_code_gen_epilogue != NULL); } } diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 83af3108a4..76f8ae48ad 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1873,7 +1873,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_exit_tb: /* Reuse the zeroing that exists for goto_ptr. */ if (a0 == 0) { - tcg_out_goto_long(s, s->code_gen_epilogue); + tcg_out_goto_long(s, tcg_code_gen_epilogue); } else { tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_X0, a0); tcg_out_goto_long(s, tb_ret_addr); @@ -2894,7 +2894,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - s->code_gen_epilogue = s->code_ptr; + tcg_code_gen_epilogue = s->code_ptr; tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_X0, 0); /* TB epilogue */ diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 62c37a954b..1e32bf42b8 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -2297,7 +2297,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - s->code_gen_epilogue = s->code_ptr; + tcg_code_gen_epilogue = s->code_ptr; tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R0, 0); tcg_out_epilogue(s); } diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index d8797ed398..424dd1cdcf 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -2267,7 +2267,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_exit_tb: /* Reuse the zeroing that exists for goto_ptr. */ if (a0 == 0) { - tcg_out_jmp(s, s->code_gen_epilogue); + tcg_out_jmp(s, tcg_code_gen_epilogue); } else { tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_EAX, a0); tcg_out_jmp(s, tb_ret_addr); @@ -3825,7 +3825,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - s->code_gen_epilogue = s->code_ptr; + tcg_code_gen_epilogue = s->code_ptr; tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_EAX, 0); /* TB epilogue */ diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index c255ecb444..f641105f9a 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -2483,7 +2483,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - s->code_gen_epilogue = s->code_ptr; + tcg_code_gen_epilogue = s->code_ptr; tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_V0, TCG_REG_ZERO); /* TB epilogue */ diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index a848e98383..be116c6164 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -2341,7 +2341,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out32(s, BCCTR | BO_ALWAYS); /* Epilogue */ - s->code_gen_epilogue = tb_ret_addr = s->code_ptr; + tcg_code_gen_epilogue = tb_ret_addr = s->code_ptr; tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R0, TCG_REG_R1, FRAME_SIZE+LR_OFFSET); for (i = 0; i < ARRAY_SIZE(tcg_target_callee_save_regs); ++i) { diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index d536f3ccc1..ab08af7457 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1288,7 +1288,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_exit_tb: /* Reuse the zeroing that exists for goto_ptr. */ if (a0 == 0) { - tcg_out_call_int(s, s->code_gen_epilogue, true); + tcg_out_call_int(s, tcg_code_gen_epilogue, true); } else { tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A0, a0); tcg_out_call_int(s, tb_ret_addr, true); @@ -1822,7 +1822,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_opc_imm(s, OPC_JALR, TCG_REG_ZERO, tcg_target_call_iarg_regs[1], 0); /* Return path for goto_ptr. Set return value to 0 */ - s->code_gen_epilogue = s->code_ptr; + tcg_code_gen_epilogue = s->code_ptr; tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_A0, TCG_REG_ZERO); /* TB epilogue */ diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index c5e096449b..ac99ccea73 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -1756,7 +1756,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, /* Reuse the zeroing that exists for goto_ptr. */ a0 = args[0]; if (a0 == 0) { - tgen_gotoi(s, S390_CC_ALWAYS, s->code_gen_epilogue); + tgen_gotoi(s, S390_CC_ALWAYS, tcg_code_gen_epilogue); } else { tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R2, a0); tgen_gotoi(s, S390_CC_ALWAYS, tb_ret_addr); @@ -2561,7 +2561,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - s->code_gen_epilogue = s->code_ptr; + tcg_code_gen_epilogue = s->code_ptr; tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R2, 0); /* TB epilogue */ diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 6e2d755f6a..5b3bc91b05 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -1038,7 +1038,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_nop(s); /* Epilogue for goto_ptr. */ - s->code_gen_epilogue = s->code_ptr; + tcg_code_gen_epilogue = s->code_ptr; tcg_out_arithi(s, TCG_REG_G0, TCG_REG_I7, 8, RETURN); /* delay slot */ tcg_out_movi_imm13(s, TCG_REG_O0, 0); From patchwork Fri Nov 6 03:28:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885811 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB3601744 for ; Fri, 6 Nov 2020 03:30:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4254D20729 for ; Fri, 6 Nov 2020 03:30:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZTH1vMnk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4254D20729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasSl-0006Gx-5j for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:30:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRP-0004Nr-Ro for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:31 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:39701) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRO-0006uE-7N for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:31 -0500 Received: by mail-pg1-x544.google.com with SMTP id i7so2880472pgh.6 for ; Thu, 05 Nov 2020 19:29:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kjsZwqo16wWQgyXnGfAD2sB/J/+jiHAWTHwjAIw7NfU=; b=ZTH1vMnki1p5vmUOBjZzTzJM7NUOdveFifsjKnIo5PB2GuTdYJTA1vCSgtNv3SUw4R M3LjWPLD52N/0mPrvglxPepdDyOZ0s1ykWw3MSLdM6wwdbtfCdsJE8wX8qJkTVXU4iaG 5yVOHwkO+XED8+9YkLh4bYM/4zcnmAs9a9NWGm2lbvEb6xGyT4AHIRe5Fro4B0l8h5z5 SZM9QdM04FOTivgIU/zqRyfWyDSAupDgKurqRjRN1vjYdVxRuMMoMZRpsba+G97e0i3L zIolhk118ZNbB48awBa1LyFW30S2RVdlOeJDgBYNWk7I7OfC/RlmRvQKRiWDhCIR6xfI ob9w== 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=kjsZwqo16wWQgyXnGfAD2sB/J/+jiHAWTHwjAIw7NfU=; b=KGk8Z30ieUKbNAhoNuxCFUy8mHic76q0rKlGuKEDfXoomR3t4dbeYaHcIUvglCdxEv aiHsBGHNFt+y7f9y6NhmLPfzQw4tLO6iM/+PL1G/n61MtA7kOnx8eaf/QfQfvW2HL3Sr KJEYja0XKUtQitWLrBfOBBLdTG8fONtIBNFoBLOfzy+BUEFVVyTA9V79fZb7Q0zPdeZ+ W7R3VDGYwpStzHZY0+JqfMOEE8SgazCDCWS5ZESxAKJgyk+vBx7kRmAz5AUGjfs6gI7+ edJqfOGlm5l0wGs58I4k3mWz0iWs+V5oUCKjc7Vn8GOYbaknub7uY6IYTuanHtcaRIZ6 IC0w== X-Gm-Message-State: AOAM533sy5cd50zTwGkljn1/MXdf7wybtU0YCIwCzXwr53Jz8zK0evEp Nx7y22I9BTqoKM/MC86Vdf6q83sevqa7ZQ== X-Google-Smtp-Source: ABdhPJxFHQGOc3dY4qjXzdw/JdPbL2A0630inlRe2f6Pmob4YKhhhNempPn21/LWdw4actCCUZNA/A== X-Received: by 2002:a17:90a:d082:: with SMTP id k2mr128978pju.195.1604633368541; Thu, 05 Nov 2020 19:29:28 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 04/41] tcg: Add in_code_gen_buffer Date: Thu, 5 Nov 2020 19:28:44 -0800 Message-Id: <20201106032921.600200-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::544; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x544.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Create a function to determine if a pointer is within the buffer. Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 6 ++++++ accel/tcg/translate-all.c | 26 ++++++++------------------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index bb1e97b13b..e4d0ace44b 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -680,6 +680,12 @@ extern __thread TCGContext *tcg_ctx; extern void *tcg_code_gen_epilogue; extern TCGv_env cpu_env; +static inline bool in_code_gen_buffer(const void *p) +{ + const TCGContext *s = &tcg_init_ctx; + return (size_t)(p - s->code_gen_buffer) <= s->code_gen_buffer_size; +} + static inline size_t temp_idx(TCGTemp *ts) { ptrdiff_t n = ts - tcg_ctx->temps; diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 4572b4901f..744f97a717 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -392,27 +392,18 @@ void tb_destroy(TranslationBlock *tb) bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit) { - TranslationBlock *tb; - bool r = false; - uintptr_t check_offset; - - /* The host_pc has to be in the region of current code buffer. If - * it is not we will not be able to resolve it here. The two cases - * where host_pc will not be correct are: + /* + * The host_pc has to be in the region of the code buffer. + * If it is not we will not be able to resolve it here. + * The two cases where host_pc will not be correct are: * * - fault during translation (instruction fetch) * - fault from helper (not using GETPC() macro) * * Either way we need return early as we can't resolve it here. - * - * We are using unsigned arithmetic so if host_pc < - * tcg_init_ctx.code_gen_buffer check_offset will wrap to way - * above the code_gen_buffer_size */ - check_offset = host_pc - (uintptr_t) tcg_init_ctx.code_gen_buffer; - - if (check_offset < tcg_init_ctx.code_gen_buffer_size) { - tb = tcg_tb_lookup(host_pc); + if (in_code_gen_buffer((const void *)host_pc)) { + TranslationBlock *tb = tcg_tb_lookup(host_pc); if (tb) { cpu_restore_state_from_tb(cpu, tb, host_pc, will_exit); if (tb_cflags(tb) & CF_NOCACHE) { @@ -421,11 +412,10 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit) tcg_tb_remove(tb); tb_destroy(tb); } - r = true; + return true; } } - - return r; + return false; } static void page_init(void) From patchwork Fri Nov 6 03:28:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885831 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45CC36A2 for ; Fri, 6 Nov 2020 03:35:48 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CE61520729 for ; Fri, 6 Nov 2020 03:35:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="osKhKZhn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE61520729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:38584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasXS-0004r0-Mk for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:35:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRS-0004Uf-Qu for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:34 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:45606) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRQ-0006uY-7y for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:34 -0500 Received: by mail-pf1-x442.google.com with SMTP id e7so23894pfn.12 for ; Thu, 05 Nov 2020 19:29:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Klyf2Ldeaj65rfvqccN0uXcr+T7AzDXrpJ+LVKJbYic=; b=osKhKZhnWVfR0jBE5GROxH1OLx2RLLkX1r2hRQ/V57Wm8h1wY4kKcDpjsvvsLYlKCx kEJgut+VE0+1aPRZOjLoCeTQhkOWvizkGztz030XXC9BPfHa1psTjkP4DjhUCBpo1tdM BA9/mCnUx3qVZ6TfWrqdr6USIlLCmX00Uazw2w6nOWBjhbUsxoteKw2lV1cwoE/pKNMB D9jaZ17ljb08dSDFhi6+utNMV6j0TbuLdLZ8cAlSDtiseCQs4Y2tChoM1ylaZHrNV6e8 oJR5VnUpK/5KfZk3UEq+5LRl2QQ3CbXX00rWMt4TGP5hfShXUiBi0ymh5qYUGjUS7HN/ ENHA== 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=Klyf2Ldeaj65rfvqccN0uXcr+T7AzDXrpJ+LVKJbYic=; b=lCUByRsutcW9DokW9ExSisA5SfJPk9Ni+dsc9LHYgKRyYvUl+Bk+R+6V86+OD/5ss8 uM48/7VDWbpgTVwdvMIFnP78fgmWvqAhVzBV2POl8HqNpkEsEgSEirdbkeQQa+TYJ7+O nkvlANNHrq7l4+k5D52KUWq/KBWGVCNE6grZBtruaZgk1nzkdABtDb03PneT3hApmHMs Ffr3uUhPtquy83NiG8ZQqHNbHUmQu60P0IPR04OSIMXfotn2y0b4jaLLhfwsbibw6Tz0 aY89b8Ggabqj278lmJXyZEuusVT9A10e18h82Xs2DjK4N+J8lh2xnxKi1sBbrB2vIjiG FBDg== X-Gm-Message-State: AOAM533zA61p7VSDD1Q8Ibrn0blJxgKfLuC+Mz6Me5tEbrSKqdjH1sQM A9/ZY00TCd7gYvJKW4LFSGxbrFE1Ks9nZw== X-Google-Smtp-Source: ABdhPJwHA+xj5VVMzXWVlCJnGB0ie/PmIufdvAnt5X1R1hNBFANyABp6lp2xYXg/Fe+hX6gfMTYrBQ== X-Received: by 2002:a65:5784:: with SMTP id b4mr5155180pgr.217.1604633369983; Thu, 05 Nov 2020 19:29:29 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 05/41] tcg: Introduce tcg_splitwx_to_{rx,rw} Date: Thu, 5 Nov 2020 19:28:45 -0800 Message-Id: <20201106032921.600200-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::442; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Add two helper functions, using a global variable to hold the displacement. The displacement is currently always 0, so no change in behaviour. Begin using the functions in tcg common code only. Signed-off-by: Richard Henderson --- accel/tcg/tcg-runtime.h | 2 +- include/disas/disas.h | 2 +- include/exec/exec-all.h | 2 +- include/exec/log.h | 2 +- include/tcg/tcg.h | 26 ++++++++++++++---- accel/tcg/cpu-exec.c | 2 +- accel/tcg/tcg-runtime.c | 2 +- accel/tcg/translate-all.c | 33 +++++++++++------------ disas.c | 4 ++- tcg/tcg.c | 56 ++++++++++++++++++++++++++++++++++----- tcg/tci.c | 5 ++-- accel/tcg/trace-events | 2 +- tcg/tcg-pool.c.inc | 6 ++++- 13 files changed, 104 insertions(+), 40 deletions(-) diff --git a/accel/tcg/tcg-runtime.h b/accel/tcg/tcg-runtime.h index 4eda24e63a..c276c8beb5 100644 --- a/accel/tcg/tcg-runtime.h +++ b/accel/tcg/tcg-runtime.h @@ -24,7 +24,7 @@ DEF_HELPER_FLAGS_1(clrsb_i64, TCG_CALL_NO_RWG_SE, i64, i64) DEF_HELPER_FLAGS_1(ctpop_i32, TCG_CALL_NO_RWG_SE, i32, i32) DEF_HELPER_FLAGS_1(ctpop_i64, TCG_CALL_NO_RWG_SE, i64, i64) -DEF_HELPER_FLAGS_1(lookup_tb_ptr, TCG_CALL_NO_WG_SE, ptr, env) +DEF_HELPER_FLAGS_1(lookup_tb_ptr, TCG_CALL_NO_WG_SE, cptr, env) DEF_HELPER_FLAGS_1(exit_atomic, TCG_CALL_NO_WG, noreturn, env) diff --git a/include/disas/disas.h b/include/disas/disas.h index 36c33f6f19..d363e95ede 100644 --- a/include/disas/disas.h +++ b/include/disas/disas.h @@ -7,7 +7,7 @@ #include "cpu.h" /* Disassemble this for me please... (debugging). */ -void disas(FILE *out, void *code, unsigned long size); +void disas(FILE *out, const void *code, unsigned long size); void target_disas(FILE *out, CPUState *cpu, target_ulong code, target_ulong size); diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 4707ac140c..aa65103702 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -448,7 +448,7 @@ int probe_access_flags(CPUArchState *env, target_ulong addr, * Note: the address of search data can be obtained by adding @size to @ptr. */ struct tb_tc { - void *ptr; /* pointer to the translated code */ + const void *ptr; /* pointer to the translated code */ size_t size; }; diff --git a/include/exec/log.h b/include/exec/log.h index e02fff5de1..3c7fa65ead 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -56,7 +56,7 @@ static inline void log_target_disas(CPUState *cpu, target_ulong start, rcu_read_unlock(); } -static inline void log_disas(void *code, unsigned long size) +static inline void log_disas(const void *code, unsigned long size) { QemuLogFile *logfile; rcu_read_lock(); diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index e4d0ace44b..249f83be72 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -678,6 +678,7 @@ struct TCGContext { extern TCGContext tcg_init_ctx; extern __thread TCGContext *tcg_ctx; extern void *tcg_code_gen_epilogue; +extern uintptr_t tcg_splitwx_diff; extern TCGv_env cpu_env; static inline bool in_code_gen_buffer(const void *p) @@ -686,6 +687,21 @@ static inline bool in_code_gen_buffer(const void *p) return (size_t)(p - s->code_gen_buffer) <= s->code_gen_buffer_size; } +#ifdef CONFIG_DEBUG_TCG +const void *tcg_splitwx_to_rx(void *rw); +void *tcg_splitwx_to_rw(const void *rx); +#else +static inline const void *tcg_splitwx_to_rx(void *rw) +{ + return rw ? rw + tcg_splitwx_diff : NULL; +} + +static inline void *tcg_splitwx_to_rw(const void *rx) +{ + return rx ? (void *)rx - tcg_splitwx_diff : NULL; +} +#endif + static inline size_t temp_idx(TCGTemp *ts) { ptrdiff_t n = ts - tcg_ctx->temps; @@ -1106,7 +1122,7 @@ static inline TCGLabel *arg_label(TCGArg i) * correct result. */ -static inline ptrdiff_t tcg_ptr_byte_diff(void *a, void *b) +static inline ptrdiff_t tcg_ptr_byte_diff(const void *a, const void *b) { return a - b; } @@ -1120,9 +1136,9 @@ static inline ptrdiff_t tcg_ptr_byte_diff(void *a, void *b) * to the destination address. */ -static inline ptrdiff_t tcg_pcrel_diff(TCGContext *s, void *target) +static inline ptrdiff_t tcg_pcrel_diff(TCGContext *s, const void *target) { - return tcg_ptr_byte_diff(target, s->code_ptr); + return tcg_ptr_byte_diff(target, tcg_splitwx_to_rx(s->code_ptr)); } /** @@ -1228,9 +1244,9 @@ static inline unsigned get_mmuidx(TCGMemOpIdx oi) #define TB_EXIT_REQUESTED 3 #ifdef CONFIG_TCG_INTERPRETER -uintptr_t tcg_qemu_tb_exec(CPUArchState *env, void *tb_ptr); +uintptr_t tcg_qemu_tb_exec(CPUArchState *env, const void *tb_ptr); #else -typedef uintptr_t tcg_prologue_fn(CPUArchState *env, void *tb_ptr); +typedef uintptr_t tcg_prologue_fn(CPUArchState *env, const void *tb_ptr); extern tcg_prologue_fn *tcg_qemu_tb_exec; #endif diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 58aea605d8..1e3cb570f6 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -150,7 +150,7 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) uintptr_t ret; TranslationBlock *last_tb; int tb_exit; - uint8_t *tb_ptr = itb->tc.ptr; + const void *tb_ptr = itb->tc.ptr; qemu_log_mask_and_addr(CPU_LOG_EXEC, itb->pc, "Trace %d: %p [" diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c index f85dfefeab..d736f4ff55 100644 --- a/accel/tcg/tcg-runtime.c +++ b/accel/tcg/tcg-runtime.c @@ -145,7 +145,7 @@ uint64_t HELPER(ctpop_i64)(uint64_t arg) return ctpop64(arg); } -void *HELPER(lookup_tb_ptr)(CPUArchState *env) +const void *HELPER(lookup_tb_ptr)(CPUArchState *env) { CPUState *cpu = env_cpu(env); TranslationBlock *tb; diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 744f97a717..7b85ddacd2 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -269,9 +269,9 @@ static uint8_t *encode_sleb128(uint8_t *p, target_long val) /* Decode a signed leb128 sequence at *PP; increment *PP past the decoded value. Return the decoded value. */ -static target_long decode_sleb128(uint8_t **pp) +static target_long decode_sleb128(const uint8_t **pp) { - uint8_t *p = *pp; + const uint8_t *p = *pp; target_long val = 0; int byte, shift = 0; @@ -342,7 +342,7 @@ static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, target_ulong data[TARGET_INSN_START_WORDS] = { tb->pc }; uintptr_t host_pc = (uintptr_t)tb->tc.ptr; CPUArchState *env = cpu->env_ptr; - uint8_t *p = tb->tc.ptr + tb->tc.size; + const uint8_t *p = tb->tc.ptr + tb->tc.size; int i, j, num_insns = tb->icount; #ifdef CONFIG_PROFILER TCGProfile *prof = &tcg_ctx->prof; @@ -393,7 +393,7 @@ void tb_destroy(TranslationBlock *tb) bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit) { /* - * The host_pc has to be in the region of the code buffer. + * The host_pc has to be in the rx region of the code buffer. * If it is not we will not be able to resolve it here. * The two cases where host_pc will not be correct are: * @@ -402,7 +402,7 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit) * * Either way we need return early as we can't resolve it here. */ - if (in_code_gen_buffer((const void *)host_pc)) { + if (in_code_gen_buffer((const void *)(host_pc - tcg_splitwx_diff))) { TranslationBlock *tb = tcg_tb_lookup(host_pc); if (tb) { cpu_restore_state_from_tb(cpu, tb, host_pc, will_exit); @@ -1712,7 +1712,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, } gen_code_buf = tcg_ctx->code_gen_ptr; - tb->tc.ptr = gen_code_buf; + tb->tc.ptr = tcg_splitwx_to_rx(gen_code_buf); tb->pc = pc; tb->cs_base = cs_base; tb->flags = flags; @@ -1806,15 +1806,19 @@ TranslationBlock *tb_gen_code(CPUState *cpu, if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) && qemu_log_in_addr_range(tb->pc)) { FILE *logfile = qemu_log_lock(); - int code_size, data_size = 0; + int code_size, data_size; + const tcg_target_ulong *rx_data_gen_ptr; size_t chunk_start; int insn = 0; if (tcg_ctx->data_gen_ptr) { - code_size = tcg_ctx->data_gen_ptr - tb->tc.ptr; + rx_data_gen_ptr = tcg_splitwx_to_rx(tcg_ctx->data_gen_ptr); + code_size = (const void *)rx_data_gen_ptr - tb->tc.ptr; data_size = gen_code_size - code_size; } else { + rx_data_gen_ptr = 0; code_size = gen_code_size; + data_size = 0; } /* Dump header and the first instruction */ @@ -1849,16 +1853,9 @@ TranslationBlock *tb_gen_code(CPUState *cpu, if (data_size) { int i; qemu_log(" data: [size=%d]\n", data_size); - for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) { - if (sizeof(tcg_target_ulong) == 8) { - qemu_log("0x%08" PRIxPTR ": .quad 0x%016" PRIx64 "\n", - (uintptr_t)tcg_ctx->data_gen_ptr + i, - *(uint64_t *)(tcg_ctx->data_gen_ptr + i)); - } else { - qemu_log("0x%08" PRIxPTR ": .long 0x%08x\n", - (uintptr_t)tcg_ctx->data_gen_ptr + i, - *(uint32_t *)(tcg_ctx->data_gen_ptr + i)); - } + for (i = 0; i < data_size / sizeof(tcg_target_ulong); i++) { + qemu_log("0x%08" PRIxPTR ": .quad 0x%" TCG_PRIlx "\n", + (uintptr_t)&rx_data_gen_ptr[i], rx_data_gen_ptr[i]); } } qemu_log("\n"); diff --git a/disas.c b/disas.c index 7c18d7d2a7..de1de7be94 100644 --- a/disas.c +++ b/disas.c @@ -299,8 +299,10 @@ char *plugin_disas(CPUState *cpu, uint64_t addr, size_t size) } /* Disassemble this for me please... (debugging). */ -void disas(FILE *out, void *code, unsigned long size) +void disas(FILE *out, const void *ccode, unsigned long size) { + /* TODO: Push constness through the disas backends. */ + void *code = (void *)ccode; uintptr_t pc; int count; CPUDebug s; diff --git a/tcg/tcg.c b/tcg/tcg.c index 1e83eed83f..cea3a4e4f2 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -161,6 +161,7 @@ static TCGContext **tcg_ctxs; static unsigned int n_tcg_ctxs; TCGv_env cpu_env = 0; void *tcg_code_gen_epilogue; +uintptr_t tcg_splitwx_diff; #ifndef CONFIG_TCG_INTERPRETER tcg_prologue_fn *tcg_qemu_tb_exec; @@ -405,8 +406,9 @@ static void tcg_region_trees_init(void) } } -static struct tcg_region_tree *tc_ptr_to_region_tree(void *p) +static struct tcg_region_tree *tc_ptr_to_region_tree(const void *cp) { + void *p = tcg_splitwx_to_rw(cp); size_t region_idx; if (p < region.start_aligned) { @@ -700,6 +702,7 @@ void tcg_region_init(void) size_t region_size; size_t n_regions; size_t i; + uintptr_t splitwx_diff; n_regions = tcg_n_regions(); @@ -730,6 +733,7 @@ void tcg_region_init(void) region.end -= page_size; /* set guard pages */ + splitwx_diff = tcg_splitwx_diff; for (i = 0; i < region.n; i++) { void *start, *end; int rc; @@ -737,6 +741,10 @@ void tcg_region_init(void) tcg_region_bounds(i, &start, &end); rc = qemu_mprotect_none(end, page_size); g_assert(!rc); + if (splitwx_diff) { + rc = qemu_mprotect_none(end + splitwx_diff, page_size); + g_assert(!rc); + } } tcg_region_trees_init(); @@ -751,6 +759,29 @@ void tcg_region_init(void) #endif } +#ifdef CONFIG_DEBUG_TCG +const void *tcg_splitwx_to_rx(void *rw) +{ + /* Pass NULL pointers unchanged. */ + if (rw) { + g_assert(in_code_gen_buffer(rw)); + rw += tcg_splitwx_diff; + } + return rw; +} + +void *tcg_splitwx_to_rw(const void *rx) +{ + /* Pass NULL pointers unchanged. */ + if (rx) { + rx -= tcg_splitwx_diff; + /* Assert that we end with a pointer in the rw region. */ + g_assert(in_code_gen_buffer(rx)); + } + return (void *)rx; +} +#endif /* CONFIG_DEBUG_TCG */ + static void alloc_tcg_plugin_context(TCGContext *s) { #ifdef CONFIG_PLUGIN @@ -1060,8 +1091,15 @@ void tcg_prologue_init(TCGContext *s) s->code_buf = buf0; s->data_gen_ptr = NULL; + /* + * The region trees are not yet configured, but tcg_splitwx_to_rx + * needs the bounds for an assert. + */ + region.start = buf0; + region.end = buf0 + total_size; + #ifndef CONFIG_TCG_INTERPRETER - tcg_qemu_tb_exec = (tcg_prologue_fn *)buf0; + tcg_qemu_tb_exec = (tcg_prologue_fn *)tcg_splitwx_to_rx(buf0); #endif /* Compute a high-water mark, at which we voluntarily flush the buffer @@ -1085,7 +1123,7 @@ void tcg_prologue_init(TCGContext *s) #endif buf1 = s->code_ptr; - flush_idcache_range((uintptr_t)buf0, (uintptr_t)buf0, + flush_idcache_range((uintptr_t)tcg_splitwx_to_rx(buf0), (uintptr_t)buf0, tcg_ptr_byte_diff(buf1, buf0)); /* Deduct the prologue from the buffer. */ @@ -4224,8 +4262,13 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) tcg_reg_alloc_start(s); - s->code_buf = tb->tc.ptr; - s->code_ptr = tb->tc.ptr; + /* + * Reset the buffer pointers when restarting after overflow. + * TODO: Move this into translate-all.c with the rest of the + * buffer management. Having only this done here is confusing. + */ + s->code_buf = tcg_splitwx_to_rw(tb->tc.ptr); + s->code_ptr = s->code_buf; #ifdef TCG_TARGET_NEED_LDST_LABELS QSIMPLEQ_INIT(&s->ldst_labels); @@ -4329,7 +4372,8 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) } /* flush instruction cache */ - flush_idcache_range((uintptr_t)s->code_buf, (uintptr_t)s->code_buf, + flush_idcache_range((uintptr_t)tcg_splitwx_to_rx(s->code_buf), + (uintptr_t)s->code_buf, tcg_ptr_byte_diff(s->code_ptr, s->code_buf)); return tcg_current_code_size(s); diff --git a/tcg/tci.c b/tcg/tci.c index d996eb7cf8..262a2b39ce 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -475,9 +475,10 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition) #endif /* Interpret pseudo code in tb. */ -uintptr_t tcg_qemu_tb_exec(CPUArchState *env, void *v_tb_ptr) +uintptr_t tcg_qemu_tb_exec(CPUArchState *env, const void *v_tb_ptr) { - uint8_t *tb_ptr = v_tb_ptr; + /* TODO: Propagate const through this file. */ + uint8_t *tb_ptr = (uint8_t *)v_tb_ptr; tcg_target_ulong regs[TCG_TARGET_NB_REGS]; long tcg_temps[CPU_TEMP_BUF_NLONGS]; uintptr_t sp_value = (uintptr_t)(tcg_temps + CPU_TEMP_BUF_NLONGS); diff --git a/accel/tcg/trace-events b/accel/tcg/trace-events index 385b9f749b..6eefb37f5d 100644 --- a/accel/tcg/trace-events +++ b/accel/tcg/trace-events @@ -7,4 +7,4 @@ exec_tb_nocache(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR exec_tb_exit(void *last_tb, unsigned int flags) "tb:%p flags=0x%x" # translate-all.c -translate_block(void *tb, uintptr_t pc, uint8_t *tb_code) "tb:%p, pc:0x%"PRIxPTR", tb_code:%p" +translate_block(void *tb, uintptr_t pc, const void *tb_code) "tb:%p, pc:0x%"PRIxPTR", tb_code:%p" diff --git a/tcg/tcg-pool.c.inc b/tcg/tcg-pool.c.inc index 82cbcc89bd..90c2e63b7f 100644 --- a/tcg/tcg-pool.c.inc +++ b/tcg/tcg-pool.c.inc @@ -140,6 +140,8 @@ static int tcg_out_pool_finalize(TCGContext *s) for (; p != NULL; p = p->next) { size_t size = sizeof(tcg_target_ulong) * p->nlong; + uintptr_t value; + if (!l || l->nlong != p->nlong || memcmp(l->data, p->data, size)) { if (unlikely(a > s->code_gen_highwater)) { return -1; @@ -148,7 +150,9 @@ static int tcg_out_pool_finalize(TCGContext *s) a += size; l = p; } - if (!patch_reloc(p->label, p->rtype, (intptr_t)a - size, p->addend)) { + + value = (uintptr_t)tcg_splitwx_to_rx(a) - size; + if (!patch_reloc(p->label, p->rtype, value, p->addend)) { return -2; } } From patchwork Fri Nov 6 03:28:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885821 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E0DA1130 for ; Fri, 6 Nov 2020 03:33:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AB45B20729 for ; Fri, 6 Nov 2020 03:33:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="DrixGB18" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB45B20729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:58174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasVN-0001L9-KN for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:33:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRU-0004XF-09 for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:36 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:45380) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRQ-0006uh-S5 for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:35 -0500 Received: by mail-pg1-x542.google.com with SMTP id 62so2858697pgg.12 for ; Thu, 05 Nov 2020 19:29:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=umlTSoDWsL7GMFuN8NYGzjEz6Eu8noAzDLdtJRqQ4Ig=; b=DrixGB18CuU/9aIYd3avoWoo18nA0RUNEU1IUUP82Gj+Uwzo9q7TP1jM/F6NddADji +i7P+/LezZaRFEvmfjguKjn9mSCBgW84Z7kf8LkQdiHD4U08MYyrcqDk7TNsvEjRkyTi EjtuWj1iytmoXfhjxgHGmisMhElSyTrFg9SUIR5U6UrNb9YIeXJiAdDwNiZNclbND747 AcR4pHv26Db2r32V+glAdjCBFhVsGhDkWS3/Tv+5344viwPZZ8p7g2PiYvAk3ojS+CzP zLT2WMcJhRgyXd70Ert1y4p30F+8ZXF1CUE/M1nEr5hYHHZ/zb9Nslqsn07QO1ocKGY4 axHQ== 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=umlTSoDWsL7GMFuN8NYGzjEz6Eu8noAzDLdtJRqQ4Ig=; b=rQHnz4bRaaUVllYpQdb1hC5szbkL6Pk58kwPtjWnssbwExVPHCKDYn7ZH04PE4+2sv h/z+nye6J8KCe0eEkJ3nVRkcJ3KX41SckuC0wsEIzbc3likbCcV2wLmZLr51cQCjGTio mIcnNUKMDnrUxLOQX6uL87+5rk8qvRii1D0pakpYpt/r688M1NiOZ230NeuSaVvgGlfX GPO1lijTK7ZyaW0urRKCGgDDFFeowpsBmEO/DpQ1vLaaB46zMR6ihhdIlEBrSy5+DqKd y7310Uf7hc/e4Ja9IGPqycmMCQVg70edb/7BQETJ5wf+1zVTy+IzdEDVvz4M6PimnJaP ZCBQ== X-Gm-Message-State: AOAM531H59CnfDmbwJeWYfNKqwBtDEZrSQ1vslQ9TekV3HlUtckVOnDE nXlpKBo8laEM4BqFdZIyaZjZUBz52tw0vA== X-Google-Smtp-Source: ABdhPJzBaG8+Iwbdm/A1Z+EzeK2lBRnJ+TI6RjU1hjfD/T0SJvn9aKGOsoP9RQD1bnc/HRM0TwytqA== X-Received: by 2002:a17:90a:17ad:: with SMTP id q42mr187342pja.36.1604633371216; Thu, 05 Nov 2020 19:29:31 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:30 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 06/41] tcg: Adjust TCGLabel for const Date: Thu, 5 Nov 2020 19:28:46 -0800 Message-Id: <20201106032921.600200-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::542; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x542.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Change TCGLabel.u.value_ptr to const, and initialize it with tcg_splitwx_to_rx. Propagate const through tcg/host/ only as far as needed to avoid errors from the value_ptr change. Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 2 +- tcg/tcg.c | 2 +- tcg/aarch64/tcg-target.c.inc | 2 +- tcg/arm/tcg-target.c.inc | 2 +- tcg/mips/tcg-target.c.inc | 5 +++-- tcg/ppc/tcg-target.c.inc | 4 ++-- tcg/s390/tcg-target.c.inc | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 249f83be72..b2ba16ea8c 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -261,7 +261,7 @@ struct TCGLabel { unsigned refs : 16; union { uintptr_t value; - tcg_insn_unit *value_ptr; + const tcg_insn_unit *value_ptr; } u; QSIMPLEQ_HEAD(, TCGRelocation) relocs; QSIMPLEQ_ENTRY(TCGLabel) next; diff --git a/tcg/tcg.c b/tcg/tcg.c index cea3a4e4f2..a88b314e97 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -305,7 +305,7 @@ static void tcg_out_label(TCGContext *s, TCGLabel *l, tcg_insn_unit *ptr) { tcg_debug_assert(!l->has_value); l->has_value = 1; - l->u.value_ptr = ptr; + l->u.value_ptr = tcg_splitwx_to_rx(ptr); } TCGLabel *gen_new_label(void) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 76f8ae48ad..96dc9f4d0b 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1306,7 +1306,7 @@ static void tcg_out_cmp(TCGContext *s, TCGType ext, TCGReg a, } } -static inline void tcg_out_goto(TCGContext *s, tcg_insn_unit *target) +static void tcg_out_goto(TCGContext *s, const tcg_insn_unit *target) { ptrdiff_t offset = target - s->code_ptr; tcg_debug_assert(offset == sextract64(offset, 0, 26)); diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 1e32bf42b8..f8f485d807 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1019,7 +1019,7 @@ static inline void tcg_out_st8(TCGContext *s, int cond, * with the code buffer limited to 16MB we wouldn't need the long case. * But we also use it for the tail-call to the qemu_ld/st helpers, which does. */ -static void tcg_out_goto(TCGContext *s, int cond, tcg_insn_unit *addr) +static void tcg_out_goto(TCGContext *s, int cond, const tcg_insn_unit *addr) { intptr_t addri = (intptr_t)addr; ptrdiff_t disp = tcg_pcrel_diff(s, addr); diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index f641105f9a..a3f838fa51 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -144,7 +144,8 @@ static tcg_insn_unit *bswap32_addr; static tcg_insn_unit *bswap32u_addr; static tcg_insn_unit *bswap64_addr; -static inline uint32_t reloc_pc16_val(tcg_insn_unit *pc, tcg_insn_unit *target) +static inline uint32_t reloc_pc16_val(tcg_insn_unit *pc, + const tcg_insn_unit *target) { /* Let the compiler perform the right-shift as part of the arithmetic. */ ptrdiff_t disp = target - (pc + 1); @@ -152,7 +153,7 @@ static inline uint32_t reloc_pc16_val(tcg_insn_unit *pc, tcg_insn_unit *target) return disp & 0xffff; } -static inline void reloc_pc16(tcg_insn_unit *pc, tcg_insn_unit *target) +static inline void reloc_pc16(tcg_insn_unit *pc, const tcg_insn_unit *target) { *pc = deposit32(*pc, 0, 16, reloc_pc16_val(pc, target)); } diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index be116c6164..8a0b20a86b 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -184,7 +184,7 @@ static inline bool in_range_b(tcg_target_long target) return target == sextract64(target, 0, 26); } -static uint32_t reloc_pc24_val(tcg_insn_unit *pc, tcg_insn_unit *target) +static uint32_t reloc_pc24_val(tcg_insn_unit *pc, const tcg_insn_unit *target) { ptrdiff_t disp = tcg_ptr_byte_diff(target, pc); tcg_debug_assert(in_range_b(disp)); @@ -201,7 +201,7 @@ static bool reloc_pc24(tcg_insn_unit *pc, tcg_insn_unit *target) return false; } -static uint16_t reloc_pc14_val(tcg_insn_unit *pc, tcg_insn_unit *target) +static uint16_t reloc_pc14_val(tcg_insn_unit *pc, const tcg_insn_unit *target) { ptrdiff_t disp = tcg_ptr_byte_diff(target, pc); tcg_debug_assert(disp == (int16_t) disp); diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index ac99ccea73..1b5c4f0ab0 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -1302,7 +1302,7 @@ static void tgen_extract(TCGContext *s, TCGReg dest, TCGReg src, tcg_out_risbg(s, dest, src, 64 - len, 63, 64 - ofs, 1); } -static void tgen_gotoi(TCGContext *s, int cc, tcg_insn_unit *dest) +static void tgen_gotoi(TCGContext *s, int cc, const tcg_insn_unit *dest) { ptrdiff_t off = dest - s->code_ptr; if (off == (int16_t)off) { From patchwork Fri Nov 6 03:28:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885815 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B0E06A2 for ; Fri, 6 Nov 2020 03:31:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0501A20729 for ; Fri, 6 Nov 2020 03:31:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="cRYekqJq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0501A20729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:50342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasSq-0006XI-TZ for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:31:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46892) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRU-0004ZD-V7 for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:36 -0500 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:46770) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRS-0006uo-5e for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:36 -0500 Received: by mail-pg1-x52b.google.com with SMTP id w4so2857680pgg.13 for ; Thu, 05 Nov 2020 19:29:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NKx3ODzfKfyLFKhuotqig5XnvxrUEP579TW7wok+x2w=; b=cRYekqJqe2olIYtTUCMZWetOAsanDiYM0ID1+I+63c6omdTq3Vxy2JxIpplIstpFUJ Goh8dGlJNfxwqMcmG1cIAjCRpjjgfV9Xa9LF3w06qLiIcu9aInfYBawy9eBZA/iv78LH SCQByACCFj/GMAWtqv275aM3K2IZIBYwe039iKKHs5xIlGW92XlhYukxXeHK/eix1/bt C4m/YKS0mvtK2ozS27kQ+0t4lr9orkN4aiO5ci+bMZX5UznxdmNT5l5GS2ZvfBgNQ4Bf MziFywqBRnhy4U+TZ5OY6n03KERieTVHCjCSEusbavZOTFYEZSlocPZ7cSpgXTlzQCXu EbUA== 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=NKx3ODzfKfyLFKhuotqig5XnvxrUEP579TW7wok+x2w=; b=TtwgLgmT4YNficqpOhcNrP0518DU+KkNTZFaevbzvMzhZJBdQU/31cZf/E+v9mObSH T6SYJREuTKW3WNZDeKdZbpbTi/3yEezTOWTjOucHWQRsZztI2KfjPIX69T+cbWfV3Tdw wJ0rASmDRyGp9nk0mj3CgtuIiKcFezYu6wd022MdmESO7DBQiFpqe4zqqywtWbu13G4c dF8rKbiiAawBlYoFvtxQvN2cJuL5Uj0uIt3nyeaAwYgEtD268IOQ5fggHk80/aj9hfNo tmHkQEzVjITMwTAK2oYI4CcnvNl+5ghKmVHXX+cNsuK5NRswAU9AY1Inr0i1BJ3utxel PK5Q== X-Gm-Message-State: AOAM531FlA2AtGb60xXCKwI8ZgAI/dlceb6y5kw9aVpQ84ddQfAtZeOS E6YchMq9qrFMfZyfehJu3aW1sN+U12p8fA== X-Google-Smtp-Source: ABdhPJyh4Gj72zvchV5Bxd2HGyklejgSFomFYaBRH99EURI/r5LovaVIfWLeM2diaG1wsXsa20c+2Q== X-Received: by 2002:a65:44cd:: with SMTP id g13mr5163196pgs.259.1604633372412; Thu, 05 Nov 2020 19:29:32 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 07/41] tcg: Adjust tcg_out_call for const Date: Thu, 5 Nov 2020 19:28:47 -0800 Message-Id: <20201106032921.600200-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" We must change all targets at once, since all must match the declaration in tcg.c. Signed-off-by: Richard Henderson --- tcg/tcg.c | 2 +- tcg/aarch64/tcg-target.c.inc | 2 +- tcg/arm/tcg-target.c.inc | 2 +- tcg/i386/tcg-target.c.inc | 4 ++-- tcg/mips/tcg-target.c.inc | 6 +++--- tcg/ppc/tcg-target.c.inc | 8 ++++---- tcg/riscv/tcg-target.c.inc | 6 +++--- tcg/s390/tcg-target.c.inc | 2 +- tcg/sparc/tcg-target.c.inc | 4 ++-- tcg/tci/tcg-target.c.inc | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index a88b314e97..d3eeea355c 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -148,7 +148,7 @@ static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, TCGReg arg1, intptr_t arg2); static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, TCGReg base, intptr_t ofs); -static void tcg_out_call(TCGContext *s, tcg_insn_unit *target); +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target); static int tcg_target_const_match(tcg_target_long val, TCGType type, const TCGArgConstraint *arg_ct); #ifdef TCG_TARGET_NEED_LDST_LABELS diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 96dc9f4d0b..6d8152c468 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1329,7 +1329,7 @@ static inline void tcg_out_callr(TCGContext *s, TCGReg reg) tcg_out_insn(s, 3207, BLR, reg); } -static inline void tcg_out_call(TCGContext *s, tcg_insn_unit *target) +static inline void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) { ptrdiff_t offset = target - s->code_ptr; if (offset == sextract64(offset, 0, 26)) { diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index f8f485d807..a197e6bc45 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1033,7 +1033,7 @@ static void tcg_out_goto(TCGContext *s, int cond, const tcg_insn_unit *addr) /* The call case is mostly used for helpers - so it's not unreasonable * for them to be beyond branch range */ -static void tcg_out_call(TCGContext *s, tcg_insn_unit *addr) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *addr) { intptr_t addri = (intptr_t)addr; ptrdiff_t disp = tcg_pcrel_diff(s, addr); diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 424dd1cdcf..095553ce28 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1591,7 +1591,7 @@ static void tcg_out_clz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, } } -static void tcg_out_branch(TCGContext *s, int call, tcg_insn_unit *dest) +static void tcg_out_branch(TCGContext *s, int call, const tcg_insn_unit *dest) { intptr_t disp = tcg_pcrel_diff(s, dest) - 5; @@ -1610,7 +1610,7 @@ static void tcg_out_branch(TCGContext *s, int call, tcg_insn_unit *dest) } } -static inline void tcg_out_call(TCGContext *s, tcg_insn_unit *dest) +static inline void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) { tcg_out_branch(s, 1, dest); } diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index a3f838fa51..6d2c369a85 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -517,7 +517,7 @@ static void tcg_out_opc_sa64(TCGContext *s, MIPSInsn opc1, MIPSInsn opc2, * Type jump. * Returns true if the branch was in range and the insn was emitted. */ -static bool tcg_out_opc_jmp(TCGContext *s, MIPSInsn opc, void *target) +static bool tcg_out_opc_jmp(TCGContext *s, MIPSInsn opc, const void *target) { uintptr_t dest = (uintptr_t)target; uintptr_t from = (uintptr_t)s->code_ptr + 4; @@ -1080,7 +1080,7 @@ static void tcg_out_movcond(TCGContext *s, TCGCond cond, TCGReg ret, } } -static void tcg_out_call_int(TCGContext *s, tcg_insn_unit *arg, bool tail) +static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool tail) { /* Note that the ABI requires the called function's address to be loaded into T9, even if a direct branch is in range. */ @@ -1098,7 +1098,7 @@ static void tcg_out_call_int(TCGContext *s, tcg_insn_unit *arg, bool tail) } } -static void tcg_out_call(TCGContext *s, tcg_insn_unit *arg) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) { tcg_out_call_int(s, arg, false); tcg_out_nop(s); diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 8a0b20a86b..36129b976f 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -1106,7 +1106,7 @@ static void tcg_out_xori32(TCGContext *s, TCGReg dst, TCGReg src, uint32_t c) tcg_out_zori32(s, dst, src, c, XORI, XORIS); } -static void tcg_out_b(TCGContext *s, int mask, tcg_insn_unit *target) +static void tcg_out_b(TCGContext *s, int mask, const tcg_insn_unit *target) { ptrdiff_t disp = tcg_pcrel_diff(s, target); if (in_range_b(disp)) { @@ -1762,13 +1762,13 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, } } -static void tcg_out_call(TCGContext *s, tcg_insn_unit *target) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) { #ifdef _CALL_AIX /* Look through the descriptor. If the branch is in range, and we don't have to spend too much effort on building the toc. */ - void *tgt = ((void **)target)[0]; - uintptr_t toc = ((uintptr_t *)target)[1]; + const void *tgt = ((const void * const *)target)[0]; + uintptr_t toc = ((const uintptr_t *)target)[1]; intptr_t diff = tcg_pcrel_diff(s, tgt); if (in_range_b(diff) && toc == (uint32_t)toc) { diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index ab08af7457..4416a93e1f 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -449,7 +449,7 @@ static bool reloc_jimm20(tcg_insn_unit *code_ptr, tcg_insn_unit *target) return false; } -static bool reloc_call(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +static bool reloc_call(tcg_insn_unit *code_ptr, const tcg_insn_unit *target) { intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; int32_t lo = sextreg(offset, 0, 12); @@ -861,7 +861,7 @@ static inline void tcg_out_goto(TCGContext *s, tcg_insn_unit *target) tcg_out_opc_jump(s, OPC_JAL, TCG_REG_ZERO, offset); } -static void tcg_out_call_int(TCGContext *s, tcg_insn_unit *arg, bool tail) +static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool tail) { TCGReg link = tail ? TCG_REG_ZERO : TCG_REG_RA; ptrdiff_t offset = tcg_pcrel_diff(s, arg); @@ -888,7 +888,7 @@ static void tcg_out_call_int(TCGContext *s, tcg_insn_unit *arg, bool tail) } } -static void tcg_out_call(TCGContext *s, tcg_insn_unit *arg) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) { tcg_out_call_int(s, arg, false); } diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index 1b5c4f0ab0..37f4dc4cfd 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -1415,7 +1415,7 @@ static void tgen_brcond(TCGContext *s, TCGType type, TCGCond c, tgen_branch(s, cc, l); } -static void tcg_out_call(TCGContext *s, tcg_insn_unit *dest) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) { ptrdiff_t off = dest - s->code_ptr; if (off == (int32_t)off) { diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 5b3bc91b05..1a40911660 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -840,7 +840,7 @@ static void tcg_out_addsub2_i64(TCGContext *s, TCGReg rl, TCGReg rh, tcg_out_mov(s, TCG_TYPE_I64, rl, tmp); } -static void tcg_out_call_nodelay(TCGContext *s, tcg_insn_unit *dest, +static void tcg_out_call_nodelay(TCGContext *s, const tcg_insn_unit *dest, bool in_prologue) { ptrdiff_t disp = tcg_pcrel_diff(s, dest); @@ -855,7 +855,7 @@ static void tcg_out_call_nodelay(TCGContext *s, tcg_insn_unit *dest, } } -static void tcg_out_call(TCGContext *s, tcg_insn_unit *dest) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) { tcg_out_call_nodelay(s, dest, false); tcg_out_nop(s); diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index 231b9b1775..d5a4d9d37c 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -545,7 +545,7 @@ static void tcg_out_movi(TCGContext *s, TCGType type, old_code_ptr[1] = s->code_ptr - old_code_ptr; } -static inline void tcg_out_call(TCGContext *s, tcg_insn_unit *arg) +static inline void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) { uint8_t *old_code_ptr = s->code_ptr; tcg_out_op_t(s, INDEX_op_call); From patchwork Fri Nov 6 03:28:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885825 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5FCE6A2 for ; Fri, 6 Nov 2020 03:33:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6BA1C20729 for ; Fri, 6 Nov 2020 03:33:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Wb1ky7aZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6BA1C20729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:58834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasVT-0001cG-CM for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:33:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRV-0004bF-Rv for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:37 -0500 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:33480) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRT-0006uu-61 for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:37 -0500 Received: by mail-pf1-x443.google.com with SMTP id q10so66244pfn.0 for ; Thu, 05 Nov 2020 19:29:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hAEMbLEJD/eBtWNiswR+L4HBV0VLxFFaL5IoMfIX6Q4=; b=Wb1ky7aZaeMc9ZSq/zJT7asggQ/Dsu6qsjq8mAcTxU+2nC7pzEtfu7ttl/u1as64UC 7FvRh8VNYpLVomedrVsq5YszXmVg0FZA5Q/OTV2pgAFKQgbuyyA/WSlLn7SUjZnumBih y9OohcyXCcQajRKG9Lhw/LeyRzTBjg/nDQzwYpFMHdmsiRynw99zqLgfSUEacCCGa0Rb jTgmQq1ky0LVDY+YItLP8OZdXiGTPJ7+Lcj92rPEXPFRJghf/BZIuXUE9XHEePUwb7i4 EO2KW9Ks8Ewtl0dlsvhbd25fdWarfQk/qXm16ShCkE589tfNmKQzN0xfAElbZkHTgaTS IWww== 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=hAEMbLEJD/eBtWNiswR+L4HBV0VLxFFaL5IoMfIX6Q4=; b=m1XjfRykn54RYJKjfVuWMhPVDBNYqu+RSk2qQdsCXIKXtCb4gPs2PTA9CsvilT7CLA YSzAOFel0bleoojsf+SRvzD1adGS7HUGgol6BR0ORZ2PgQS+JL8WBlDwyQSDN9FsL5U5 ljK159t3phEumDeXQqsNjGa0l42pgYov3l52EUTM90iGF0iIFih5Qn22Td/6nqmY5NS9 n9tuWt0H+I0WuAc0pulnd7eSyJD1T+jSnomujDaef1B+XqqJB3v5X2zveNfHxlcX09qS hIM8jmOkKRJfZ61l6WmMybE2L546Ecj/6QXozzXA9yMSjBnAjsViIyXu2h7lU/jRlB68 DtEA== X-Gm-Message-State: AOAM53226vwY9FC1ElJt5c3aMV027QYEhKUp7mCSJxGFbTGjwESFfGmF YLUI+GNNY9dWHuawP96rogMmIJG6YtzPpw== X-Google-Smtp-Source: ABdhPJyPTzWtqtckewyZ/+MrCh77Nuv2dQhJ189dcXcaOYrfFu/1rp2/l5O/U5fb0u6xVVjmbprmNA== X-Received: by 2002:aa7:8b0b:0:b029:152:900d:2288 with SMTP id f11-20020aa78b0b0000b0290152900d2288mr91746pfd.53.1604633373663; Thu, 05 Nov 2020 19:29:33 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 08/41] tcg: Adjust tcg_out_label for const Date: Thu, 5 Nov 2020 19:28:48 -0800 Message-Id: <20201106032921.600200-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::443; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Simplify the arguments to always use s->code_ptr instead of take it as an argument. That makes it easy to ensure that the value_ptr is always the rx version. Signed-off-by: Richard Henderson --- tcg/tcg.c | 6 +++--- tcg/i386/tcg-target.c.inc | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index d3eeea355c..e5d2208e88 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -301,11 +301,11 @@ static void tcg_out_reloc(TCGContext *s, tcg_insn_unit *code_ptr, int type, QSIMPLEQ_INSERT_TAIL(&l->relocs, r, next); } -static void tcg_out_label(TCGContext *s, TCGLabel *l, tcg_insn_unit *ptr) +static void tcg_out_label(TCGContext *s, TCGLabel *l) { tcg_debug_assert(!l->has_value); l->has_value = 1; - l->u.value_ptr = tcg_splitwx_to_rx(ptr); + l->u.value_ptr = tcg_splitwx_to_rx(s->code_ptr); } TCGLabel *gen_new_label(void) @@ -4322,7 +4322,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) break; case INDEX_op_set_label: tcg_reg_alloc_bb_end(s, s->reserved_regs); - tcg_out_label(s, arg_label(op->args[0]), s->code_ptr); + tcg_out_label(s, arg_label(op->args[0])); break; case INDEX_op_call: tcg_reg_alloc_call(s, op); diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 095553ce28..0ac1ef3d82 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1452,7 +1452,7 @@ static void tcg_out_brcond2(TCGContext *s, const TCGArg *args, default: tcg_abort(); } - tcg_out_label(s, label_next, s->code_ptr); + tcg_out_label(s, label_next); } #endif @@ -1494,10 +1494,10 @@ static void tcg_out_setcond2(TCGContext *s, const TCGArg *args, tcg_out_movi(s, TCG_TYPE_I32, args[0], 0); tcg_out_jxx(s, JCC_JMP, label_over, 1); - tcg_out_label(s, label_true, s->code_ptr); + tcg_out_label(s, label_true); tcg_out_movi(s, TCG_TYPE_I32, args[0], 1); - tcg_out_label(s, label_over, s->code_ptr); + tcg_out_label(s, label_over); } else { /* When the destination does not overlap one of the arguments, clear the destination first, jump if cond false, and emit an @@ -1511,7 +1511,7 @@ static void tcg_out_setcond2(TCGContext *s, const TCGArg *args, tcg_out_brcond2(s, new_args, const_args+1, 1); tgen_arithi(s, ARITH_ADD, args[0], 1, 0); - tcg_out_label(s, label_over, s->code_ptr); + tcg_out_label(s, label_over); } } #endif @@ -1525,7 +1525,7 @@ static void tcg_out_cmov(TCGContext *s, TCGCond cond, int rexw, TCGLabel *over = gen_new_label(); tcg_out_jxx(s, tcg_cond_to_jcc[tcg_invert_cond(cond)], over, 1); tcg_out_mov(s, TCG_TYPE_I32, dest, v1); - tcg_out_label(s, over, s->code_ptr); + tcg_out_label(s, over); } } From patchwork Fri Nov 6 03:28:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885843 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F9041130 for ; Fri, 6 Nov 2020 03:38:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 090E320729 for ; Fri, 6 Nov 2020 03:38:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="XbfKkVLa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 090E320729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:50246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasa0-0001DT-W4 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:38:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRW-0004cy-K4 for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:38 -0500 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:37432) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRU-0006v4-Lw for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:38 -0500 Received: by mail-pf1-x42d.google.com with SMTP id 13so52227pfy.4 for ; Thu, 05 Nov 2020 19:29:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kmX00pdaVuC+SHXGXI/iAqpTaWv1k3LGabjYAKxqLXM=; b=XbfKkVLaa+IAQqdBtN2XUCkLzdXNr01ySCVVkwO/shkGiqT25WpNBGCEMdwxo3fGLa 6wgzsRCcGYeRDGzXK3y4eT8EWjxoeS1v1C4qhSqWV2K3UqNZ0eoPe2RHhg98S+jOF5LL PYpk5oWzYenqVx0xVelAiXZNSs3vbM7iii4DWIpqJktn2j9Tk1VsVX5yjpym71Gf4acM Ir1p5MSKbSVQLA2zmiN+NhZy7WsH6qiR/Fp8jueu3DRLvdUhM1VxH5Fekm8hkby7SnHc ttIpYvOb4rTXywlCVKlN7CI/CKl+Lz+uMJX/j09qc1Ad5+vtUNBDPPrtEU/SFEFqeTqO KZeg== 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=kmX00pdaVuC+SHXGXI/iAqpTaWv1k3LGabjYAKxqLXM=; b=Mh9NfWfutaEfzWly6Y4O2kOehqMJzE1RqF0dbguoTm7FcztPQyJoA+dckWvZ4ysmjC FhA+sWRhhb8+0OEI9Z9rOchs3UpvhSXUpMYyY7xAOqwCZZkOg9pVGYE9EVSQecacfnxJ i6vxZSj+HWx+4jNov2qjG/YKKgzIYM2oIMpFh817jeb/PnUoEN3+mgYGu5T2KOmgD3wt jve/zbXa5uDL3YCJXvNFsRncro54lx3M+YbPW8lMNyaCFzsxHNCFsrFzB0jBN4wBWXro M/CkdJDl0uyp1PoHYH3UysqK2BeFSK4R6Ku4HyxiuPzq71PrdhvG/0f1QE2K+wU9x1Gf JIbg== X-Gm-Message-State: AOAM530GzP5HoJSISW8yMt8zeBgh2C7FlBWMG3Qw42382Djxfgz3rwY6 GApodgQzjUYNZTDaFoBNBtOpqsNCBEJ0Rw== X-Google-Smtp-Source: ABdhPJxwQOhRBeBZcIbB19oHb1A8H/Mdkh4Zqd70ACLLbbvWSshHthZqRbMEX7zoKy4SsBUTReosqQ== X-Received: by 2002:a05:6a00:8ca:b029:15d:7af3:8360 with SMTP id s10-20020a056a0008cab029015d7af38360mr12261pfu.12.1604633374845; Thu, 05 Nov 2020 19:29:34 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:34 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 09/41] tcg: Adjust tcg_register_jit for const Date: Thu, 5 Nov 2020 19:28:49 -0800 Message-Id: <20201106032921.600200-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" We must change all targets at once, since all must match the declaration in tcg.c. Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 2 +- tcg/tcg.c | 10 +++++----- tcg/aarch64/tcg-target.c.inc | 2 +- tcg/arm/tcg-target.c.inc | 2 +- tcg/i386/tcg-target.c.inc | 2 +- tcg/mips/tcg-target.c.inc | 2 +- tcg/ppc/tcg-target.c.inc | 2 +- tcg/riscv/tcg-target.c.inc | 2 +- tcg/s390/tcg-target.c.inc | 2 +- tcg/sparc/tcg-target.c.inc | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index b2ba16ea8c..67d57695c2 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -1250,7 +1250,7 @@ typedef uintptr_t tcg_prologue_fn(CPUArchState *env, const void *tb_ptr); extern tcg_prologue_fn *tcg_qemu_tb_exec; #endif -void tcg_register_jit(void *buf, size_t buf_size); +void tcg_register_jit(const void *buf, size_t buf_size); #if TCG_TARGET_MAYBE_vec /* Return zero if the tuple (opc, type, vece) is unsupportable; diff --git a/tcg/tcg.c b/tcg/tcg.c index e5d2208e88..07a4bd2c57 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -96,7 +96,7 @@ typedef struct QEMU_PACKED { DebugFrameFDEHeader fde; } DebugFrameHeader; -static void tcg_register_jit_int(void *buf, size_t size, +static void tcg_register_jit_int(const void *buf, size_t size, const void *debug_frame, size_t debug_frame_size) __attribute__((unused)); @@ -1134,7 +1134,7 @@ void tcg_prologue_init(TCGContext *s) total_size -= prologue_size; s->code_gen_buffer_size = total_size; - tcg_register_jit(s->code_gen_buffer, total_size); + tcg_register_jit(tcg_splitwx_to_rx(s->code_gen_buffer), total_size); #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM)) { @@ -4502,7 +4502,7 @@ static int find_string(const char *strtab, const char *str) } } -static void tcg_register_jit_int(void *buf_ptr, size_t buf_size, +static void tcg_register_jit_int(const void *buf_ptr, size_t buf_size, const void *debug_frame, size_t debug_frame_size) { @@ -4704,13 +4704,13 @@ static void tcg_register_jit_int(void *buf_ptr, size_t buf_size, /* No support for the feature. Provide the entry point expected by exec.c, and implement the internal function we declared earlier. */ -static void tcg_register_jit_int(void *buf, size_t size, +static void tcg_register_jit_int(const void *buf, size_t size, const void *debug_frame, size_t debug_frame_size) { } -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { } #endif /* ELF_HOST_MACHINE */ diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 6d8152c468..9ace859db3 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -2964,7 +2964,7 @@ static const DebugFrame debug_frame = { } }; -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index a197e6bc45..9b9400f164 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -2353,7 +2353,7 @@ static const DebugFrame debug_frame = { } }; -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 0ac1ef3d82..7f74c77d7f 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -3998,7 +3998,7 @@ static const DebugFrame debug_frame = { #endif #if defined(ELF_HOST_MACHINE) -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 6d2c369a85..e9c8c24741 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -2703,7 +2703,7 @@ static const DebugFrame debug_frame = { } }; -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 36129b976f..ff667b1531 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -3847,7 +3847,7 @@ static DebugFrame debug_frame = { } }; -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { uint8_t *p = &debug_frame.fde_reg_ofs[3]; int i; diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 4416a93e1f..025e3cd0bb 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1907,7 +1907,7 @@ static const DebugFrame debug_frame = { } }; -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index 37f4dc4cfd..1444914428 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -2620,7 +2620,7 @@ static const DebugFrame debug_frame = { } }; -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 1a40911660..4c81d5f1c2 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -1816,7 +1816,7 @@ static const DebugFrame debug_frame = { .fde_ret_save = { 9, 15, 31 }, /* DW_CFA_register o7, i7 */ }; -void tcg_register_jit(void *buf, size_t buf_size) +void tcg_register_jit(const void *buf, size_t buf_size) { tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } From patchwork Fri Nov 6 03:28:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885833 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7AEFD6A2 for ; Fri, 6 Nov 2020 03:35:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 042D620729 for ; Fri, 6 Nov 2020 03:35:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="aTl3CKee" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 042D620729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:39060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasXX-00054h-RY for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:35:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRY-0004hY-C0 for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:40 -0500 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:46557) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRW-0006vF-0W for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:40 -0500 Received: by mail-pg1-x543.google.com with SMTP id w4so2857760pgg.13 for ; Thu, 05 Nov 2020 19:29:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FN7eaRY1DFewRq+5QytfG73XvKQyLklp5pw6gaXWtVo=; b=aTl3CKeeAoIXQL8RygtWkPZrXgWy7FbT9z/2AwL2LOPDwwXvDFGfKCwgr8yic5d/BI r0o1JcO6UMAHO++B2BedmVpNd3fMgrA1Zy+ogPfovE8GE3H/p8jrLV/999LFfDOv95U+ k0laMeeWla6lRwqymnWj0poM5oupdClDQXAukR1eF66wx/2+VC4QEVrKbi7EU6ZRyamt jtrviS4eGO9wqfj06bnxxq0GoK6lQaYUY6q9fHFLPXL677xZgpBJOIe6iH2IH7ESEMrb 42kvr+l9Bnaps/a4ZS2FEOpY2MttaZqE5cMVI4ag1lXLWiSjYck1RqF8e3IZghIZXX9x O8kg== 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=FN7eaRY1DFewRq+5QytfG73XvKQyLklp5pw6gaXWtVo=; b=QZzn4aYX/Y7ltyH1wnrrp0jN0pYpBtTwVL2b1IPRKY/tpllnckx4HFPBQI6HGzI6fO AdmEAdIIwqn3XkyvsLEkSj+LR327E38lqIsY7KWTaTdmB9+G7HaVlyhP4Y8vAcS90yvH o2gknITH1MDGTgHZFjrUZu2Y4zgznxzTKBDSBiUN1zAxalPTSoMd+Mty7paiMwMv3xlb N2Pem2iJOWcOxdH4SAotQtJSfUMSBBh2H0bU78Ke9ODVl9wmDcJ1iQSoSL8lfPbaYQh7 IVX+wbD0u1+rmpEm3BELc3p3/bxpdedammg4p5TUd9NV84b0UdGhqLzBf42KmoLxJKmg jVVA== X-Gm-Message-State: AOAM531laPjNZ5U9utNCf/sGfb3fE/8lFpOs6S++TX3mqZkJXFkQcvPS b249J7Q81u06w8L1Qxu6qBJ1M+pohl0bCw== X-Google-Smtp-Source: ABdhPJxDVVK3VFIuzD3qURUJsIXKPehOKdr1Rbx7lr84fd1KKyqMcCb2/kmDADlfX0xcWXc6qO/ZgQ== X-Received: by 2002:a17:90a:c201:: with SMTP id e1mr177735pjt.16.1604633376114; Thu, 05 Nov 2020 19:29:36 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 10/41] tcg: Adjust tb_target_set_jmp_target for split-wx Date: Thu, 5 Nov 2020 19:28:50 -0800 Message-Id: <20201106032921.600200-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::543; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x543.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Pass both rx and rw addresses to tb_target_set_jmp_target. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.h | 2 +- tcg/arm/tcg-target.h | 2 +- tcg/i386/tcg-target.h | 6 +++--- tcg/mips/tcg-target.h | 2 +- tcg/ppc/tcg-target.h | 2 +- tcg/riscv/tcg-target.h | 2 +- tcg/s390/tcg-target.h | 8 ++++---- tcg/sparc/tcg-target.h | 2 +- tcg/tci/tcg-target.h | 6 +++--- accel/tcg/cpu-exec.c | 4 +++- tcg/aarch64/tcg-target.c.inc | 12 ++++++------ tcg/mips/tcg-target.c.inc | 8 ++++---- tcg/ppc/tcg-target.c.inc | 16 ++++++++-------- tcg/sparc/tcg-target.c.inc | 14 +++++++------- 14 files changed, 44 insertions(+), 42 deletions(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index d0a6a059b7..91313d93be 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -158,7 +158,7 @@ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) __builtin___clear_cache((char *)rx, (char *)(rx + len)); } -void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); +void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index fa88b24e43..b21a2fb6a1 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -144,7 +144,7 @@ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) } /* not defined -- call should be eliminated at compile time */ -void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); +void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 8323e72639..f52ba0ffec 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -211,11 +211,11 @@ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { } -static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, - uintptr_t jmp_addr, uintptr_t addr) +static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, + uintptr_t jmp_rw, uintptr_t addr) { /* patch the branch destination */ - qatomic_set((int32_t *)jmp_addr, addr - (jmp_addr + 4)); + qatomic_set((int32_t *)jmp_rw, addr - (jmp_rx + 4)); /* no need to flush icache explicitly */ } diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 47b1226ee9..cd548dacec 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -216,7 +216,7 @@ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) cacheflush((void *)rx, len, ICACHE); } -void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); +void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index fbb6dc1b47..8f3e4c924a 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -176,7 +176,7 @@ extern bool have_vsx; #define TCG_TARGET_HAS_cmpsel_vec 0 void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len); -void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); +void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 0fa6ae358e..e03fd17427 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -169,7 +169,7 @@ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) } /* not defined -- call should be eliminated at compile time */ -void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); +void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_DEFAULT_MO (0) diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h index c3dc2e8938..c5a749e425 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -150,12 +150,12 @@ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { } -static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, - uintptr_t jmp_addr, uintptr_t addr) +static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, + uintptr_t jmp_rw, uintptr_t addr) { /* patch the branch destination */ - intptr_t disp = addr - (jmp_addr - 2); - qatomic_set((int32_t *)jmp_addr, disp / 2); + intptr_t disp = addr - (jmp_rx - 2); + qatomic_set((int32_t *)jmp_rw, disp / 2); /* no need to flush icache explicitly */ } diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h index c27c40231e..87e2be61e6 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -178,7 +178,7 @@ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) } } -void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); +void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_POOL_LABELS diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index 49f3291f8a..a19a6b06e5 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -201,11 +201,11 @@ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, - uintptr_t jmp_addr, uintptr_t addr) +static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, + uintptr_t jmp_rw, uintptr_t addr) { /* patch the branch destination */ - qatomic_set((int32_t *)jmp_addr, addr - (jmp_addr + 4)); + qatomic_set((int32_t *)jmp_rw, addr - (jmp_rx + 4)); /* no need to flush icache explicitly */ } diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 1e3cb570f6..272d596e0c 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -354,7 +354,9 @@ void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr) if (TCG_TARGET_HAS_direct_jump) { uintptr_t offset = tb->jmp_target_arg[n]; uintptr_t tc_ptr = (uintptr_t)tb->tc.ptr; - tb_target_set_jmp_target(tc_ptr, tc_ptr + offset, addr); + uintptr_t jmp_rx = tc_ptr + offset; + uintptr_t jmp_rw = jmp_rx - tcg_splitwx_diff; + tb_target_set_jmp_target(tc_ptr, jmp_rx, jmp_rw, addr); } else { tb->jmp_target_arg[n] = addr; } diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 9ace859db3..fea784cf75 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1340,21 +1340,21 @@ static inline void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) } } -void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, - uintptr_t addr) +void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, + uintptr_t jmp_rw, uintptr_t addr) { tcg_insn_unit i1, i2; TCGType rt = TCG_TYPE_I64; TCGReg rd = TCG_REG_TMP; uint64_t pair; - ptrdiff_t offset = addr - jmp_addr; + ptrdiff_t offset = addr - jmp_rx; if (offset == sextract64(offset, 0, 26)) { i1 = I3206_B | ((offset >> 2) & 0x3ffffff); i2 = NOP; } else { - offset = (addr >> 12) - (jmp_addr >> 12); + offset = (addr >> 12) - (jmp_rx >> 12); /* patch ADRP */ i1 = I3406_ADRP | (offset & 3) << 29 | (offset & 0x1ffffc) << (5 - 2) | rd; @@ -1362,8 +1362,8 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, i2 = I3401_ADDI | rt << 31 | (addr & 0xfff) << 10 | rd << 5 | rd; } pair = (uint64_t)i2 << 32 | i1; - qatomic_set((uint64_t *)jmp_addr, pair); - flush_idcache_range(jmp_addr, jmp_addr, 8); + qatomic_set((uint64_t *)jmp_rw, pair); + flush_idcache_range(jmp_rx, jmp_rw, 8); } static inline void tcg_out_goto_label(TCGContext *s, TCGLabel *l) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index e9c8c24741..52638e920c 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -2657,11 +2657,11 @@ static void tcg_target_init(TCGContext *s) tcg_regset_set_reg(s->reserved_regs, TCG_REG_GP); /* global pointer */ } -void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, - uintptr_t addr) +void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, + uintptr_t jmp_rw, uintptr_t addr) { - qatomic_set((uint32_t *)jmp_addr, deposit32(OPC_J, 0, 26, addr >> 2)); - flush_idcache_range(jmp_addr, jmp_addr, 4); + qatomic_set((uint32_t *)jmp_rw, deposit32(OPC_J, 0, 26, addr >> 2)); + flush_idcache_range(jmp_rx, jmp_rw, 4); } typedef struct { diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index ff667b1531..bc0057eedf 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -1722,13 +1722,13 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) tcg_out32(s, insn); } -void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, - uintptr_t addr) +void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, + uintptr_t jmp_rw, uintptr_t addr) { if (TCG_TARGET_REG_BITS == 64) { tcg_insn_unit i1, i2; intptr_t tb_diff = addr - tc_ptr; - intptr_t br_diff = addr - (jmp_addr + 4); + intptr_t br_diff = addr - (jmp_rx + 4); uint64_t pair; /* This does not exercise the range of the branch, but we do @@ -1752,13 +1752,13 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, /* As per the enclosing if, this is ppc64. Avoid the _Static_assert within qatomic_set that would fail to build a ppc32 host. */ - qatomic_set__nocheck((uint64_t *)jmp_addr, pair); - flush_idcache_range(jmp_addr, jmp_addr, 8); + qatomic_set__nocheck((uint64_t *)jmp_rw, pair); + flush_idcache_range(jmp_rx, jmp_rw, 8); } else { - intptr_t diff = addr - jmp_addr; + intptr_t diff = addr - jmp_rx; tcg_debug_assert(in_range_b(diff)); - qatomic_set((uint32_t *)jmp_addr, B | (diff & 0x3fffffc)); - flush_idcache_range(jmp_addr, jmp_addr, 4); + qatomic_set((uint32_t *)jmp_rw, B | (diff & 0x3fffffc)); + flush_idcache_range(jmp_rx, jmp_rw, 4); } } diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 4c81d5f1c2..d599ae27b5 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -1821,11 +1821,11 @@ void tcg_register_jit(const void *buf, size_t buf_size) tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } -void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, - uintptr_t addr) +void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, + uintptr_t jmp_rw, uintptr_t addr) { intptr_t tb_disp = addr - tc_ptr; - intptr_t br_disp = addr - jmp_addr; + intptr_t br_disp = addr - jmp_rx; tcg_insn_unit i1, i2; /* We can reach the entire address space for ILP32. @@ -1834,9 +1834,9 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, tcg_debug_assert(br_disp == (int32_t)br_disp); if (!USE_REG_TB) { - qatomic_set((uint32_t *)jmp_addr, + qatomic_set((uint32_t *)jmp_rw, deposit32(CALL, 0, 30, br_disp >> 2)); - flush_idcache_range(jmp_addr, jmp_addr, 4); + flush_idcache_range(jmp_rx, jmp_rw, 4); return; } @@ -1859,6 +1859,6 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, | INSN_IMM13((tb_disp & 0x3ff) | -0x400)); } - qatomic_set((uint64_t *)jmp_addr, deposit64(i2, 32, 32, i1)); - flush_idcache_range(jmp_addr, jmp_addr, 8); + qatomic_set((uint64_t *)jmp_rw, deposit64(i2, 32, 32, i1)); + flush_idcache_range(jmp_rx, jmp_rw, 8); } From patchwork Fri Nov 6 03:28:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885841 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F9E11130 for ; Fri, 6 Nov 2020 03:38:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CDC5020729 for ; Fri, 6 Nov 2020 03:37:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="RIi3e/3p" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CDC5020729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:47474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasZa-000053-Ix for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:37:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRc-0004k0-Nz for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:44 -0500 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:34753) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRX-0006vk-7K for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:44 -0500 Received: by mail-pf1-x443.google.com with SMTP id o129so63073pfb.1 for ; Thu, 05 Nov 2020 19:29:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zWq3TtkAOfWsyJy+wkM7x05DqyCE4LSUBk+gDjNkgzY=; b=RIi3e/3pR+2JUkXc8eUBYHuZuux4QoeDLJ8fE8Vl+qQLUYUPsbaHsmz9pLKACjaLGr Oh64S5oJjWrvKXeyRaHUuV8lHgSUlGeyCSQ2qvSIEyhZufhsuITLaqrHv5Z2riXtYJ7+ j6nzcG2kCULXKNYrz2DjayUXjW2kF9TPtgo8FmXCkmUSxXcZ+fsHrHwEH0AasCgtmyxM X/FZDjY9PssmBNDdFn5pLVbN6/X6CdFZI9mltK38Ansq3cqxXxvCrwjymYCilGFR2+ta ID6Klhp442f0fj9hMQwCeRYHOYwNm5i8KdTMKNWiMAvfeQWBW9URcZc5piW9LcLPGskP KNNg== 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=zWq3TtkAOfWsyJy+wkM7x05DqyCE4LSUBk+gDjNkgzY=; b=pKADmPiJyTLeC/vjnmeCWpyQVb36WQjP3KP2yvav56sYwvnhbeIfqDXen0go6oKKU7 FOuHuLybDGS8V6wMvSMirBXMUuCFAs08sEXvw/OpFEb37/hTuWGhrukN+kEpaGKjR+in Ahcpzs1jLln+hNHZReX31tn9D7gLfxjHaBCGQqmlfxvAnhxyuYohf9VtusYYdIBOENQi bBWAJ0bSWly3bUkKtA3TU7uuinLm1Mq2vF4M1EEF5G1zBwnft2GuCiomXqOupNg56Miv nlcXzJqt9RwhHUMQphHcviltHf3mRzZ4BjKZK2LAQawHCkb6h4xQskVYrVtg/onUXxh+ woQQ== X-Gm-Message-State: AOAM530VX5gFZxLI/mueNLGTMpN8Rt42Yer8Iv2sO85mCh1jFhS56Omh 90mhAYHwVwvdRllSIScyj9Zx3+Kg1DH1HQ== X-Google-Smtp-Source: ABdhPJzZRa6ahbH12XcSrkvwzMG3rYUSUHqRmfslrhGMwxJ/9mLLNNz1Z5AB9Gu5EiMJE/XBQKSBJw== X-Received: by 2002:aa7:9f06:0:b029:18a:e1a6:cec9 with SMTP id g6-20020aa79f060000b029018ae1a6cec9mr5462945pfr.20.1604633377512; Thu, 05 Nov 2020 19:29:37 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 11/41] tcg: Make DisasContextBase.tb const Date: Thu, 5 Nov 2020 19:28:51 -0800 Message-Id: <20201106032921.600200-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::443; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" There is nothing within the translators that ought to be changing the TranslationBlock data, so make it const. This does not actually use the read-only copy of the data structure that exists within the rx region. Signed-off-by: Richard Henderson --- include/exec/gen-icount.h | 4 ++-- include/exec/translator.h | 2 +- include/tcg/tcg-op.h | 2 +- accel/tcg/translator.c | 4 ++-- target/arm/translate-a64.c | 2 +- tcg/tcg-op.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h index 822c43cfd3..aa4b44354a 100644 --- a/include/exec/gen-icount.h +++ b/include/exec/gen-icount.h @@ -32,7 +32,7 @@ static inline void gen_io_end(void) tcg_temp_free_i32(tmp); } -static inline void gen_tb_start(TranslationBlock *tb) +static inline void gen_tb_start(const TranslationBlock *tb) { TCGv_i32 count, imm; @@ -71,7 +71,7 @@ static inline void gen_tb_start(TranslationBlock *tb) tcg_temp_free_i32(count); } -static inline void gen_tb_end(TranslationBlock *tb, int num_insns) +static inline void gen_tb_end(const TranslationBlock *tb, int num_insns) { if (tb_cflags(tb) & CF_USE_ICOUNT) { /* Update the num_insn immediate parameter now that we know diff --git a/include/exec/translator.h b/include/exec/translator.h index 638e1529c5..24232ead41 100644 --- a/include/exec/translator.h +++ b/include/exec/translator.h @@ -67,7 +67,7 @@ typedef enum DisasJumpType { * Architecture-agnostic disassembly context. */ typedef struct DisasContextBase { - TranslationBlock *tb; + const TranslationBlock *tb; target_ulong pc_first; target_ulong pc_next; DisasJumpType is_jmp; diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h index 5abf17fecc..cbe39a3b95 100644 --- a/include/tcg/tcg-op.h +++ b/include/tcg/tcg-op.h @@ -805,7 +805,7 @@ static inline void tcg_gen_insn_start(target_ulong pc, target_ulong a1, * be NULL and @idx should be 0. Otherwise, @tb should be valid and * @idx should be one of the TB_EXIT_ values. */ -void tcg_gen_exit_tb(TranslationBlock *tb, unsigned idx); +void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx); /** * tcg_gen_goto_tb() - output goto_tb TCG operation diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index fb1e19c585..a49a794065 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -133,8 +133,8 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, } /* The disas_log hook may use these values rather than recompute. */ - db->tb->size = db->pc_next - db->pc_first; - db->tb->icount = db->num_insns; + tb->size = db->pc_next - db->pc_first; + tb->icount = db->num_insns; #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 072754fa24..297782e6ef 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -410,7 +410,7 @@ static inline bool use_goto_tb(DisasContext *s, int n, uint64_t dest) static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest) { - TranslationBlock *tb; + const TranslationBlock *tb; tb = s->base.tb; if (use_goto_tb(s, n, dest)) { diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 4b8a473fad..e3dc0cb4cb 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2664,7 +2664,7 @@ void tcg_gen_extr32_i64(TCGv_i64 lo, TCGv_i64 hi, TCGv_i64 arg) /* QEMU specific operations. */ -void tcg_gen_exit_tb(TranslationBlock *tb, unsigned idx) +void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx) { uintptr_t val = (uintptr_t)tb + idx; From patchwork Fri Nov 6 03:28:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885849 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 513AE1744 for ; Fri, 6 Nov 2020 03:39:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EBA912072E for ; Fri, 6 Nov 2020 03:39:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oqR/bUhr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBA912072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:55832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasaq-0003Qt-V3 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:39:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRf-0004qz-4L for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:47 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:34694) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRc-0006wb-EZ for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:46 -0500 Received: by mail-pl1-x633.google.com with SMTP id p4so33365plr.1 for ; Thu, 05 Nov 2020 19:29:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EZoWS2rDJTXqXpM5kSibnRtpefjrKqjOzA1oHfZm56Y=; b=oqR/bUhrHnAHVQoxbHf53anIdc7hqhvPg2ocOAywG6Q5um8Ug7uTuRjWwz9vWYEMvd zD04VzsFq5pR1fU6WVmmgn42aMFBp8votNgdOMel6fZBhyiUpkSNPO3x6KS2cx7vLX7J s9m8gfnGoRRAz8uCrVKyYg8SjLYZJJ+oAcMwFRFtyTi4Dc7RpdiEfsYqq7mBK/vw4UZ3 4B/T2uDhH4PkdILH4ZCf6T853eOPzXBIxm+gyjzD98+V0ZxoUukFjtKjF1hB2Ugj2iRI vQrM5xLy3m7mBFe7j4OOPSO5EkVTZz+rWwYC7yBQsgqbQTkWVtd4zmN6Oymz1bFpQkEK +JjQ== 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=EZoWS2rDJTXqXpM5kSibnRtpefjrKqjOzA1oHfZm56Y=; b=XuauZahu9DvhWx4tpIy0SH5QsnFwZkH31HaH1ggJCQsYtcTy7KQhodVtUvGCaQs3hU KlBrqLgWfXH0Db0CAuBB6WI2wrRYfXatJL2w3RcocW5TPq6PThtP7E7b+ZFgy20qu5lM Nz+/0NmOwYkaiBB5l1qD4yxnItSw2+dljwssVbKTh2hZtAe8K2Eef8QcfqDBOOTrxoPv Ot/gKYFeQ9iJJ/8lSWS+LX93+JtJIoEFTF1b8gk0FqpFYTsfXSVnfhfFb6/J4m5ia6b+ wAT4cBZgJ8wC4NQro6+8t5Bdz6xctKZU3nXu2X2GvqKTENQl5/omyMdN7OTNSyVIxGmi 3HpA== X-Gm-Message-State: AOAM531KTn8eInZRUxRGWCQ2lyERpwGy+b+gDfZq03CXPFqkDjqoe72e SFSYCUVnCzBXlxXPiodWFp0sTF4g5lq0Xg== X-Google-Smtp-Source: ABdhPJyttSIGD0mcUUeLALdD8kxbNkkL6IfS1x6hnw9nJXZOku8mvpWY9+5iWuZ0KU3C0lnB9K5sjg== X-Received: by 2002:a17:902:6f10:b029:d6:e6f5:1dab with SMTP id w16-20020a1709026f10b02900d6e6f51dabmr4989074plk.1.1604633378748; Thu, 05 Nov 2020 19:29:38 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 12/41] tcg: Make tb arg to synchronize_from_tb const Date: Thu, 5 Nov 2020 19:28:52 -0800 Message-Id: <20201106032921.600200-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" There is nothing within the translators that ought to be changing the TranslationBlock data, so make it const. This does not actually use the read-only copy of the data structure that exists within the rx region. Signed-off-by: Richard Henderson --- include/hw/core/cpu.h | 3 ++- target/arm/cpu.c | 3 ++- target/avr/cpu.c | 3 ++- target/hppa/cpu.c | 3 ++- target/i386/cpu.c | 3 ++- target/microblaze/cpu.c | 3 ++- target/mips/cpu.c | 3 ++- target/riscv/cpu.c | 3 ++- target/rx/cpu.c | 3 ++- target/sh4/cpu.c | 3 ++- target/sparc/cpu.c | 3 ++- target/tricore/cpu.c | 2 +- 12 files changed, 23 insertions(+), 12 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 3d92c967ff..44c336a96a 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -189,7 +189,8 @@ struct CPUClass { void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list, Error **errp); void (*set_pc)(CPUState *cpu, vaddr value); - void (*synchronize_from_tb)(CPUState *cpu, struct TranslationBlock *tb); + void (*synchronize_from_tb)(CPUState *cpu, + const struct TranslationBlock *tb); bool (*tlb_fill)(CPUState *cpu, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 07492e9f9a..2f9be1c0ee 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -54,7 +54,8 @@ static void arm_cpu_set_pc(CPUState *cs, vaddr value) } } -static void arm_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void arm_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; diff --git a/target/avr/cpu.c b/target/avr/cpu.c index 5d9c4ad5bf..6f3d5a9e4a 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -41,7 +41,8 @@ static bool avr_cpu_has_work(CPUState *cs) && cpu_interrupts_enabled(env); } -static void avr_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void avr_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { AVRCPU *cpu = AVR_CPU(cs); CPUAVRState *env = &cpu->env; diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 71b6aca45d..e28f047d10 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -35,7 +35,8 @@ static void hppa_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.iaoq_b = value + 4; } -static void hppa_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void hppa_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { HPPACPU *cpu = HPPA_CPU(cs); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 0d8606958e..01a8acafe3 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7012,7 +7012,8 @@ static void x86_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.eip = value; } -static void x86_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void x86_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { X86CPU *cpu = X86_CPU(cs); diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 9b2482159d..c8e754cfb1 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -83,7 +83,8 @@ static void mb_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.iflags = 0; } -static void mb_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void mb_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 76d50b00b4..79eee215cf 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -44,7 +44,8 @@ static void mips_cpu_set_pc(CPUState *cs, vaddr value) } } -static void mips_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void mips_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { MIPSCPU *cpu = MIPS_CPU(cs); CPUMIPSState *env = &cpu->env; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 6a0264fc6b..1b2f40de47 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -285,7 +285,8 @@ static void riscv_cpu_set_pc(CPUState *cs, vaddr value) env->pc = value; } -static void riscv_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void riscv_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { RISCVCPU *cpu = RISCV_CPU(cs); CPURISCVState *env = &cpu->env; diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 23ee17a701..2bb14144a7 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -33,7 +33,8 @@ static void rx_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } -static void rx_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void rx_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { RXCPU *cpu = RX_CPU(cs); diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 3c68021c56..1e0f05a15b 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -34,7 +34,8 @@ static void superh_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } -static void superh_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void superh_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { SuperHCPU *cpu = SUPERH_CPU(cs); diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index cf21efd85f..b9241208b1 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -691,7 +691,8 @@ static void sparc_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.npc = value + 4; } -static void sparc_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) +static void sparc_cpu_synchronize_from_tb(CPUState *cs, + const TranslationBlock *tb) { SPARCCPU *cpu = SPARC_CPU(cs); diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 2f2e5b029f..4bff1d4718 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -42,7 +42,7 @@ static void tricore_cpu_set_pc(CPUState *cs, vaddr value) } static void tricore_cpu_synchronize_from_tb(CPUState *cs, - TranslationBlock *tb) + const TranslationBlock *tb) { TriCoreCPU *cpu = TRICORE_CPU(cs); CPUTriCoreState *env = &cpu->env; From patchwork Fri Nov 6 03:28:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885851 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B70C1752 for ; Fri, 6 Nov 2020 03:39:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A5BE420729 for ; Fri, 6 Nov 2020 03:39:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mxqUqH+B" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5BE420729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:58756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasbO-0004cm-CY for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:39:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRe-0004p2-CS for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:46 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:39961) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRc-0006wk-Fb for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:46 -0500 Received: by mail-pg1-x542.google.com with SMTP id x13so2880121pgp.7 for ; Thu, 05 Nov 2020 19:29:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8YnkrBigavL+C33hr6dUiCjy8qumFXs3cayqbgFA/m8=; b=mxqUqH+BWQ26sJiNfIn68XQ3gHoLP/bmGhk6VoFytLpZGEe3sAyB8u/Zx6J4ZV1ynj LjPn8GNr4RB/d7n0H8ry6+D5CqVqemRWhGK3nLWe7nBHPG9pbdsrTZ5Ve++v8TSBMy+4 BZtCdsz4LpE0IaUKTXSL2gF0pydLDQWoLX+UQD41PEE6mn1Gc3AUkIaLTE2DzhaT+f3S LD61+AJLnflvZvMUkFLquPVkOaSFyie65TD5KHHjfjSnWj+U+Xtv69T96G8HbTDp1hSw /9nz5C6YsJSSaG+dTe599kXOc+GEtBSLOUKvfPy0+LpF08sED6OqU0Qv0uoFr6IjFjsL zPEg== 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=8YnkrBigavL+C33hr6dUiCjy8qumFXs3cayqbgFA/m8=; b=aFUGQ84bcWYJyP/Uqqj5jJ7CkjyrVSz2XXFRDtJs3L8jxT8xTNjM9NpjtDyue0B8Hu FlkYGQmfNTISdbKDf7oFxVBhIqsO683VpALfhu9ss0z2I1XMmd0RUD/0R/b6KvrKWGv2 uigL0gjrDQduJk6vK27qO11UnV9fBjxcjQbBeYkweuMd9N5a9FhgTnWwxPufxrzCD/OY THBlY7LkYOVo1qWrqshfj70OR44uaWqfj9CLUDgEdhMh8CZr3SfyiFu7K/FOPWIKhEJG aglkOJ60NB2UW3U4+UQ5JW+Sv3w5F3YHGHv/6oHpEVJJonZYrZ+29ZdSDAsGrn9KUsD6 KeAw== X-Gm-Message-State: AOAM5319DyFYkDmBs7namTGgEzkbXiEsjy+KrtzTH8/eoIEcpXMLinDX 9dyysiIu4ZdvtisGTkwoNNM2rAAcBYVjZw== X-Google-Smtp-Source: ABdhPJxDbA4eEhreLH+Mv0CLiM6PMMCAgVtMdkHmAahjMK7Dz/3/BkQ3niqZY96afg+zajPPyypwyw== X-Received: by 2002:a63:4825:: with SMTP id v37mr5222841pga.256.1604633379990; Thu, 05 Nov 2020 19:29:39 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 13/41] tcg: Use Error with alloc_code_gen_buffer Date: Thu, 5 Nov 2020 19:28:53 -0800 Message-Id: <20201106032921.600200-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::542; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x542.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Report better error messages than just "could not allocate". Let alloc_code_gen_buffer set ctx->code_gen_buffer_size and ctx->code_gen_buffer, and simply return bool. Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 60 ++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 7b85ddacd2..2824b3e387 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -59,6 +59,7 @@ #include "sysemu/cpus.h" #include "sysemu/cpu-timers.h" #include "sysemu/tcg.h" +#include "qapi/error.h" /* #define DEBUG_TB_INVALIDATE */ /* #define DEBUG_TB_FLUSH */ @@ -963,7 +964,7 @@ static void page_lock_pair(PageDesc **ret_p1, tb_page_addr_t phys1, (DEFAULT_CODE_GEN_BUFFER_SIZE_1 < MAX_CODE_GEN_BUFFER_SIZE \ ? DEFAULT_CODE_GEN_BUFFER_SIZE_1 : MAX_CODE_GEN_BUFFER_SIZE) -static inline size_t size_code_gen_buffer(size_t tb_size) +static size_t size_code_gen_buffer(size_t tb_size) { /* Size the buffer. */ if (tb_size == 0) { @@ -1014,7 +1015,7 @@ static inline void *split_cross_256mb(void *buf1, size_t size1) static uint8_t static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE] __attribute__((aligned(CODE_GEN_ALIGN))); -static inline void *alloc_code_gen_buffer(void) +static bool alloc_code_gen_buffer(size_t tb_size, Error **errp) { void *buf = static_code_gen_buffer; void *end = static_code_gen_buffer + sizeof(static_code_gen_buffer); @@ -1027,9 +1028,8 @@ static inline void *alloc_code_gen_buffer(void) size = end - buf; /* Honor a command-line option limiting the size of the buffer. */ - if (size > tcg_ctx->code_gen_buffer_size) { - size = QEMU_ALIGN_DOWN(tcg_ctx->code_gen_buffer_size, - qemu_real_host_page_size); + if (size > tb_size) { + size = QEMU_ALIGN_DOWN(tb_size, qemu_real_host_page_size); } tcg_ctx->code_gen_buffer_size = size; @@ -1041,31 +1041,43 @@ static inline void *alloc_code_gen_buffer(void) #endif if (qemu_mprotect_rwx(buf, size)) { - abort(); + error_setg_errno(errp, errno, "mprotect of jit buffer"); + return false; } qemu_madvise(buf, size, QEMU_MADV_HUGEPAGE); - return buf; + tcg_ctx->code_gen_buffer = buf; + return true; } #elif defined(_WIN32) -static inline void *alloc_code_gen_buffer(void) +static bool alloc_code_gen_buffer(size_t size, Error **errp) { - size_t size = tcg_ctx->code_gen_buffer_size; - return VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, - PAGE_EXECUTE_READWRITE); + void *buf = VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, + PAGE_EXECUTE_READWRITE); + if (buf == NULL) { + error_setg_win32(errp, GetLastError(), + "allocate %zu bytes for jit buffer", size); + return false; + } + + tcg_ctx->code_gen_buffer = buf; + tcg_ctx->code_gen_buffer_size = size; + return true; } #else -static inline void *alloc_code_gen_buffer(void) +static bool alloc_code_gen_buffer(size_t size, Error **errp) { int prot = PROT_WRITE | PROT_READ | PROT_EXEC; int flags = MAP_PRIVATE | MAP_ANONYMOUS; - size_t size = tcg_ctx->code_gen_buffer_size; void *buf; buf = mmap(NULL, size, prot, flags, -1, 0); if (buf == MAP_FAILED) { - return NULL; + error_setg_errno(errp, errno, + "allocate %zu bytes for jit buffer", size); + return false; } + tcg_ctx->code_gen_buffer_size = size; #ifdef __mips__ if (cross_256mb(buf, size)) { @@ -1104,20 +1116,11 @@ static inline void *alloc_code_gen_buffer(void) /* Request large pages for the buffer. */ qemu_madvise(buf, size, QEMU_MADV_HUGEPAGE); - return buf; + tcg_ctx->code_gen_buffer = buf; + return true; } #endif /* USE_STATIC_CODE_GEN_BUFFER, WIN32, POSIX */ -static inline void code_gen_alloc(size_t tb_size) -{ - tcg_ctx->code_gen_buffer_size = size_code_gen_buffer(tb_size); - tcg_ctx->code_gen_buffer = alloc_code_gen_buffer(); - if (tcg_ctx->code_gen_buffer == NULL) { - fprintf(stderr, "Could not allocate dynamic translator buffer\n"); - exit(1); - } -} - static bool tb_cmp(const void *ap, const void *bp) { const TranslationBlock *a = ap; @@ -1144,11 +1147,16 @@ static void tb_htable_init(void) size. */ void tcg_exec_init(unsigned long tb_size) { + bool ok; + tcg_allowed = true; cpu_gen_init(); page_init(); tb_htable_init(); - code_gen_alloc(tb_size); + + ok = alloc_code_gen_buffer(size_code_gen_buffer(tb_size), &error_fatal); + assert(ok); + #if defined(CONFIG_SOFTMMU) /* There's no guest base to take into account, so go ahead and initialize the prologue now. */ From patchwork Fri Nov 6 03:28:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885829 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C2711130 for ; Fri, 6 Nov 2020 03:35:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EC1B920729 for ; Fri, 6 Nov 2020 03:35:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="FeoFaiUZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC1B920729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:38374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasXQ-0004lr-UF for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:35:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRe-0004qJ-St for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:46 -0500 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:34752) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRc-0006wq-GG for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:46 -0500 Received: by mail-pf1-x441.google.com with SMTP id o129so63187pfb.1 for ; Thu, 05 Nov 2020 19:29:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5S5FVYwmKp9iGdEx0YkNjwJAvfyyQ5CRcf+gaFezy/Y=; b=FeoFaiUZMXk40Cc0c6BmXWGCm0RpP42O4v/Fb/x+gH+Gfmdv5CkeVL7js5F2KtD7iv XjA4o17kGDsBH1RBeP4sUk3T+2+hCD59NCQ95/1Y/chbpTv1XQ3O2Z3pZOaDEf5JdXj5 PapdRYzXyfdeCdZbqhV8BbSFgwwVTsvGwTomK2qTBkAbLbs1t6MgYms501qTtVxgq9Te 37EDgPD/I8sAF5Ni9cuRiweBw45EhdSoqRQUWdB+KbsHMt17REGL9Tt7yf/+/IOej4mA VlBi7V4yaVIqu1tsFX2KGCxmzKz0ul/cTfk2R/Valgxtbm2xgtqpUc+rm2w4DPvDR7nb KtRw== 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=5S5FVYwmKp9iGdEx0YkNjwJAvfyyQ5CRcf+gaFezy/Y=; b=Ciw1GuHDAQ7Q3uxEDh3LWCWMx5x+DZ5Gc0fpTPQQqK4w+A53tQrGVnxADnbKK3WR98 QpMLJrZQWJl3QGjRJxKRUaerYp4ZHjFogoNY/+XJzDWHiYva8zHtZyugQXNbYIHlhQWY ccb5vwhC7iYIfTpjXsenKCEW7FMjnBmMJ3Vrv08sQw70aP7rDSrehbNRg68IH7FUpvyl ZR3hc3StHgll+4WYSKaxjUTUkkNUzddI/wufe+uAQ8ZknKMDxUdDHLCDKqQ+p4Ey+SrQ rHIDpkA/SZZDykGUeAg2i9zQ4tXc91+9hDAjGJLIcHz54S03gJYWiUkJla4CIiooeX7c +whg== X-Gm-Message-State: AOAM532X7KVvaeYwO+ybaHv0gGuDqPJsFMfPw8BnDUnqToVNUN5brIzc fYvDZXreXSuRtPVzhzxAc0DNlQV+jtqkgw== X-Google-Smtp-Source: ABdhPJxng/MS4TeF2Q3bO6gJpp2n8oJutCpAcAZrFPpqxuRcPmo9H5MEaiNSY4206OBGWG+Ob0bGYA== X-Received: by 2002:a17:90b:3314:: with SMTP id kf20mr178672pjb.156.1604633381341; Thu, 05 Nov 2020 19:29:41 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 14/41] tcg: Add --accel tcg,split-wx property Date: Thu, 5 Nov 2020 19:28:54 -0800 Message-Id: <20201106032921.600200-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Plumb the value through to alloc_code_gen_buffer. This is not supported by any os or tcg backend, so for now enabling it will result in an error. Signed-off-by: Richard Henderson --- include/sysemu/tcg.h | 3 ++- tcg/aarch64/tcg-target.h | 1 + tcg/arm/tcg-target.h | 1 + tcg/i386/tcg-target.h | 1 + tcg/mips/tcg-target.h | 1 + tcg/ppc/tcg-target.h | 1 + tcg/riscv/tcg-target.h | 1 + tcg/s390/tcg-target.h | 1 + tcg/sparc/tcg-target.h | 1 + tcg/tci/tcg-target.h | 1 + accel/tcg/tcg-all.c | 26 +++++++++++++++++++++++++- accel/tcg/translate-all.c | 35 +++++++++++++++++++++++++++-------- bsd-user/main.c | 2 +- linux-user/main.c | 2 +- 14 files changed, 65 insertions(+), 12 deletions(-) diff --git a/include/sysemu/tcg.h b/include/sysemu/tcg.h index d9d3ca8559..00349fb18a 100644 --- a/include/sysemu/tcg.h +++ b/include/sysemu/tcg.h @@ -8,7 +8,8 @@ #ifndef SYSEMU_TCG_H #define SYSEMU_TCG_H -void tcg_exec_init(unsigned long tb_size); +void tcg_exec_init(unsigned long tb_size, int splitwx); + #ifdef CONFIG_TCG extern bool tcg_allowed; #define tcg_enabled() (tcg_allowed) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 91313d93be..fa64058d43 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -164,5 +164,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 #endif /* AARCH64_TCG_TARGET_H */ diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index b21a2fb6a1..e355d6a4b2 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -150,5 +150,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 #endif diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index f52ba0ffec..1b9d41bd56 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -236,5 +236,6 @@ static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 #endif diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index cd548dacec..d231522dc9 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -206,6 +206,7 @@ extern bool use_mips32r2_instructions; #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 +#define TCG_TARGET_SUPPORT_MIRROR 0 /* Flush the dcache at RW, and the icache at RX, as necessary. */ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 8f3e4c924a..78d6a5e96f 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -185,5 +185,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 #endif diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index e03fd17427..3c2e8305b0 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -179,5 +179,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_POOL_LABELS #define TCG_TARGET_HAS_MEMORY_BSWAP 0 +#define TCG_TARGET_SUPPORT_MIRROR 0 #endif diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h index c5a749e425..8324197127 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -163,5 +163,6 @@ static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 #endif diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h index 87e2be61e6..517840705f 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -181,5 +181,6 @@ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_POOL_LABELS +#define TCG_TARGET_SUPPORT_MIRROR 0 #endif diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index a19a6b06e5..3653fef947 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -200,6 +200,7 @@ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 +#define TCG_TARGET_SUPPORT_MIRROR 0 static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, uintptr_t jmp_rw, uintptr_t addr) diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index fa1208158f..5f07ab09a9 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -38,6 +38,7 @@ struct TCGState { AccelState parent_obj; bool mttcg_enabled; + int splitwx_enabled; unsigned long tb_size; }; typedef struct TCGState TCGState; @@ -94,6 +95,13 @@ static void tcg_accel_instance_init(Object *obj) TCGState *s = TCG_STATE(obj); s->mttcg_enabled = default_mttcg_enabled(); + + /* If debugging enabled, default "auto on", otherwise off. */ +#ifdef CONFIG_DEBUG_TCG + s->splitwx_enabled = -1; +#else + s->splitwx_enabled = 0; +#endif } bool mttcg_enabled; @@ -102,7 +110,7 @@ static int tcg_init(MachineState *ms) { TCGState *s = TCG_STATE(current_accel()); - tcg_exec_init(s->tb_size * 1024 * 1024); + tcg_exec_init(s->tb_size * 1024 * 1024, s->splitwx_enabled); mttcg_enabled = s->mttcg_enabled; cpus_register_accel(&tcg_cpus); @@ -168,6 +176,18 @@ static void tcg_set_tb_size(Object *obj, Visitor *v, s->tb_size = value; } +static bool tcg_get_splitwx(Object *obj, Error **errp) +{ + TCGState *s = TCG_STATE(obj); + return s->splitwx_enabled; +} + +static void tcg_set_splitwx(Object *obj, bool value, Error **errp) +{ + TCGState *s = TCG_STATE(obj); + s->splitwx_enabled = value; +} + static void tcg_accel_class_init(ObjectClass *oc, void *data) { AccelClass *ac = ACCEL_CLASS(oc); @@ -185,6 +205,10 @@ static void tcg_accel_class_init(ObjectClass *oc, void *data) object_class_property_set_description(oc, "tb-size", "TCG translation block cache size"); + object_class_property_add_bool(oc, "split-wx", + tcg_get_splitwx, tcg_set_splitwx); + object_class_property_set_description(oc, "split-wx", + "Map jit pages into separate RW and RX regions"); } static const TypeInfo tcg_accel_type = { diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 2824b3e387..a29cb4a42e 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1015,13 +1015,19 @@ static inline void *split_cross_256mb(void *buf1, size_t size1) static uint8_t static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE] __attribute__((aligned(CODE_GEN_ALIGN))); -static bool alloc_code_gen_buffer(size_t tb_size, Error **errp) +static bool alloc_code_gen_buffer(size_t tb_size, int splitwx, Error **errp) { - void *buf = static_code_gen_buffer; - void *end = static_code_gen_buffer + sizeof(static_code_gen_buffer); + void *buf, *end; size_t size; + if (splitwx > 0) { + error_setg(errp, "jit split-wx not supported"); + return false; + } + /* page-align the beginning and end of the buffer */ + buf = static_code_gen_buffer; + end = static_code_gen_buffer + sizeof(static_code_gen_buffer); buf = QEMU_ALIGN_PTR_UP(buf, qemu_real_host_page_size); end = QEMU_ALIGN_PTR_DOWN(end, qemu_real_host_page_size); @@ -1050,9 +1056,16 @@ static bool alloc_code_gen_buffer(size_t tb_size, Error **errp) return true; } #elif defined(_WIN32) -static bool alloc_code_gen_buffer(size_t size, Error **errp) +static bool alloc_code_gen_buffer(size_t size, int splitwx, Error **errp) { - void *buf = VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, + void *buf; + + if (splitwx > 0) { + error_setg(errp, "jit split-wx not supported"); + return false; + } + + buf = VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (buf == NULL) { error_setg_win32(errp, GetLastError(), @@ -1065,12 +1078,17 @@ static bool alloc_code_gen_buffer(size_t size, Error **errp) return true; } #else -static bool alloc_code_gen_buffer(size_t size, Error **errp) +static bool alloc_code_gen_buffer(size_t size, int splitwx, Error **errp) { int prot = PROT_WRITE | PROT_READ | PROT_EXEC; int flags = MAP_PRIVATE | MAP_ANONYMOUS; void *buf; + if (splitwx > 0) { + error_setg(errp, "jit split-wx not supported"); + return false; + } + buf = mmap(NULL, size, prot, flags, -1, 0); if (buf == MAP_FAILED) { error_setg_errno(errp, errno, @@ -1145,7 +1163,7 @@ static void tb_htable_init(void) /* Must be called before using the QEMU cpus. 'tb_size' is the size (in bytes) allocated to the translation buffer. Zero means default size. */ -void tcg_exec_init(unsigned long tb_size) +void tcg_exec_init(unsigned long tb_size, int splitwx) { bool ok; @@ -1154,7 +1172,8 @@ void tcg_exec_init(unsigned long tb_size) page_init(); tb_htable_init(); - ok = alloc_code_gen_buffer(size_code_gen_buffer(tb_size), &error_fatal); + ok = alloc_code_gen_buffer(size_code_gen_buffer(tb_size), + splitwx, &error_fatal); assert(ok); #if defined(CONFIG_SOFTMMU) diff --git a/bsd-user/main.c b/bsd-user/main.c index ac40d79bfa..ffd4888a26 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -910,7 +910,7 @@ int main(int argc, char **argv) } /* init tcg before creating CPUs and to get qemu_host_page_size */ - tcg_exec_init(0); + tcg_exec_init(0, false); cpu_type = parse_cpu_option(cpu_model); cpu = cpu_create(cpu_type); diff --git a/linux-user/main.c b/linux-user/main.c index 75c9785157..3856b2611d 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -705,7 +705,7 @@ int main(int argc, char **argv, char **envp) cpu_type = parse_cpu_option(cpu_model); /* init tcg before creating CPUs and to get qemu_host_page_size */ - tcg_exec_init(0); + tcg_exec_init(0, false); cpu = cpu_create(cpu_type); env = cpu->env_ptr; From patchwork Fri Nov 6 03:28:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885827 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E9B061130 for ; Fri, 6 Nov 2020 03:35:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7DEC720729 for ; Fri, 6 Nov 2020 03:35:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TSmWNu5f" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7DEC720729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:38118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasXO-0004fc-Eo for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:35:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRf-0004sv-R1 for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:47 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:38999) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRc-0006x4-Jo for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:47 -0500 Received: by mail-pf1-x442.google.com with SMTP id z3so45447pfz.6 for ; Thu, 05 Nov 2020 19:29:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QxiqvQ209wXHxoJuZyW/ayX9Rmszqy3dKezpaxev5Pc=; b=TSmWNu5fGLyzHJJu9w08BvM4mojzlhQfiimiZuHvYITzrSh/8++k6IrCnS9ilUMPzR 99N8C1HP2APDXp/TmDXA1ecVQIK/SeVOoaYEm6wY6FjjY4IJ9DSCDzYlO/D8XHgM8QyH EfJWGOKMhfp/sSr0cmI9RGC6hojUWEOqhW3T8alRR4FVNdC9oVCMEhFhJj3DgX2cqs+O GSfSW06TExb7BOrTlO3bdVJ0WaRhSqvxJ8NvaAP17XfD3DcSRux+XgGIuIXq7HNxPqsz cR9+XNILqRNbt2IaTOR+SsWIGAJsGOH1QyxeNJCh5xE+OJfKRvqLGU35d6AZw+JwjLkv Jp8A== 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=QxiqvQ209wXHxoJuZyW/ayX9Rmszqy3dKezpaxev5Pc=; b=QeRmcBi3Y5BPgZACPv5yGb+w4DmVHbTOmPYgR72dqxy1vTJO7Uo2Hr2S6oWJh2csTy gEOqvKYJgX//rC1rbP80HQZGVkxj8prI29syju9rRJghV2vJjloHGJJBHUK0SDFOw8ow r0XZZrV5KMiCDagRmoRKfc/esVLBLrDiLIDaEKD2lfC1cgP3tun6OPFEZBpFJfSkqUiI sd9gXan2O5P38mAx0kMkBmHZrPuD6gs60Y5APhHzxxZOUlbl3Z+fPshNFgQ9KvNIchyC 6eumxB6AqvC4POMGwEIrJ6Gatdr1zIUw8L0jRJe13quUk6HWulhcgk6jNMrdIYcjBN0Q le4g== X-Gm-Message-State: AOAM530hnICOiYwksflDm6DVWir7TYAXAsCXw/d0AduT6K7pzeUECnHv DILuiNRAsHNmwdt00gfRYcfj8OZP0llgJA== X-Google-Smtp-Source: ABdhPJwC8nKRQBeSgXlFT1QLMFd4F4bnVLsuvrmNB2FMvsoZBEedc+GLhSsEPANltyKCupua3WNESQ== X-Received: by 2002:a63:134d:: with SMTP id 13mr5293337pgt.370.1604633382549; Thu, 05 Nov 2020 19:29:42 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 15/41] accel/tcg: Support split-wx for linux with memfd Date: Thu, 5 Nov 2020 19:28:55 -0800 Message-Id: <20201106032921.600200-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::442; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" We cannot use a real temp file, because we would need to find a filesystem that does not have noexec enabled. However, a memfd is not associated with any filesystem. Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 84 +++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 8 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index a29cb4a42e..1931e65365 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1078,17 +1078,11 @@ static bool alloc_code_gen_buffer(size_t size, int splitwx, Error **errp) return true; } #else -static bool alloc_code_gen_buffer(size_t size, int splitwx, Error **errp) +static bool alloc_code_gen_buffer_anon(size_t size, int prot, + int flags, Error **errp) { - int prot = PROT_WRITE | PROT_READ | PROT_EXEC; - int flags = MAP_PRIVATE | MAP_ANONYMOUS; void *buf; - if (splitwx > 0) { - error_setg(errp, "jit split-wx not supported"); - return false; - } - buf = mmap(NULL, size, prot, flags, -1, 0); if (buf == MAP_FAILED) { error_setg_errno(errp, errno, @@ -1137,6 +1131,80 @@ static bool alloc_code_gen_buffer(size_t size, int splitwx, Error **errp) tcg_ctx->code_gen_buffer = buf; return true; } + +#ifdef CONFIG_POSIX +#include "qemu/memfd.h" + +static bool alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp) +{ + void *buf_rw, *buf_rx; + int fd = -1; + + buf_rw = qemu_memfd_alloc("tcg-jit", size, 0, &fd, errp); + if (buf_rw == NULL) { + return false; + } + + buf_rx = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_SHARED, fd, 0); + if (buf_rx == MAP_FAILED) { + error_setg_errno(errp, errno, + "failed to map shared memory for execute"); + munmap(buf_rw, size); + close(fd); + return false; + } + close(fd); + + tcg_ctx->code_gen_buffer = buf_rw; + tcg_ctx->code_gen_buffer_size = size; + tcg_splitwx_diff = buf_rx - buf_rw; + + /* Request large pages for the buffer and the splitwx. */ + qemu_madvise(buf_rw, size, QEMU_MADV_HUGEPAGE); + qemu_madvise(buf_rx, size, QEMU_MADV_HUGEPAGE); + return true; +} +#endif /* CONFIG_POSIX */ + +static bool alloc_code_gen_buffer_splitwx(size_t size, Error **errp) +{ + if (TCG_TARGET_SUPPORT_MIRROR) { +#ifdef CONFIG_POSIX + return alloc_code_gen_buffer_splitwx_memfd(size, errp); +#endif + } + error_setg(errp, "jit split-wx not supported"); + return false; +} + +static bool alloc_code_gen_buffer(size_t size, int splitwx, Error **errp) +{ + ERRP_GUARD(); + int prot, flags; + + if (splitwx) { + if (alloc_code_gen_buffer_splitwx(size, errp)) { + return true; + } + /* + * If splitwx force-on (1), fail; + * if splitwx default-on (-1), fall through to splitwx off. + */ + if (splitwx > 0) { + return false; + } + error_free_or_abort(errp); + } + + prot = PROT_READ | PROT_WRITE | PROT_EXEC; + flags = MAP_PRIVATE | MAP_ANONYMOUS; +#ifdef CONFIG_TCG_INTERPRETER + /* The tcg interpreter does not need execute permission. */ + prot = PROT_READ | PROT_WRITE; +#endif + + return alloc_code_gen_buffer_anon(size, prot, flags, errp); +} #endif /* USE_STATIC_CODE_GEN_BUFFER, WIN32, POSIX */ static bool tb_cmp(const void *ap, const void *bp) From patchwork Fri Nov 6 03:28:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885859 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 652D8921 for ; Fri, 6 Nov 2020 03:41:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 76E1820735 for ; Fri, 6 Nov 2020 03:41:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="L7gUHdwg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 76E1820735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasdK-000700-1A for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:41:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRg-0004tb-27 for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:48 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:44939) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRd-0006xO-Lu for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:47 -0500 Received: by mail-pf1-x442.google.com with SMTP id y7so28322pfq.11 for ; Thu, 05 Nov 2020 19:29:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lq4IkwTkjjjV6cEfjyzqrZr7JH5rLAW05aEI0Sl+9Jw=; b=L7gUHdwguNP4jAPxpnFrHEN0Zm+hJa/7DI9lwXNVrV/UmOQEC6wB/jqvRCwuELzI8/ rRARviqfWrnGWfUwAbBwHQDmNpUYk/j0mWI8rNByReuPcoqFkA8ci4GLWA9e4Zwu1U5z N1mEVstlRexLy3mhvFVjB3h88w83IB0YnCOlDD0qTtMPDk5xarHdVmbpOqGPke7sjeQg L1hUfU104zpzpTcV1FYrtaJDaprf9EYglOVaKubllZL5MFyrV4XBuSMfhwNk4K/KWVVU cVNtdvb+3UXXspiPO1gdMw/y1NCvbl1M5VTw85Vl2sxsQZYAL1vbHq2xbRLVeT+dnaIm Tt4Q== 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=lq4IkwTkjjjV6cEfjyzqrZr7JH5rLAW05aEI0Sl+9Jw=; b=pt2IjQdEci1BrLPW4r4alENKxW5Kk4Ja5TEVLys0jWl8awLvskL7A9EVUugc7lR1ou l6smo0It/5HaKXrMjv08bx/wA9BWlYAaD1luTW6KARyZ0V7dcxGSlzjPfWM9fag2FWil sRCFH3cahelxnc7izENLtLbiDKt7LYEKzHI+mHwQYLGdqO65yT2W2sfpWXRtwngriG/9 QijGgD1HZzRkSpFWLe1IOjM4rmDHLfoQ9LhHhH9BAKiSwuq73VC6ETtD8sDmbLAMeb2t v4Hwc7mLuFoJDtQ1ghfHc6fNQ9433Nm73k4PCuZJPCTjvaGxTW29MMHSslNkaLPZYner RtHQ== X-Gm-Message-State: AOAM532lHft/XKnHX/8+S6NXoW7tR8Pu21hqrbVsman/o08BUTsE3MgY REye0FSZ0p3MjMPR3/KEtXFhHVezLEuUvQ== X-Google-Smtp-Source: ABdhPJz00PzHzCtmUoiVhdR1vXp3DQwHjq94TIr0/r+y5W5hTDSziRxyOTECinXCM7jX0odc3q2Mkw== X-Received: by 2002:aa7:96ce:0:b029:155:8c02:e74a with SMTP id h14-20020aa796ce0000b02901558c02e74amr722pfq.32.1604633384041; Thu, 05 Nov 2020 19:29:44 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 16/41] accel/tcg: Support split-wx for darwin/iOS with vm_remap Date: Thu, 5 Nov 2020 19:28:56 -0800 Message-Id: <20201106032921.600200-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::442; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Cribbed from code posted by Joelle van Dyne , and rearranged to a cleaner structure. Completely untested. Signed-off-by: Richard Henderson Reviewed-by: Joelle van Dyne --- accel/tcg/translate-all.c | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 1931e65365..17df6c94fa 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1166,9 +1166,71 @@ static bool alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp) } #endif /* CONFIG_POSIX */ +#ifdef CONFIG_DARWIN +#include + +extern kern_return_t mach_vm_remap(vm_map_t target_task, + mach_vm_address_t *target_address, + mach_vm_size_t size, + mach_vm_offset_t mask, + int flags, + vm_map_t src_task, + mach_vm_address_t src_address, + boolean_t copy, + vm_prot_t *cur_protection, + vm_prot_t *max_protection, + vm_inherit_t inheritance); + +static bool alloc_code_gen_buffer_splitwx_vmremap(size_t size, Error **errp) +{ + kern_return_t ret; + mach_vm_address_t buf_rw, buf_rx; + vm_prot_t cur_prot, max_prot; + + /* Map the read-write portion via normal anon memory. */ + if (!alloc_code_gen_buffer_anon(size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, errp)) { + return false; + } + + buf_rw = (mach_vm_address_t)tcg_ctx->code_gen_buffer; + buf_rx = 0; + ret = mach_vm_remap(mach_task_self(), + &buf_rx, + size, + 0, + VM_FLAGS_ANYWHERE, + mach_task_self(), + buf_rw, + false, + &cur_prot, + &max_prot, + VM_INHERIT_NONE); + if (ret != KERN_SUCCESS) { + /* TODO: Convert "ret" to a human readable error message. */ + error_setg(errp, "vm_remap for jit splitwx failed"); + munmap((void *)buf_rw, size); + return false; + } + + if (mprotect((void *)buf_rx, size, PROT_READ | PROT_EXEC) != 0) { + error_setg_errno(errp, errno, "mprotect for jit splitwx"); + munmap((void *)buf_rx, size); + munmap((void *)buf_rw, size); + return false; + } + + tcg_splitwx_diff = buf_rx - buf_rw; + return true; +} +#endif /* CONFIG_DARWIN */ + static bool alloc_code_gen_buffer_splitwx(size_t size, Error **errp) { if (TCG_TARGET_SUPPORT_MIRROR) { +#ifdef CONFIG_DARWIN + return alloc_code_gen_buffer_splitwx_vmremap(size, errp); +#endif #ifdef CONFIG_POSIX return alloc_code_gen_buffer_splitwx_memfd(size, errp); #endif @@ -1201,6 +1263,9 @@ static bool alloc_code_gen_buffer(size_t size, int splitwx, Error **errp) #ifdef CONFIG_TCG_INTERPRETER /* The tcg interpreter does not need execute permission. */ prot = PROT_READ | PROT_WRITE; +#elif defined(CONFIG_DARWIN) + /* Applicable to both iOS and macOS (Apple Silicon). */ + flags |= MAP_JIT; #endif return alloc_code_gen_buffer_anon(size, prot, flags, errp); From patchwork Fri Nov 6 03:28:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885837 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 82B4A1130 for ; Fri, 6 Nov 2020 03:37:49 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2826E20729 for ; Fri, 6 Nov 2020 03:37:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Nh1h5Cqr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2826E20729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasZQ-00085O-3w for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:37:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRg-0004ve-UZ for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:48 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:38583) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRe-0006xk-Te for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:48 -0500 Received: by mail-pl1-x635.google.com with SMTP id f21so26185plr.5 for ; Thu, 05 Nov 2020 19:29:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PE5zDJYupwBF6LFLJEA3Vgnp30HPDgVW1boJkF7byFo=; b=Nh1h5CqrdiO/dUF3trMOKu+s2Lhzmdg6eOQ5Sr8RJSinrg+WoGQ3uDI3T1EIudNskN qEEJ7BW/DCLDsU86p3ZZ7niofar2Kl6Fb1sAfTVOxn+00HUj5KiGntrs/Ixxipf48Gf5 YWY3pJYNdb8EzfWNCmvO+OOnr2yVOcW5gPVhQD8pmGxgK0L8mCj2jaRfj9RhtM4eI3fG 8WS1o51PB8aXd6QvasDVwqPbN6uM4aCf8mW0+Ay4irjPx7sUym+UdiRWYJEiTb58UyQa 3UUpMta4bhmaSUm/YSexHmzq0bN3o6VsAA7vtzeZePfwAtwGJlSqrwPobkIS0hEXZtJn rOKQ== 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=PE5zDJYupwBF6LFLJEA3Vgnp30HPDgVW1boJkF7byFo=; b=RAdm6C9Xw5sK4VyGvYXNUROdvyYiMRqBifU7lm2y6EV4TzN1RCx+n5+La/vsvUJeIt j15zjZA7pXDfcotibWairnWulMtww5cbkRarhFA7edXrJA5KRUePOu/ycErOH8fF8oHk NnUZl0LH9iDCXNInhLsMswjRPjSYX8ymC1oHwS//rVeuAWxzqd14MJuOE9LKR1QSXbIw QvEVYwx7ulb4EM8WMz5vFo+DwDMz0aYCqNlcZj9IX/r1r6Y1UbbMBGDecdgYE2Gs2k7W t6TMrNjBNFFVtrxb90RCn0Ud9gV443FnQNlrO0NnZhBjc4gI8Usye4n71wEneUAvq02Q qufQ== X-Gm-Message-State: AOAM532Pd56JAB2oueChah3VgSnHyvEOWkI3zDxgy2L1ORXNh778eM3p RhvwYWEeu/G93mzSd/Oi5vRp8WSnMQ7dRA== X-Google-Smtp-Source: ABdhPJwkkxUyUcAF9Ehvx4S6RNVRSRvbLtrgf8R51y8H8IVfQlWPeziQwU68kLCc317mDeh8H5jxoQ== X-Received: by 2002:a17:902:7c14:b029:d4:d894:7eed with SMTP id x20-20020a1709027c14b02900d4d8947eedmr7851pll.81.1604633385145; Thu, 05 Nov 2020 19:29:45 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 17/41] tcg: Return the TB pointer from the rx region from exit_tb Date: Thu, 5 Nov 2020 19:28:57 -0800 Message-Id: <20201106032921.600200-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This produces a small pc-relative displacement within the generated code to the TB structure that preceeds it. Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 35 ++++++++++++++++++++++------------- tcg/tcg-op.c | 13 ++++++++++++- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 272d596e0c..8df0a1782e 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -144,12 +144,13 @@ static void init_delay_params(SyncClocks *sc, const CPUState *cpu) #endif /* CONFIG USER ONLY */ /* Execute a TB, and fix up the CPU state afterwards if necessary */ -static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) +static inline TranslationBlock *cpu_tb_exec(CPUState *cpu, + TranslationBlock *itb, + int *tb_exit) { CPUArchState *env = cpu->env_ptr; uintptr_t ret; TranslationBlock *last_tb; - int tb_exit; const void *tb_ptr = itb->tc.ptr; qemu_log_mask_and_addr(CPU_LOG_EXEC, itb->pc, @@ -177,11 +178,20 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) ret = tcg_qemu_tb_exec(env, tb_ptr); cpu->can_do_io = 1; - last_tb = (TranslationBlock *)(ret & ~TB_EXIT_MASK); - tb_exit = ret & TB_EXIT_MASK; - trace_exec_tb_exit(last_tb, tb_exit); + /* + * TODO: Delay swapping back to the read-write region of the TB + * until we actually need to modify the TB. The read-only copy, + * coming from the rx region, shares the same host TLB entry as + * the code that executed the exit_tb opcode that arrived here. + * If we insist on touching both the RX and the RW pages, we + * double the host TLB pressure. + */ + last_tb = tcg_splitwx_to_rw((void *)(ret & ~TB_EXIT_MASK)); + *tb_exit = ret & TB_EXIT_MASK; - if (tb_exit > TB_EXIT_IDX1) { + trace_exec_tb_exit(last_tb, *tb_exit); + + if (*tb_exit > TB_EXIT_IDX1) { /* We didn't start executing this TB (eg because the instruction * counter hit zero); we must restore the guest PC to the address * of the start of the TB. @@ -199,7 +209,7 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) cc->set_pc(cpu, last_tb->pc); } } - return ret; + return last_tb; } #ifndef CONFIG_USER_ONLY @@ -210,6 +220,7 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles, { TranslationBlock *tb; uint32_t cflags = curr_cflags() | CF_NOCACHE; + int tb_exit; if (ignore_icount) { cflags &= ~CF_USE_ICOUNT; @@ -227,7 +238,7 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles, /* execute the generated code */ trace_exec_tb_nocache(tb, tb->pc); - cpu_tb_exec(cpu, tb); + cpu_tb_exec(cpu, tb, &tb_exit); mmap_lock(); tb_phys_invalidate(tb, -1); @@ -244,6 +255,7 @@ void cpu_exec_step_atomic(CPUState *cpu) uint32_t flags; uint32_t cflags = 1; uint32_t cf_mask = cflags & CF_HASH_MASK; + int tb_exit; if (sigsetjmp(cpu->jmp_env, 0) == 0) { start_exclusive(); @@ -260,7 +272,7 @@ void cpu_exec_step_atomic(CPUState *cpu) cc->cpu_exec_enter(cpu); /* execute the generated code */ trace_exec_tb(tb, pc); - cpu_tb_exec(cpu, tb); + cpu_tb_exec(cpu, tb, &tb_exit); cc->cpu_exec_exit(cpu); } else { /* @@ -653,13 +665,10 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, TranslationBlock **last_tb, int *tb_exit) { - uintptr_t ret; int32_t insns_left; trace_exec_tb(tb, tb->pc); - ret = cpu_tb_exec(cpu, tb); - tb = (TranslationBlock *)(ret & ~TB_EXIT_MASK); - *tb_exit = ret & TB_EXIT_MASK; + tb = cpu_tb_exec(cpu, tb, tb_exit); if (*tb_exit != TB_EXIT_REQUESTED) { *last_tb = tb; return; diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index e3dc0cb4cb..56bb8db040 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2666,7 +2666,18 @@ void tcg_gen_extr32_i64(TCGv_i64 lo, TCGv_i64 hi, TCGv_i64 arg) void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx) { - uintptr_t val = (uintptr_t)tb + idx; + /* + * Let the jit code return the read-only version of the + * TranslationBlock, so that we minimize the pc-relative + * distance of the address of the exit_tb code to TB. + * This will improve utilization of pc-relative address loads. + * + * TODO: Move this to translator_loop, so that all const + * TranslationBlock pointers refer to read-only memory. + * This requires coordination with targets that do not use + * the translator_loop. + */ + uintptr_t val = (uintptr_t)tcg_splitwx_to_rx((void *)tb) + idx; if (tb == NULL) { tcg_debug_assert(idx == 0); From patchwork Fri Nov 6 03:28:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885861 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 070A71130 for ; Fri, 6 Nov 2020 03:42:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A3FE82072E for ; Fri, 6 Nov 2020 03:42:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yfW98G6T" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A3FE82072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:39026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaseM-0008Cp-FF for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:42:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRi-0004ym-0E for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:50 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:41678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRg-0006yH-3O for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:49 -0500 Received: by mail-pl1-x62a.google.com with SMTP id w11so20453pll.8 for ; Thu, 05 Nov 2020 19:29:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2fcZxHMc1N8IMdttXnckxhY78ayrgXYsVfY7nu4z0HQ=; b=yfW98G6TjHQjEOUKTeuzWMbHFxxJ24MVA3ojDfUt+r1BWrUvAylbtIMUsD760C9i1X 1zwI8Q6dbS8ntt3lvTZYAxiR5uB/WNietqWaxMlbdzX3TWXS8VNeNfdwvuA76MpoV41G Pv0v/2WVaQLb4v4Nu55nL0OjtZF1kdF5WI3G9MhgzI5oEAepKdR2p+5DOKfQX4DHHRgU O6gW79jIIqILqpPUsekbSiX2NRF+ZphquyBuyjLNkEkObDlxCFDqpvymkpyvdLe+RiRY VXkpIpPdKw68iKSEr1cPDk8rpK9wsc1CKGwoJbR4AjfsvjVyUSl16E+uZGGR7MJ2M4/m tKGw== 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=2fcZxHMc1N8IMdttXnckxhY78ayrgXYsVfY7nu4z0HQ=; b=naTrtQ5XGp5dMICFTXL8uLb7ECLIHnkGk8Dsf0dRJML+Lc5g++35o1M9ZLeKFMRZMw U/j/XkmYiXXjJbUHrsbvZj0V74d6ESaOuqdTYnTW9JbVkeAGqfTP3PIPzDu7EaELAYof 1hJwLt1A8B7wGa/gDnXEkGQvc6HJRGExnGy8b+JqZmfGxTzWPezSFOUXnbBB+YVduoQM ggLrrRPFIdGcKgzbJrVTNPkrf5V+AprAG3WKDRQ75MUW2JiS4UwFAa/8soW27fptNcD8 Gs+rai9m/wUWrpgXnObKdEuGYAu74H+dU9za5+Y8fW+J3nGuFBHyPOT6KkBpSN8/m2eb w17w== X-Gm-Message-State: AOAM532jZpIJg2yCIUi5AR0FNyjKMoVWTtdDVPqe+akak/T+K+/hQJwM 0njMyOIZQ3Jg3uSmnND2AM5IepiVBb6Gcg== X-Google-Smtp-Source: ABdhPJwIjwkvrrRbdrrprdVtuj8lwoIN5T0wu7rZxAtL7+SH30/lXm0rwaG8z6wP1yCOCEvzc+7sOA== X-Received: by 2002:a17:902:9347:b029:d3:b2c6:1500 with SMTP id g7-20020a1709029347b02900d3b2c61500mr31383plp.5.1604633386385; Thu, 05 Nov 2020 19:29:46 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 18/41] tcg/i386: Support split-wx code generation Date: Thu, 5 Nov 2020 19:28:58 -0800 Message-Id: <20201106032921.600200-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.h | 2 +- tcg/i386/tcg-target.c.inc | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 1b9d41bd56..bbbd1c2d4a 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -236,6 +236,6 @@ static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 #endif diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 7f74c77d7f..23c7a8a383 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -165,7 +165,7 @@ static bool have_lzcnt; # define have_lzcnt 0 #endif -static tcg_insn_unit *tb_ret_addr; +static const tcg_insn_unit *tb_ret_addr; static bool patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) @@ -173,7 +173,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, value += addend; switch(type) { case R_386_PC32: - value -= (uintptr_t)code_ptr; + value -= (uintptr_t)tcg_splitwx_to_rx(code_ptr); if (value != (int32_t)value) { return false; } @@ -182,7 +182,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, tcg_patch32(code_ptr, value); break; case R_386_PC8: - value -= (uintptr_t)code_ptr; + value -= (uintptr_t)tcg_splitwx_to_rx(code_ptr); if (value != (int8_t)value) { return false; } @@ -1006,7 +1006,7 @@ static void tcg_out_movi(TCGContext *s, TCGType type, } /* Try a 7 byte pc-relative lea before the 10 byte movq. */ - diff = arg - ((uintptr_t)s->code_ptr + 7); + diff = tcg_pcrel_diff(s, (const void *)arg) - 7; if (diff == (int32_t)diff) { tcg_out_opc(s, OPC_LEA | P_REXW, ret, 0, 0); tcg_out8(s, (LOWREGMASK(ret) << 3) | 5); @@ -1615,7 +1615,7 @@ static inline void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) tcg_out_branch(s, 1, dest); } -static void tcg_out_jmp(TCGContext *s, tcg_insn_unit *dest) +static void tcg_out_jmp(TCGContext *s, const tcg_insn_unit *dest) { tcg_out_branch(s, 0, dest); } @@ -1786,7 +1786,8 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, bool is_64, label->datahi_reg = datahi; label->addrlo_reg = addrlo; label->addrhi_reg = addrhi; - label->raddr = raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr = (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr[0]; if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) { label->label_ptr[1] = label_ptr[1]; @@ -2280,7 +2281,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, /* jump displacement must be aligned for atomic patching; * see if we need to add extra nops before jump */ - gap = tcg_pcrel_diff(s, QEMU_ALIGN_PTR_UP(s->code_ptr + 1, 4)); + gap = QEMU_ALIGN_PTR_UP(s->code_ptr + 1, 4) - s->code_ptr; if (gap != 1) { tcg_out_nopn(s, gap - 1); } @@ -3825,11 +3826,12 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - tcg_code_gen_epilogue = s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_EAX, 0); /* TB epilogue */ - tb_ret_addr = s->code_ptr; + tb_ret_addr = tcg_splitwx_to_rx(s->code_ptr); tcg_out_addi(s, TCG_REG_CALL_STACK, stack_addend); From patchwork Fri Nov 6 03:28:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885865 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E7E5A921 for ; Fri, 6 Nov 2020 03:43:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 94B502072E for ; Fri, 6 Nov 2020 03:43:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oNT/2z+v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94B502072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:43376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasfF-0001Wz-By for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:43:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRi-00050n-Ov for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:50 -0500 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:42647) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRh-0006yu-2q for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:50 -0500 Received: by mail-pf1-x436.google.com with SMTP id x13so35457pfa.9 for ; Thu, 05 Nov 2020 19:29:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YKIoLTi5ySgzCVvhycZMdw7nP6Jv58IFUwkqltF23wU=; b=oNT/2z+vahNd8FRuo0RBTPK/El7HxwyZBAP/QdPYWEDCo48i9MCc34T3VnZUDAkYSN /AW2sDAOtpQNkuEwjaCX5laWW779KeUfq3iLJ/R2K5OjQUAN6HeyubhvZ5fYscyg6Pat nYZ4aGgm8OVPCcyh5N3f378pziIGlkLog9zcRQBwWMplOn+essc7xNKplg5bpDvSqTOu qZhemAh2ul83Mmeehuxkg15A2Xx+++/Gko3EBJBJGMNpWlpr4oee9O/QuLpmuioRvOno 1l0y9zPy0lGudwdp2aQFr8I+iQH9g0yN6fdNPXPOLW0QisL0KqVORES1UwydahzEQvBu 6WYA== 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=YKIoLTi5ySgzCVvhycZMdw7nP6Jv58IFUwkqltF23wU=; b=aJcoVeyByBUP0SSuKJf7nj1d6nxrG9J4cdB0Kawt2Tz6mOAcNWvClY8iFkJLKo9ojH jQI0SMzABffpzUYVCZr5rfjrMwFogTAbe21AwmGm3F46eSo4wdqvY0PUIonYhdw9o16l WhUtF8sksrYbWiSqXX7WcDl/lejTIt9D10MWdFpCuP34ujn6OxInRgWxo3QPJtBMNONK VEjuTJCmDRe5gaD/z1RWNnN2gAOR34d3bAIhF0MGmpH5+HJrhzOEK93Ot+Rx7ejoy6HH LxEZ+lZPFw9dkhPs1qpPSNPJCJEj5/HJJuKNwLeI4kuC/78PLxnCQ4ZKLsMRLe9FqO8g wa8g== X-Gm-Message-State: AOAM532N9sHSR22d6nQmasD3O/qjLmMxAI7wZML6xK0opQo/FEtuNBDA 2CNQVJbwQO7PUIXOTVopbEwUcTFX+Y1Xlw== X-Google-Smtp-Source: ABdhPJyYAGBur9xl4xGo9nYXx4yOJpPKUvSLw2EMSNA8gIOzjcQvjMnZba5HHr1CjWhRxUnSRJbxcg== X-Received: by 2002:a05:6a00:212b:b029:18b:ad77:1a27 with SMTP id n11-20020a056a00212bb029018bad771a27mr126668pfj.40.1604633387463; Thu, 05 Nov 2020 19:29:47 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 19/41] tcg/aarch64: Use B not BL for tcg_out_goto_long Date: Thu, 5 Nov 2020 19:28:59 -0800 Message-Id: <20201106032921.600200-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" A typo generated a branch-and-link insn instead of plain branch. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index fea784cf75..bd888bc66d 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1317,7 +1317,7 @@ static inline void tcg_out_goto_long(TCGContext *s, tcg_insn_unit *target) { ptrdiff_t offset = target - s->code_ptr; if (offset == sextract64(offset, 0, 26)) { - tcg_out_insn(s, 3206, BL, offset); + tcg_out_insn(s, 3206, B, offset); } else { tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, (intptr_t)target); tcg_out_insn(s, 3207, BR, TCG_REG_TMP); From patchwork Fri Nov 6 03:29:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885867 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7E90921 for ; Fri, 6 Nov 2020 03:44:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 82A582072E for ; Fri, 6 Nov 2020 03:44:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fjGF/+cr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82A582072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:45554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasfe-0002OZ-Ge for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:44:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRk-00056E-Ng for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:52 -0500 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:34753) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRi-0006zm-On for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:52 -0500 Received: by mail-pf1-x441.google.com with SMTP id o129so63416pfb.1 for ; Thu, 05 Nov 2020 19:29:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pKuwnlUIT6JfwyL/m5qNM+3MOPkBgPWHJhGqKzX+RB8=; b=fjGF/+crcWe4wFONKjPaVOqD72H+BNwvutDAFDtd2yxqCGi10BOCcv5WRuM0PBKAbG asjmsyZ99OTIRBEkDjMMiXXIqRSjCwvZ5aGvirGAW0KCe6O539QeJ8SnueTSApmJA3JW utPnAN05fXJUvn+rU0107Xu/jWAsfIhUeuWpG2EzVOfvp0LgmsYAR1WE3W2ENp5CwoKV n8GCYSa/FPHEHlkD2oSqD7JL4avIokeu23i4vcm7TEC+XDzU2QngtACIM1MzgelfZMaV jXGyAZ4XFPSPjH1OnFJ+r4JMg7b4cQux5moCqIfQijZk2aLewcBjALW+8R177wDWRQsh NM6Q== 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=pKuwnlUIT6JfwyL/m5qNM+3MOPkBgPWHJhGqKzX+RB8=; b=Cr6H6706Mgx9L3mh1kfaAncMg5yVGq8YGRsMNdOEuOh8tLJ1DoxNQvZOIxjkV4aZH+ KAxWdFAPfPv2kyMyzHLpCvPWHo6GxQZObaA3p1+ouMuGX1OiyjAVzOngXI85Nz1dDEde xIv9zKs2CB4gUAVPL9qv4cccjz/TBYXDGtajxxcUHoCnnAs3ftRREvwf3tpPBIU+3dR5 tVYwDi0OnAB7OuacJxcIeduBieYxuDf7+VqK5MzdHpDGcFvLgO8u+nU7GwISn8qblRCi qErJsExllKBaYJQE12euqSGE2zRAkwnhIH7S7833zZx0VMvfNCPz3mQ/HM4ZjLMmjQvM 6exg== X-Gm-Message-State: AOAM532yiONXZUBfjAgBb6f85mBll5tVGaXKQVk9Zue4cEek8PLMYR9D M8gND+81BdfLaZ6UbWe76S77xG4ahqIEsw== X-Google-Smtp-Source: ABdhPJwh1Bs2pG6zaa7p1cAXAaB0qbiyhHWVJjSCpuJRDuaogvQkwCZRAYHOT7JaMn2OS0QfONLWMw== X-Received: by 2002:a17:90a:80c6:: with SMTP id k6mr146051pjw.73.1604633389007; Thu, 05 Nov 2020 19:29:49 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 20/41] tcg/aarch64: Implement flush_idcache_range manually Date: Thu, 5 Nov 2020 19:29:00 -0800 Message-Id: <20201106032921.600200-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Copy the single pointer implementation from libgcc and modify it to support the double pointer interface we require. This halves the number of cache operations required when split-rwx is enabled. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.h | 11 +------ tcg/aarch64/tcg-target.c.inc | 64 ++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 10 deletions(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index fa64058d43..e62d38ba55 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -148,16 +148,7 @@ typedef enum { #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -/* Flush the dcache at RW, and the icache at RX, as necessary. */ -static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) -{ - /* TODO: Copy this from gcc to avoid 4 loops instead of 2. */ - if (rw != rx) { - __builtin___clear_cache((char *)rw, (char *)(rw + len)); - } - __builtin___clear_cache((char *)rx, (char *)(rx + len)); -} - +void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len); void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #ifdef CONFIG_SOFTMMU diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index bd888bc66d..8aa1fafd91 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -2968,3 +2968,67 @@ void tcg_register_jit(const void *buf, size_t buf_size) { tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); } + +/* Flush the dcache at RW, and the icache at RX, as necessary. */ +#ifdef CONFIG_DARWIN +/* Apple does not expose CTR_EL0, so we must use system interfaces. */ +extern void sys_icache_invalidate(void *start, size_t len); +extern void sys_dcache_flush(void *start, size_t len); +void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) +{ + sys_dcache_flush((void *)rw, len); + sys_icache_invalidate((void *)rx, len); +} +#else +/* + * This is a copy of gcc's __aarch64_sync_cache_range, modified + * to fit this three-operand interface. + */ +void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) +{ + const unsigned CTR_IDC = 1u << 28; + const unsigned CTR_DIC = 1u << 29; + static unsigned int cache_info; + uintptr_t icache_lsize, dcache_lsize, p; + + if (!cache_info) { + /* + * CTR_EL0 [3:0] contains log2 of icache line size in words. + * CTR_EL0 [19:16] contains log2 of dcache line size in words. + */ + asm volatile("mrs\t%0, ctr_el0" : "=r"(cache_info)); + } + + icache_lsize = 4 << extract32(cache_info, 0, 4); + dcache_lsize = 4 << extract32(cache_info, 16, 4); + + /* + * If CTR_EL0.IDC is enabled, Data cache clean to the Point of Unification + * is not required for instruction to data coherence. + */ + if (!(cache_info & CTR_IDC)) { + /* + * Loop over the address range, clearing one cache line at once. + * Data cache must be flushed to unification first to make sure + * the instruction cache fetches the updated data. + */ + for (p = rw & -dcache_lsize; p < rw + len; p += dcache_lsize) { + asm volatile("dc\tcvau, %0" : : "r" (p) : "memory"); + } + asm volatile("dsb\tish" : : : "memory"); + } + + /* + * If CTR_EL0.DIC is enabled, Instruction cache cleaning to the Point + * of Unification is not required for instruction to data coherence. + */ + if (!(cache_info & CTR_DIC)) { + for (p = rx & -icache_lsize; p < rx + len; p += icache_lsize) { + asm volatile("ic\tivau, %0" : : "r"(p) : "memory"); + } + asm volatile ("dsb\tish" : : : "memory"); + } + + asm volatile("isb" : : : "memory"); +} +#endif /* CONFIG_DARWIN */ From patchwork Fri Nov 6 03:29:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885873 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB5DA697 for ; Fri, 6 Nov 2020 03:45:49 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7B6412072E for ; Fri, 6 Nov 2020 03:45:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="noj/dyWQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B6412072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:51870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kashA-00053W-Eo for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:45:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRm-0005AX-9Z for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:54 -0500 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]:46291) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRk-00070H-1d for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:53 -0500 Received: by mail-pf1-x432.google.com with SMTP id v12so20831pfm.13 for ; Thu, 05 Nov 2020 19:29:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nrSCPy8u60mXIYP8HiCY0+UKnU0R7mNRnsgNMv25vvQ=; b=noj/dyWQ7ueVAgN9KWXUVuNNbl/w+NihV3Lwubd9ru+sPcuVIrQATlCT0XZqce73CP e7VcBAQL443Vjp8RMTbyO9+k2J5eETY1S6djGw8aen+20Ej8e5bbXZ3xCgFcFCj7TZst VNNJSPGmcOVGw0zJ2H1sGgJppbAMJbhE7cEXdOT6G6DBF1u3a/gRkhyCryW0jk8gjUzW h2VcFkeiDvJmIBLIIKpDIfZGrrDoGH+09Uzyuh4IrKOkqTrQR0b/Uza6oO3Mdygb5wQC Nf+diLBNSwkiKbymtmTxNf3o/hR6448n7jFYc8WOBDORrrcUyR4qa/zTqgxF2C6cfCNr LUHw== 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=nrSCPy8u60mXIYP8HiCY0+UKnU0R7mNRnsgNMv25vvQ=; b=EbkJomUm/VWh0W7x8PQkg8OGV0sBcr71lfwUwZ1jcfuWepHXefM1iQ0n8pVqoCKhLX I731GRvSIDyggC8p1JGGmrUxolB40USeVHHgAwrrKrAGtr5e3b2HCTMnEsfX3RBEdJoY 7/LEqeZuiQDl2iN0zJVJ2Wrb4MMSsUTtECi5GcpSPukVTSkC2WEvToRly2nKB2b/yzku 4AxHU9PuGURLee7NoHWlVqzT70A7PYK7XLoSHDcYvi5JaOY55Uyfy84WM2inq9+pfmpQ mCXwfAZgj1UELiF/NHuJH/tASuqPzxlcfH970M7/EyXiWUIL2cIUtsfD6yHi67wVYG5M jmxQ== X-Gm-Message-State: AOAM533Jsxp3zZNNrhPK+jsDOrkn2pOgLKSx0jYdg3R0E/ePQYg3epp1 OYPK67aVF7Y06S9UsHE0kcPx00+sjUdeUg== X-Google-Smtp-Source: ABdhPJwBcIV07kYTX50oKCAoS8Y+7tb4PkUW2wI/oMAarJugw1MTvK+XHw379dnBf4PadaUq9ndFdA== X-Received: by 2002:a62:be04:0:b029:160:6c5:d7fe with SMTP id l4-20020a62be040000b029016006c5d7femr109342pff.21.1604633390265; Thu, 05 Nov 2020 19:29:50 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 21/41] tcg/aarch64: Support split-wx code generation Date: Thu, 5 Nov 2020 19:29:01 -0800 Message-Id: <20201106032921.600200-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.h | 2 +- tcg/aarch64/tcg-target.c.inc | 57 ++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index e62d38ba55..abb94f9458 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -155,6 +155,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 #endif /* AARCH64_TCG_TARGET_H */ diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 8aa1fafd91..e398913c0c 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -78,38 +78,42 @@ static const int tcg_target_call_oarg_regs[1] = { #define TCG_REG_GUEST_BASE TCG_REG_X28 #endif -static inline bool reloc_pc26(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +static bool reloc_pc26(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t offset = target - code_ptr; + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset = target - src_rx; + if (offset == sextract64(offset, 0, 26)) { /* read instruction, mask away previous PC_REL26 parameter contents, set the proper offset, then write back the instruction. */ - *code_ptr = deposit32(*code_ptr, 0, 26, offset); + *src_rw = deposit32(*src_rw, 0, 26, offset); return true; } return false; } -static inline bool reloc_pc19(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +static bool reloc_pc19(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t offset = target - code_ptr; + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset = target - src_rx; + if (offset == sextract64(offset, 0, 19)) { - *code_ptr = deposit32(*code_ptr, 5, 19, offset); + *src_rw = deposit32(*src_rw, 5, 19, offset); return true; } return false; } -static inline bool patch_reloc(tcg_insn_unit *code_ptr, int type, - intptr_t value, intptr_t addend) +static bool patch_reloc(tcg_insn_unit *code_ptr, int type, + intptr_t value, intptr_t addend) { tcg_debug_assert(addend == 0); switch (type) { case R_AARCH64_JUMP26: case R_AARCH64_CALL26: - return reloc_pc26(code_ptr, (tcg_insn_unit *)value); + return reloc_pc26(code_ptr, (const tcg_insn_unit *)value); case R_AARCH64_CONDBR19: - return reloc_pc19(code_ptr, (tcg_insn_unit *)value); + return reloc_pc19(code_ptr, (const tcg_insn_unit *)value); default: g_assert_not_reached(); } @@ -1050,12 +1054,13 @@ static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, /* Look for host pointer values within 4G of the PC. This happens often when loading pointers to QEMU's own data structures. */ if (type == TCG_TYPE_I64) { - tcg_target_long disp = value - (intptr_t)s->code_ptr; + intptr_t src_rx = (intptr_t)tcg_splitwx_to_rx(s->code_ptr); + tcg_target_long disp = value - src_rx; if (disp == sextract64(disp, 0, 21)) { tcg_out_insn(s, 3406, ADR, rd, disp); return; } - disp = (value >> 12) - ((intptr_t)s->code_ptr >> 12); + disp = (value >> 12) - (src_rx >> 12); if (disp == sextract64(disp, 0, 21)) { tcg_out_insn(s, 3406, ADRP, rd, disp); if (value & 0xfff) { @@ -1308,14 +1313,14 @@ static void tcg_out_cmp(TCGContext *s, TCGType ext, TCGReg a, static void tcg_out_goto(TCGContext *s, const tcg_insn_unit *target) { - ptrdiff_t offset = target - s->code_ptr; + ptrdiff_t offset = tcg_pcrel_diff(s, target) >> 2; tcg_debug_assert(offset == sextract64(offset, 0, 26)); tcg_out_insn(s, 3206, B, offset); } -static inline void tcg_out_goto_long(TCGContext *s, tcg_insn_unit *target) +static void tcg_out_goto_long(TCGContext *s, const tcg_insn_unit *target) { - ptrdiff_t offset = target - s->code_ptr; + ptrdiff_t offset = tcg_pcrel_diff(s, target) >> 2; if (offset == sextract64(offset, 0, 26)) { tcg_out_insn(s, 3206, B, offset); } else { @@ -1329,9 +1334,9 @@ static inline void tcg_out_callr(TCGContext *s, TCGReg reg) tcg_out_insn(s, 3207, BLR, reg); } -static inline void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) { - ptrdiff_t offset = target - s->code_ptr; + ptrdiff_t offset = tcg_pcrel_diff(s, target) >> 2; if (offset == sextract64(offset, 0, 26)) { tcg_out_insn(s, 3206, BL, offset); } else { @@ -1393,7 +1398,7 @@ static void tcg_out_brcond(TCGContext *s, TCGType ext, TCGCond c, TCGArg a, tcg_out_reloc(s, s->code_ptr, R_AARCH64_CONDBR19, l, 0); offset = tcg_in32(s) >> 5; } else { - offset = l->u.value_ptr - s->code_ptr; + offset = tcg_pcrel_diff(s, l->u.value_ptr) >> 2; tcg_debug_assert(offset == sextract64(offset, 0, 19)); } @@ -1568,7 +1573,7 @@ static void * const qemu_st_helpers[16] = { [MO_BEQ] = helper_be_stq_mmu, }; -static inline void tcg_out_adr(TCGContext *s, TCGReg rd, void *target) +static inline void tcg_out_adr(TCGContext *s, TCGReg rd, const void *target) { ptrdiff_t offset = tcg_pcrel_diff(s, target); tcg_debug_assert(offset == sextract64(offset, 0, 21)); @@ -1581,7 +1586,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) MemOp opc = get_memop(oi); MemOp size = opc & MO_SIZE; - if (!reloc_pc19(lb->label_ptr[0], s->code_ptr)) { + if (!reloc_pc19(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } @@ -1606,7 +1611,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) MemOp opc = get_memop(oi); MemOp size = opc & MO_SIZE; - if (!reloc_pc19(lb->label_ptr[0], s->code_ptr)) { + if (!reloc_pc19(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } @@ -1631,7 +1636,8 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, label->type = ext; label->datalo_reg = data_reg; label->addrlo_reg = addr_reg; - label->raddr = raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr = (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr; } @@ -1849,7 +1855,7 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg data_reg, TCGReg addr_reg, #endif /* CONFIG_SOFTMMU */ } -static tcg_insn_unit *tb_ret_addr; +static const tcg_insn_unit *tb_ret_addr; static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg args[TCG_MAX_OP_ARGS], @@ -2894,11 +2900,12 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - tcg_code_gen_epilogue = s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_X0, 0); /* TB epilogue */ - tb_ret_addr = s->code_ptr; + tb_ret_addr = tcg_splitwx_to_rx(s->code_ptr); /* Remove TCG locals stack space. */ tcg_out_insn(s, 3401, ADDI, TCG_TYPE_I64, TCG_REG_SP, TCG_REG_SP, From patchwork Fri Nov 6 03:29:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885871 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D8F39697 for ; Fri, 6 Nov 2020 03:45:48 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 644312072E for ; Fri, 6 Nov 2020 03:45:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PVd9OiTz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 644312072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:51798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kash9-00051o-D7 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:45:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRn-0005Cs-7D for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:55 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:39701) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRl-00070n-DU for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:54 -0500 Received: by mail-pg1-x542.google.com with SMTP id i7so2881104pgh.6 for ; Thu, 05 Nov 2020 19:29:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GhRqALWf9y48BIzmwb6ec/JDv3hDJBRmMXBLeIk5tow=; b=PVd9OiTz07UJ7Oyr+RHrlqG5g3BMhQUcj8txKh9hKP/lhuAiJkF8qcAMB/8P1zqK13 isXy9qaRe98nsADZM9e57elE0vVur6EiO/DT6h/6VdE/wfMbQ9rPnyfOMVmS8C0Dekf/ l6275MPJ1+o5zKwHXJmxt3KH511z3Qy0p9P8m1QIqHxXIijmvqtfb6qxI7UfQolv1063 lZKewG+bIUVFWkgWD1ft/wfyuA5rE6jpxZsMKsqaO4vpJYxe1r0w3uL0HluDv3vpku9Z UULZ4rtBBwjHLJA7rsuDvx/j0LPo1z1oaSocGP2NqXrNkVJcbRX4vol07nRwEcSs1swt CPzg== 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=GhRqALWf9y48BIzmwb6ec/JDv3hDJBRmMXBLeIk5tow=; b=Lw3uyjCuufBaWOy6oZEfRUgqMUu6YeC3R2UuAST72OBHok4AphU46eC2lB67fJtzRy DMlmXmza6VGcrZrBYcEnpgGaIfJ3yiC1JNP8W/Iea4iFaHxuUc923hYsHYSu+7cF/Cch XqPli92lSNuQ6eEZXZwl8XU40SJLbzBUK064ok9A7ipnAiccZRJ3yAxNHA5NmoAeX5T0 KLoyBt0U4Twf/6IDDb/YXSJcYHzbbiQw0NfG/ArCeR0xS/lucFWRLPhIsgqslDa/tTfr NO/XX1eT+zoumZHrPDaGYclC4Jjz+ytrfIC1ncn6w/Ihf8vQyDYPGx9qsUYj0uBDwtq9 ZBfw== X-Gm-Message-State: AOAM533g3u9n7yuxFXV4UUX45L/Qnqy19RfwEO6DYptAukZm6kQNnUx1 D2Gi0XymV7NDe3EFW40lTWqVDc5TqnLwPw== X-Google-Smtp-Source: ABdhPJwNOjkKvb0hxulvS+ui0ckDkTszzhXCU6hepRXUNY/zXghGL2EAZKZbmEfv23leouAqTRAzTg== X-Received: by 2002:a62:2e47:0:b029:155:853a:80d5 with SMTP id u68-20020a622e470000b0290155853a80d5mr102567pfu.29.1604633391633; Thu, 05 Nov 2020 19:29:51 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 22/41] disas: Push const down through host disasassembly Date: Thu, 5 Nov 2020 19:29:02 -0800 Message-Id: <20201106032921.600200-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::542; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x542.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- include/disas/dis-asm.h | 4 ++-- disas.c | 4 +--- disas/capstone.c | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/disas/dis-asm.h b/include/disas/dis-asm.h index 2164762b46..d1133a4e04 100644 --- a/include/disas/dis-asm.h +++ b/include/disas/dis-asm.h @@ -358,7 +358,7 @@ typedef struct disassemble_info { (bfd_vma addr, struct disassemble_info * info); /* These are for buffer_read_memory. */ - bfd_byte *buffer; + const bfd_byte *buffer; bfd_vma buffer_vma; int buffer_length; @@ -462,7 +462,7 @@ int print_insn_rx(bfd_vma, disassemble_info *); #ifdef CONFIG_CAPSTONE bool cap_disas_target(disassemble_info *info, uint64_t pc, size_t size); -bool cap_disas_host(disassemble_info *info, void *code, size_t size); +bool cap_disas_host(disassemble_info *info, const void *code, size_t size); bool cap_disas_monitor(disassemble_info *info, uint64_t pc, int count); bool cap_disas_plugin(disassemble_info *info, uint64_t pc, size_t size); #else diff --git a/disas.c b/disas.c index de1de7be94..a61f95b580 100644 --- a/disas.c +++ b/disas.c @@ -299,10 +299,8 @@ char *plugin_disas(CPUState *cpu, uint64_t addr, size_t size) } /* Disassemble this for me please... (debugging). */ -void disas(FILE *out, const void *ccode, unsigned long size) +void disas(FILE *out, const void *code, unsigned long size) { - /* TODO: Push constness through the disas backends. */ - void *code = (void *)ccode; uintptr_t pc; int count; CPUDebug s; diff --git a/disas/capstone.c b/disas/capstone.c index 7462c0e305..20bc8f9669 100644 --- a/disas/capstone.c +++ b/disas/capstone.c @@ -229,7 +229,7 @@ bool cap_disas_target(disassemble_info *info, uint64_t pc, size_t size) } /* Disassemble SIZE bytes at CODE for the host. */ -bool cap_disas_host(disassemble_info *info, void *code, size_t size) +bool cap_disas_host(disassemble_info *info, const void *code, size_t size) { csh handle; const uint8_t *cbuf; From patchwork Fri Nov 6 03:29:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885879 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 721D5697 for ; Fri, 6 Nov 2020 03:47:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E109820735 for ; Fri, 6 Nov 2020 03:47:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mwKZPJPA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E109820735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:58278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasj0-0007g8-Rp for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:47:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRr-0005OZ-DL for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:59 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:35041) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRp-00072p-9B for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:59 -0500 Received: by mail-pl1-x629.google.com with SMTP id 1so31612ple.2 for ; Thu, 05 Nov 2020 19:29:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oktQi4LY/JF34qnZTuyLsQ8kBIo/j/CH/m+PcKBIxn4=; b=mwKZPJPAWbMaHoCtW78bfp8y0RRtYPpk05IQNBoBjQGFVPxR8tB5A+ZrpBB5NuZXuN r1TGQl5iVpzUbiqrKo+GGvuseDOZGvAghcV8KeYW+cR9xuHvCYiUWefzlBZEBGCOzpnh xTJPp/DHWBFFNZODkruMIOqFFERlJ7b1EiB3J/7XQq42Xo4eKwbwlbxjwwRIFoN2nmyd u17Sc5cDbz4oHo/BD60pwWCs3w8U/eUW2rRFlZD4Y2pU6HEKDH4/ukcCDL8UBYu1FETD sO90sKiqp3Ah55Udqd2vCUgsJvmY3+ry86xRHUG3ZkJwZy0X6TH+Ph2yAcZh0PgX+keO IlyA== 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=oktQi4LY/JF34qnZTuyLsQ8kBIo/j/CH/m+PcKBIxn4=; b=g0QXrIkwWdFR6uTX4EzEmGjiX2keRY6GpfsZF3R62Mn7/tzgdJydrQBe/hCBe9pYqw r+HCBzKh7b2YdybNJRi4aJnz9DCRpXc6bePSSOwfXOqd2PJfD/v4IC4J7XD3Sr/VtYwg NmJsXKRMqbWE4ssmvxT5E0JoJqGlD2R3q/6o/tCqFZQRAXGCCreVcHdSXiQDKvr1CvAp /txkT50DJQtP2ln4kP41d4rj3A/LPkcD1vO2PlIg4MeBVNd1l8cz6w4khZbV8DZpg8oY zgDl/EJ2Yl+0thXxTjylDoMjwQMfsT4Yw7Ho8E/U7Dn2gW0+/hH0BdfAx9YIrcGJAGUk CBDA== X-Gm-Message-State: AOAM531lu8eeeeGLNXntkpXyv/KDdppt7wloXDPEA9gb38eILs2D/ACB Fb8EJ0nLlqtHk5uumkXI6VAHZJCBCJWrSA== X-Google-Smtp-Source: ABdhPJzVhoebuV5aIFFg7/NCNkQaHsz4JKABQrk75UFtZgxwsv7qU4qfYupwpTlhkF5TD1piLDy2PA== X-Received: by 2002:a17:902:b582:b029:d6:6008:264d with SMTP id a2-20020a170902b582b02900d66008264dmr5192126pls.80.1604633393382; Thu, 05 Nov 2020 19:29:53 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 23/41] tcg/tci: Push const down through bytecode reading Date: Thu, 5 Nov 2020 19:29:03 -0800 Message-Id: <20201106032921.600200-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/tci.c | 60 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/tcg/tci.c b/tcg/tci.c index 262a2b39ce..388c1dbee8 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -163,34 +163,34 @@ static uint64_t tci_uint64(uint32_t high, uint32_t low) #endif /* Read constant (native size) from bytecode. */ -static tcg_target_ulong tci_read_i(uint8_t **tb_ptr) +static tcg_target_ulong tci_read_i(const uint8_t **tb_ptr) { - tcg_target_ulong value = *(tcg_target_ulong *)(*tb_ptr); + tcg_target_ulong value = *(const tcg_target_ulong *)(*tb_ptr); *tb_ptr += sizeof(value); return value; } /* Read unsigned constant (32 bit) from bytecode. */ -static uint32_t tci_read_i32(uint8_t **tb_ptr) +static uint32_t tci_read_i32(const uint8_t **tb_ptr) { - uint32_t value = *(uint32_t *)(*tb_ptr); + uint32_t value = *(const uint32_t *)(*tb_ptr); *tb_ptr += sizeof(value); return value; } /* Read signed constant (32 bit) from bytecode. */ -static int32_t tci_read_s32(uint8_t **tb_ptr) +static int32_t tci_read_s32(const uint8_t **tb_ptr) { - int32_t value = *(int32_t *)(*tb_ptr); + int32_t value = *(const int32_t *)(*tb_ptr); *tb_ptr += sizeof(value); return value; } #if TCG_TARGET_REG_BITS == 64 /* Read constant (64 bit) from bytecode. */ -static uint64_t tci_read_i64(uint8_t **tb_ptr) +static uint64_t tci_read_i64(const uint8_t **tb_ptr) { - uint64_t value = *(uint64_t *)(*tb_ptr); + uint64_t value = *(const uint64_t *)(*tb_ptr); *tb_ptr += sizeof(value); return value; } @@ -198,7 +198,7 @@ static uint64_t tci_read_i64(uint8_t **tb_ptr) /* Read indexed register (native size) from bytecode. */ static tcg_target_ulong -tci_read_r(const tcg_target_ulong *regs, uint8_t **tb_ptr) +tci_read_r(const tcg_target_ulong *regs, const uint8_t **tb_ptr) { tcg_target_ulong value = tci_read_reg(regs, **tb_ptr); *tb_ptr += 1; @@ -206,7 +206,7 @@ tci_read_r(const tcg_target_ulong *regs, uint8_t **tb_ptr) } /* Read indexed register (8 bit) from bytecode. */ -static uint8_t tci_read_r8(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static uint8_t tci_read_r8(const tcg_target_ulong *regs, const uint8_t **tb_ptr) { uint8_t value = tci_read_reg8(regs, **tb_ptr); *tb_ptr += 1; @@ -215,7 +215,7 @@ static uint8_t tci_read_r8(const tcg_target_ulong *regs, uint8_t **tb_ptr) #if TCG_TARGET_HAS_ext8s_i32 || TCG_TARGET_HAS_ext8s_i64 /* Read indexed register (8 bit signed) from bytecode. */ -static int8_t tci_read_r8s(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static int8_t tci_read_r8s(const tcg_target_ulong *regs, const uint8_t **tb_ptr) { int8_t value = tci_read_reg8s(regs, **tb_ptr); *tb_ptr += 1; @@ -224,7 +224,8 @@ static int8_t tci_read_r8s(const tcg_target_ulong *regs, uint8_t **tb_ptr) #endif /* Read indexed register (16 bit) from bytecode. */ -static uint16_t tci_read_r16(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static uint16_t tci_read_r16(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint16_t value = tci_read_reg16(regs, **tb_ptr); *tb_ptr += 1; @@ -233,7 +234,8 @@ static uint16_t tci_read_r16(const tcg_target_ulong *regs, uint8_t **tb_ptr) #if TCG_TARGET_HAS_ext16s_i32 || TCG_TARGET_HAS_ext16s_i64 /* Read indexed register (16 bit signed) from bytecode. */ -static int16_t tci_read_r16s(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static int16_t tci_read_r16s(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { int16_t value = tci_read_reg16s(regs, **tb_ptr); *tb_ptr += 1; @@ -242,7 +244,8 @@ static int16_t tci_read_r16s(const tcg_target_ulong *regs, uint8_t **tb_ptr) #endif /* Read indexed register (32 bit) from bytecode. */ -static uint32_t tci_read_r32(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static uint32_t tci_read_r32(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint32_t value = tci_read_reg32(regs, **tb_ptr); *tb_ptr += 1; @@ -251,14 +254,16 @@ static uint32_t tci_read_r32(const tcg_target_ulong *regs, uint8_t **tb_ptr) #if TCG_TARGET_REG_BITS == 32 /* Read two indexed registers (2 * 32 bit) from bytecode. */ -static uint64_t tci_read_r64(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static uint64_t tci_read_r64(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint32_t low = tci_read_r32(regs, tb_ptr); return tci_uint64(tci_read_r32(regs, tb_ptr), low); } #elif TCG_TARGET_REG_BITS == 64 /* Read indexed register (32 bit signed) from bytecode. */ -static int32_t tci_read_r32s(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static int32_t tci_read_r32s(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { int32_t value = tci_read_reg32s(regs, **tb_ptr); *tb_ptr += 1; @@ -266,7 +271,8 @@ static int32_t tci_read_r32s(const tcg_target_ulong *regs, uint8_t **tb_ptr) } /* Read indexed register (64 bit) from bytecode. */ -static uint64_t tci_read_r64(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static uint64_t tci_read_r64(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint64_t value = tci_read_reg64(regs, **tb_ptr); *tb_ptr += 1; @@ -276,7 +282,7 @@ static uint64_t tci_read_r64(const tcg_target_ulong *regs, uint8_t **tb_ptr) /* Read indexed register(s) with target address from bytecode. */ static target_ulong -tci_read_ulong(const tcg_target_ulong *regs, uint8_t **tb_ptr) +tci_read_ulong(const tcg_target_ulong *regs, const uint8_t **tb_ptr) { target_ulong taddr = tci_read_r(regs, tb_ptr); #if TARGET_LONG_BITS > TCG_TARGET_REG_BITS @@ -287,7 +293,7 @@ tci_read_ulong(const tcg_target_ulong *regs, uint8_t **tb_ptr) /* Read indexed register or constant (native size) from bytecode. */ static tcg_target_ulong -tci_read_ri(const tcg_target_ulong *regs, uint8_t **tb_ptr) +tci_read_ri(const tcg_target_ulong *regs, const uint8_t **tb_ptr) { tcg_target_ulong value; TCGReg r = **tb_ptr; @@ -301,7 +307,8 @@ tci_read_ri(const tcg_target_ulong *regs, uint8_t **tb_ptr) } /* Read indexed register or constant (32 bit) from bytecode. */ -static uint32_t tci_read_ri32(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static uint32_t tci_read_ri32(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint32_t value; TCGReg r = **tb_ptr; @@ -316,14 +323,16 @@ static uint32_t tci_read_ri32(const tcg_target_ulong *regs, uint8_t **tb_ptr) #if TCG_TARGET_REG_BITS == 32 /* Read two indexed registers or constants (2 * 32 bit) from bytecode. */ -static uint64_t tci_read_ri64(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static uint64_t tci_read_ri64(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint32_t low = tci_read_ri32(regs, tb_ptr); return tci_uint64(tci_read_ri32(regs, tb_ptr), low); } #elif TCG_TARGET_REG_BITS == 64 /* Read indexed register or constant (64 bit) from bytecode. */ -static uint64_t tci_read_ri64(const tcg_target_ulong *regs, uint8_t **tb_ptr) +static uint64_t tci_read_ri64(const tcg_target_ulong *regs, + const uint8_t **tb_ptr) { uint64_t value; TCGReg r = **tb_ptr; @@ -337,7 +346,7 @@ static uint64_t tci_read_ri64(const tcg_target_ulong *regs, uint8_t **tb_ptr) } #endif -static tcg_target_ulong tci_read_label(uint8_t **tb_ptr) +static tcg_target_ulong tci_read_label(const uint8_t **tb_ptr) { tcg_target_ulong label = tci_read_i(tb_ptr); tci_assert(label != 0); @@ -477,8 +486,7 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition) /* Interpret pseudo code in tb. */ uintptr_t tcg_qemu_tb_exec(CPUArchState *env, const void *v_tb_ptr) { - /* TODO: Propagate const through this file. */ - uint8_t *tb_ptr = (uint8_t *)v_tb_ptr; + const uint8_t *tb_ptr = v_tb_ptr; tcg_target_ulong regs[TCG_TARGET_NB_REGS]; long tcg_temps[CPU_TEMP_BUF_NLONGS]; uintptr_t sp_value = (uintptr_t)(tcg_temps + CPU_TEMP_BUF_NLONGS); @@ -492,7 +500,7 @@ uintptr_t tcg_qemu_tb_exec(CPUArchState *env, const void *v_tb_ptr) TCGOpcode opc = tb_ptr[0]; #if defined(CONFIG_DEBUG_TCG) && !defined(NDEBUG) uint8_t op_size = tb_ptr[1]; - uint8_t *old_code_ptr = tb_ptr; + const uint8_t *old_code_ptr = tb_ptr; #endif tcg_target_ulong t0; tcg_target_ulong t1; From patchwork Fri Nov 6 03:29:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885845 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC5586A2 for ; Fri, 6 Nov 2020 03:39:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 961E02072E for ; Fri, 6 Nov 2020 03:39:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mWN4lVou" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 961E02072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:54910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasai-00034M-Il for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:39:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRs-0005Pq-2p for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:00 -0500 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:45385) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRq-00073g-DX for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:29:59 -0500 Received: by mail-pg1-x543.google.com with SMTP id 62so2859345pgg.12 for ; Thu, 05 Nov 2020 19:29:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UM21CD1mNWN7mJCqUB/udHXRZq9uSUYW+rGuZNQcpWU=; b=mWN4lVou6WXoGKcq3p7fbPc6jIhkoS5I3k1g4rfo41b8DG9GYUmtR7LustisERj0PC f8tO7MZLvWkfmRUROWILIjfnDoDOiIF8vSViuG9XEZsjBg0Ei/Xe5/P22kOehKmPH1+A PJSQWauqbzhb2VG3EAKTM5toZq2U0dfVq3wDrANw25eIFFcvS/38MAAUBYt5GWPaxXWh KpfjFIAlIQPivuPEUztGP2uDVmKqGFIx4VIBdbazP6gZz+D6InT/+MqCxvgbCXNmytS/ IBjQpumlFzt6lJocQukUcrZsi/u99na3Kyi0G0zSYloJAqFB0e0EhnUxUaJG3sZpxe9t uEFQ== 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=UM21CD1mNWN7mJCqUB/udHXRZq9uSUYW+rGuZNQcpWU=; b=k2AdQShZG+5FMUt0yEWnDvZzlm8GAq51lNvaj/s/iSB90pTAynZ70pY83T/Pkg1cC8 ykJyHLrG35CbtDxLrmEyvX3LE9QAWwxINW1CIAKPBqgInwq5Z19lhnhgWfjBxEuAP9AL eC5aRNtUKujcpwDR9xSpyh5aRgDOD7bwr6WAN8YEgwJmQmz2txJZupb0VjKYbZAhF4x/ LLtPNG/47wSi4uCSWAvfe0Mnx/tFPFc/m/hpZ66BVmFTxvfSt5kurFcQvpVzVk79mhQX S31K/Iel85sH3udfGfHNcMAPLjVdA2PxHLCTIW9svrPIrfBQD/mRl4YdC8JTbhHui+II ANKg== X-Gm-Message-State: AOAM530rbCeCgc8s1UUTugUVG8YO2S4m5Hy7+T4nPDSsj7woXzkbk0Y1 CNGF+FQH+UEA3nhb6bHwy8wpmcvkQ2s1dQ== X-Google-Smtp-Source: ABdhPJzGVn8gGyy5bmTTCNO9XzcyM32F2d/pqpd95f1KExqexBK+E3Gfc5Yz4IlVS2j36StrIFukIw== X-Received: by 2002:a62:1408:0:b029:18b:78d:4c4b with SMTP id 8-20020a6214080000b029018b078d4c4bmr105881pfu.25.1604633396758; Thu, 05 Nov 2020 19:29:56 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 24/41] tcg: Introduce tcg_tbrel_diff Date: Thu, 5 Nov 2020 19:29:04 -0800 Message-Id: <20201106032921.600200-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::543; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x543.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 67d57695c2..90ec7c1445 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -1141,6 +1141,19 @@ static inline ptrdiff_t tcg_pcrel_diff(TCGContext *s, const void *target) return tcg_ptr_byte_diff(target, tcg_splitwx_to_rx(s->code_ptr)); } +/** + * tcg_tbrel_diff + * @s: the tcg context + * @target: address of the target + * + * Produce a difference, from the beginning of the current TB code + * to the destination address. + */ +static inline ptrdiff_t tcg_tbrel_diff(TCGContext *s, const void *target) +{ + return tcg_ptr_byte_diff(target, tcg_splitwx_to_rx(s->code_buf)); +} + /** * tcg_current_code_size * @s: the tcg context From patchwork Fri Nov 6 03:29:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885855 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A20E921 for ; Fri, 6 Nov 2020 03:41:24 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E87C82072C for ; Fri, 6 Nov 2020 03:41:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Hq4/9sLP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E87C82072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kascs-0006Yv-Mw for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:41:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRt-0005SS-HQ for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:05 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:36462) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRr-00074Z-PA for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:01 -0500 Received: by mail-pl1-x642.google.com with SMTP id k7so30214plk.3 for ; Thu, 05 Nov 2020 19:29:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0nOzDi9GCulBBSiNGVZiKYWH3fm6VYqbKdWJcIsxfhQ=; b=Hq4/9sLPxHok2kFbCEfNYXfwEG4m3JZgJs6Vcx0FHPFS1NqxxQkae0il1LHcVrUsu8 vPeE6ga+uMS5OvP8WpgDS/Vj6fjxRNkyMqinFtuuppfqiuQDEQoW5WwWq6o+mCdfLA4t 23EMm//HV2mgj49il1uYc1JTPjILYE+nVJR0K0gD4PY7Mnxrh103VfFgt5THJEkB5r2k rU21+IM51PPQu8JlpX7AdrGUeAY7wjtmDcKrM4YAN9rNqOd+HcT/6RGClcKOwyh0EfjZ /MSNJgK7W3hweVkW9PWEC/OSF/21pjesw+eurkvEpVphBMkulomFnvGKz9fS288IyfzO 3RgA== 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=0nOzDi9GCulBBSiNGVZiKYWH3fm6VYqbKdWJcIsxfhQ=; b=FxjsDoxeQ4ZJeaulKnyXZpguC9tCQiMCDSHDg38lnnsMCHmq40prxKsVK6thWi1DDQ 3vNccbGeGIGn/NtaLWI/psBeCNczlM4QD+hn88ib84pshW5Zz55ubReyB+/kCT5rVjGb oqIzt7xVUCrwvluUlnki3W+h9oAwwnbOw9WioneBShVohjILfjVFqqIQpY9MaQBLD2rV c+DDT0PreefWRZvI2VYBT8wk59LcnhCL7NxLTBsn9AeSnuVS0FdKCXYarPQpc9g7eBKe HBY3REZCFKPpiSHlUa2z947aq9IMwkrPPfsmBCfGichKswiq+Wg5rcNbHzvmNhehau8i hJTw== X-Gm-Message-State: AOAM532CTgijFqx0ifDCYoVSE3kgoiBCNLFEcuthBy7WpNG46gcO0Vmo 2azB+J5rs2BMMy13NalVZD0jfu7LpghneQ== X-Google-Smtp-Source: ABdhPJxx6m/bAg9EHhnK32sHRVM9jigANIfpJdy197L4XpeKxWvAoCV89p8X6JXqKncYq8IybpuVHA== X-Received: by 2002:a17:902:9f86:b029:d6:d25f:7ad8 with SMTP id g6-20020a1709029f86b02900d6d25f7ad8mr136493plq.4.1604633398094; Thu, 05 Nov 2020 19:29:58 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 25/41] tcg/ppc: Use tcg_tbrel_diff Date: Thu, 5 Nov 2020 19:29:05 -0800 Message-Id: <20201106032921.600200-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::642; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x642.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Use tcg_tbrel_diff when we need a displacement to a label, and with a NULL argument when we need the normalizing addend. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index bc0057eedf..dc90705d02 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -837,7 +837,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, } /* Load addresses within the TB with one insn. */ - tb_diff = arg - (intptr_t)s->code_gen_ptr; + tb_diff = tcg_tbrel_diff(s, (void *)arg); if (!in_prologue && USE_REG_TB && tb_diff == (int16_t)tb_diff) { tcg_out32(s, ADDI | TAI(ret, TCG_REG_TB, tb_diff)); return; @@ -890,7 +890,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, /* Use the constant pool, if possible. */ if (!in_prologue && USE_REG_TB) { new_pool_label(s, arg, R_PPC_ADDR16, s->code_ptr, - -(intptr_t)s->code_gen_ptr); + tcg_tbrel_diff(s, NULL)); tcg_out32(s, LD | TAI(ret, TCG_REG_TB, 0)); return; } @@ -940,7 +940,7 @@ static void tcg_out_dupi_vec(TCGContext *s, TCGType type, TCGReg ret, */ if (USE_REG_TB) { rel = R_PPC_ADDR16; - add = -(intptr_t)s->code_gen_ptr; + add = tcg_tbrel_diff(s, NULL); } else { rel = R_PPC_ADDR32; add = 0; From patchwork Fri Nov 6 03:29:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885863 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D95231130 for ; Fri, 6 Nov 2020 03:43:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8231F2072E for ; Fri, 6 Nov 2020 03:43:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jaFmAEZd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8231F2072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasf6-0001BL-GK for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:43:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasRy-0005TT-70 for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:07 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:44180) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasRt-00075U-5q for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:05 -0500 Received: by mail-pg1-x544.google.com with SMTP id e21so2865993pgr.11 for ; Thu, 05 Nov 2020 19:30:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lR9ILVXMVkME60wGI8pWnBaKO2y1Li21DXN5Z4ukxX8=; b=jaFmAEZd3q6hKFAfLjDCKTZf6mgsn+43MkS0j0Q7ND9xFtCm5dbS2sdJC6U+cTOMqt 157uPA80qIDqR93Dxt0TLjyhYF7wZx/48TvK8InU0wHgWVbJKn2bQ5dJhIDoxCg1MvZF ra17Gict90s/pk0wogAP3RQh67dnjHj7suqaveMqhUQRDsCPtUT0LgrM8S2chPcJiEVn mtI7cnG2HbsgFH/rX6LIqdf6ryLJK+Dg3zTl8BZg4S2FNuZ5LrZ4NLqhFuFFNk5cwftu J4wy0RSL+rUI96V41uQGRpSFDpZfHiQeF1+axbk71ScCvxxsab/9tQavgLBHUQDqaMlb F+DA== 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=lR9ILVXMVkME60wGI8pWnBaKO2y1Li21DXN5Z4ukxX8=; b=p5XKrT3wI7wo13X5mDi3u/uIT9tXgkb/W+j3sXKlz9gzsWprwasx1i41ISDEIQVca4 bfFpUs+TU9sQ2cDa+zbwD5E6EOJjVkVICG6gwRU7QIkx9XeemTIGgWN6AnOu+r+lUVYA DmmJ6TZ1eELC9xMeZYn0Gw3jUofpe3una7LO2qM27TYwBL2Iz/Rtlq4AxKat9z74xGTb 7Ct1UqBgCbCOA5H7g+Ow5se2NfJwxrlYLcBG81tgsfyMyLbccUYA2Xx5RoCsjO4RmdQg cqr4X33acjeRQqHs6fbZIVdZbYRcjOv8KtHartYB779FCEAmOP1kuO/bGYWJq1hqBNmH pmpw== X-Gm-Message-State: AOAM533Bn4KpEG4pRoohiC+nZfhnqiSApPq+ksIsYn8USlZLp5BuVr37 GsD84Ux+nLAC5dpw7mM+SFea3qxDLh+GYw== X-Google-Smtp-Source: ABdhPJxg5NT13ldS9qh1aZC2A4bTg0Xv/FPkpeMM6jGAXP0pq8UdY48Ms6ZwWrdkakB+ltJ8RV2jUQ== X-Received: by 2002:a17:90a:eb12:: with SMTP id j18mr150225pjz.15.1604633399544; Thu, 05 Nov 2020 19:29:59 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:29:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 26/41] tcg/ppc: Use tcg_out_mem_long to reset TCG_REG_TB Date: Thu, 5 Nov 2020 19:29:06 -0800 Message-Id: <20201106032921.600200-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::544; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x544.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The maximum TB code gen size is UINT16_MAX, which the current code does not support. Use our utility function to optimally add an arbitrary constant. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index dc90705d02..91d5d95ddf 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -2392,9 +2392,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, set_jmp_reset_offset(s, args[0]); if (USE_REG_TB) { /* For the unlinked case, need to reset TCG_REG_TB. */ - c = -tcg_current_code_size(s); - assert(c == (int16_t)c); - tcg_out32(s, ADDI | TAI(TCG_REG_TB, TCG_REG_TB, c)); + tcg_out_mem_long(s, ADDI, ADD, TCG_REG_TB, TCG_REG_TB, + -tcg_current_code_size(s)); } break; case INDEX_op_goto_ptr: From patchwork Fri Nov 6 03:29:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885869 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8CC9D697 for ; Fri, 6 Nov 2020 03:45:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 334EB2072E for ; Fri, 6 Nov 2020 03:45:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nCoKluwl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 334EB2072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasgT-0003kE-WD for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:45:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasS5-0005Vb-FH for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:14 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:39964) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasS1-00077M-OR for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:11 -0500 Received: by mail-pg1-x542.google.com with SMTP id x13so2880672pgp.7 for ; Thu, 05 Nov 2020 19:30:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pY7YptV5jK52/EGSfz+70ZXeLAnSsRhMupI/NGLlfao=; b=nCoKluwlNDu2+WsZadTbwfyDuW4VcgCWFPKDcbSQ6yJKvQFdcE6/tpKzIhhw6aYnNu 2q5WyMOfuIP1SXFZ8QsZV5LNqenkfVQB8POnPWDZyzX/Mbr1yx8mLWNgf+XBF52qPBdF W1E752WaFxlSj/9ANVbv7pXw6d6C/RWMN3VC7KBOu9omRXrzPGgdGmxBlSAsA35lsqZ5 GOFApu/GKMw+vE0YMdZmMLUOZqgbCqZj0lzct7I2XmEu8VljaHg+/kZZneHl5bpWkMSA 70xB7OMm+jFcD4CVDKJP33SZouJOfBOfxkrcCqL9NBpW5ZSpuKDYwTQyRWB3XAI6JU5L niDw== 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=pY7YptV5jK52/EGSfz+70ZXeLAnSsRhMupI/NGLlfao=; b=ZMM+zgIpZZWvEc3j+XuTx6k+KjEUgP6ONhyCICcbXKniSPyj35YUisU6EimwcWTWRU R47Rxvo8Gumlmlxt4wa4SqZuT6UL2c+KxCchjLq0la2yUCHPUpOKGDONezHbI3ITMByk OLiUjD9QMP50CKAQvCYw76QGL/I7MBH4XN/19jIavUYjmc97tsE655B0qi/OVlIuqu5E szVzthCZIeh9jGQ3EocUr6gWm06nRjP9lYhL2fM96G54mV3zsWtWYJTj3tpx0agXRnpC EBJyp1TxjfO8eTtuTZuI0cocB1+8GwypJ9c6biGydX7amev/lFqXf907P/jH0qtlU0at iAOg== X-Gm-Message-State: AOAM530rXRKgVpQ5T7XdrQkx4Speh/V5UPFZde/QKAJomOKHShMdMssX BLk+Xj75HTuh+2lpWSweU6tI4q1voDRrOA== X-Google-Smtp-Source: ABdhPJwYnH+zP4tJHNiwsPCY34BxnpN42esb6FVkVb1xKT3Mz8oXyJU+qAP/5Rw06kBrG0jF6hGNXw== X-Received: by 2002:a17:90a:f211:: with SMTP id bs17mr138622pjb.153.1604633400809; Thu, 05 Nov 2020 19:30:00 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:30:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 27/41] tcg/ppc: Support split-wx code generation Date: Thu, 5 Nov 2020 19:29:07 -0800 Message-Id: <20201106032921.600200-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::542; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x542.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.h | 2 +- tcg/ppc/tcg-target.c.inc | 53 +++++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 78d6a5e96f..a8628b6cad 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -185,6 +185,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 #endif diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 91d5d95ddf..fe33687787 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -62,8 +62,6 @@ #define TCG_CT_CONST_MONE 0x2000 #define TCG_CT_CONST_WSZ 0x4000 -static tcg_insn_unit *tb_ret_addr; - TCGPowerISA have_isa; static bool have_isel; bool have_altivec; @@ -184,35 +182,41 @@ static inline bool in_range_b(tcg_target_long target) return target == sextract64(target, 0, 26); } -static uint32_t reloc_pc24_val(tcg_insn_unit *pc, const tcg_insn_unit *target) +static uint32_t reloc_pc24_val(const tcg_insn_unit *pc, + const tcg_insn_unit *target) { ptrdiff_t disp = tcg_ptr_byte_diff(target, pc); tcg_debug_assert(in_range_b(disp)); return disp & 0x3fffffc; } -static bool reloc_pc24(tcg_insn_unit *pc, tcg_insn_unit *target) +static bool reloc_pc24(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t disp = tcg_ptr_byte_diff(target, pc); + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t disp = tcg_ptr_byte_diff(target, src_rx); + if (in_range_b(disp)) { - *pc = (*pc & ~0x3fffffc) | (disp & 0x3fffffc); + *src_rw = (*src_rw & ~0x3fffffc) | (disp & 0x3fffffc); return true; } return false; } -static uint16_t reloc_pc14_val(tcg_insn_unit *pc, const tcg_insn_unit *target) +static uint16_t reloc_pc14_val(const tcg_insn_unit *pc, + const tcg_insn_unit *target) { ptrdiff_t disp = tcg_ptr_byte_diff(target, pc); tcg_debug_assert(disp == (int16_t) disp); return disp & 0xfffc; } -static bool reloc_pc14(tcg_insn_unit *pc, tcg_insn_unit *target) +static bool reloc_pc14(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t disp = tcg_ptr_byte_diff(target, pc); + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t disp = tcg_ptr_byte_diff(target, src_rx); + if (disp == (int16_t) disp) { - *pc = (*pc & ~0xfffc) | (disp & 0xfffc); + *src_rw = (*src_rw & ~0xfffc) | (disp & 0xfffc); return true; } return false; @@ -673,12 +677,12 @@ static const uint32_t tcg_to_isel[] = { static bool patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) { - tcg_insn_unit *target; + const tcg_insn_unit *target; int16_t lo; int32_t hi; value += addend; - target = (tcg_insn_unit *)value; + target = (const tcg_insn_unit *)value; switch (type) { case R_PPC_REL14: @@ -1544,7 +1548,7 @@ static void tcg_out_setcond(TCGContext *s, TCGType type, TCGCond cond, static void tcg_out_bc(TCGContext *s, int bc, TCGLabel *l) { if (l->has_value) { - bc |= reloc_pc14_val(s->code_ptr, l->u.value_ptr); + bc |= reloc_pc14_val(tcg_splitwx_to_rx(s->code_ptr), l->u.value_ptr); } else { tcg_out_reloc(s, s->code_ptr, R_PPC_REL14, l, 0); } @@ -1997,7 +2001,8 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, label->datahi_reg = datahi_reg; label->addrlo_reg = addrlo_reg; label->addrhi_reg = addrhi_reg; - label->raddr = raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr = (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] = lptr; } @@ -2007,7 +2012,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) MemOp opc = get_memop(oi); TCGReg hi, lo, arg = TCG_REG_R3; - if (!reloc_pc14(lb->label_ptr[0], s->code_ptr)) { + if (!reloc_pc14(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } @@ -2055,7 +2060,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) MemOp s_bits = opc & MO_SIZE; TCGReg hi, lo, arg = TCG_REG_R3; - if (!reloc_pc14(lb->label_ptr[0], s->code_ptr)) { + if (!reloc_pc14(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } @@ -2306,10 +2311,10 @@ static void tcg_target_qemu_prologue(TCGContext *s) int i; #ifdef _CALL_AIX - void **desc = (void **)s->code_ptr; - desc[0] = desc + 2; /* entry point */ - desc[1] = 0; /* environment pointer */ - s->code_ptr = (void *)(desc + 2); /* skip over descriptor */ + const void **desc = (const void **)s->code_ptr; + desc[0] = tcg_splitwx_to_rx(desc + 2); /* entry point */ + desc[1] = 0; /* environment pointer */ + s->code_ptr = (void *)(desc + 2); /* skip over descriptor */ #endif tcg_set_frame(s, TCG_REG_CALL_STACK, REG_SAVE_BOT - CPU_TEMP_BUF_SIZE, @@ -2341,7 +2346,8 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out32(s, BCCTR | BO_ALWAYS); /* Epilogue */ - tcg_code_gen_epilogue = tb_ret_addr = s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R0, TCG_REG_R1, FRAME_SIZE+LR_OFFSET); for (i = 0; i < ARRAY_SIZE(tcg_target_callee_save_regs); ++i) { @@ -2362,7 +2368,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, switch (opc) { case INDEX_op_exit_tb: tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R3, args[0]); - tcg_out_b(s, 0, tb_ret_addr); + tcg_out_b(s, 0, tcg_code_gen_epilogue); break; case INDEX_op_goto_tb: if (s->tb_jmp_insn_offset) { @@ -2410,7 +2416,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, uint32_t insn = B; if (l->has_value) { - insn |= reloc_pc24_val(s->code_ptr, l->u.value_ptr); + insn |= reloc_pc24_val(tcg_splitwx_to_rx(s->code_ptr), + l->u.value_ptr); } else { tcg_out_reloc(s, s->code_ptr, R_PPC_REL24, l, 0); } From patchwork Fri Nov 6 03:29:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885893 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 878E71130 for ; Fri, 6 Nov 2020 03:53:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2B6BD2075A for ; Fri, 6 Nov 2020 03:53:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="C7wrLVWz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B6BD2075A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:44564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasoH-0005KI-04 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:53:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasSL-0005ql-8t for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:29 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:33762) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasSD-000782-KG for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:28 -0500 Received: by mail-pg1-x542.google.com with SMTP id r186so2901134pgr.0 for ; Thu, 05 Nov 2020 19:30:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mZ7Cv5t9pDHcLwkTAHUkGoZLzbW+EIVJw5j5xRLRZ3w=; b=C7wrLVWzSbo5zuChMYXczJZR/AgSPwsJHXK7QHRq2zn7Ab29v5QwH2BZpzKDJ1eQLN PMCfsAwkdLKaIlkAUfO5CThmScXL+JYSOEJ7zz33fETJ+Rdi3H5/umeiJyLnrKcOLOCf IVyJk8n959I/lPmWrvn7/BZ/XUNOxsqgXXxTb/axVd9DzyiJ4a2AVVnU/exu6WW9RskQ o3hO+PhDc/l1ktCDe1slScCxjFAYscAbIJM+yB2BdQVXAmm+mFN4tcruZmkQkSJlXMQB zNg3OoRZGz915NAhcDKoKl4L/bm1sZ27GDRa6UyL98kPWouhxGCQ7F2+822kAztZjq8+ s9Vg== 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=mZ7Cv5t9pDHcLwkTAHUkGoZLzbW+EIVJw5j5xRLRZ3w=; b=D+EIbfyxiFEAOpQwDznrLLHnrhLE9c+jch5EqNKHNh2YGsb095yzu9HMt+zG8SlwWR G0p1/ZT28Ru+G+TLDdIvLgpxqnHv8ewZHcgitTL9tehb3DL+WguhWTQIjTlQPLphFGR1 7WMC45HdZ8dvB6yQxoyCVyNzxU0CnuK0xZxMDdpfpos0Gjf8QW3/zW7+XwyuIfAsltb8 PjkBzmIzSySN5VZYC7qvJ/Sgu9hIyF3jU1Sg3mTJ6I/RjRekxmqE3Vz8VElxtp4dd5gK tD79kCesSEgloKUF4pB4DCpL+3jpe85fBfN1ZMvA921eY8Ta6ODZ4P6MWHOOfD/gd40y DMiw== X-Gm-Message-State: AOAM5304A4q8sIAdngVmp9+/26t2unNMhkcWZgi/bnNSmg7AKuQ98Lb5 tRhasdV2kkoIkQDPDNqdq2VUJT0Ant8vPA== X-Google-Smtp-Source: ABdhPJyCTceehDjzGcLnoTEatk14hCxooiDUt5eFLqKs3bgZbDxZIy9Z0TO01RRbQKVG2FhFr9lFEw== X-Received: by 2002:a17:90b:19d6:: with SMTP id nm22mr142429pjb.159.1604633402203; Thu, 05 Nov 2020 19:30:02 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:30:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 28/41] tcg/sparc: Use tcg_tbrel_diff Date: Thu, 5 Nov 2020 19:29:08 -0800 Message-Id: <20201106032921.600200-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::542; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x542.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c.inc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index d599ae27b5..8f04fdf981 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -440,7 +440,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, /* A 13-bit constant relative to the TB. */ if (!in_prologue && USE_REG_TB) { - test = arg - (uintptr_t)s->code_gen_ptr; + test = tcg_tbrel_diff(s, (void *)arg); if (check_fit_ptr(test, 13)) { tcg_out_arithi(s, ret, TCG_REG_TB, test, ARITH_ADD); return; @@ -537,15 +537,15 @@ static inline bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, return false; } -static void tcg_out_ld_ptr(TCGContext *s, TCGReg ret, uintptr_t arg) +static void tcg_out_ld_ptr(TCGContext *s, TCGReg ret, const void *arg) { - intptr_t diff = arg - (uintptr_t)s->code_gen_ptr; + intptr_t diff = tcg_tbrel_diff(s, arg); if (USE_REG_TB && check_fit_ptr(diff, 13)) { tcg_out_ld(s, TCG_TYPE_PTR, ret, TCG_REG_TB, diff); return; } - tcg_out_movi(s, TCG_TYPE_PTR, ret, arg & ~0x3ff); - tcg_out_ld(s, TCG_TYPE_PTR, ret, ret, arg & 0x3ff); + tcg_out_movi(s, TCG_TYPE_PTR, ret, (uintptr_t)arg & ~0x3ff); + tcg_out_ld(s, TCG_TYPE_PTR, ret, ret, (uintptr_t)arg & 0x3ff); } static inline void tcg_out_sety(TCGContext *s, TCGReg rs) @@ -1313,7 +1313,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_movi_imm13(s, TCG_REG_O0, a0); break; } else if (USE_REG_TB) { - intptr_t tb_diff = a0 - (uintptr_t)s->code_gen_ptr; + intptr_t tb_diff = tcg_tbrel_diff(s, (void *)a0); if (check_fit_ptr(tb_diff, 13)) { tcg_out_arithi(s, TCG_REG_G0, TCG_REG_I7, 8, RETURN); /* Note that TCG_REG_TB has been unwound to O1. */ @@ -1345,8 +1345,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, } } else { /* indirect jump method */ - tcg_out_ld_ptr(s, TCG_REG_TB, - (uintptr_t)(s->tb_jmp_target_addr + a0)); + tcg_out_ld_ptr(s, TCG_REG_TB, s->tb_jmp_target_addr + a0); tcg_out_arithi(s, TCG_REG_G0, TCG_REG_TB, 0, JMPL); tcg_out_nop(s); } From patchwork Fri Nov 6 03:29:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885877 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A41C697 for ; Fri, 6 Nov 2020 03:47:42 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 097F420735 for ; Fri, 6 Nov 2020 03:47:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TyE0kEPg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 097F420735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:58086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasiy-0007aB-VP for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:47:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasSA-0005Wn-1k for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:19 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:38576) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasS5-000795-TU for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:17 -0500 Received: by mail-pl1-x62d.google.com with SMTP id f21so26467plr.5 for ; Thu, 05 Nov 2020 19:30:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jc6eykP6VpfCDyGHj3QveBxbyuogYi8aKD+vVVs4fs4=; b=TyE0kEPgtT1OOI3WZprO/Qa2EoxEkPjjAzrjAm+6PoxST2IF2Sax6ToQxVgDalj3mg WLEpcLNID+6qQdItWG3moDht+Mq5Bvxagro0Y5efVws9sCENEmTvUxdmFqHWP1RprM3K C0ghvOz1pK2WTm7Sp525TrxPt8KmWkTOuhOrIGDp7FPqFkqvf4vkRUH/YeWRW1NbTeCG ZuSLDGcpkDNdyTu59ARH80tO4n84qQGZEOO0dpcC9+2vnDnPxTF0d/Yrk0TnJs4W9KA/ O02alKD1EmjfW8BWhjaA+dc/xEqhLgJV7XkB3auKJn4EN8CqbocDieZJ9BuMVrM2XAQg WuIw== 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=jc6eykP6VpfCDyGHj3QveBxbyuogYi8aKD+vVVs4fs4=; b=IoBzeiHmvJjSTC4RgNRlqiSvHY2O8JRElp4Np5mQjJrHK3X4QPuQVwNtHB1WAHCExq 9akW0n0Hk5phf9MfAWznVRtHe+pRkS2hWvIyS25kmDIHuzR2RmC8J93NIXVwyCuY0J2Q zlbXBrP9Tf6P+Y8gxSvygNZShcPqYkih0BR/55gzL623kAWtfsNT/RSSakeKrYiMs4KD xbB6jLu39YdjbgXehR1ziJUo5wyxQ7bR2VZ6mR+PoviE0R8FSph7s4CZAlgGJMB6eXcb Bk6Yr0ChKlfaXjyOS8W/j+EcJV4vl4E3FpUKFOBxWg0W3mA5viHmZdG6Cm+PO1e6QgYk B7LQ== X-Gm-Message-State: AOAM533RnF3+M+cFEckIsAl1287oqUndJm7tsSiJknSLlHNAUNHwv57J 2KM3EtxHT1TqMzy0ar7rRxN5gmidY9uIXA== X-Google-Smtp-Source: ABdhPJw+LyjkJbsodJMtWF/4WUteRHfjLTm2EvNhTKLG7C4U3e79rxVcxLCUdKYFr8f9ijgbV/HWAQ== X-Received: by 2002:a17:902:7c8c:b029:d4:e5b2:fba4 with SMTP id y12-20020a1709027c8cb02900d4e5b2fba4mr34375pll.82.1604633403573; Thu, 05 Nov 2020 19:30:03 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:30:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 29/41] tcg/sparc: Support split-wx code generation Date: Thu, 5 Nov 2020 19:29:09 -0800 Message-Id: <20201106032921.600200-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.h | 2 +- tcg/sparc/tcg-target.c.inc | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h index 517840705f..bb2505bfc7 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -181,6 +181,6 @@ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 #endif diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 8f04fdf981..182124b96c 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -291,14 +291,15 @@ static inline int check_fit_i32(int32_t val, unsigned int bits) # define check_fit_ptr check_fit_i32 #endif -static bool patch_reloc(tcg_insn_unit *code_ptr, int type, +static bool patch_reloc(tcg_insn_unit *src_rw, int type, intptr_t value, intptr_t addend) { - uint32_t insn = *code_ptr; + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + uint32_t insn = *src_rw; intptr_t pcrel; value += addend; - pcrel = tcg_ptr_byte_diff((tcg_insn_unit *)value, code_ptr); + pcrel = tcg_ptr_byte_diff((tcg_insn_unit *)value, src_rx); switch (type) { case R_SPARC_WDISP16: @@ -315,7 +316,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, g_assert_not_reached(); } - *code_ptr = insn; + *src_rw = insn; return true; } @@ -868,8 +869,8 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) } #ifdef CONFIG_SOFTMMU -static tcg_insn_unit *qemu_ld_trampoline[16]; -static tcg_insn_unit *qemu_st_trampoline[16]; +static const tcg_insn_unit *qemu_ld_trampoline[16]; +static const tcg_insn_unit *qemu_st_trampoline[16]; static void emit_extend(TCGContext *s, TCGReg r, int op) { @@ -930,7 +931,7 @@ static void build_trampolines(TCGContext *s) while ((uintptr_t)s->code_ptr & 15) { tcg_out_nop(s); } - qemu_ld_trampoline[i] = s->code_ptr; + qemu_ld_trampoline[i] = tcg_splitwx_to_rx(s->code_ptr); if (SPARC64 || TARGET_LONG_BITS == 32) { ra = TCG_REG_O3; @@ -958,7 +959,7 @@ static void build_trampolines(TCGContext *s) while ((uintptr_t)s->code_ptr & 15) { tcg_out_nop(s); } - qemu_st_trampoline[i] = s->code_ptr; + qemu_st_trampoline[i] = tcg_splitwx_to_rx(s->code_ptr); if (SPARC64) { emit_extend(s, TCG_REG_O2, i); @@ -1038,7 +1039,8 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_nop(s); /* Epilogue for goto_ptr. */ - tcg_code_gen_epilogue = s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_arithi(s, TCG_REG_G0, TCG_REG_I7, 8, RETURN); /* delay slot */ tcg_out_movi_imm13(s, TCG_REG_O0, 0); @@ -1163,7 +1165,7 @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg data, TCGReg addr, #ifdef CONFIG_SOFTMMU unsigned memi = get_mmuidx(oi); TCGReg addrz, param; - tcg_insn_unit *func; + const tcg_insn_unit *func; tcg_insn_unit *label_ptr; addrz = tcg_out_tlb_load(s, addr, memi, memop, @@ -1245,7 +1247,7 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg data, TCGReg addr, #ifdef CONFIG_SOFTMMU unsigned memi = get_mmuidx(oi); TCGReg addrz, param; - tcg_insn_unit *func; + const tcg_insn_unit *func; tcg_insn_unit *label_ptr; addrz = tcg_out_tlb_load(s, addr, memi, memop, From patchwork Fri Nov 6 03:29:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885847 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1FDD16A2 for ; Fri, 6 Nov 2020 03:39:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ADCFB20729 for ; Fri, 6 Nov 2020 03:39:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="O0+Fw83d" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ADCFB20729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:55146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasak-00039o-KY for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:39:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasSP-0005vn-2u for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:33 -0500 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:34520) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasSD-0007B3-5c for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:32 -0500 Received: by mail-pl1-x643.google.com with SMTP id p4so33863plr.1 for ; Thu, 05 Nov 2020 19:30:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wkypnopb5BzPYlv4jtMpd96OEpFhEMM9GKjZQ7ld/TU=; b=O0+Fw83dySV1vv5sKmEmGRTkh9KTnXeaOSaE9o7KHj9Vll2Ncx89JRC8e9Spga/P3T oSCj0hy5nxkgsmaavoDExjnUECniawcu5PPGaBie9i+/Wye+kW1UhCvhMBkn+T2HvsGt Ea4wCke+RUghjwPQGISCyC6GKMxleU8rtRwYchZ298LMw4zeeCv4uUD6bYXg0PCfZHgl 61XM4eT9L4HPzFWEaaKeDcQrdCArai1gCzQmSHCqIriA4fLHiJsuO1sUkf8oBYBynrUx xZ8QnbVdmJ3kOuT6l+KL2fIQVZJKNls3EUu3VDR0SRMdQB2SIG7EevzFtd0KaHTNJjLK egfw== 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=wkypnopb5BzPYlv4jtMpd96OEpFhEMM9GKjZQ7ld/TU=; b=U/JlFWRy/g0Vwt9fiNxelm4OmCj8bJR7/ADzgLb6juigtSFhOmYCW9pRng6rUA4ib6 RQ8MyQuRwX1RMZk7G345sD+6NddUlbxnCBnCTuZsvVbWPcUy+mQQnhtDoaaEmnoHhjTw 5yKhxq9MwmFFHVtdW55QdqCDzcCjf9NvFAo0DVg9YoRn36PrHHMdH0EhmavxEF4cC6Li oM9Qdm1piCcqUJVUr4FwDRCydqeZuMXF5o/csGlXzKKB2eB+21aW4tpQ/Z5tSBohqMon 3tApYnnKWLfqqZfJ14V+D2amwmZrFFH+BVyCVmlKaCfkBmaA/oTlGuPxdwcNkwVRnfMj Xv5A== X-Gm-Message-State: AOAM533wXtyVmvutklP2e2GV4PCekUlLwOmmq4AHrvXFWcPINRgg3Tjf Qa2+FZ57k1pacPU4r7sbcCeJeNOf8cmuUg== X-Google-Smtp-Source: ABdhPJxv7hM+aqOFg8iuiXoYaMaQeGjWGwqd68iHyYe0siQ6RIiECmVR2xg1ragAD2Qu0B1Z1edFhA== X-Received: by 2002:a17:902:b604:b029:d5:d9d6:1938 with SMTP id b4-20020a170902b604b02900d5d9d61938mr123740pls.52.1604633405383; Thu, 05 Nov 2020 19:30:05 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:30:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 30/41] tcg/s390: Use tcg_tbrel_diff Date: Thu, 5 Nov 2020 19:29:10 -0800 Message-Id: <20201106032921.600200-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::643; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x643.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Use tcg_tbrel_diff when we need a displacement to a label, and with a NULL argument when we need the normalizing addend. Signed-off-by: Richard Henderson --- tcg/s390/tcg-target.c.inc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index 1444914428..e4c61fc014 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -630,7 +630,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, return; } } else if (USE_REG_TB && !in_prologue) { - ptrdiff_t off = sval - (uintptr_t)s->code_gen_ptr; + ptrdiff_t off = tcg_tbrel_diff(s, (void *)sval); if (off == sextract64(off, 0, 20)) { /* This is certain to be an address within TB, and therefore OFF will be negative; don't try RX_LA. */ @@ -655,7 +655,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, } else if (USE_REG_TB && !in_prologue) { tcg_out_insn(s, RXY, LG, ret, TCG_REG_TB, TCG_REG_NONE, 0); new_pool_label(s, sval, R_390_20, s->code_ptr - 2, - -(intptr_t)s->code_gen_ptr); + tcg_tbrel_diff(s, NULL)); } else { TCGReg base = ret ? ret : TCG_TMP0; tcg_out_insn(s, RIL, LARL, base, 0); @@ -746,7 +746,7 @@ static void tcg_out_ld_abs(TCGContext *s, TCGType type, TCGReg dest, void *abs) } } if (USE_REG_TB) { - ptrdiff_t disp = abs - (void *)s->code_gen_ptr; + ptrdiff_t disp = tcg_tbrel_diff(s, abs); if (disp == sextract64(disp, 0, 20)) { tcg_out_ld(s, type, dest, TCG_REG_TB, disp); return; @@ -956,7 +956,7 @@ static void tgen_andi(TCGContext *s, TCGType type, TCGReg dest, uint64_t val) if (!maybe_out_small_movi(s, type, TCG_TMP0, val)) { tcg_out_insn(s, RXY, NG, dest, TCG_REG_TB, TCG_REG_NONE, 0); new_pool_label(s, val & valid, R_390_20, s->code_ptr - 2, - -(intptr_t)s->code_gen_ptr); + tcg_tbrel_diff(s, NULL)); return; } } else { @@ -1015,7 +1015,7 @@ static void tgen_ori(TCGContext *s, TCGType type, TCGReg dest, uint64_t val) } else if (USE_REG_TB) { tcg_out_insn(s, RXY, OG, dest, TCG_REG_TB, TCG_REG_NONE, 0); new_pool_label(s, val, R_390_20, s->code_ptr - 2, - -(intptr_t)s->code_gen_ptr); + tcg_tbrel_diff(s, NULL)); } else { /* Perform the OR via sequential modifications to the high and low parts. Do this via recursion to handle 16-bit vs 32-bit @@ -1050,7 +1050,7 @@ static void tgen_xori(TCGContext *s, TCGType type, TCGReg dest, uint64_t val) } else if (USE_REG_TB) { tcg_out_insn(s, RXY, XG, dest, TCG_REG_TB, TCG_REG_NONE, 0); new_pool_label(s, val, R_390_20, s->code_ptr - 2, - -(intptr_t)s->code_gen_ptr); + tcg_tbrel_diff(s, NULL)); } else { /* Perform the xor by parts. */ tcg_debug_assert(s390_facilities & FACILITY_EXT_IMM); @@ -1108,12 +1108,12 @@ static int tgen_cmp(TCGContext *s, TCGType type, TCGCond c, TCGReg r1, op = (is_unsigned ? RXY_CLY : RXY_CY); tcg_out_insn_RXY(s, op, r1, TCG_REG_TB, TCG_REG_NONE, 0); new_pool_label(s, (uint32_t)c2, R_390_20, s->code_ptr - 2, - 4 - (intptr_t)s->code_gen_ptr); + 4 - tcg_tbrel_diff(s, NULL)); } else { op = (is_unsigned ? RXY_CLG : RXY_CG); tcg_out_insn_RXY(s, op, r1, TCG_REG_TB, TCG_REG_NONE, 0); new_pool_label(s, c2, R_390_20, s->code_ptr - 2, - -(intptr_t)s->code_gen_ptr); + tcg_tbrel_diff(s, NULL)); } goto exit; } else { From patchwork Fri Nov 6 03:29:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885887 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A640E1130 for ; Fri, 6 Nov 2020 03:50:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4B77C20735 for ; Fri, 6 Nov 2020 03:50:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GiHR9fUR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4B77C20735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaslW-0001q0-8r for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:50:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasSH-0005go-5R for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:25 -0500 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:39738) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasSC-0007CG-Uq for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:24 -0500 Received: by mail-pf1-x435.google.com with SMTP id z3so46255pfz.6 for ; Thu, 05 Nov 2020 19:30:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aArTyFb7Ktq31UPOCddipIoQqJqHp+0fJTTegnZpRQ8=; b=GiHR9fURSlcdPxqERsGOqa9+NQjIirDf8iD08SgqCBNvJ6h7mOA/GQ9FGleeAVuBEu Bodn2ewrKJXFlxhENZLpnNfFNzziMu9vOVXRt4R8D7YfJYJ3TyGiqPjpJzko26sf1CR7 K5SWJRzeQORR1iFmaNstE871LrzyR/qN/kuSdN5U+1b6x+lVOOWJ4q16FNKIyjJc0N6h tXJwWXqkjFyAbYaOgVN6RMMgtRCo7Yh0g+SWpXncLFysCokNev6Q809IEPJz36L832OU 4Yo6DM3/Y4jEMNnXrUArNUgE4/gY0XoFrqtSgrKwRcKGYnz9crUB0kqXfvJXbl+dF1SO mScg== 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=aArTyFb7Ktq31UPOCddipIoQqJqHp+0fJTTegnZpRQ8=; b=LaruWT5EMptYkDaBNXj5KlJThSqUj8JYleFiYvXzPDnNWnQPoY3B+ZFbBWHKV8Am5W oOM6nofhOJrpdaa7ntB0n02IFFuQ7WNgkdai6J5Q6Im3NMHwJo858vYZSjQXqQ09lZDT aF5BKopUSTjbYdxBAXQg2zWoMNeZahMa7dlIK4zfmzLKS8CrgkktHajOZee7iZuyF1xa aj6RQjVZvfUU5mjWAVDhVDjJ6u/kqeZbn5Cn72Y/cu8yfdBexALQ/QHq1XT4e5YLmZU/ pnXJye/u1nSVlAJNxXAA8SaYIoBnhR/Xqm7T6CzxO3OHacS4YTXgsIySNbkfWXx5QVjq 2tJw== X-Gm-Message-State: AOAM530GkxfloNWk3mdSdHKRYzC6RAf+upGEAJLbQOY+DuZLrDNoC3BD pYMPXF7S+88t/M66E9FNhg54XGzf+7RqRg== X-Google-Smtp-Source: ABdhPJxkSkH+0OlN7DO+Cs103Vp/eys3x10LZxz2ubmOzH3T/Z1KRIcrlCo53usWyrQxYKmPvwiVqQ== X-Received: by 2002:a05:6a00:1389:b029:18b:2d21:2f1a with SMTP id t9-20020a056a001389b029018b2d212f1amr117500pfg.1.1604633406665; Thu, 05 Nov 2020 19:30:06 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:30:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 31/41] tcg/s390: Support split-wx code generation Date: Thu, 5 Nov 2020 19:29:11 -0800 Message-Id: <20201106032921.600200-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/s390/tcg-target.h | 2 +- tcg/s390/tcg-target.c.inc | 69 +++++++++++++++++---------------------- 2 files changed, 31 insertions(+), 40 deletions(-) diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h index 8324197127..1fd8b3858e 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -163,6 +163,6 @@ static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 #endif diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index e4c61fc014..582a8ef941 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -363,36 +363,37 @@ static void * const qemu_st_helpers[16] = { }; #endif -static tcg_insn_unit *tb_ret_addr; +static const tcg_insn_unit *tb_ret_addr; uint64_t s390_facilities; -static bool patch_reloc(tcg_insn_unit *code_ptr, int type, +static bool patch_reloc(tcg_insn_unit *src_rw, int type, intptr_t value, intptr_t addend) { + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); intptr_t pcrel2; uint32_t old; value += addend; - pcrel2 = (tcg_insn_unit *)value - code_ptr; + pcrel2 = (tcg_insn_unit *)value - src_rx; switch (type) { case R_390_PC16DBL: if (pcrel2 == (int16_t)pcrel2) { - tcg_patch16(code_ptr, pcrel2); + tcg_patch16(src_rw, pcrel2); return true; } break; case R_390_PC32DBL: if (pcrel2 == (int32_t)pcrel2) { - tcg_patch32(code_ptr, pcrel2); + tcg_patch32(src_rw, pcrel2); return true; } break; case R_390_20: if (value == sextract64(value, 0, 20)) { - old = *(uint32_t *)code_ptr & 0xf00000ff; + old = *(uint32_t *)src_rw & 0xf00000ff; old |= ((value & 0xfff) << 16) | ((value & 0xff000) >> 4); - tcg_patch32(code_ptr, old); + tcg_patch32(src_rw, old); return true; } break; @@ -730,7 +731,8 @@ static inline bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, } /* load data from an absolute host address */ -static void tcg_out_ld_abs(TCGContext *s, TCGType type, TCGReg dest, void *abs) +static void tcg_out_ld_abs(TCGContext *s, TCGType type, + TCGReg dest, const void *abs) { intptr_t addr = (intptr_t)abs; @@ -1304,7 +1306,7 @@ static void tgen_extract(TCGContext *s, TCGReg dest, TCGReg src, static void tgen_gotoi(TCGContext *s, int cc, const tcg_insn_unit *dest) { - ptrdiff_t off = dest - s->code_ptr; + ptrdiff_t off = tcg_pcrel_diff(s, dest) >> 1; if (off == (int16_t)off) { tcg_out_insn(s, RI, BRC, cc, off); } else if (off == (int32_t)off) { @@ -1333,34 +1335,18 @@ static void tgen_branch(TCGContext *s, int cc, TCGLabel *l) static void tgen_compare_branch(TCGContext *s, S390Opcode opc, int cc, TCGReg r1, TCGReg r2, TCGLabel *l) { - intptr_t off = 0; - - if (l->has_value) { - off = l->u.value_ptr - s->code_ptr; - tcg_debug_assert(off == (int16_t)off); - } else { - tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, l, 2); - } - + tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, l, 2); tcg_out16(s, (opc & 0xff00) | (r1 << 4) | r2); - tcg_out16(s, off); + tcg_out16(s, 0); tcg_out16(s, cc << 12 | (opc & 0xff)); } static void tgen_compare_imm_branch(TCGContext *s, S390Opcode opc, int cc, TCGReg r1, int i2, TCGLabel *l) { - tcg_target_long off = 0; - - if (l->has_value) { - off = l->u.value_ptr - s->code_ptr; - tcg_debug_assert(off == (int16_t)off); - } else { - tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, l, 2); - } - + tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, l, 2); tcg_out16(s, (opc & 0xff00) | (r1 << 4) | cc); - tcg_out16(s, off); + tcg_out16(s, 0); tcg_out16(s, (i2 << 8) | (opc & 0xff)); } @@ -1417,7 +1403,7 @@ static void tgen_brcond(TCGContext *s, TCGType type, TCGCond c, static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest) { - ptrdiff_t off = dest - s->code_ptr; + ptrdiff_t off = tcg_pcrel_diff(s, dest) >> 1; if (off == (int32_t)off) { tcg_out_insn(s, RIL, BRASL, TCG_REG_R14, off); } else { @@ -1601,7 +1587,8 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, label->oi = oi; label->datalo_reg = data; label->addrlo_reg = addr; - label->raddr = raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr = (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr; } @@ -1613,7 +1600,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) MemOp opc = get_memop(oi); if (!patch_reloc(lb->label_ptr[0], R_390_PC16DBL, - (intptr_t)s->code_ptr, 2)) { + (intptr_t)tcg_splitwx_to_rx(s->code_ptr), 2)) { return false; } @@ -1638,7 +1625,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) MemOp opc = get_memop(oi); if (!patch_reloc(lb->label_ptr[0], R_390_PC16DBL, - (intptr_t)s->code_ptr, 2)) { + (intptr_t)tcg_splitwx_to_rx(s->code_ptr), 2)) { return false; } @@ -1766,7 +1753,8 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_goto_tb: a0 = args[0]; if (s->tb_jmp_insn_offset) { - /* branch displacement must be aligned for atomic patching; + /* + * branch displacement must be aligned for atomic patching; * see if we need to add extra nop before branch */ if (!QEMU_PTR_IS_ALIGNED(s->code_ptr + 1, 4)) { @@ -1779,7 +1767,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, } else { /* load address stored at s->tb_jmp_target_addr + a0 */ tcg_out_ld_abs(s, TCG_TYPE_PTR, TCG_REG_TB, - s->tb_jmp_target_addr + a0); + tcg_splitwx_to_rx(s->tb_jmp_target_addr + a0)); /* and go there */ tcg_out_insn(s, RR, BCR, S390_CC_ALWAYS, TCG_REG_TB); } @@ -1789,8 +1777,10 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, TCG_REG_TB to the beginning of this TB. */ if (USE_REG_TB) { int ofs = -tcg_current_code_size(s); - assert(ofs == (int16_t)ofs); - tcg_out_insn(s, RI, AGHI, TCG_REG_TB, ofs); + /* All TB are restricted to 64KiB by unwind info. */ + tcg_debug_assert(ofs == sextract64(ofs, 0, 20)); + tcg_out_insn(s, RXY, LAY, TCG_REG_TB, + TCG_REG_TB, TCG_REG_NONE, ofs); } break; @@ -2561,11 +2551,12 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - tcg_code_gen_epilogue = s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R2, 0); /* TB epilogue */ - tb_ret_addr = s->code_ptr; + tb_ret_addr = tcg_splitwx_to_rx(s->code_ptr); /* lmg %r6,%r15,fs+48(%r15) (restore registers) */ tcg_out_insn(s, RXY, LMG, TCG_REG_R6, TCG_REG_R15, TCG_REG_R15, From patchwork Fri Nov 6 03:29:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885875 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E020C697 for ; Fri, 6 Nov 2020 03:46:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 73D6020735 for ; Fri, 6 Nov 2020 03:46:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AvQTND5a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73D6020735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:55194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasiB-0006Q2-FN for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:46:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasSE-0005f2-UU for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:22 -0500 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:37255) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasSC-0007D0-7f for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:22 -0500 Received: by mail-pl1-x643.google.com with SMTP id b12so27295plr.4 for ; Thu, 05 Nov 2020 19:30:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cOhvs0ghq8muGX3iEeRtFXrjJiLy3u5yfl5gf+ftseU=; b=AvQTND5azXdlgOoPmrY31+7AmHD68NiGIyZQgKjqvWWgpHgP0f0RI7osvKzOW0CjsG f5zk+kp7LDbMDJHpVNVrHnCpBuatpRjAXgSG5V216x8NjAQAzlufKjYxwTYfnuffhZ3f AotgP2Miv0ARh8Y1WlbEw/FLrSamV2EIpnibq/9LfGFpaM1c/ZAWsgk6P2HRS36NO6Ba jmSi+obGeWixJ01EtAewe0jX/78znceIIRJx1aerclDlkczaJZXxBOYveU099H1JD/7j W9Ovk3N/aYUtu2sjF1aeTl6BwXC0SQ/aoA9+THxCDq4DPwsPnf7Zdqrux3HmQh6xESfK LtdA== 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=cOhvs0ghq8muGX3iEeRtFXrjJiLy3u5yfl5gf+ftseU=; b=E97VyvN/cGt/HRYFIfPANH2ZEgQ5m21YW7yP2ZQmbc505FGmZ44zyNVUm3VL6a/hPL WBQsbmJRzsEr78mef4LyoOOJuC9QqHLSg/r7XaYweJ2d02cBfZ2pKuH2Xy2x5L6P8cF4 96609QoE4K98vMePhlRs6ouB5UcDmDb1GQleoqM47QXEvq893MYiBAMsuYt5io1SkTZV jZ/nuRyy/bmDiNpXR6eZdqnbW+ElTHkhjGVpMie/k31Cy2vx5ZfjudnRFLc4bEwuOFi0 PEWWC/RNHCI6siuZs6v6MvvC5DhC3jD2jyoCuJZk+NuL7sVUO+R3+4ddTvOsOpp1kwS8 R6Lw== X-Gm-Message-State: AOAM531tCOBwzojXRsyr7USItiFeutxqd7pfdaHmwhlTo/IWU0sEyboq 0YdfdRNVR+ibdvSclc7CO1Pf5nOQvgn4JA== X-Google-Smtp-Source: ABdhPJyjSuBRgtQT6+VRgJh6kXWkvQHAQ5ByhNICn3KvUuGKeW8uLEBB5PrHJWBg2cTlxoglVLu5mQ== X-Received: by 2002:a17:902:ab89:b029:d5:b297:2cc1 with SMTP id f9-20020a170902ab89b02900d5b2972cc1mr121527plr.7.1604633408196; Thu, 05 Nov 2020 19:30:08 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.30.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:30:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 32/41] tcg/riscv: Fix branch range checks Date: Thu, 5 Nov 2020 19:29:12 -0800 Message-Id: <20201106032921.600200-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::643; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x643.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The offset even checks were folded into the range check incorrectly. By offsetting by 1, and not decrementing the width, we silently allowed out of range branches. Assert that the offset is always even instead. Move tcg_out_goto down into the CONFIG_SOFTMMU block so that it is not unused. Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.c.inc | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 025e3cd0bb..195c3eff03 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -429,7 +429,8 @@ static bool reloc_sbimm12(tcg_insn_unit *code_ptr, tcg_insn_unit *target) { intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; - if (offset == sextreg(offset, 1, 12) << 1) { + tcg_debug_assert((offset & 1) == 0); + if (offset == sextreg(offset, 0, 12)) { code_ptr[0] |= encode_sbimm12(offset); return true; } @@ -441,7 +442,8 @@ static bool reloc_jimm20(tcg_insn_unit *code_ptr, tcg_insn_unit *target) { intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; - if (offset == sextreg(offset, 1, 20) << 1) { + tcg_debug_assert((offset & 1) == 0); + if (offset == sextreg(offset, 0, 20)) { code_ptr[0] |= encode_ujimm20(offset); return true; } @@ -854,28 +856,21 @@ static void tcg_out_setcond2(TCGContext *s, TCGCond cond, TCGReg ret, g_assert_not_reached(); } -static inline void tcg_out_goto(TCGContext *s, tcg_insn_unit *target) -{ - ptrdiff_t offset = tcg_pcrel_diff(s, target); - tcg_debug_assert(offset == sextreg(offset, 1, 20) << 1); - tcg_out_opc_jump(s, OPC_JAL, TCG_REG_ZERO, offset); -} - static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool tail) { TCGReg link = tail ? TCG_REG_ZERO : TCG_REG_RA; ptrdiff_t offset = tcg_pcrel_diff(s, arg); int ret; - if (offset == sextreg(offset, 1, 20) << 1) { + tcg_debug_assert((offset & 1) == 0); + if (offset == sextreg(offset, 0, 20)) { /* short jump: -2097150 to 2097152 */ tcg_out_opc_jump(s, OPC_JAL, link, offset); - } else if (TCG_TARGET_REG_BITS == 32 || - offset == sextreg(offset, 1, 31) << 1) { + } else if (TCG_TARGET_REG_BITS == 32 || offset == (int32_t)offset) { /* long jump: -2147483646 to 2147483648 */ tcg_out_opc_upper(s, OPC_AUIPC, TCG_REG_TMP0, 0); tcg_out_opc_imm(s, OPC_JALR, link, TCG_REG_TMP0, 0); - ret = reloc_call(s->code_ptr - 2, arg);\ + ret = reloc_call(s->code_ptr - 2, arg); tcg_debug_assert(ret == true); } else if (TCG_TARGET_REG_BITS == 64) { /* far jump: 64-bit */ @@ -962,6 +957,13 @@ QEMU_BUILD_BUG_ON(TCG_TARGET_REG_BITS < TARGET_LONG_BITS); QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) > 0); QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) < -(1 << 11)); +static void tcg_out_goto(TCGContext *s, tcg_insn_unit *target) +{ + tcg_out_opc_jump(s, OPC_JAL, TCG_REG_ZERO, 0); + bool ok = reloc_jimm20(s->code_ptr - 1, target); + tcg_debug_assert(ok); +} + static void tcg_out_tlb_load(TCGContext *s, TCGReg addrl, TCGReg addrh, TCGMemOpIdx oi, tcg_insn_unit **label_ptr, bool is_load) From patchwork Fri Nov 6 03:29:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885839 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19BB46A2 for ; Fri, 6 Nov 2020 03:37:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AA3EF20729 for ; Fri, 6 Nov 2020 03:37:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="tcTpOl35" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA3EF20729 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasZT-0008F9-L1 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:37:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasSK-0005pL-Lf for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:28 -0500 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:37594) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasSC-0007Dj-NX for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:28 -0500 Received: by mail-pf1-x441.google.com with SMTP id 13so53329pfy.4 for ; Thu, 05 Nov 2020 19:30:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LiVRLDdLRLwNh3EAfOwsqGZsrXFOtm3LiOx00UdIraE=; b=tcTpOl35MRMenBDQkroMiOrRPcQ6qceMjXWca0iYK4BIhZmRmUrP8nIcZG4dmxKycs GugXJOEn0a+xOEVnILgLEQ7KRBxhusgEr5l9lxkdueh7/CyDfWk3jEroSXsxgHgyPAsD C16goSeskUZOQDsQ25y2Mr91ykRSpv7zVEF6/HK8t5JXdeAJU2NiADJHEO0L+6RRZxab qwhwcQa/+Yu55WMj+xXPtPnn4FwhjxE1Q55/OlBHr/D8Ni8worQR5fm7Hfd3A9u0LWw/ 9UODj+w8buq2XD4dnU11qZAhUrfRI+Lvct5G4qdgdUV7XgzrXIbs4FdYKEHKHpUCfkGb MzeQ== 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=LiVRLDdLRLwNh3EAfOwsqGZsrXFOtm3LiOx00UdIraE=; b=sNkIalUcgakOG44XplLEt2BytRkKXwH46oC3EmDtDxbKX8w8eUFN6XYoE2rLODL9j4 OF8oa+FFQypOIYjRnl1Ww6U2+eVOv/oYpimAajOzvWiEzU7JoYej5yNdfDymS0Am6tnN wwYhjcLTUbx6n5ndyfQ1xFhGufDZpKFX7p7ku+3v8zc4hV1cZcD43A/iy9UUZkey8uWg UlTTeVp+oGgJbC9i8NsTY4X0sCe4ul9+UfifZP20DMlAa/2BFtTCMwZF18vTOVzbOM6O kouU5cYKU4gY9D8HVcrhQdJq/Kn68A/9VDt/sYFEQD+S7HQz156NVqWmj5FmRHpNgvFp 5XUQ== X-Gm-Message-State: AOAM53003nOOiuKpHGSZO3Lp9lYtNpn8nlcupjtn2bqs6ZjjclsPWwx+ 57AUgLC0l4THQcTx7LDTKZMwZbfJgyl/Gw== X-Google-Smtp-Source: ABdhPJz07sfqL3/tvzipxS1AKbfibmdlgwErkVdnQEUQ4Uv9hAI1TJo9OE5USOBeR+sBglGFP1ky0w== X-Received: by 2002:a17:90a:17ad:: with SMTP id q42mr189826pja.36.1604633409703; Thu, 05 Nov 2020 19:30:09 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.30.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:30:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 33/41] tcg/riscv: Remove branch-over-branch fallback Date: Thu, 5 Nov 2020 19:29:13 -0800 Message-Id: <20201106032921.600200-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Since 7ecd02a06f8, we are prepared to re-start code generation with a smaller TB if a relocation is out of range. We no longer need to leave a nop in the stream Just In Case. Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.c.inc | 56 ++++---------------------------------- 1 file changed, 6 insertions(+), 50 deletions(-) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 195c3eff03..02beb86977 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -469,43 +469,16 @@ static bool reloc_call(tcg_insn_unit *code_ptr, const tcg_insn_unit *target) static bool patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) { - uint32_t insn = *code_ptr; - intptr_t diff; - bool short_jmp; - tcg_debug_assert(addend == 0); - switch (type) { case R_RISCV_BRANCH: - diff = value - (uintptr_t)code_ptr; - short_jmp = diff == sextreg(diff, 0, 12); - if (short_jmp) { - return reloc_sbimm12(code_ptr, (tcg_insn_unit *)value); - } else { - /* Invert the condition */ - insn = insn ^ (1 << 12); - /* Clear the offset */ - insn &= 0x01fff07f; - /* Set the offset to the PC + 8 */ - insn |= encode_sbimm12(8); - - /* Move forward */ - code_ptr[0] = insn; - - /* Overwrite the NOP with jal x0,value */ - diff = value - (uintptr_t)(code_ptr + 1); - insn = encode_uj(OPC_JAL, TCG_REG_ZERO, diff); - code_ptr[1] = insn; - - return true; - } - break; + return reloc_sbimm12(code_ptr, (tcg_insn_unit *)value); case R_RISCV_JAL: return reloc_jimm20(code_ptr, (tcg_insn_unit *)value); case R_RISCV_CALL: return reloc_call(code_ptr, (tcg_insn_unit *)value); default: - tcg_abort(); + g_assert_not_reached(); } } @@ -779,21 +752,8 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGReg arg1, arg2 = t; } - if (l->has_value) { - intptr_t diff = tcg_pcrel_diff(s, l->u.value_ptr); - if (diff == sextreg(diff, 0, 12)) { - tcg_out_opc_branch(s, op, arg1, arg2, diff); - } else { - /* Invert the conditional branch. */ - tcg_out_opc_branch(s, op ^ (1 << 12), arg1, arg2, 8); - tcg_out_opc_jump(s, OPC_JAL, TCG_REG_ZERO, diff - 4); - } - } else { - tcg_out_reloc(s, s->code_ptr, R_RISCV_BRANCH, l, 0); - tcg_out_opc_branch(s, op, arg1, arg2, 0); - /* NOP to allow patching later */ - tcg_out_opc_imm(s, OPC_ADDI, TCG_REG_ZERO, TCG_REG_ZERO, 0); - } + tcg_out_reloc(s, s->code_ptr, R_RISCV_BRANCH, l, 0); + tcg_out_opc_branch(s, op, arg1, arg2, 0); } static void tcg_out_setcond(TCGContext *s, TCGCond cond, TCGReg ret, @@ -1009,8 +969,6 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg addrl, /* Compare masked address with the TLB entry. */ label_ptr[0] = s->code_ptr; tcg_out_opc_branch(s, OPC_BNE, TCG_REG_TMP0, TCG_REG_TMP1, 0); - /* NOP to allow patching later */ - tcg_out_opc_imm(s, OPC_ADDI, TCG_REG_ZERO, TCG_REG_ZERO, 0); /* TLB Hit - translate address using addend. */ if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { @@ -1054,8 +1012,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) } /* resolve label address */ - if (!patch_reloc(l->label_ptr[0], R_RISCV_BRANCH, - (intptr_t) s->code_ptr, 0)) { + if (!reloc_sbimm12(l->label_ptr[0], s->code_ptr)) { return false; } @@ -1089,8 +1046,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) } /* resolve label address */ - if (!patch_reloc(l->label_ptr[0], R_RISCV_BRANCH, - (intptr_t) s->code_ptr, 0)) { + if (!reloc_sbimm12(l->label_ptr[0], s->code_ptr)) { return false; } From patchwork Fri Nov 6 03:29:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885897 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45D701130 for ; Fri, 6 Nov 2020 03:55:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D3DCA20756 for ; Fri, 6 Nov 2020 03:55:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hWfZw76t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3DCA20756 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasqG-00075u-Oe for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:55:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasSM-0005tm-Mt for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:30 -0500 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:46562) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasSC-0007ED-Vm for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:30 -0500 Received: by mail-pg1-x541.google.com with SMTP id w4so2858770pgg.13 for ; Thu, 05 Nov 2020 19:30:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X069CiQ8RfhdePwhlJh4L+vOpoRIhJZjo/+F//DMvos=; b=hWfZw76tIAopRt9JUUbxhcXJJAXWvF265V5ztFcYBz/B0G5dw0hCti5EyxYA8ipGKS WIyY9hDDSs4GDP1xAECR+P9T6qA935U3ZjFaqG2ITyrjT2MmrX6HERdon/7ZeLLqUVeb jLUrJ6mO8OcONSVS+euwjko/N9SUhsuaJBkZOsBk0coag/rkHxod2bcrPsnvX+URAejs NBsUk9pbtAJIfoJgPoEsransOcxUB558okPrVhYtxBLGrqnJsWlzCKUPPua70qliW6f6 IdIpYRVaGUZQHR78oVdQxPK6IUzKT8nrHr1ZhZaDGsmc01bE0Hj8v5u/tttKj4LfApos IXSQ== 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=X069CiQ8RfhdePwhlJh4L+vOpoRIhJZjo/+F//DMvos=; b=DZFKDpVngJWsqPLTygXAakhAtVWXj1RUzNEbeG6KecTONP4vZTA+q+uSDgt1m9dkqy D5NIAfJwBQiVukMbZqTNhcHYndLPVToBKv2gUVdfUn0ETtWsP31URWqByACWp1fxk/uj BUeXgJuvyvE9Bzca8ig0hsyT9m0IirEzKBJOwKNpMP4qnOeD+zxTxfftzuEacXeYtoH3 pGTzSpsm+UVWZ1B5Y+8/0XP98787qNFtTW6zxh8IrxBc2SVxtDJhEZEUKTZnJ9DnL3tu 3uVmBUQfdzbw48GCzEA8zrwSGH++6umjWiIIyxM4bpMQKft5VZNjVE4xDjA+6DUvAW5F JP2Q== X-Gm-Message-State: AOAM533p1k6REMxSrxDxOjg2Emc+S9N9JRTfnGtzbdMuCmETestrzuy2 crwWK688SQnoGAnXtYAEVqUBO0A07CmC3Q== X-Google-Smtp-Source: ABdhPJwiOrYh7BphkTVTM4tS63LVlREuywa6wrj2QGtbWHGAbZifzlePD4PC2dVB7OdJ+XR90DwohA== X-Received: by 2002:a17:90a:e997:: with SMTP id v23mr129407pjy.195.1604633411905; Thu, 05 Nov 2020 19:30:11 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:30:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 34/41] tcg/riscv: Support split-wx code generation Date: Thu, 5 Nov 2020 19:29:14 -0800 Message-Id: <20201106032921.600200-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::541; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x541.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.h | 2 +- tcg/riscv/tcg-target.c.inc | 41 +++++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 3c2e8305b0..0eb19f2b11 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -179,6 +179,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_POOL_LABELS #define TCG_TARGET_HAS_MEMORY_BSWAP 0 -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 #endif diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 02beb86977..5c1e0f8fc1 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -425,41 +425,44 @@ static void tcg_out_nop_fill(tcg_insn_unit *p, int count) * Relocations */ -static bool reloc_sbimm12(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +static bool reloc_sbimm12(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + intptr_t offset = (intptr_t)target - (intptr_t)src_rx; tcg_debug_assert((offset & 1) == 0); if (offset == sextreg(offset, 0, 12)) { - code_ptr[0] |= encode_sbimm12(offset); + *src_rw |= encode_sbimm12(offset); return true; } return false; } -static bool reloc_jimm20(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +static bool reloc_jimm20(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + intptr_t offset = (intptr_t)target - (intptr_t)src_rx; tcg_debug_assert((offset & 1) == 0); if (offset == sextreg(offset, 0, 20)) { - code_ptr[0] |= encode_ujimm20(offset); + *src_rw |= encode_ujimm20(offset); return true; } return false; } -static bool reloc_call(tcg_insn_unit *code_ptr, const tcg_insn_unit *target) +static bool reloc_call(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + intptr_t offset = (intptr_t)target - (intptr_t)src_rx; int32_t lo = sextreg(offset, 0, 12); int32_t hi = offset - lo; if (offset == hi + lo) { - code_ptr[0] |= encode_uimm20(hi); - code_ptr[1] |= encode_imm12(lo); + src_rw[0] |= encode_uimm20(hi); + src_rw[1] |= encode_imm12(lo); return true; } @@ -532,7 +535,7 @@ static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, if (tmp == (int32_t)tmp) { tcg_out_opc_upper(s, OPC_AUIPC, rd, 0); tcg_out_opc_imm(s, OPC_ADDI, rd, rd, 0); - ret = reloc_call(s->code_ptr - 2, (tcg_insn_unit *)val); + ret = reloc_call(s->code_ptr - 2, (const tcg_insn_unit *)val); tcg_debug_assert(ret == true); return; } @@ -917,7 +920,7 @@ QEMU_BUILD_BUG_ON(TCG_TARGET_REG_BITS < TARGET_LONG_BITS); QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) > 0); QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) < -(1 << 11)); -static void tcg_out_goto(TCGContext *s, tcg_insn_unit *target) +static void tcg_out_goto(TCGContext *s, const tcg_insn_unit *target) { tcg_out_opc_jump(s, OPC_JAL, TCG_REG_ZERO, 0); bool ok = reloc_jimm20(s->code_ptr - 1, target); @@ -993,7 +996,8 @@ static void add_qemu_ldst_label(TCGContext *s, int is_ld, TCGMemOpIdx oi, label->datahi_reg = datahi; label->addrlo_reg = addrlo; label->addrhi_reg = addrhi; - label->raddr = raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr = (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr[0]; } @@ -1012,7 +1016,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) } /* resolve label address */ - if (!reloc_sbimm12(l->label_ptr[0], s->code_ptr)) { + if (!reloc_sbimm12(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } @@ -1046,7 +1050,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) } /* resolve label address */ - if (!reloc_sbimm12(l->label_ptr[0], s->code_ptr)) { + if (!reloc_sbimm12(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } @@ -1232,7 +1236,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) #endif } -static tcg_insn_unit *tb_ret_addr; +static const tcg_insn_unit *tb_ret_addr; static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, const int *const_args) @@ -1780,11 +1784,12 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_opc_imm(s, OPC_JALR, TCG_REG_ZERO, tcg_target_call_iarg_regs[1], 0); /* Return path for goto_ptr. Set return value to 0 */ - tcg_code_gen_epilogue = s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_A0, TCG_REG_ZERO); /* TB epilogue */ - tb_ret_addr = s->code_ptr; + tb_ret_addr = tcg_splitwx_to_rx(s->code_ptr); for (i = 0; i < ARRAY_SIZE(tcg_target_callee_save_regs); i++) { tcg_out_ld(s, TCG_TYPE_REG, tcg_target_callee_save_regs[i], TCG_REG_SP, SAVE_OFS + i * REG_SIZE); From patchwork Fri Nov 6 03:29:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885889 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 99084697 for ; Fri, 6 Nov 2020 03:50:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3809220735 for ; Fri, 6 Nov 2020 03:50:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="G6hAM3hI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3809220735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaslZ-0001w4-3s for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:50:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasSE-0005di-5S for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:22 -0500 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:47055) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasSB-0007Fk-TD for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:21 -0500 Received: by mail-pl1-x643.google.com with SMTP id g11so11785pll.13 for ; Thu, 05 Nov 2020 19:30:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vrSqwZKXMyaSyRVRtm4Hh+vS+LTe1orOUMFlnbJhADM=; b=G6hAM3hIi28RAVNWEStLM2rNDVdFf0W9pSyPNmCzYHmAt1ZLLzUxjjCVHcVoj7jCjz Q9/HFnVNEptMNSHjzjl2bwMnDQC+WBcyJt7TksP859x2/ZN8F3cc12Xl4ABeKasquXdF qt/tgM75gi0cUvnJXhXj1k70urcWwlQzJsonXEaw75PI9L0vl7zv8wtpv818q3nWZyYs /DqeN6JvScQWzTRAuV/xpUUgKfY6Idl+IV6tQQRHDZHtP2APrAV2XgWyotijRtvJnbUI It9a9e3/m6x9BdKAzJjvnML2llNw2K8phx2XF43IKTM+mWir6QCAUIObR1oTnyTXBwrZ +5jg== 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=vrSqwZKXMyaSyRVRtm4Hh+vS+LTe1orOUMFlnbJhADM=; b=rWNpwCwKP9G6al5Jpb3j2WuVxvjgLKMZyBQlLWc0cuTZLxkfy2ekHp2svh1ywcdNhQ BhQ9F+dYCI1Mn2Cxcv3tLtsYieRPl2o12FLFHcqI7tMKDdxhc+7xD+jI2xt1IQsCRG11 +8W/DqjDBpAHef2JvARqfZIOLrEuBylt9GWVncAZRX3YdAF3v0ZN791wKb/zhQLbZt/w uyuz2aAJFKLp2OAWl9A0qWi7HHC92TDTbutAVa9BcxNHi7BLT6KJCt/GPbK6LvFyz83C 1IkQvwoKPSk+FngWVyFWzaULKhXcDb1Lvi4pFhhmRZFkktU0AWK8gqpdgesvPEXMbOkw viWQ== X-Gm-Message-State: AOAM530vSsmjb1bkIVvxFdj+zSelWX897ANmtce6kg5YpQgwl2LQiYUx DFiiZIHnY2FgHhXi1JXA0C7bjTKefF8ARw== X-Google-Smtp-Source: ABdhPJy18AYH1Dsf2PDRQRLz6TFG5teLIJ1o4AOTnY3JThL2/1hG1pFJaUrmS2VzkEmDTHLgCK2RCQ== X-Received: by 2002:a17:902:c20a:b029:d6:b2d6:8006 with SMTP id 10-20020a170902c20ab02900d6b2d68006mr111993pll.31.1604633414342; Thu, 05 Nov 2020 19:30:14 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.30.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:30:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 35/41] accel/tcg: Add mips support to alloc_code_gen_buffer_splitwx_memfd Date: Thu, 5 Nov 2020 19:29:15 -0800 Message-Id: <20201106032921.600200-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::643; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x643.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Re-use the 256MiB region handling from alloc_code_gen_buffer_anon, and replace that with the shared file mapping. Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 46 ++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 17df6c94fa..b49aaf1026 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1137,24 +1137,40 @@ static bool alloc_code_gen_buffer_anon(size_t size, int prot, static bool alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp) { - void *buf_rw, *buf_rx; + void *buf_rw = NULL, *buf_rx = MAP_FAILED; int fd = -1; +#ifdef __mips__ + /* Find space for the RX mapping, vs the 256MiB regions. */ + if (!alloc_code_gen_buffer_anon(size, PROT_NONE, + MAP_PRIVATE | MAP_ANONYMOUS | + MAP_NORESERVE, errp)) { + return false; + } + /* The size of the mapping may have been adjusted. */ + size = tcg_ctx->code_gen_buffer_size; + buf_rx = tcg_ctx->code_gen_buffer; +#endif + buf_rw = qemu_memfd_alloc("tcg-jit", size, 0, &fd, errp); if (buf_rw == NULL) { - return false; + goto fail; } +#ifdef __mips__ + void *tmp = mmap(buf_rx, size, PROT_READ | PROT_EXEC, + MAP_SHARED | MAP_FIXED, fd, 0); + if (tmp != buf_rx) { + goto fail_rx; + } +#else buf_rx = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_SHARED, fd, 0); if (buf_rx == MAP_FAILED) { - error_setg_errno(errp, errno, - "failed to map shared memory for execute"); - munmap(buf_rw, size); - close(fd); - return false; + goto fail_rx; } - close(fd); +#endif + close(fd); tcg_ctx->code_gen_buffer = buf_rw; tcg_ctx->code_gen_buffer_size = size; tcg_splitwx_diff = buf_rx - buf_rw; @@ -1163,6 +1179,20 @@ static bool alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp) qemu_madvise(buf_rw, size, QEMU_MADV_HUGEPAGE); qemu_madvise(buf_rx, size, QEMU_MADV_HUGEPAGE); return true; + + fail_rx: + error_setg_errno(errp, errno, "failed to map shared memory for execute"); + fail: + if (buf_rx != MAP_FAILED) { + munmap(buf_rx, size); + } + if (buf_rw) { + munmap(buf_rw, size); + } + if (fd >= 0) { + close(fd); + } + return false; } #endif /* CONFIG_POSIX */ From patchwork Fri Nov 6 03:29:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885891 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A092697 for ; Fri, 6 Nov 2020 03:52:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F370F20756 for ; Fri, 6 Nov 2020 03:52:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mwiMtw+l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F370F20756 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasnp-0004Zp-Ul for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:52:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasSH-0005gg-3H for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:25 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:35355) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasSC-0007Gu-On for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:24 -0500 Received: by mail-pf1-x442.google.com with SMTP id g7so61102pfc.2 for ; Thu, 05 Nov 2020 19:30:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9/TRkK1ohPG7NzFVdGar1E3FliGdhxt5t+NNXefLhVw=; b=mwiMtw+lFgR/O0zFthRkLlkc6VdyBFETItDbjPnbZv5EDLYGkfx7E9IKMknuaghZAE oR2PEuwR6CqcOxU+Ydivn2j6Y0zen0lrIDDnORUR89fAmQX1ken3at/Jfp8lfMaCr9XX IK/G7ZUMoQvzn73Mf4EueRPdnXCA1ui32LSICTMa+x3VKNjBVvNsQ2QEzmsGql6uZM9d SWxNgw6osY3ZwPOVrIPyD3J6sPgExQkpp9LLXb1hMAyCJTQQBgEQ0iMtK/Z5gcJrw+nA Ha3jn/wDT9Iwa3A1NpLxPEnBGFGUhN98jqSc1HIRm6simJIdGOuyGu1dl2Ue40+UgleC kwAw== 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=9/TRkK1ohPG7NzFVdGar1E3FliGdhxt5t+NNXefLhVw=; b=OBX+URQLe+jsVbC5NvlKBwDiKcJnoxKEg00bRmK2Jm9fRrny3xx7AIEus34rQPIFh+ oNGqpurd+wJWsr3oXPJg1iQiXdwgWK2JH5ZVdrpbzgrD2UfmFNeFew8RKUpAtnbQSsSk gkMdIgFidDUy7mHxHznz7K0qBItdMxroItHctFTRw1c7Xnb9HYBCJ/+0BHF5wdnSIFiY 9NG7dMxoep6lwfyqQ8apDD/jq/qM4BWlotiFXq/4K8g5+MkgXvmYu1yjA/B9xfd13zuw z7n9pnBhB++yRTnBlnbhqUoVGQSpxVfARo28QlfNgz9Dex9shkrk21dzPYNT75Na8dmY YkZg== X-Gm-Message-State: AOAM530hP32Y7D2XWOOgcImaoie6VawHHPq7vGQxqix1RmKP3LbGtw6j +DRdJ+tPoaNgoIAy2fcsWAywVV5kfbY/RA== X-Google-Smtp-Source: ABdhPJxYmFL/86db9Ukr4SZl1iUX+UJeI//C8EnzkJI74D167lON3to7kQZMxyiyJ/JPzawOs7PsPA== X-Received: by 2002:a17:90a:c201:: with SMTP id e1mr180377pjt.16.1604633416671; Thu, 05 Nov 2020 19:30:16 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:30:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 36/41] tcg/mips: Do not assert on relocation overflow Date: Thu, 5 Nov 2020 19:29:16 -0800 Message-Id: <20201106032921.600200-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::442; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This target was not updated with 7ecd02a06f8, and so did not allow re-compilation with relocation overflow. Remove reloc_26 and reloc_26_val as unused. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 53 ++++++++++++++------------------------- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 52638e920c..37faf1356c 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -144,29 +144,15 @@ static tcg_insn_unit *bswap32_addr; static tcg_insn_unit *bswap32u_addr; static tcg_insn_unit *bswap64_addr; -static inline uint32_t reloc_pc16_val(tcg_insn_unit *pc, - const tcg_insn_unit *target) +static bool reloc_pc16(tcg_insn_unit *pc, const tcg_insn_unit *target) { /* Let the compiler perform the right-shift as part of the arithmetic. */ ptrdiff_t disp = target - (pc + 1); - tcg_debug_assert(disp == (int16_t)disp); - return disp & 0xffff; -} - -static inline void reloc_pc16(tcg_insn_unit *pc, const tcg_insn_unit *target) -{ - *pc = deposit32(*pc, 0, 16, reloc_pc16_val(pc, target)); -} - -static inline uint32_t reloc_26_val(tcg_insn_unit *pc, tcg_insn_unit *target) -{ - tcg_debug_assert((((uintptr_t)pc ^ (uintptr_t)target) & 0xf0000000) == 0); - return ((uintptr_t)target >> 2) & 0x3ffffff; -} - -static inline void reloc_26(tcg_insn_unit *pc, tcg_insn_unit *target) -{ - *pc = deposit32(*pc, 0, 26, reloc_26_val(pc, target)); + if (disp == (int16_t)disp) { + *pc = deposit32(*pc, 0, 16, disp); + return true; + } + return false; } static bool patch_reloc(tcg_insn_unit *code_ptr, int type, @@ -174,8 +160,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, { tcg_debug_assert(type == R_MIPS_PC16); tcg_debug_assert(addend == 0); - reloc_pc16(code_ptr, (tcg_insn_unit *)value); - return true; + return reloc_pc16(code_ptr, (const tcg_insn_unit *)value); } #define TCG_CT_CONST_ZERO 0x100 @@ -925,11 +910,7 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGReg arg1, } tcg_out_opc_br(s, b_opc, arg1, arg2); - if (l->has_value) { - reloc_pc16(s->code_ptr - 1, l->u.value_ptr); - } else { - tcg_out_reloc(s, s->code_ptr - 1, R_MIPS_PC16, l, 0); - } + tcg_out_reloc(s, s->code_ptr - 1, R_MIPS_PC16, l, 0); tcg_out_nop(s); } @@ -1316,9 +1297,10 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) int i; /* resolve label address */ - reloc_pc16(l->label_ptr[0], s->code_ptr); - if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { - reloc_pc16(l->label_ptr[1], s->code_ptr); + if (!reloc_pc16(l->label_ptr[0], s->code_ptr) + || (TCG_TARGET_REG_BITS < TARGET_LONG_BITS + && !reloc_pc16(l->label_ptr[1], s->code_ptr))) { + return false; } i = 1; @@ -1346,7 +1328,9 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) } tcg_out_opc_br(s, OPC_BEQ, TCG_REG_ZERO, TCG_REG_ZERO); - reloc_pc16(s->code_ptr - 1, l->raddr); + if (!reloc_pc16(s->code_ptr - 1, l->raddr)) { + return false; + } /* delay slot */ if (TCG_TARGET_REG_BITS == 64 && l->type == TCG_TYPE_I32) { @@ -1366,9 +1350,10 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) int i; /* resolve label address */ - reloc_pc16(l->label_ptr[0], s->code_ptr); - if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { - reloc_pc16(l->label_ptr[1], s->code_ptr); + if (!reloc_pc16(l->label_ptr[0], s->code_ptr) + || (TCG_TARGET_REG_BITS < TARGET_LONG_BITS + && !reloc_pc16(l->label_ptr[1], s->code_ptr))) { + return false; } i = 1; From patchwork Fri Nov 6 03:29:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885895 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 131261130 for ; Fri, 6 Nov 2020 03:54:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AFEA220756 for ; Fri, 6 Nov 2020 03:54:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="J7etCM5B" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AFEA220756 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:47420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaspM-0006V7-M1 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:54:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasSJ-0005lX-6n for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:27 -0500 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:34490) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasSD-0007Hu-9z for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:26 -0500 Received: by mail-pg1-x543.google.com with SMTP id t14so2896485pgg.1 for ; Thu, 05 Nov 2020 19:30:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i/8RU487BVd0btRakBjFsuP0ajWNBfCw0WmrLKKXBMA=; b=J7etCM5BpJaxIICtLqgMhIzoAG5XqPbBJfFqIITXS4ZsX/I6NeoJ6VLn9670OzyBUT dUm+ofsW37bnLnHBbUHqevCrBNBPMZK4VKxJVIaMumsVgZWndHb5s5ZthMbk9LEr9n7r 1xhp53oTaMGe3vr7fLXyWvvkeOmR3FiJfQXAYN8ImJr1A9J1rScJPAhtbtNWgo4zp/G0 c5XwuFvkdOoHcSCuBLXdzjiQvkFofWBwMfN0jlOLGqi180DT+k5+j7eLXO3LtErisjPF 0FofQdrpDGbFN3785WZGzjKzpdqMJDF6mb4wwwNzG39vY/CaGZAr2k+8tSApsJIpUEJP evhg== 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=i/8RU487BVd0btRakBjFsuP0ajWNBfCw0WmrLKKXBMA=; b=RStPSkVM4wDHtwqwyn++xIhsK4PP7oVfjc639AqDImD354UH3MTTzcGrYz9/wMrI3u 4tjnSa/4xHOOGLkU2rGhwCjXL1RqadQfERAuhH13w553L5RistigKBZKN5peF37+zJl1 /5GebYDqMIUFrYa//19KkB7BISDTNd+45eoBiD4OcWsjPvERJ4zNdq/lQ417a2Gso/+K gt4mKpTrKyu0feTTJvBxTpyrtIqqQOLaCBeO6HlylwtUuwAspKHX5pT4l4ZhcvT4DZee exRC7TrNKKqVyYjWtFooxgiQkJtsqq1BS+4Wbl6wOwIcdD1XYyIf/vsxo9lCvM8Zmsdt j51Q== X-Gm-Message-State: AOAM533NzHlsHAWLLigY73NuHmKCEHQx7lsEcAnRiyhVFZ6WQ40LFiVO vh0omuLADSMzH+GiUmVzy5Cd7MqCPirrTg== X-Google-Smtp-Source: ABdhPJy9bz3E2y1BTj3JQbZBYCvNTQNqb+3JOR1zj1pqTx/rdi3kvQn7aOXCwucpLytQRdkXrUHfuA== X-Received: by 2002:aa7:9e90:0:b029:18b:a94:3498 with SMTP id p16-20020aa79e900000b029018b0a943498mr5163436pfq.54.1604633418535; Thu, 05 Nov 2020 19:30:18 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.30.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:30:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 37/41] tcg/mips: Support split-wx code generation Date: Thu, 5 Nov 2020 19:29:17 -0800 Message-Id: <20201106032921.600200-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::543; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x543.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.h | 2 +- tcg/mips/tcg-target.c.inc | 43 ++++++++++++++++++++++----------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index d231522dc9..d7d8e6ea1c 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -206,7 +206,7 @@ extern bool use_mips32r2_instructions; #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 /* Flush the dcache at RW, and the icache at RX, as necessary. */ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 37faf1356c..a2201bd1dd 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -139,17 +139,18 @@ static const TCGReg tcg_target_call_oarg_regs[2] = { TCG_REG_V1 }; -static tcg_insn_unit *tb_ret_addr; -static tcg_insn_unit *bswap32_addr; -static tcg_insn_unit *bswap32u_addr; -static tcg_insn_unit *bswap64_addr; +static const tcg_insn_unit *tb_ret_addr; +static const tcg_insn_unit *bswap32_addr; +static const tcg_insn_unit *bswap32u_addr; +static const tcg_insn_unit *bswap64_addr; -static bool reloc_pc16(tcg_insn_unit *pc, const tcg_insn_unit *target) +static bool reloc_pc16(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { /* Let the compiler perform the right-shift as part of the arithmetic. */ - ptrdiff_t disp = target - (pc + 1); + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t disp = target - (src_rx + 1); if (disp == (int16_t)disp) { - *pc = deposit32(*pc, 0, 16, disp); + *src_rw = deposit32(*src_rw, 0, 16, disp); return true; } return false; @@ -505,7 +506,7 @@ static void tcg_out_opc_sa64(TCGContext *s, MIPSInsn opc1, MIPSInsn opc2, static bool tcg_out_opc_jmp(TCGContext *s, MIPSInsn opc, const void *target) { uintptr_t dest = (uintptr_t)target; - uintptr_t from = (uintptr_t)s->code_ptr + 4; + uintptr_t from = (uintptr_t)tcg_splitwx_to_rx(s->code_ptr) + 4; int32_t inst; /* The pc-region branch happens within the 256MB region of @@ -617,7 +618,7 @@ static inline void tcg_out_bswap16s(TCGContext *s, TCGReg ret, TCGReg arg) } } -static void tcg_out_bswap_subr(TCGContext *s, tcg_insn_unit *sub) +static void tcg_out_bswap_subr(TCGContext *s, const tcg_insn_unit *sub) { bool ok = tcg_out_opc_jmp(s, OPC_JAL, sub); tcg_debug_assert(ok); @@ -1282,7 +1283,8 @@ static void add_qemu_ldst_label(TCGContext *s, int is_ld, TCGMemOpIdx oi, label->datahi_reg = datahi; label->addrlo_reg = addrlo; label->addrhi_reg = addrhi; - label->raddr = raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr = (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr[0]; if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { label->label_ptr[1] = label_ptr[1]; @@ -1291,15 +1293,16 @@ static void add_qemu_ldst_label(TCGContext *s, int is_ld, TCGMemOpIdx oi, static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) { + const tcg_insn_unit *tgt_rx = tcg_splitwx_to_rx(s->code_ptr); TCGMemOpIdx oi = l->oi; MemOp opc = get_memop(oi); TCGReg v0; int i; /* resolve label address */ - if (!reloc_pc16(l->label_ptr[0], s->code_ptr) + if (!reloc_pc16(l->label_ptr[0], tgt_rx) || (TCG_TARGET_REG_BITS < TARGET_LONG_BITS - && !reloc_pc16(l->label_ptr[1], s->code_ptr))) { + && !reloc_pc16(l->label_ptr[1], tgt_rx))) { return false; } @@ -1344,15 +1347,16 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) { + const tcg_insn_unit *tgt_rx = tcg_splitwx_to_rx(s->code_ptr); TCGMemOpIdx oi = l->oi; MemOp opc = get_memop(oi); MemOp s_bits = opc & MO_SIZE; int i; /* resolve label address */ - if (!reloc_pc16(l->label_ptr[0], s->code_ptr) + if (!reloc_pc16(l->label_ptr[0], tgt_rx) || (TCG_TARGET_REG_BITS < TARGET_LONG_BITS - && !reloc_pc16(l->label_ptr[1], s->code_ptr))) { + && !reloc_pc16(l->label_ptr[1], tgt_rx))) { return false; } @@ -2469,11 +2473,12 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - tcg_code_gen_epilogue = s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_V0, TCG_REG_ZERO); /* TB epilogue */ - tb_ret_addr = s->code_ptr; + tb_ret_addr = tcg_splitwx_to_rx(s->code_ptr); for (i = 0; i < ARRAY_SIZE(tcg_target_callee_save_regs); i++) { tcg_out_ld(s, TCG_TYPE_REG, tcg_target_callee_save_regs[i], TCG_REG_SP, SAVE_OFS + i * REG_SIZE); @@ -2493,7 +2498,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) /* * bswap32 -- 32-bit swap (signed result for mips64). a0 = abcd. */ - bswap32_addr = align_code_ptr(s); + bswap32_addr = tcg_splitwx_to_rx(align_code_ptr(s)); /* t3 = (ssss)d000 */ tcg_out_opc_sa(s, OPC_SLL, TCG_TMP3, TCG_TMP0, 24); /* t1 = 000a */ @@ -2521,7 +2526,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) /* * bswap32u -- unsigned 32-bit swap. a0 = ....abcd. */ - bswap32u_addr = align_code_ptr(s); + bswap32u_addr = tcg_splitwx_to_rx(align_code_ptr(s)); /* t1 = (0000)000d */ tcg_out_opc_imm(s, OPC_ANDI, TCG_TMP1, TCG_TMP0, 0xff); /* t3 = 000a */ @@ -2547,7 +2552,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) /* * bswap64 -- 64-bit swap. a0 = abcdefgh */ - bswap64_addr = align_code_ptr(s); + bswap64_addr = tcg_splitwx_to_rx(align_code_ptr(s)); /* t3 = h0000000 */ tcg_out_dsll(s, TCG_TMP3, TCG_TMP0, 56); /* t1 = 0000000a */ From patchwork Fri Nov 6 03:29:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885899 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 162EF697 for ; Fri, 6 Nov 2020 03:56:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A0ADF20756 for ; Fri, 6 Nov 2020 03:56:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="JLR5C7+E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A0ADF20756 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:51698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasrF-0008Mv-Lf for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:56:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasSM-0005uQ-VM for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:31 -0500 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:42641) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasSE-0007IK-5L for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:30 -0500 Received: by mail-pf1-x42d.google.com with SMTP id x13so36544pfa.9 for ; Thu, 05 Nov 2020 19:30:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pyQvpP38RVhGXRmBv3wfEHupXT2MMazBgzWEsDRUfoQ=; b=JLR5C7+EAwPEZG5nWaVNoPTsoCXLWB2ZYMvL787b4igdjEUjJPfJqy16Fr33TbcLcq jMMIV8o5NRBo/9u1Bj7vbHfGn/kF4pfweysVOyoAp4zJ/1rs2XIx3oVP/yi2GSs5iIOM A7CjHbBu2G1UNIwu9SwfSSTcOetMMCskOzlVPigQVYusFgfmYh8ikD0sw6BhjQHOPnky JBiEHW6NpiKA943GbbqQU66f+Re3FPUIOMaTCC/fgzlEG6PKC2jKsy7YBvAdh4PJ1nF+ g8XWb3XCXiICqtzk1FLiSngAEZ1UHbDKVfiB5hNYa6MnkZHgQFjDWglYBb5tFyT6P40f KisA== 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=pyQvpP38RVhGXRmBv3wfEHupXT2MMazBgzWEsDRUfoQ=; b=CbhzFi7xNQ5ePYQFZ4H/3MyuuhgRMb4ZWyPjQ+oUm2SOCw37L1y/NipyXPTpz66yFr k3QVLFORoktJhc3XOcGo5i9T8fJ7Hr1EAiXGfHzcBgHU/cvzY0exOnSSvVwJ7NZYDM5l G/OyaXB8RS5F2te9CsMghn8AWPf+tVsxHXikIjM/DENh0PR7DvGRg+x9/zB3eKrVIBiM xUB7thYDTBjiz6+NomTwlCHeX76ahoOMIrm3mfwZatNQo6uc0z70mdGk2Cp18syXbrfj po88TWAt9WlUqtRUmWKMQPTxGqkmacOR1TPWmIFN2yPncwzvYAa7AoPe8enh4yno2st0 CoYA== X-Gm-Message-State: AOAM532Q6gzrFD9x5KR6Cmn2qHsIuQBnsKV0mp9AZBUv82EcBSxQQV8Y QSNyA6FaWzyTt8UA3CAsQqQkD/ulBVYzPg== X-Google-Smtp-Source: ABdhPJwiE4CZ/OCZ8oQLIB56S2XhpWkjLdqwm4sxEYHnLhgB3uP19kLRYZkbuIUpcKyMVgDPuaAFqA== X-Received: by 2002:a63:1262:: with SMTP id 34mr5151712pgs.452.1604633420301; Thu, 05 Nov 2020 19:30:20 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.30.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:30:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 38/41] tcg/arm: Support split-wx code generation Date: Thu, 5 Nov 2020 19:29:18 -0800 Message-Id: <20201106032921.600200-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.h | 2 +- tcg/arm/tcg-target.c.inc | 37 +++++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index e355d6a4b2..17f6be9cfc 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -150,6 +150,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 #endif diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 9b9400f164..3d2717aeb0 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -187,29 +187,32 @@ static const uint8_t tcg_cond_to_arm_cond[] = { [TCG_COND_GTU] = COND_HI, }; -static inline bool reloc_pc24(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +static bool reloc_pc24(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t offset = (tcg_ptr_byte_diff(target, code_ptr) - 8) >> 2; + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset = (tcg_ptr_byte_diff(target, src_rx) - 8) >> 2; + if (offset == sextract32(offset, 0, 24)) { - *code_ptr = (*code_ptr & ~0xffffff) | (offset & 0xffffff); + *src_rw = deposit32(*src_rw, 0, 24, offset); return true; } return false; } -static inline bool reloc_pc13(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +static bool reloc_pc13(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t offset = tcg_ptr_byte_diff(target, code_ptr) - 8; + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset = tcg_ptr_byte_diff(target, src_rx) - 8; if (offset >= -0xfff && offset <= 0xfff) { - tcg_insn_unit insn = *code_ptr; + tcg_insn_unit insn = *src_rw; bool u = (offset >= 0); if (!u) { offset = -offset; } insn = deposit32(insn, 23, 1, u); insn = deposit32(insn, 0, 12, offset); - *code_ptr = insn; + *src_rw = insn; return true; } return false; @@ -221,9 +224,9 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, tcg_debug_assert(addend == 0); if (type == R_ARM_PC24) { - return reloc_pc24(code_ptr, (tcg_insn_unit *)value); + return reloc_pc24(code_ptr, (const tcg_insn_unit *)value); } else if (type == R_ARM_PC13) { - return reloc_pc13(code_ptr, (tcg_insn_unit *)value); + return reloc_pc13(code_ptr, (const tcg_insn_unit *)value); } else { g_assert_not_reached(); } @@ -617,7 +620,7 @@ static void tcg_out_movi32(TCGContext *s, int cond, int rd, uint32_t arg) /* Check for a pc-relative address. This will usually be the TB, or within the TB, which is immediately before the code block. */ - diff = arg - ((intptr_t)s->code_ptr + 8); + diff = tcg_pcrel_diff(s, (void *)arg) - 8; if (diff >= 0) { rot = encode_imm(diff); if (rot >= 0) { @@ -1337,7 +1340,8 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, label->datahi_reg = datahi; label->addrlo_reg = addrlo; label->addrhi_reg = addrhi; - label->raddr = raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr = (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr; } @@ -1348,7 +1352,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) MemOp opc = get_memop(oi); void *func; - if (!reloc_pc24(lb->label_ptr[0], s->code_ptr)) { + if (!reloc_pc24(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } @@ -1411,7 +1415,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) TCGMemOpIdx oi = lb->oi; MemOp opc = get_memop(oi); - if (!reloc_pc24(lb->label_ptr[0], s->code_ptr)) { + if (!reloc_pc24(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } @@ -1762,8 +1766,8 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, TCGReg base = TCG_REG_PC; tcg_debug_assert(s->tb_jmp_insn_offset == 0); - ptr = (intptr_t)(s->tb_jmp_target_addr + args[0]); - dif = ptr - ((intptr_t)s->code_ptr + 8); + ptr = (intptr_t)tcg_splitwx_to_rx(s->tb_jmp_target_addr + args[0]); + dif = tcg_pcrel_diff(s, (void *)ptr) - 8; dil = sextract32(dif, 0, 12); if (dif != dil) { /* The TB is close, but outside the 12 bits addressable by @@ -2297,7 +2301,8 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - tcg_code_gen_epilogue = s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R0, 0); tcg_out_epilogue(s); } From patchwork Fri Nov 6 03:29:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885857 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DF70921 for ; Fri, 6 Nov 2020 03:41:27 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CB5CC2072C for ; Fri, 6 Nov 2020 03:41:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nuK8DZ3V" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB5CC2072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:35328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kascv-0006gD-NC for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:41:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasSP-0005wp-In for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:33 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:33489) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasSG-0007It-TC for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:33 -0500 Received: by mail-pf1-x444.google.com with SMTP id q10so67877pfn.0 for ; Thu, 05 Nov 2020 19:30:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+d27eU2L8HgDgwohO42SmmVaHgpu663rk7fnfFSZMqQ=; b=nuK8DZ3VsZkS0PXRlY00qP+A4+AW9DM19HWN59gGRHfOlSWQQeOB4GNaS6uSRvtLy7 xFkRMCb+3XVco8hrgTysZug0EZ6xqzjxOKAPT41InJDzZGM4qS4n5NOkR3/3/UpCQ5+s WztJFohkpmK6lfiiHxDpfR2+C+lNUx5o6tazPmgs5YlbBhog05wxRtns8H43Uj2HbJ7K 7GENmD9HX/EJ20lBJSm+Tv5KI49ZcErodnFarjzuGck7nmI1CtFSUaUNvb2+XCc1W21l njueLOEoTQqL5tPc01VizryJnSHtD16rq7q44J4BoHjbpS5e0olGPXDNM+U0PuIpdQ+m BiCQ== 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=+d27eU2L8HgDgwohO42SmmVaHgpu663rk7fnfFSZMqQ=; b=YCPudEhi1+me9J/YeQRUAKN9kS2bC/HBd9WstkIVk6IFcpBi8Ykm7oV+Q/M8PCNFMZ eFeORtikrjUHdu/jnnbWXJ180wvVvC5fQgJpN6skU2+P/yCBN0OzZbHfYQA34z9b3rgO Q1zQiClBYqH9XcrPoUTcmUKcq9q94kZdRwrozayIbbmjU/7ML8bdiNBB6XYAQOANp6Rt c+rmWH0kZjkGNunTL1+8lkex18/XxyGORRtezPpH/WSMyNIfj2TKqtSDGjn6vsAiDxrg my6FLRdqPf/odMXYtYT/nRX+vPkfbEITVOgiSvehvi//qlaP1Fkb3ISI/la4qlnMnQbf x6yw== X-Gm-Message-State: AOAM533A19piMlhCgDdS174Q8KhqrQPbeCFryR2yIS3WYV8UqXIGiPJ9 ZfIqDFjOIYZb9G1z8L1mVf/ISiz+uoFPhg== X-Google-Smtp-Source: ABdhPJyCtHHsmrqsZLiOp2CADViNcAnqIeivcpYUGQdpGf2sJ++cDB3MUDFNEzdpvC1OM2GygBnMuQ== X-Received: by 2002:aa7:9f06:0:b029:18a:e1a6:cec9 with SMTP id g6-20020aa79f060000b029018ae1a6cec9mr5465343pfr.20.1604633421689; Thu, 05 Nov 2020 19:30:21 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.30.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:30:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 39/41] tcg: Remove TCG_TARGET_SUPPORT_MIRROR Date: Thu, 5 Nov 2020 19:29:19 -0800 Message-Id: <20201106032921.600200-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::444; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Now that all native tcg hosts support splitwx, remove the define. Replace the one use with a test for CONFIG_TCG_INTERPRETER. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.h | 1 - tcg/arm/tcg-target.h | 1 - tcg/i386/tcg-target.h | 1 - tcg/mips/tcg-target.h | 1 - tcg/ppc/tcg-target.h | 1 - tcg/riscv/tcg-target.h | 1 - tcg/s390/tcg-target.h | 1 - tcg/sparc/tcg-target.h | 1 - tcg/tci/tcg-target.h | 1 - accel/tcg/translate-all.c | 14 +++++++------- 10 files changed, 7 insertions(+), 16 deletions(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index abb94f9458..fedd88f6fb 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -155,6 +155,5 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 #endif /* AARCH64_TCG_TARGET_H */ diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 17f6be9cfc..b21a2fb6a1 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -150,6 +150,5 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 #endif diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index bbbd1c2d4a..f52ba0ffec 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -236,6 +236,5 @@ static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 #endif diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index d7d8e6ea1c..cd548dacec 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -206,7 +206,6 @@ extern bool use_mips32r2_instructions; #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -#define TCG_TARGET_SUPPORT_MIRROR 1 /* Flush the dcache at RW, and the icache at RX, as necessary. */ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index a8628b6cad..8f3e4c924a 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -185,6 +185,5 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 #endif diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index 0eb19f2b11..e03fd17427 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -179,6 +179,5 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_POOL_LABELS #define TCG_TARGET_HAS_MEMORY_BSWAP 0 -#define TCG_TARGET_SUPPORT_MIRROR 1 #endif diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h index 1fd8b3858e..c5a749e425 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -163,6 +163,5 @@ static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 #endif diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h index bb2505bfc7..87e2be61e6 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -181,6 +181,5 @@ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 1 #endif diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index 3653fef947..a19a6b06e5 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -200,7 +200,6 @@ static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 -#define TCG_TARGET_SUPPORT_MIRROR 0 static inline void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, uintptr_t jmp_rw, uintptr_t addr) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index b49aaf1026..06102871e7 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1257,14 +1257,14 @@ static bool alloc_code_gen_buffer_splitwx_vmremap(size_t size, Error **errp) static bool alloc_code_gen_buffer_splitwx(size_t size, Error **errp) { - if (TCG_TARGET_SUPPORT_MIRROR) { -#ifdef CONFIG_DARWIN - return alloc_code_gen_buffer_splitwx_vmremap(size, errp); +#ifndef CONFIG_TCG_INTERPRETER +# ifdef CONFIG_DARWIN + return alloc_code_gen_buffer_splitwx_vmremap(size, errp); +# endif +# ifdef CONFIG_POSIX + return alloc_code_gen_buffer_splitwx_memfd(size, errp); +# endif #endif -#ifdef CONFIG_POSIX - return alloc_code_gen_buffer_splitwx_memfd(size, errp); -#endif - } error_setg(errp, "jit split-wx not supported"); return false; } From patchwork Fri Nov 6 03:29:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885901 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 514A6697 for ; Fri, 6 Nov 2020 03:56:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ECCF9206CB for ; Fri, 6 Nov 2020 03:56:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xZwf/mDV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ECCF9206CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasrd-0000VO-Up for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:56:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasSP-0005wQ-Ch for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:33 -0500 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:45616) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasSG-0007JW-Rg for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:33 -0500 Received: by mail-pf1-x443.google.com with SMTP id e7so25638pfn.12 for ; Thu, 05 Nov 2020 19:30:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WPMt5y9/CEVXiVdd1wzKuw7r3/x04DmCpdWE8TQ6bV4=; b=xZwf/mDVFouqeHdv+1LY9G1u3LtHP1Bcyu4guksK8BHCmTBq0AwoGcgRykjPC2a1Wt rf5FqVYUB3jK2kp/5eEOW8gQMUigOCVA3ndcroxuPuTHB6Y4ORu/qmy701DR2K7jxNBM WF7FV5rG4cskB6h6vSyAYIBpPr6j5GvHvGEXi3X6bRPwN/2BJ7Om/MbuhRm4U9cw8la3 g3cFytK/aVWxmgi2hho/TqWyTaiE2vPiSMyvaWo/lYaZT2Ce/fob5SqTFhlBzAzfu8CF dqP9IO0TyyZF0tU+AeB8V1/6miHwZ03Dsb9W6h+bD9BVb+y12drXG1WK8A2XHMmLO/Mv yDvA== 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=WPMt5y9/CEVXiVdd1wzKuw7r3/x04DmCpdWE8TQ6bV4=; b=VqNN7dbD2auXTi/OgUIn/ixUhsmTpBNDqZpxFAC7R9lmxk7qw+vd9Ov2Du9YLiuKy1 ybDX/a2rcTETgJc0YP2xoASKIF/Nj9wm6feoWWKwwQOkEps/K3gt9PGrZ+Wc2gRXvrD4 C4lHD3vwog+nFvhmZeUpIirGLAzLuAA1dfoYEaco9F9lPhMQtklBw9DRBudmZI5SrXqd j1vO/MNq6llWJ7TdJAMX5AWA5NoQUi79H4iNlmR6jFfN0TCUOzMG+drX8r+R3QvOZlzj rubU24+Wgf8zfULSmTXC8ufeuBF5nQnrssKyj9fauRHRidWRJVV7435GjTn34Uzwuzqs VmFA== X-Gm-Message-State: AOAM532y/K7pmXMaqTsBs/QlkmRUkFi+/XqNKRli9e2DLX58EPrPqnwj kUugUUuGaz5zZGT4nvI4Ef0SmwWCeXQIVg== X-Google-Smtp-Source: ABdhPJxyOXgOgRLzaAlxA++Uok3g7eRFIKPVSKjJkrADyGQ42zdrlbI4We2V/PxVT6Zk753d5po+cw== X-Received: by 2002:a63:cb51:: with SMTP id m17mr5215435pgi.337.1604633422959; Thu, 05 Nov 2020 19:30:22 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.30.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:30:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 40/41] tcg: Constify tcg_code_gen_epilogue Date: Thu, 5 Nov 2020 19:29:20 -0800 Message-Id: <20201106032921.600200-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::443; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Now that all native tcg hosts support splitwx, make this pointer const. Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 2 +- tcg/tcg.c | 2 +- tcg/aarch64/tcg-target.c.inc | 3 +-- tcg/arm/tcg-target.c.inc | 3 +-- tcg/i386/tcg-target.c.inc | 3 +-- tcg/mips/tcg-target.c.inc | 3 +-- tcg/ppc/tcg-target.c.inc | 3 +-- tcg/riscv/tcg-target.c.inc | 3 +-- tcg/s390/tcg-target.c.inc | 3 +-- tcg/sparc/tcg-target.c.inc | 3 +-- 10 files changed, 10 insertions(+), 18 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 90ec7c1445..477919aeb6 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -677,7 +677,7 @@ struct TCGContext { extern TCGContext tcg_init_ctx; extern __thread TCGContext *tcg_ctx; -extern void *tcg_code_gen_epilogue; +extern const void *tcg_code_gen_epilogue; extern uintptr_t tcg_splitwx_diff; extern TCGv_env cpu_env; diff --git a/tcg/tcg.c b/tcg/tcg.c index 07a4bd2c57..5c19b1e6b3 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -160,7 +160,7 @@ static int tcg_out_ldst_finalize(TCGContext *s); static TCGContext **tcg_ctxs; static unsigned int n_tcg_ctxs; TCGv_env cpu_env = 0; -void *tcg_code_gen_epilogue; +const void *tcg_code_gen_epilogue; uintptr_t tcg_splitwx_diff; #ifndef CONFIG_TCG_INTERPRETER diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index e398913c0c..32a60eba5e 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -2900,8 +2900,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_X0, 0); /* TB epilogue */ diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 3d2717aeb0..d6cb19ca9f 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -2301,8 +2301,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R0, 0); tcg_out_epilogue(s); } diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 23c7a8a383..be57d2330a 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -3826,8 +3826,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_EAX, 0); /* TB epilogue */ diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index a2201bd1dd..18fd474593 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -2473,8 +2473,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr); tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_V0, TCG_REG_ZERO); /* TB epilogue */ diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index fe33687787..3580bbabc1 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -2346,8 +2346,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out32(s, BCCTR | BO_ALWAYS); /* Epilogue */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr); tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R0, TCG_REG_R1, FRAME_SIZE+LR_OFFSET); for (i = 0; i < ARRAY_SIZE(tcg_target_callee_save_regs); ++i) { diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 5c1e0f8fc1..7b4ee4a084 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1784,8 +1784,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_opc_imm(s, OPC_JALR, TCG_REG_ZERO, tcg_target_call_iarg_regs[1], 0); /* Return path for goto_ptr. Set return value to 0 */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr); tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_A0, TCG_REG_ZERO); /* TB epilogue */ diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index 582a8ef941..b3660ffedf 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -2551,8 +2551,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R2, 0); /* TB epilogue */ diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 182124b96c..922ae96481 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -1039,8 +1039,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_nop(s); /* Epilogue for goto_ptr. */ - /* TODO: Cast goes away when all hosts converted */ - tcg_code_gen_epilogue = (void *)tcg_splitwx_to_rx(s->code_ptr); + tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr); tcg_out_arithi(s, TCG_REG_G0, TCG_REG_I7, 8, RETURN); /* delay slot */ tcg_out_movi_imm13(s, TCG_REG_O0, 0); From patchwork Fri Nov 6 03:29:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11885885 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B556D1130 for ; Fri, 6 Nov 2020 03:48:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 60B9D20735 for ; Fri, 6 Nov 2020 03:48:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NkdrAp1D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 60B9D20735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:33530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasjy-0000fe-BB for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Nov 2020 22:48:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasSQ-0005yH-TR for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:38 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:42521) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasSI-0007Jy-Uy for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:34 -0500 Received: by mail-pg1-x544.google.com with SMTP id u4so2872797pgr.9 for ; Thu, 05 Nov 2020 19:30:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=U1AlMjq14SkWUeaRW64JEUc91BuQIjZvXubJwS4y6yc=; b=NkdrAp1DUQ19z8It1EAI73AI/mVT2EzJWvY2tYzHGtTld7oNDUZAqfDuFpU4pIxATv mAMTnmNZyDJDxMcep+DaPj+CfpdCzO+P77qhsu8Cg7RdNy/8/XIhNhYkdO9aDreZzM9n lnloWf/U4CTvVbdtg4+gUsNct/6iN8KTu59TMKGGfArAwhj8DFIZet4w41V++svBRBo9 uOicCLGH15fFfIyiVx4JXlm+YFe1koV9daJCdxOaFWUzaScEOE29fQJDTtEwNbw7i9Z8 XPFusJ889FLbYyYZ0FuF9h/49fI3xVD2IeVFlV+w+dIteju2YhZ1CNGRhcx3M/3cMh+x aZww== 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=U1AlMjq14SkWUeaRW64JEUc91BuQIjZvXubJwS4y6yc=; b=oyeEmeHDbfxgrKR4HtSgj9PgIjJOuM4EJx7NmD+lVgMMosqwPyCjBJlwPdOMviXFuw VwrAQVR7toXycu+YeB/d4U8gmhpqHi/03JjJdqg8zF9U2MfBAf77BO5RwyLOeO/EXa45 lK9J6OBaoKxv98RBx1H4swikUPdBJA+LGY7/GhfmI5tbOSvGudHQQG01Ei9rPrgajUZV fRfu6hp0UzKH2Wh+G+dlGrqeZ5bblsedikA2M6LSCDcu+EtC04jxmjde2JCZFlVredt0 wSbdaRezDsnUEZi0Gm0lqz1T5mxw8vhFNOQHzqVL+lpqzhUEe7TOI6ZsltXIshcyqeaO KoiQ== X-Gm-Message-State: AOAM530b2fhQEWtqKAFQ0z9YBIUR+NllbEG+f38UiPMZ4SuftItFJ2xp PAK/JXGPIFhp2JY/n92uWeNWQX7rzq8Dww== X-Google-Smtp-Source: ABdhPJx63iSBsUCuDJp2XvKMCbsyunWafJgkFdaKjcwNlDD9MpdbY1csC+gVrNIEVxhPQxLQjyYT/A== X-Received: by 2002:a05:6a00:212b:b029:18b:ad77:1a27 with SMTP id n11-20020a056a00212bb029018bad771a27mr128686pfj.40.1604633425282; Thu, 05 Nov 2020 19:30:25 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.30.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:30:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 41/41] tcg: Constify TCGLabelQemuLdst.raddr Date: Thu, 5 Nov 2020 19:29:21 -0800 Message-Id: <20201106032921.600200-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::544; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x544.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j@getutm.app Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Now that all native tcg hosts support splitwx, make this pointer const. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.c.inc | 3 +-- tcg/arm/tcg-target.c.inc | 3 +-- tcg/i386/tcg-target.c.inc | 3 +-- tcg/mips/tcg-target.c.inc | 3 +-- tcg/ppc/tcg-target.c.inc | 3 +-- tcg/riscv/tcg-target.c.inc | 3 +-- tcg/s390/tcg-target.c.inc | 3 +-- tcg/tcg-ldst.c.inc | 2 +- 8 files changed, 8 insertions(+), 15 deletions(-) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 32a60eba5e..9e15128f31 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1636,8 +1636,7 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, label->type = ext; label->datalo_reg = data_reg; label->addrlo_reg = addr_reg; - /* TODO: Cast goes away when all hosts converted */ - label->raddr = (void *)tcg_splitwx_to_rx(raddr); + label->raddr = tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr; } diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index d6cb19ca9f..0fd1126454 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1340,8 +1340,7 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, label->datahi_reg = datahi; label->addrlo_reg = addrlo; label->addrhi_reg = addrhi; - /* TODO: Cast goes away when all hosts converted */ - label->raddr = (void *)tcg_splitwx_to_rx(raddr); + label->raddr = tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr; } diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index be57d2330a..18a3af53bb 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1786,8 +1786,7 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, bool is_64, label->datahi_reg = datahi; label->addrlo_reg = addrlo; label->addrhi_reg = addrhi; - /* TODO: Cast goes away when all hosts converted */ - label->raddr = (void *)tcg_splitwx_to_rx(raddr); + label->raddr = tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr[0]; if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) { label->label_ptr[1] = label_ptr[1]; diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 18fd474593..add157f6c3 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -1283,8 +1283,7 @@ static void add_qemu_ldst_label(TCGContext *s, int is_ld, TCGMemOpIdx oi, label->datahi_reg = datahi; label->addrlo_reg = addrlo; label->addrhi_reg = addrhi; - /* TODO: Cast goes away when all hosts converted */ - label->raddr = (void *)tcg_splitwx_to_rx(raddr); + label->raddr = tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr[0]; if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { label->label_ptr[1] = label_ptr[1]; diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 3580bbabc1..71b40e7490 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -2001,8 +2001,7 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, label->datahi_reg = datahi_reg; label->addrlo_reg = addrlo_reg; label->addrhi_reg = addrhi_reg; - /* TODO: Cast goes away when all hosts converted */ - label->raddr = (void *)tcg_splitwx_to_rx(raddr); + label->raddr = tcg_splitwx_to_rx(raddr); label->label_ptr[0] = lptr; } diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 7b4ee4a084..f48a028dac 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -996,8 +996,7 @@ static void add_qemu_ldst_label(TCGContext *s, int is_ld, TCGMemOpIdx oi, label->datahi_reg = datahi; label->addrlo_reg = addrlo; label->addrhi_reg = addrhi; - /* TODO: Cast goes away when all hosts converted */ - label->raddr = (void *)tcg_splitwx_to_rx(raddr); + label->raddr = tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr[0]; } diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index b3660ffedf..d7ef079055 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -1587,8 +1587,7 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOpIdx oi, label->oi = oi; label->datalo_reg = data; label->addrlo_reg = addr; - /* TODO: Cast goes away when all hosts converted */ - label->raddr = (void *)tcg_splitwx_to_rx(raddr); + label->raddr = tcg_splitwx_to_rx(raddr); label->label_ptr[0] = label_ptr; } diff --git a/tcg/tcg-ldst.c.inc b/tcg/tcg-ldst.c.inc index 05f9b3ccd6..c3ce88e69d 100644 --- a/tcg/tcg-ldst.c.inc +++ b/tcg/tcg-ldst.c.inc @@ -28,7 +28,7 @@ typedef struct TCGLabelQemuLdst { TCGReg addrhi_reg; /* reg index for high word of guest virtual addr */ TCGReg datalo_reg; /* reg index for low word to be loaded or stored */ TCGReg datahi_reg; /* reg index for high word to be loaded or stored */ - tcg_insn_unit *raddr; /* gen code addr of the next IR of qemu_ld/st IR */ + const tcg_insn_unit *raddr; /* addr of the next IR of qemu_ld/st IR */ tcg_insn_unit *label_ptr[2]; /* label pointers to be updated */ QSIMPLEQ_ENTRY(TCGLabelQemuLdst) next; } TCGLabelQemuLdst;