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

monitor: Add support for write command #1589

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

jamesbrq
Copy link

Adds a new command to monitor named write|w. The syntax is write addr size data. This adds the capability to write up to 4 bytes of data at a time to the xbox.ram memory region.

@mborgerson
Copy link
Member

mborgerson commented Feb 20, 2024

Thank you for the PR

I was certain this must exist in QEMU monitor already, and was totally surprised not to find it! I usually just use GDB to do this, but I think it would be nice for users to be able to easily poke memory in the monitor too, for playing with games and whatnot, and the feature is not too complex. In the future maybe we should just bake in a GDB client for people to use.

In the mean time, can you please expand the PR to support writing to both physical and virtual arbitrary addresses, regardless of any particular internal region. You can model this after the other related monitor / GDB stub commands.

This feature might also be good for upstream QEMU, if you're interested in submitting to qemu-devel.

@jamesbrq
Copy link
Author

jamesbrq commented Feb 20, 2024

I added an extra command, so there is one for virtual and one for physical now.

I'm assuming the syntax and everything is okay but if you think anything else needs to be changed let me know.
I'll also have to look into upstream qemu as well, but I'll see if I can get around to it. At the very least having it on xemu will be a nice addition. I can finally write to ram without having to pause the whole emulator lol

#include "qemu/timer.h"
#include "qemu/sockets.h"
#include "qemu/help_option.h"
#include "exec/memory.h"
Copy link
Member

Choose a reason for hiding this comment

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

Please revert any non-essential changes to this header order

#include "sysemu/kvm.h"
#include "sysemu/runstate.h"
#include "sysemu/tcg.h"
#include "qemu/accel.h"
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as above re header order

QTAILQ_FOREACH (mr, &sm->subregions, subregions_link) {
if (strcmp(memory_region_name(mr), "xbox.ram") == 0) {
uint8_t *ram_ptr = qemu_map_ram_ptr(mr->ram_block, addr);
memcpy(ram_ptr, buf, len);
Copy link
Member

Choose a reason for hiding this comment

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

Is there not an existing physical memory write function somewhere?

Anyway, we should check here that we don't accidentally write out of bounds

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.

2 participants