Capturing code generated by Qemu in a file - linux

In qemu, when we are giving instructions it gets converted to the machine code for the particular architecture. I would like to write this code to a file. For that I think in cpu-exec.c the generated code is obtained (it is returned for execution). How will i copy it to a file?
/qemu-0.14.0/cpu-exec.c

find cpu_gen_code() # translate-all.c:57,
-to->
# line104: log_disas(tb->tc_ptr, *gen_code_size_ptr);
try to hack it.

Related

WIM to ISO fails, failure when attempting to copy boot files

I am facing a bit of a conundrum.
I've been trying to form an ISO from a WIM for some time now, but always run into the same error:
It plays up nicely, merges the swm-files as well, but in the end the error comes:
failure when attempting to copy boot files
It may be that I miss the forest for the trees, but I can't find the error.
I am already in the subfolder where etfsboot.com is.
oscdimg -n -m -o -betfsboot.com C:\ZZ C:\YY\XXXXTestimage.iso
So my command, which was also executed.
On C:\ZZ are the subfolders like on a deployment stick, in the subfolder "target" are
the swm-files, the files were adjusted so that it assembles the swm-files (it did this without any problems).
But why can't it write boot files?
Where exactly is my error in thinking that I don't see?
Would be cool if someone here looks into this and maybe sees the needle in the haystack.
Thanks in advance.
applying the iso in the vm
oscdimg without any problems
I just try to create an ISO from a WIM-file
I also splitted the WIM-file and put it into the target-folder

Golem Task respons back with runtime error 2, can't determine the cause

Repo for all code I've been using is updated here . When I run the requestor script it exits with a runtime error 2 (File not found). I am not sure how to further debug this or fix it. So far I've converted my code over to a python slim docker image to better mirror the example. It also works for me when I spin up a docker image that typing and running "/golem/work/imageclassifier.py --trainmodel" works from root. I switched all my code to use absolute paths. I also did make sure the shebang (#!) uses linux end of file characters rather than windows before which was giving me errors. Fixed a bug where my script returns error code 2 when called with no args to now pass.
clf.fit(trainDataGlobal, trainLabelsGlobal)
pkl_file = "classifier.pkl"
with open(pkl_file, 'wb') as file:
pickle.dump(clf, file)
is the only piece I could think of that causes the issue, but as far as I can tell this is the proper way to pickle something in python. Requestor script is also heavily based on the simple service example and I tried to mirror my design to that. I just need help in getting more information while debugging, or guidance on how to move forward from here

Disable write to ext4 after memory modification

I'm trying to modify user space application code in run-time from a Linux kernel driver.
Given the following code snippet:
writeCR3(process_cr3);
writeCR0(cr0 & ~X86_CR0_WP); // to allow writing to RO pages
*(char*)someUserAddress = 0x90; // just an example, nop
writeCR0(cr0 | X86_CR0_WP); // restore write protection
it successfully modifies the user application code in run-time but for some reason the file it self also changes (If I use 'OBJDUMP' or 'READELF' on the modified executable file after writing I can actually see that it has been modified) - it seems that it is getting written into the ext4 file system as well.
I do not want that. I want the code to be modified only inside the memory.
How do I achieve that? and why does the file system actually modify the file it self as well?

driver not working when built as built in driver

I wrote a basic character driver for beagle-bone which prints two message in 1 second interval via a workqueue and a tasklet using printk.
At first i build it as module driver, generated .ko file, load it using insmod command and the print is coming when viewed via dmesg.
Then i built as inbuilt driver and load the uImage and after bootup i checked the dmesg prints. But there is no prints.
In the .config file
CONFIG_MY_DRIVER=y
So its taken as built in driver i think.
How can i confirm whether its actually built in the final image. No error was reported while building.
Is there any additional steps to be done for loading the build in driver.
Please pardon me if i went wrong on any basics. I am really new to linux.
This means that you added it probably somewhere to Kconfig file:
"CONFIG_MY_DRIVER=y"
but, Have you added it to Makefile? It works like that, then kernel during a building an Image, takes all of this directives "CONFIG_*" and use it to build particular source files from Makefile.
Example:
cat fs/ext2/Makefile
ext2-$(CONFIG_EXT2_FS_SECURITY) += xattr_security.o
cat fs/ext2/Kconfig
config EXT2_FS_SECURITY
bool "Ext2 Security Labels"
depends on EXT2_FS_XATTR
so in this example above if your source file is xattr_security.c then you should get xattr_security.o file in fs/ext2 dir, when this is build. You should also see it if your file is build, during a compilation process.

About the /proc file system

I am using a command in the proc file system which is the following
echo 0 > /proc/sys/net/ipv4/ip_forward
Note: I don't want to know the basic of the command written above, I want what all happens when it goes inside the kernel. As, I want to implement one of the /proc file.
Now if I want to trace the code right from when the 0 is echoed in the file-system then how to go about it. I mean if I want to trace what happens when I do this.
I want to see where in the kernel code this 0 is accepted and in which value does it get stored inorder to make the changes. Please, can somebody tell what all happens when you call this command. I want in detail explain. I don't want the description of the command.
Any related article on how it changes the kernel parameters is also fine.
I have read this but, not explained there. http://www.linuxjournal.com/article/8381
Thanks
search through linux tree (especially network stack) for create_proc_entry function. Figure out what file creates ip_forward (it must be in ip4v drivers) from name passed to create_proc_entry.
When you find the file, look at where proc_dir_entry structure is created and what functions are assigned to its read_proc, write_proc members.

Resources