From patchwork Tue Jul 26 13:03:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Haley X-Patchwork-Id: 106869 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id B7EA4B70C5 for ; Tue, 26 Jul 2011 23:04:21 +1000 (EST) Received: (qmail 21476 invoked by alias); 26 Jul 2011 13:04:20 -0000 Received: (qmail 21459 invoked by uid 22791); 26 Jul 2011 13:04:18 -0000 X-SWARE-Spam-Status: No, hits=-7.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_CP X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 26 Jul 2011 13:04:03 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6QD3po8009231 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 26 Jul 2011 09:03:51 -0400 Received: from zebedee.pink (ovpn-116-36.ams2.redhat.com [10.36.116.36]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6QD3mYR007029; Tue, 26 Jul 2011 09:03:49 -0400 Message-ID: <4E2EBB34.10604@redhat.com> Date: Tue, 26 Jul 2011 14:03:48 +0100 From: Andrew Haley User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Thunderbird/3.1.11 MIME-Version: 1.0 To: "Joseph S. Myers" CC: Richard Earnshaw , GCC Patches , "libffi-discuss@sourceware.org" Subject: Re: ARM: Clear icache when creating a closure References: <4E1B2384.5080001@redhat.com> <4E1C0FEA.4040209@arm.com> <4E1C10CF.6020201@redhat.com> <4E2D385E.90500@redhat.com> In-Reply-To: <4E2D385E.90500@redhat.com> X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On 07/25/2011 10:33 AM, Andrew Haley wrote: > On 21/07/11 16:33, Joseph S. Myers wrote: >> My suggestion would be putting the instruction sequence in a .s file, >> rather than hardcoding the instruction encodings here, and writing the >> code to read from the sequence as assembled by the assembler. That way it >> will have the appropriate mapping symbols to mark it as ARM-mode code and >> the linker will deal with adjusting endianness, so you don't need to test >> for BE-8 at all. I did this, and it passes the testsuite. Is it OK? Andrew. 2011-07-26 Andrew Haley * src/arm/ffi.c (FFI_INIT_TRAMPOLINE): Remove hard-coded assembly instructions. * src/arm/sysv.S (ffi_arm_trampoline): Put them here instead. Index: src/arm/ffi.c =================================================================== --- src/arm/ffi.c (revision 176744) +++ src/arm/ffi.c (working copy) @@ -337,14 +337,14 @@ /* How to make a trampoline. */ +extern unsigned int ffi_arm_trampoline[3]; + #define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \ ({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ unsigned int __fun = (unsigned int)(FUN); \ unsigned int __ctx = (unsigned int)(CTX); \ unsigned char *insns = (unsigned char *)(CTX); \ - *(unsigned int*) &__tramp[0] = 0xe92d000f; /* stmfd sp!, {r0-r3} */ \ - *(unsigned int*) &__tramp[4] = 0xe59f0000; /* ldr r0, [pc] */ \ - *(unsigned int*) &__tramp[8] = 0xe59ff000; /* ldr pc, [pc] */ \ + memcpy (__tramp, ffi_arm_trampoline, sizeof ffi_arm_trampoline); \ *(unsigned int*) &__tramp[12] = __ctx; \ *(unsigned int*) &__tramp[16] = __fun; \ __clear_cache((&__tramp[0]), (&__tramp[19])); /* Clear data mapping. */ \ Index: src/arm/sysv.S =================================================================== --- src/arm/sysv.S (revision 176744) +++ src/arm/sysv.S (working copy) @@ -461,6 +461,11 @@ UNWIND .fnend .size CNAME(ffi_closure_VFP),.ffi_closure_VFP_end-CNAME(ffi_closure_VFP) +ENTRY(ffi_arm_trampoline) + stmfd sp!, {r0-r3} + ldr r0, [pc] + ldr pc, [pc] + #if defined __ELF__ && defined __linux__ .section .note.GNU-stack,"",%progbits #endif