Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can arm64 big endian support be added? #802

Closed
ZakDanger opened this issue Apr 21, 2017 · 11 comments
Closed

Can arm64 big endian support be added? #802

ZakDanger opened this issue Apr 21, 2017 · 11 comments

Comments

@ZakDanger
Copy link
Contributor

I see that recently ARM big endian support was added, nice work @xizhizhang !
I was wondering if you might be able to add the relevant changes for ARM64 big endian support too?

That would then cover pretty much all main cases for arm:
armle, armbe, arm64le and arm64be.

@aquynh
Copy link
Member

aquynh commented Apr 21, 2017

afaik, Arm64 does not have big-endian implementation.

@aquynh
Copy link
Member

aquynh commented Apr 21, 2017

i mean there is no real hardware for Arm64 big-endian, so there is no reason to emulate it.

@ZakDanger
Copy link
Contributor Author

Hm ok, i've seen various mentions of arm64be though not what hardware it was intended for. Perhaps it is just support that people have added for various things in case something uses arm64be in the future.

I don't know how complex the additions were to add the armbe support, but if they were simple enough it might still be worth it for completeness.

@aquynh
Copy link
Member

aquynh commented Apr 21, 2017

yes i dont mind to support that, as long as there is demand.

@xizhizhang
Copy link
Contributor

yep, I have added ARM64 big endian support too.
Thanks to unicorn and QEMU's good design, it is easy to support big endian.
But I afraid there are still some bugs, since I have not checked all the translate codes if there are some endian issue.

here is my code:
#806

Thanks.

@ZakDanger
Copy link
Contributor Author

thanks @xizhizhang :)

@aquynh
Copy link
Member

aquynh commented Apr 25, 2017

merged everything, thanks. i also updated CREDITS.TXT with 3c7e299.

@aquynh aquynh closed this as completed Apr 25, 2017
@ZakDanger
Copy link
Contributor Author

Ok so today I found some time to test arm64be support with a real ELF file and found that it is not working correctly, It seems that arm64 (aka ARMv8 in Aarch64 mode) only supports little endian instructions but can access data as little or big endian.

You can get a PDF of the ARMv8 Architecture Reference Manual here:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.aeg0014g/ABCDEFGH.html

Section B2.6 is for Endian support (page 104 onwards).

"Section B2.6.2 Instruction endianness" says:
"In ARMv8-A, A64 instructions have a fixed length of 32 bits and are always little-endian."

"Section B2.6.3 Data endianness" discusses how data endianess is handled

As a test I used some of the prebuild library binaries inside these packs:
https://releases.linaro.org/archive/14.11/components/toolchain/binaries/aarch64_be-none-elf/
Specifically I downloaded the file "gcc-linaro-4.9-2014.11-x86_64_aarch64_be-elf.tar.xz" and extracted "gcc-linaro-4.9-2014.11-x86_64_aarch64_be-elf\lib\gcc\aarch64_be-none-elf\4.9.3\libgcc.a" from it and then extracted "muldi3.o" from "libgcc.a". I used 7zip to do both extractions in windows.

So can we look at altering the arm64be support in unicorn to only deal with data accesses in big endian but instruction accesses in little endian?

@aquynh
Copy link
Member

aquynh commented Apr 26, 2017

yes we need to fix the core of arm64 to handle big endian data.

should we revert these arm64 bigendian commits?

@aquynh aquynh reopened this Apr 26, 2017
@ZakDanger
Copy link
Contributor Author

I think this is @xizhizhang 's call.
Probably its just a matter of not swapping instruction fetches but still swapping data fetches.

@xizhizhang
Copy link
Contributor

Yes, we can swap the instructions by just setting dc->bswap_code = 1 at qemu/trarget-arm/translate.c line 11063.

@wtdcode wtdcode closed this as completed Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants