From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 5F30A532601; Wed, 16 Aug 2023 16:25:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5F30A532601 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1692192348; bh=x4t7m83LrgJ1M1qlYfcm+ViLlxF6f4kauMf9X6n39Mo=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=XcnvH3V2LeN6j6hUgui03XeItDBOKvZU8iJBmw8bntogRChqLllsmBxrteRXxg+N8 mKAHK6CJaG93T4eyqre1XPMZOaHahFffOwlLthxe1fDn4HbbcO9AE52JlPIQb3U2xf Rc4EQWeoFafaXB4rtn+fSHpuUekZUWOG2ZIM8UCA= Received: from smtp47.i.mail.ru (smtp47.i.mail.ru [95.163.41.85]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 9BFD0532601 for ; Wed, 16 Aug 2023 16:25:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9BFD0532601 Received: by smtp47.i.mail.ru with esmtpa (envelope-from ) id 1qWGWv-000Ypj-17; Wed, 16 Aug 2023 16:25:45 +0300 Message-ID: <8fce876c-315a-f177-8a90-4bac356aba8c@tarantool.org> Date: Wed, 16 Aug 2023 16:25:44 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 To: Sergey Kaplun , Igor Munkin Cc: tarantool-patches@dev.tarantool.org References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9700E0DCE2907754D1F9D5B7CD6B34A186ED0A35A424B74BD182A05F538085040803F4C4770F1CE176D950E4569FF193E9949D295448BDFC087E9E0E27295AF6F X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE79145AB6E9E75F07EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637A361B53D384D9D40EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BE5CCB53A13BC8DBAEB2EDF5AC533C7BB590F3E4843AFEF48CC7F00164DA146DAFE8445B8C89999728AA50765F79006372255A60090D554F4389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8A9FF340AA05FB58CF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C65B78C30F681404D6E0066C2D8992A164AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C31EBBAFDAEF65C2E6BA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166176DF2183F8FC7C08CCB3ED2A1DE2304725E5C173C3A84C332C16DEEF884694935872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A528D23E84714E4B11E9753063D4232B6294DCD9D07DA569F0F87CCE6106E1FC07E67D4AC08A07B9B065B78C30F681404DCB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADBF74143AD284FC7177DD89D51EBB7742424CF958EAFF5D571004E42C50DC4CA955A7F0CF078B5EC49A30900B95165D34F804B400765FFFF9191A4324E09C8885D7C482E163FB25DBD667207834F55DC59F33F425CE6F01391D7E09C32AA3244C4BD08FDF98EA2B20971793C65DFB08D2F94338140B71B8EE85A42E4C463514DC5DA084F8E80FEBD3FFA33E6B6B2F82C47A83BD0C44CE203720ABEDE4BBDD9CDD X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojHVl7ekwB6hhbJ8gH5xQiWQ== X-Mailru-Sender: C4F68CFF4024C8867DFDF7C7F25884589F52FFC9D69D325EE91897DDC3E25A7997492E63326EC16F282EC151BADDC1D3523A6D01B4765B2DFB59E2DDD9FE06B14FA522850F29BC30B0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 01/19] MIPS: Use precise search for exit jump patching. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey Thanks for the patch! LGTM On 8/9/23 18:35, Sergey Kaplun wrote: > From: Mike Pall > > Contributed by Djordje Kovacevic and Stefan Pejic. > > (cherry-picked from commit 7381b620358c2561e8690149f1d25828fdad6675) > > Without the aforementioned checks, some non-branch instructions may be > interpreted as some branch due to memory address collisions. This patch > adds the corresponding comparisons masked values with instruction > opcodes used in the LuaJIT: > * `MIPSI_BEQ` for `beq` and `bne`, > * `MIPSI_BLTZ` for `bltz`, `blez`, `bgtz` and `bgez`, > * `MIPSI_BC1F` for `bc1f` and `bc1t`, > see and MIPS Instruction Set Manual [1] for > details. > > To reproduce this failure, we need specific memory mapping, so testcase > is omitted. > > Since MIPS architecture is not supported by Tarantool (at the moment) > this patch is not necessary for backport. OTOH, it gives to us the > following benefits: > * Be in sync with the LuaJIT upstream not only for x86_64, arm64 > architectures. > * Avoid conflicts during the future backporting. > So, it's more useful to backport some of the patches to avoid conflicts > with the future patch series. > > [1]: https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00086-2B-MIPS32BIS-AFP-6.06.pdf > > Sergey Kaplun: > * added the description for the problem > > Part of tarantool/tarantool#8825 > --- > src/lj_asm_mips.h | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/src/lj_asm_mips.h b/src/lj_asm_mips.h > index 03417013..03215821 100644 > --- a/src/lj_asm_mips.h > +++ b/src/lj_asm_mips.h > @@ -2472,7 +2472,11 @@ void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, MCode *target) > MCode tjump = MIPSI_J|(((uintptr_t)target>>2)&0x03ffffffu); > for (p++; p < pe; p++) { > if (*p == exitload) { /* Look for load of exit number. */ > - if (((p[-1] ^ (px-p)) & 0xffffu) == 0) { /* Look for exitstub branch. */ > + /* Look for exitstub branch. Yes, this covers all used branch variants. */ > + if (((p[-1] ^ (px-p)) & 0xffffu) == 0 && > + ((p[-1] & 0xf0000000u) == MIPSI_BEQ || > + (p[-1] & 0xfc1e0000u) == MIPSI_BLTZ || > + (p[-1] & 0xffe00000u) == MIPSI_BC1F)) { > ptrdiff_t delta = target - p; > if (((delta + 0x8000) >> 16) == 0) { /* Patch in-range branch. */ > patchbranch: