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

TriCore Support #1568

Merged
merged 15 commits into from
Apr 29, 2022
Merged

TriCore Support #1568

merged 15 commits into from
Apr 29, 2022

Conversation

uberwoozle
Copy link
Contributor

@uberwoozle uberwoozle commented Mar 11, 2022

Works when tricore is built alone.

Run into issue where when building all targets tricore switches to s390x when entering 'tb_gen_code_tricore'.

#0 0x00007ffff513beab in memory_mapping (uc=0xa00000073, address=14899176) at /unicorn/uc.c:1492
#1 0x00007ffff5f613ec in load_helper (env=0xc2a930, addr=14899176, oi=147, retaddr=0, op=MO_BEUW, code_read=true, full_load=0x7ffff5f6bead <full_lduw_code>) at /unicorn/qemu/accel/tcg/cputlb.c:1439
#2 0x00007ffff5f6bef7 in full_lduw_code (env=0xc2a930, addr=14899176, oi=147, retaddr=0) at /unicorn/qemu/accel/tcg/cputlb.c:2389
#3 0x00007ffff5f6bf49 in cpu_lduw_code_s390x (env=0xc2a930, addr=14899176) at /unicorn/qemu/accel/tcg/cputlb.c:2395
#4 0x00007ffff5f99a11 in ld_code2 (env=0xc2a930, pc=14899176) at /unicorn/qemu/target/s390x/translate.c:385
#5 0x00007ffff5fba5f1 in extract_insn (env=0xc2a930, s=0x7fffffffcf60) at /unicorn/qemu/target/s390x/translate.c:6547
#6 0x00007ffff5fba8cb in translate_one (env=0xc2a930, s=0x7fffffffcf60) at /unicorn/qemu/target/s390x/translate.c:6679
#7 0x00007ffff5fbb0b5 in s390x_tr_translate_insn (dcbase=0x7fffffffcf60, cs=0xc22200) at /unicorn/qemu/target/s390x/translate.c:6877
#8 0x00007ffff5fd8278 in translator_loop_s390x (ops=0x7ffff63d9840 <s390x_tr_ops>, db=0x7fffffffcf60, cpu=0xc22200, tb=0x7fffb4be2040, max_insns=512) at /unicorn/qemu/accel/tcg/translator.c:124
#9 0x00007ffff5fbb2a3 in gen_intermediate_code (cs=0xc22200, tb=0x7fffb4be2040, max_insns=512) at /unicorn/qemu/target/s390x/translate.c:6944
#10 0x00007ffff4cfe614 in tb_gen_code_tricore (cpu=0xc22200, pc=2162382824, cs_base=0, flags=0, cflags=-16777216) at /unicorn/qemu/accel/tcg/translate-all.c:1623
#11 0x00007ffff4ce7a4f in tb_find (cpu=0xc22200, last_tb=0x0, tb_exit=0, cf_mask=0) at /unicorn/qemu/accel/tcg/cpu-exec.c:256
#12 0x00007ffff4ce82c9 in cpu_exec_tricore (uc=0xbf74d0, cpu=0xc22200) at /unicorn/qemu/accel/tcg/cpu-exec.c:597
#13 0x00007ffff4c96616 in tcg_cpu_exec (uc=0xbf74d0) at /unicorn/qemu/softmmu/cpus.c:96
#14 0x00007ffff4c9689f in resume_all_vcpus_tricore (uc=0xbf74d0) at /unicorn/qemu/softmmu/cpus.c:209
#15 0x00007ffff4c96937 in vm_start_tricore (uc=0xbf74d0) at /unicorn/qemu/softmmu/cpus.c:228
#16 0x00007ffff513ab83 in uc_emu_start (uc=0xbf74d0, begin=2162382824, until=0, timeout=0, count=1) at /unicorn/uc.c:857

uberwoozle and others added 4 commits March 11, 2022 12:42
python sample
Correct attribution
Fixed byte code to execute properly.
Removed testing artifact
@uberwoozle
Copy link
Contributor Author

I do not have a windows machine to target, but I must have missed some configuration parameters to target arm64 and android.

Seems the above TriCore and s390x may be a hardcoded value or missed auto configuration in an enumeration somewhere.

Any thoughts?

@wtdcode
Copy link
Member

wtdcode commented Apr 2, 2022

I do not have a windows machine to target, but I must have missed some configuration parameters to target arm64 and android.

Seems the above TriCore and s390x may be a hardcoded value or missed auto configuration in an enumeration somewhere.

Any thoughts?

You have to somehow grab an MSVC to test it or just push to your branch and our CI would help you do so.

I would have a review ASAP.

@wtdcode
Copy link
Member

wtdcode commented Apr 3, 2022

You are failing CI because you don't add the corresponding header in msvc/ directory.

The PR itself looks good to me but the CI needs to be fixed.

@uberwoozle
Copy link
Contributor Author

uberwoozle commented Apr 4, 2022

Adding the config-target.h file in the TriCore softmmu didn't seem to resolve the problem. I'll keep combing through the build environment.

@uberwoozle
Copy link
Contributor Author

uberwoozle commented Apr 19, 2022

There is a problem, most likely in translate.c, in handling parsing of small snippets of code, i.e., only one block of emulated code. I'm looking into it, but works fine with multi-block inputs. This means the samples do not currently work. The lines of assembly are iterated over, but the register states are not published properly while exiting.

If the PR is fine, I can submit a bug fix afterwards.

@liyansong2018
Copy link
Contributor

@uberwoozle nice work!

@wtdcode wtdcode mentioned this pull request Apr 29, 2022
@wtdcode
Copy link
Member

wtdcode commented Apr 29, 2022

Hello, the sample_tricore doesn't seem to work on my machine. Is it intended?

@uberwoozle
Copy link
Contributor Author

uberwoozle commented Apr 29, 2022

The intention was for it to work, you are referring to sample_tricore.c? I was able to build the entire code base and run the sample fine.
"It works on my machine" (trademark) let me see if I'm sitting on an unstaged change.

image

Update:
I do not see anything staged on my side, I'm not sure what the issue would be. What does building with just tricore look like? Is it possible I snuck a dependency in?

@wtdcode
Copy link
Member

wtdcode commented Apr 29, 2022

The intention was for it to work, you are referring to sample_tricore.c? I was able to build the entire code base and run the sample fine. "It works on my machine" (trademark) let me see if I'm sitting on an unstaged change.

image

Update: I do not see anything staged on my side, I'm not sure what the issue would be. What does building with just tricore look like? Is it possible I snuck a dependency in?

Nevermind, I found I used your tricore branch instead of dev branch. Let me continue my review.

@wtdcode
Copy link
Member

wtdcode commented Apr 29, 2022

Wait CI to be green ;)

@wtdcode wtdcode merged commit cfee213 into unicorn-engine:dev Apr 29, 2022
@wtdcode
Copy link
Member

wtdcode commented Apr 29, 2022

Merged, thanks!

@uberwoozle uberwoozle deleted the dev branch May 2, 2022 13:18
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

Successfully merging this pull request may close these issues.

3 participants