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

Fix few bugs on the i386 target #10

Merged
merged 3 commits into from
Nov 5, 2024

Conversation

pwissenlit
Copy link
Contributor

This pull request aims at fixing two bugs when dealing with x86 targets.

The first one is related to the gdbstub complaining about the fact that the machine doesn't provide any CPU (as illustrated in this issue: avatartwo/avatar2#110 (comment)). The fix involves plugging the CPU into the QOM hierarchy with qdev_realize.
Please note that a hardcoded apic-id is used at the moment which could prevent users from creating multiple CPUs on the target. However, I don't know if avatar-qemu could allow such possibility in any cases so I haven't dwelt on this issue.

The second bug is related to a wrong stack alignment when pushing and popping 32 bit values. This impedes the correct functioning of these instructions by preventing the value to be written in memory.
As qemu uses the CPU flag HF_SS32_MASK to retrieve the stack pointer size that is needed, the fix is to simply set it when initializing the CPU.

// target/i386/tcg/translate.c

#define SS32(S)   (((S)->flags & HF_SS32_MASK) != 0)
// [...]
/* Select the size of the stack pointer.  */
static inline MemOp mo_stacksize(DisasContext *s)
{
    return CODE64(s) ? MO_64 : SS32(s) ? MO_32 : MO_16;
}

For the record, a third bug still remains on this target: the provided entry_address is not taken into account by the CPU and the execution instead starts from the beginning of the first ROM memory.
I tried to dig into that but without much success. Since this is an issue that can easily be circumvented directly from the python script, I've put it aside for now.

@J04n5mith
Copy link

J04n5mith commented Sep 3, 2022

Hello! Thanks for the fix! I tested your fix. The gdbstub-fix ( 2aaea07 ) is working fine for me (i386 and x86_64 target), but the fix 7424366 is unfortunately not working for me. I used your minimal example in avatartwo/avatar2#110 (comment) and it outputs still this error:

Configurable: Adding peripheral[avatar-rmemory] region hello_world at address 0x40004c00
Bail out! ERROR:../qom/object.c:715:object_new_with_type: assertion failed: (type != NULL)

Could you check if it is giving you the same error?

@rawsample
Copy link
Member

@J04n5mith this commit should make it work for you now.

@rawsample rawsample merged commit 7d22a74 into avatartwo:dev/qemu-6.2 Nov 5, 2024
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