From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755268AbbCCDvK (ORCPT ); Mon, 2 Mar 2015 22:51:10 -0500 Received: from szxga01-in.huawei.com ([119.145.14.64]:16291 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751941AbbCCDvI (ORCPT ); Mon, 2 Mar 2015 22:51:08 -0500 Message-ID: <54F52F4B.3060402@hisilicon.com> Date: Tue, 3 Mar 2015 11:49:31 +0800 From: chenfeng User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: "punit.agrawal" CC: <"catalin.marinas"@arm.com>, , , , "Peter Panshilin" , Suzhuangluan , Yiping Xu , Dan zhao , qijiwen , Wangbintian Subject: Alignment issue with ldmia Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.142.192.172] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is an alignment issue with ldmia in A32 user-space with A64 Kernel. Since the famous taobao apk use this instruction, so we want to emulate this to make it work well. I make a simple test case to reproduce this issue. ----------------------------------------------------------------------- #include #include int main() { char src_addr[1024]; char dst_addr[1024]; printf("--------%lx %lx\n",src_addr,dst_addr); unsigned long src_reg = (unsigned long)src_addr | 1; unsigned long dst_reg = (unsigned long)dst_addr | 1; printf("--------%lx %lx\n",src_reg,dst_reg); asm volatile("mov r1, %0\n": : "r" (src_reg)); asm volatile("mov r2, %0\n": : "r" (dst_reg)); asm volatile("ldmia r1!,{r2}"); printf("--------------------------\n"); return 0; } ------------------------------------------------------------------------ I use the test case on A32 kernel with A32 user-space. It works well,becase of that is a do_alignment_ldmstm emulate in arch/arm/mm/alignment.c So, I want to porting the code to arch/arm64. The first step is getting the machine code of the unalignment instruction. However I have no idea how to do this. There is a commit on google master L branch to emulate the undef instruction. I use these code for getting the instruction of unalignment case. But I found the code in arch/arm/alignment.c get the instruction is 0xe8b10004 and the code in arch/arm64/kernel/traps.c is different. Since I arm not professional for the code, I am writting for asking is there a way to get the thumb instruction when traps in kernel mode.