Re: QEMU on x64
Hi folks! Wanted to share some documentation if you all want to give QEMU a try within WinDbg. This is something we've been invested in supporting. - Link to public project: https://github.com/microsoft/WinDbg-Samples/tree/master/Exdi/exdigdbsrv <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FWinDbg-Samples%2Ftree%2Fmaster%2FExdi%2Fexdigdbsrv=04%7C01%7CChristopher.Caulfield%40microsoft.com%7C7f9c66afb4f74e9cd61e08d9a625465a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637723501320501730%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000=Bd%2Bvx2JaYtse35JmHigFtWLQzbXv1H9gZ1NseZB%2BF38%3D=0> - Link to external readme: WinDbg-Samples/ExdiGdbSrv_readme.md at master · microsoft/WinDbg-Samples · GitHub <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FWinDbg-Samples%2Fblob%2Fmaster%2FExdi%2Fexdigdbsrv%2Fdoc%2FExdiGdbSrv_readme.md=04%7C01%7CChristopher.Caulfield%40microsoft.com%7C7f9c66afb4f74e9cd61e08d9a625465a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637723501320511728%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000=kWn9Tlqtx1erYK8Pg0AHCSqNOLAYh171Cb9EmrR9cLg%3D=0> . Anyone planning to add the missing x86-64 system registers to the QEMU x86-64 GDb server?: QEMU registers support on x64 (#510) · Issues · QEMU / QEMU · GitLab <https://gitlab.com/qemu-project/qemu/-/issues/510>? (I just realized the title isn't great - O well...) Thanks so much! -Christopher On Mon, Aug 2, 2021 at 6:34 PM Christopher Caulfield wrote: > Thanks folks! I went ahead and made a feature/issue request based on > Paolo's suggestion: > QEMU registers support on x64 (#510) · Issues · QEMU / QEMU · GitLab > <https://gitlab.com/qemu-project/qemu/-/issues/510> > > Please let me know if someone has the cycles to support this. > > -Christopher > > On Mon, Aug 2, 2021 at 10:37 AM Alex Bennée > wrote: > >> >> Peter Maydell writes: >> >> > On Fri, 30 Jul 2021 at 19:05, Christopher Caulfield >> > wrote: >> >> This is Christopher from the debugging experiences team at Microsoft >> focused on kernel debugging. I am reaching out with a few questions about >> QEMU on x64. >> >> >> >> Is it possible for the QEMU-x86-64 GDB Server to send the full set >> >> of x64 system registers (whether they are included in a separated >> >> system xml file or as part of the core registers xml file)? >> > >> > Do you mean "is it possible for somebody to write code for >> > QEMU to make it do that", or "does QEMU do it today if you pass >> > it the right command line option" ? The answer to the former >> > is "yes", to the latter "no". (If you want the debugger to >> > be able to write to the system registers this might be a little >> > trickier, mostly in terms of "auditing the code to make sure this >> > can't confuse QEMU if you change some sysreg under its feet.".) >> > >> >> e.g. System registers missing from i386-64bit.xml file >> > >> >> DWORD64 IDTBase; >> >> DWORD64 IDTLimit; >> >> DWORD64 GDTBase; >> >> DWORD64 GDTLimit; >> >> DWORD SelLDT; >> >> SEG64_DESC_INFO SegLDT; >> >> DWORD SelTSS; >> >> SEG64_DESC_INFO SegTSS; >> >> >> >> How can I access x64 MSR registers by using the QEMU-x86-64 GDB server? >> >> >> >> #define MSR_EFER 0xc080 // extended function enable register >> > >> > EFER is in the xml ("x64_efer") so should be already accessible. >> > For anything else you're going to need to write some code to >> > make it happen. >> > >> >>is there any plan to support reading/writing to MSRs via QEMU-x86-64 >> >GDB server? >> >> Not at the moment but I am keen to see any eventual solution try to be >> generic rather than hardwired for one architecture. The ARM code >> currently builds custom XML from it's register descriptors to expose >> it's MSR registers to the gdbstub. Ideally architecture front ends >> should register their registers with a new subsystem which can then do >> the glue between gdbstub as well as other systems that also care about >> register values (logging, HMP, TCG plugins). >> >> That said I'm not going to block any patches that just fix up the >> current XML and target/i386/gdbstub code. I'm not familiar enough with >> what the internal register representation state is for x86 w.r.t to TCG >> and hypervisor based running modes. >> >> > Not that I know of. We'd be happy to review patches if you want to >> > write them. >> > >> > thanks >> > -- PMM >> >> >> -- >> Alex Bennée >> >
Re: QEMU on x64
Thanks folks! I went ahead and made a feature/issue request based on Paolo's suggestion: QEMU registers support on x64 (#510) · Issues · QEMU / QEMU · GitLab <https://gitlab.com/qemu-project/qemu/-/issues/510> Please let me know if someone has the cycles to support this. -Christopher On Mon, Aug 2, 2021 at 10:37 AM Alex Bennée wrote: > > Peter Maydell writes: > > > On Fri, 30 Jul 2021 at 19:05, Christopher Caulfield > > wrote: > >> This is Christopher from the debugging experiences team at Microsoft > focused on kernel debugging. I am reaching out with a few questions about > QEMU on x64. > >> > >> Is it possible for the QEMU-x86-64 GDB Server to send the full set > >> of x64 system registers (whether they are included in a separated > >> system xml file or as part of the core registers xml file)? > > > > Do you mean "is it possible for somebody to write code for > > QEMU to make it do that", or "does QEMU do it today if you pass > > it the right command line option" ? The answer to the former > > is "yes", to the latter "no". (If you want the debugger to > > be able to write to the system registers this might be a little > > trickier, mostly in terms of "auditing the code to make sure this > > can't confuse QEMU if you change some sysreg under its feet.".) > > > >> e.g. System registers missing from i386-64bit.xml file > > > >> DWORD64 IDTBase; > >> DWORD64 IDTLimit; > >> DWORD64 GDTBase; > >> DWORD64 GDTLimit; > >> DWORD SelLDT; > >> SEG64_DESC_INFO SegLDT; > >> DWORD SelTSS; > >> SEG64_DESC_INFO SegTSS; > >> > >> How can I access x64 MSR registers by using the QEMU-x86-64 GDB server? > >> > >> #define MSR_EFER 0xc080 // extended function enable register > > > > EFER is in the xml ("x64_efer") so should be already accessible. > > For anything else you're going to need to write some code to > > make it happen. > > > >>is there any plan to support reading/writing to MSRs via QEMU-x86-64 > >GDB server? > > Not at the moment but I am keen to see any eventual solution try to be > generic rather than hardwired for one architecture. The ARM code > currently builds custom XML from it's register descriptors to expose > it's MSR registers to the gdbstub. Ideally architecture front ends > should register their registers with a new subsystem which can then do > the glue between gdbstub as well as other systems that also care about > register values (logging, HMP, TCG plugins). > > That said I'm not going to block any patches that just fix up the > current XML and target/i386/gdbstub code. I'm not familiar enough with > what the internal register representation state is for x86 w.r.t to TCG > and hypervisor based running modes. > > > Not that I know of. We'd be happy to review patches if you want to > > write them. > > > > thanks > > -- PMM > > > -- > Alex Bennée >
Re: QEMU on x64
Peter Maydell writes: > On Fri, 30 Jul 2021 at 19:05, Christopher Caulfield > wrote: >> This is Christopher from the debugging experiences team at Microsoft focused >> on kernel debugging. I am reaching out with a few questions about QEMU on >> x64. >> >> Is it possible for the QEMU-x86-64 GDB Server to send the full set >> of x64 system registers (whether they are included in a separated >> system xml file or as part of the core registers xml file)? > > Do you mean "is it possible for somebody to write code for > QEMU to make it do that", or "does QEMU do it today if you pass > it the right command line option" ? The answer to the former > is "yes", to the latter "no". (If you want the debugger to > be able to write to the system registers this might be a little > trickier, mostly in terms of "auditing the code to make sure this > can't confuse QEMU if you change some sysreg under its feet.".) > >> e.g. System registers missing from i386-64bit.xml file > >> DWORD64 IDTBase; >> DWORD64 IDTLimit; >> DWORD64 GDTBase; >> DWORD64 GDTLimit; >> DWORD SelLDT; >> SEG64_DESC_INFO SegLDT; >> DWORD SelTSS; >> SEG64_DESC_INFO SegTSS; >> >> How can I access x64 MSR registers by using the QEMU-x86-64 GDB server? >> >> #define MSR_EFER 0xc080 // extended function enable register > > EFER is in the xml ("x64_efer") so should be already accessible. > For anything else you're going to need to write some code to > make it happen. > >>is there any plan to support reading/writing to MSRs via QEMU-x86-64 >GDB server? Not at the moment but I am keen to see any eventual solution try to be generic rather than hardwired for one architecture. The ARM code currently builds custom XML from it's register descriptors to expose it's MSR registers to the gdbstub. Ideally architecture front ends should register their registers with a new subsystem which can then do the glue between gdbstub as well as other systems that also care about register values (logging, HMP, TCG plugins). That said I'm not going to block any patches that just fix up the current XML and target/i386/gdbstub code. I'm not familiar enough with what the internal register representation state is for x86 w.r.t to TCG and hypervisor based running modes. > Not that I know of. We'd be happy to review patches if you want to > write them. > > thanks > -- PMM -- Alex Bennée
Re: QEMU on x64
On 30/07/21 19:36, Christopher Caulfield wrote: Hi QEMU community, This is Christopher from the debugging experiences team at Microsoft focused on kernel debugging. I am reaching out with a few questions about QEMU on x64. 1. Is it possible for the QEMU-x86-64 GDB Server to send the full set of x64 system registers (whether they are included in a separated system xml file or as part of the core registers xml file)? * e.g. System registers missing from i386-64bit.xml file DWORD64 IDTBase; DWORD64 IDTLimit; DWORD64 GDTBase; DWORD64 GDTLimit; DWORD SelLDT; SEG64_DESC_INFO SegLDT; DWORD SelTSS; SEG64_DESC_INFO SegTSS; Yes, that is possible. 2. How can I access x64 MSR registers by using the QEMU-x86-64 GDB server? * #define MSR_EFER 0xc080 // extended function enable register #define MSR_STAR 0xc081 // system call selectors #define MSR_LSTAR 0xc082 // system call 64-bit entry #define MSR_CSTAR 0xc083 // system call 32-bit entry 3. Going off of #2 - can you access it via reading GDB memory command? if not - is there any plan to support reading/writing to MSRs via QEMU-x86-64 GDB server? Right now it's not possible, but for specific MSRs it's possible to add them to the XML and export them. Can you create an issue on https://gitlab.com/qemu-project/qemu/-/issues please? Paolo
Re: QEMU on x64
On Fri, 30 Jul 2021 at 19:05, Christopher Caulfield wrote: > This is Christopher from the debugging experiences team at Microsoft focused > on kernel debugging. I am reaching out with a few questions about QEMU on x64. > > Is it possible for the QEMU-x86-64 GDB Server to send the full set of x64 > system registers (whether they are included in a separated system xml file or > as part of the core registers xml file)? Do you mean "is it possible for somebody to write code for QEMU to make it do that", or "does QEMU do it today if you pass it the right command line option" ? The answer to the former is "yes", to the latter "no". (If you want the debugger to be able to write to the system registers this might be a little trickier, mostly in terms of "auditing the code to make sure this can't confuse QEMU if you change some sysreg under its feet.".) > e.g. System registers missing from i386-64bit.xml file > DWORD64 IDTBase; > DWORD64 IDTLimit; > DWORD64 GDTBase; > DWORD64 GDTLimit; > DWORD SelLDT; > SEG64_DESC_INFO SegLDT; > DWORD SelTSS; > SEG64_DESC_INFO SegTSS; > > How can I access x64 MSR registers by using the QEMU-x86-64 GDB server? > > #define MSR_EFER 0xc080 // extended function enable register EFER is in the xml ("x64_efer") so should be already accessible. For anything else you're going to need to write some code to make it happen. >is there any plan to support reading/writing to MSRs via QEMU-x86-64 GDB >server? Not that I know of. We'd be happy to review patches if you want to write them. thanks -- PMM
QEMU on x64
Hi QEMU community, This is Christopher from the debugging experiences team at Microsoft focused on kernel debugging. I am reaching out with a few questions about QEMU on x64. 1. Is it possible for the QEMU-x86-64 GDB Server to send the full set of x64 system registers (whether they are included in a separated system xml file or as part of the core registers xml file)? - e.g. System registers missing from i386-64bit.xml file DWORD64 IDTBase; DWORD64 IDTLimit; DWORD64 GDTBase; DWORD64 GDTLimit; DWORD SelLDT; SEG64_DESC_INFO SegLDT; DWORD SelTSS; SEG64_DESC_INFO SegTSS; 2. How can I access x64 MSR registers by using the QEMU-x86-64 GDB server? - #define MSR_EFER 0xc080 // extended function enable register #define MSR_STAR 0xc081 // system call selectors #define MSR_LSTAR 0xc082 // system call 64-bit entry #define MSR_CSTAR 0xc083 // system call 32-bit entry 3. Going off of #2 - can you access it via reading GDB memory command? if not - is there any plan to support reading/writing to MSRs via QEMU-x86-64 GDB server? Thank you for taking time to answer our questions! :) -Christopher LinkedIn <https://www.linkedin.com/in/ctcaulfield/> | Twitter <https://twitter.com/ctcaulfield>
Re: [Qemu-devel] run qemu on x64 system ( ARCH=i386 or ARCH=x86-64) and on x86 system
it shows: -rwxr-xr-x 1 root root 265848 يول 18 2014 /sbin/init 2016-04-03 21:13 GMT+01:00 Marwa Hamza: > it shows: > -rwxr-xr-x 1 root root 265848 يول 18 2014 /sbin/init > > > 2016-04-03 20:49 GMT+01:00 Marwa Hamza : > >> the output of this command > ./i386-softmmu/qemu-system-i386 -M pc >> -kernel >> > >> /home/marwa/Bureau/lauterbach/i386_qemu/linux-4.1.18/arch/i386/boot/bzImage >> > -initrd >> /home/marwa/Bureau/lauterbach/i386_qemu/busybox-1.21.0/rootfs.img.gz >> > -append “root=/dev/ram rdinit=/sbin/init” >> > >> starting init :/sbin/init exists but couldn't execute it (error -8) >> starting init : /bin/sh exists but couldn't execute it (error -8) >> kernel panic not syncing : no working init found , try passing init= >> option to kernel >> >> 2016-04-03 19:38 GMT+01:00 Pranith Kumar : >> >>> On Sun, Apr 3, 2016 at 9:50 AM, Marwa Hamza >>> wrote: >>> >>> > ./i386-softmmu/qemu-system-i386 -M pc -kernel >>> > >>> /home/marwa/Bureau/lauterbach/i386_qemu/linux-4.1.18/arch/i386/boot/bzImage >>> > -initrd >>> /home/marwa/Bureau/lauterbach/i386_qemu/busybox-1.21.0/rootfs.img.gz >>> > -append “root=/dev/ram rdinit=/sbin/init” >>> > >>> >>> Can you post the output when you run this command? In particular, does >>> the /sbin/init exist in the rootfs? >>> >>> -- >>> Pranith >>> >> >> >
Re: [Qemu-devel] run qemu on x64 system ( ARCH=i386 or ARCH=x86-64) and on x86 system
it shows: -rwxr-xr-x 1 root root 265848 يول 18 2014 /sbin/init 2016-04-03 20:49 GMT+01:00 Marwa Hamza: > the output of this command > ./i386-softmmu/qemu-system-i386 -M pc > -kernel > > > /home/marwa/Bureau/lauterbach/i386_qemu/linux-4.1.18/arch/i386/boot/bzImage > > -initrd > /home/marwa/Bureau/lauterbach/i386_qemu/busybox-1.21.0/rootfs.img.gz > > -append “root=/dev/ram rdinit=/sbin/init” > > > starting init :/sbin/init exists but couldn't execute it (error -8) > starting init : /bin/sh exists but couldn't execute it (error -8) > kernel panic not syncing : no working init found , try passing init= > option to kernel > > 2016-04-03 19:38 GMT+01:00 Pranith Kumar : > >> On Sun, Apr 3, 2016 at 9:50 AM, Marwa Hamza >> wrote: >> >> > ./i386-softmmu/qemu-system-i386 -M pc -kernel >> > >> /home/marwa/Bureau/lauterbach/i386_qemu/linux-4.1.18/arch/i386/boot/bzImage >> > -initrd >> /home/marwa/Bureau/lauterbach/i386_qemu/busybox-1.21.0/rootfs.img.gz >> > -append “root=/dev/ram rdinit=/sbin/init” >> > >> >> Can you post the output when you run this command? In particular, does >> the /sbin/init exist in the rootfs? >> >> -- >> Pranith >> > >
Re: [Qemu-devel] run qemu on x64 system ( ARCH=i386 or ARCH=x86-64) and on x86 system
On Sun, Apr 3, 2016 at 3:49 PM, Marwa Hamzawrote: > the output of this command > ./i386-softmmu/qemu-system-i386 -M pc -kernel >> >> /home/marwa/Bureau/lauterbach/i386_qemu/linux-4.1.18/arch/i386/boot/bzImage >> -initrd >> /home/marwa/Bureau/lauterbach/i386_qemu/busybox-1.21.0/rootfs.img.gz >> -append “root=/dev/ram rdinit=/sbin/init” >> > starting init :/sbin/init exists but couldn't execute it (error -8) > starting init : /bin/sh exists but couldn't execute it (error -8) > kernel panic not syncing : no working init found , try passing init= option > to kernel > I don't think this is a qemu problem. From the error message it looks like init in your busybox root image is not configured properly. I would focus on finding why the init file is not able to run(permissions, maybe?). -- Pranith
Re: [Qemu-devel] run qemu on x64 system ( ARCH=i386 or ARCH=x86-64) and on x86 system
the output of this command > ./i386-softmmu/qemu-system-i386 -M pc -kernel > /home/marwa/Bureau/lauterbach/i386_qemu/linux-4.1.18/arch/i386/boot/bzImage > -initrd /home/marwa/Bureau/lauterbach/i386_qemu/busybox-1.21.0/rootfs.img.gz > -append “root=/dev/ram rdinit=/sbin/init” > starting init :/sbin/init exists but couldn't execute it (error -8) starting init : /bin/sh exists but couldn't execute it (error -8) kernel panic not syncing : no working init found , try passing init= option to kernel 2016-04-03 19:38 GMT+01:00 Pranith Kumar: > On Sun, Apr 3, 2016 at 9:50 AM, Marwa Hamza > wrote: > > > ./i386-softmmu/qemu-system-i386 -M pc -kernel > > > /home/marwa/Bureau/lauterbach/i386_qemu/linux-4.1.18/arch/i386/boot/bzImage > > -initrd > /home/marwa/Bureau/lauterbach/i386_qemu/busybox-1.21.0/rootfs.img.gz > > -append “root=/dev/ram rdinit=/sbin/init” > > > > Can you post the output when you run this command? In particular, does > the /sbin/init exist in the rootfs? > > -- > Pranith >
Re: [Qemu-devel] run qemu on x64 system ( ARCH=i386 or ARCH=x86-64) and on x86 system
On Sun, Apr 3, 2016 at 9:50 AM, Marwa Hamzawrote: > ./i386-softmmu/qemu-system-i386 -M pc -kernel > /home/marwa/Bureau/lauterbach/i386_qemu/linux-4.1.18/arch/i386/boot/bzImage > -initrd /home/marwa/Bureau/lauterbach/i386_qemu/busybox-1.21.0/rootfs.img.gz > -append “root=/dev/ram rdinit=/sbin/init” > Can you post the output when you run this command? In particular, does the /sbin/init exist in the rootfs? -- Pranith
Re: [Qemu-devel] run qemu on x64 system ( ARCH=i386 or ARCH=x86-64) and on x86 system
but i tried the same thing with arm arch ( file system made by busybox) and i used sh shell and it worked well 2016-04-03 20:20 GMT+02:00 Pranith Kumar <bobby.pr...@gmail.com>: > On Sun, Apr 3, 2016 at 9:50 AM, Marwa Hamza <marwahamz...@gmail.com> > wrote: > > hello , i tried to run qemu on x64 system , > > > > those are steps that i followed > > i compile the kernel 4.4.1 with arch =i386 > > i download busybox 1.21.0 > > make ARCH=i386 menuconfig > > I checked the option to compile Busybox as a static executable > > make ARCH=i386 install > > cd _install > > mkdir proc sys dev lib etc etc/init.d > > gedit etc/inittab > > ::sysinit:/etc/init.d/rcS > > sudo chmod +x etc/inittab > > sudo gedit etc/init.d/rcS > > #!/bin/sh > > Can you try changing this line to: "#!/sbin/ash"? > > I am not sure busybox has sh shell installed or configured properly. > That is what your error message is pointing to atleast. > > > > starting init :/bin/sh exists but couldn’t execute it > > kernel panic – not syncing no working init found > > > Thanks! > -- > Pranith >
Re: [Qemu-devel] run qemu on x64 system ( ARCH=i386 or ARCH=x86-64) and on x86 system
On Sun, Apr 3, 2016 at 9:50 AM, Marwa Hamza <marwahamz...@gmail.com> wrote: > hello , i tried to run qemu on x64 system , > > those are steps that i followed > i compile the kernel 4.4.1 with arch =i386 > i download busybox 1.21.0 > make ARCH=i386 menuconfig > I checked the option to compile Busybox as a static executable > make ARCH=i386 install > cd _install > mkdir proc sys dev lib etc etc/init.d > gedit etc/inittab > ::sysinit:/etc/init.d/rcS > sudo chmod +x etc/inittab > sudo gedit etc/init.d/rcS > #!/bin/sh Can you try changing this line to: "#!/sbin/ash"? I am not sure busybox has sh shell installed or configured properly. That is what your error message is pointing to atleast. > starting init :/bin/sh exists but couldn’t execute it > kernel panic – not syncing no working init found Thanks! -- Pranith
[Qemu-devel] run qemu on x64 system ( ARCH=i386 or ARCH=x86-64) and on x86 system
hello , i tried to run qemu on x64 system , those are steps that i followed i compile the kernel 4.4.1 with arch =i386 i download busybox 1.21.0 make ARCH=i386 menuconfig I checked the option to compile Busybox as a static executable make ARCH=i386 install cd _install mkdir proc sys dev lib etc etc/init.d gedit etc/inittab ::sysinit:/etc/init.d/rcS sudo chmod +x etc/inittab sudo gedit etc/init.d/rcS #!/bin/sh echo “hello” // hello display when starting the qemu mount -t proc none /proc mount -t sysfs none /sys /sbin/mdev -s sudo chmod +x _install/etc/init.d/rcS find . | cpio -o –format=newc > ../rootfs.img cd .. gzip -c rootfs.img > rootfs.img.gz ./i386-softmmu/qemu-system-i386 -M pc -kernel /home/marwa/Bureau/lauterbach/i386_qemu/linux-4.1.18/arch/i386/boot/bzImage -initrd /home/marwa/Bureau/lauterbach/i386_qemu/busybox-1.21.0/rootfs.img.gz -append “root=/dev/ram rdinit=/sbin/init” i have tried this command too ./i386-softmmu/qemu-system-i386 -M pc -kernel /home/marwa/Bureau/lauterbach/i386_qemu/linux-4.1.18/arch/i386/boot/bzImage -initrd /home/marwa/Bureau/lauterbach/i386_qemu/busybox-1.21.0/rootfs.img.gz -append “root=/dev/ram rdinit=/bin/sh” but i got this msg in qemu ‘shell starting init :/bin/sh exists but couldn’t execute it kernel panic – not syncing no working init found should i work with another file system ? or create a new one , I got the same error with x86 , , any one please can help me to get qemu working perfectly thanks