Skip to content
New issue

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

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

Already on GitHub? # to your account

Prevent overflow with pre-allocated RAM blocks #1712

Closed

Conversation

roehling
Copy link
Contributor

This is a proposed resolution for one of the test issues discussed in #1678. Not only does it fix the failing unit test on hosts with page size larger than 4K, I believe it also fixes a defect where pre-allocated RAM could be resized inadvertently beyond the actual allocated memory by the HOST_PAGE_ALIGN macro.

@@ -1100,6 +1098,9 @@ RAMBlock *qemu_ram_alloc_from_ptr(struct uc_struct *uc, ram_addr_t size, void *h
new_block->host = host;
if (host) {
new_block->flags |= RAM_PREALLOC;
} else {
size = HOST_PAGE_ALIGN(uc, size);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks promising but assigning values to size and max_size seems doing nothing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right. The max_length assignment should have moved down as well.

@wtdcode
Copy link
Member

wtdcode commented Sep 25, 2022

Fixed in 32a3a68

@wtdcode wtdcode closed this Sep 25, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants