aboutsummaryrefslogtreecommitdiffhomepage
path: root/print.html
diff options
context:
space:
mode:
authorjohannst <johannst@users.noreply.github.com>2021-02-16 22:34:33 +0000
committerjohannst <johannst@users.noreply.github.com>2021-02-16 22:34:33 +0000
commitf2d341eb19d222c96446a3a7f20eaef53dbcacfa (patch)
tree7e15f7ae7c7557302313b9e0160931e5f67c14bb /print.html
parent03952b648648d7b52334569b5361218be9d68d77 (diff)
downloadnotes-f2d341eb19d222c96446a3a7f20eaef53dbcacfa.tar.gz
notes-f2d341eb19d222c96446a3a7f20eaef53dbcacfa.zip
deploy: e7acb2ed6b15dbd35350516a87e7b77e5ecbca0a
Diffstat (limited to 'print.html')
-rw-r--r--print.html94
1 files changed, 91 insertions, 3 deletions
diff --git a/print.html b/print.html
index d3fa8d3..2b67942 100644
--- a/print.html
+++ b/print.html
@@ -83,7 +83,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
- <ol class="chapter"><li class="expanded affix "><a href="intro.html">Introduction</a></li><li class="expanded "><a href="tools/index.html"><strong aria-hidden="true">1.</strong> Tools</a></li><li><ol class="section"><li class="expanded "><a href="tools/zsh.html"><strong aria-hidden="true">1.1.</strong> zsh</a></li><li class="expanded "><a href="tools/bash.html"><strong aria-hidden="true">1.2.</strong> bash</a></li><li class="expanded "><a href="tools/fish.html"><strong aria-hidden="true">1.3.</strong> fish</a></li><li class="expanded "><a href="tools/tmux.html"><strong aria-hidden="true">1.4.</strong> tmux</a></li><li class="expanded "><a href="tools/git.html"><strong aria-hidden="true">1.5.</strong> git</a></li><li class="expanded "><a href="tools/awk.html"><strong aria-hidden="true">1.6.</strong> awk</a></li><li class="expanded "><a href="tools/emacs.html"><strong aria-hidden="true">1.7.</strong> emacs</a></li><li class="expanded "><a href="tools/gpg.html"><strong aria-hidden="true">1.8.</strong> gpg</a></li><li class="expanded "><a href="tools/gdb.html"><strong aria-hidden="true">1.9.</strong> gdb</a></li><li class="expanded "><a href="tools/radare2.html"><strong aria-hidden="true">1.10.</strong> radare2</a></li></ol></li><li class="expanded "><a href="monitor/index.html"><strong aria-hidden="true">2.</strong> Resource analysis &amp; monitor</a></li><li><ol class="section"><li class="expanded "><a href="monitor/lsof.html"><strong aria-hidden="true">2.1.</strong> lsof</a></li><li class="expanded "><a href="monitor/ss.html"><strong aria-hidden="true">2.2.</strong> ss</a></li><li class="expanded "><a href="monitor/pidstat.html"><strong aria-hidden="true">2.3.</strong> pidstat</a></li><li class="expanded "><a href="monitor/pgrep.html"><strong aria-hidden="true">2.4.</strong> pgrep</a></li><li class="expanded "><a href="monitor/pmap.html"><strong aria-hidden="true">2.5.</strong> pmap</a></li><li class="expanded "><a href="monitor/pstack.html"><strong aria-hidden="true">2.6.</strong> pstack</a></li></ol></li><li class="expanded "><a href="trace_profile/index.html"><strong aria-hidden="true">3.</strong> Trace and Profile</a></li><li><ol class="section"><li class="expanded "><a href="trace_profile/strace.html"><strong aria-hidden="true">3.1.</strong> strace</a></li><li class="expanded "><a href="trace_profile/ltrace.html"><strong aria-hidden="true">3.2.</strong> ltrace</a></li><li class="expanded "><a href="trace_profile/perf.html"><strong aria-hidden="true">3.3.</strong> perf</a></li><li class="expanded "><a href="trace_profile/oprofile.html"><strong aria-hidden="true">3.4.</strong> OProfile</a></li><li class="expanded "><a href="trace_profile/time.html"><strong aria-hidden="true">3.5.</strong> time</a></li></ol></li><li class="expanded "><a href="binary/index.html"><strong aria-hidden="true">4.</strong> Binary</a></li><li><ol class="section"><li class="expanded "><a href="binary/od.html"><strong aria-hidden="true">4.1.</strong> od</a></li><li class="expanded "><a href="binary/xxd.html"><strong aria-hidden="true">4.2.</strong> xxd</a></li><li class="expanded "><a href="binary/readelf.html"><strong aria-hidden="true">4.3.</strong> readelf</a></li><li class="expanded "><a href="binary/objdump.html"><strong aria-hidden="true">4.4.</strong> objdump</a></li><li class="expanded "><a href="binary/nm.html"><strong aria-hidden="true">4.5.</strong> nm</a></li></ol></li><li class="expanded "><a href="development/index.html"><strong aria-hidden="true">5.</strong> Development</a></li><li><ol class="section"><li class="expanded "><a href="development/c++filt.html"><strong aria-hidden="true">5.1.</strong> c++filt</a></li><li class="expanded "><a href="development/c++.html"><strong aria-hidden="true">5.2.</strong> c++</a></li><li class="expanded "><a href="development/glibc.html"><strong aria-hidden="true">5.3.</strong> glibc</a></li><li class="expanded "><a href="development/gcc.html"><strong aria-hidden="true">5.4.</strong> gcc</a></li><li class="expanded "><a href="development/make.html"><strong aria-hidden="true">5.5.</strong> make</a></li><li class="expanded "><a href="development/ld.so.html"><strong aria-hidden="true">5.6.</strong> ld.so</a></li></ol></li><li class="expanded "><a href="arch/index.html"><strong aria-hidden="true">6.</strong> Arch</a></li><li><ol class="section"><li class="expanded "><a href="arch/x86_64.html"><strong aria-hidden="true">6.1.</strong> x86_64</a></li><li class="expanded "><a href="arch/arm64.html"><strong aria-hidden="true">6.2.</strong> arm64</a></li></ol></li></ol>
+ <ol class="chapter"><li class="expanded affix "><a href="intro.html">Introduction</a></li><li class="expanded "><a href="tools/index.html"><strong aria-hidden="true">1.</strong> Tools</a></li><li><ol class="section"><li class="expanded "><a href="tools/zsh.html"><strong aria-hidden="true">1.1.</strong> zsh</a></li><li class="expanded "><a href="tools/bash.html"><strong aria-hidden="true">1.2.</strong> bash</a></li><li class="expanded "><a href="tools/fish.html"><strong aria-hidden="true">1.3.</strong> fish</a></li><li class="expanded "><a href="tools/tmux.html"><strong aria-hidden="true">1.4.</strong> tmux</a></li><li class="expanded "><a href="tools/git.html"><strong aria-hidden="true">1.5.</strong> git</a></li><li class="expanded "><a href="tools/awk.html"><strong aria-hidden="true">1.6.</strong> awk</a></li><li class="expanded "><a href="tools/emacs.html"><strong aria-hidden="true">1.7.</strong> emacs</a></li><li class="expanded "><a href="tools/gpg.html"><strong aria-hidden="true">1.8.</strong> gpg</a></li><li class="expanded "><a href="tools/gdb.html"><strong aria-hidden="true">1.9.</strong> gdb</a></li><li class="expanded "><a href="tools/radare2.html"><strong aria-hidden="true">1.10.</strong> radare2</a></li><li class="expanded "><a href="tools/qemu.html"><strong aria-hidden="true">1.11.</strong> qemu</a></li></ol></li><li class="expanded "><a href="monitor/index.html"><strong aria-hidden="true">2.</strong> Resource analysis &amp; monitor</a></li><li><ol class="section"><li class="expanded "><a href="monitor/lsof.html"><strong aria-hidden="true">2.1.</strong> lsof</a></li><li class="expanded "><a href="monitor/ss.html"><strong aria-hidden="true">2.2.</strong> ss</a></li><li class="expanded "><a href="monitor/pidstat.html"><strong aria-hidden="true">2.3.</strong> pidstat</a></li><li class="expanded "><a href="monitor/pgrep.html"><strong aria-hidden="true">2.4.</strong> pgrep</a></li><li class="expanded "><a href="monitor/pmap.html"><strong aria-hidden="true">2.5.</strong> pmap</a></li><li class="expanded "><a href="monitor/pstack.html"><strong aria-hidden="true">2.6.</strong> pstack</a></li></ol></li><li class="expanded "><a href="trace_profile/index.html"><strong aria-hidden="true">3.</strong> Trace and Profile</a></li><li><ol class="section"><li class="expanded "><a href="trace_profile/strace.html"><strong aria-hidden="true">3.1.</strong> strace</a></li><li class="expanded "><a href="trace_profile/ltrace.html"><strong aria-hidden="true">3.2.</strong> ltrace</a></li><li class="expanded "><a href="trace_profile/perf.html"><strong aria-hidden="true">3.3.</strong> perf</a></li><li class="expanded "><a href="trace_profile/oprofile.html"><strong aria-hidden="true">3.4.</strong> OProfile</a></li><li class="expanded "><a href="trace_profile/time.html"><strong aria-hidden="true">3.5.</strong> time</a></li></ol></li><li class="expanded "><a href="binary/index.html"><strong aria-hidden="true">4.</strong> Binary</a></li><li><ol class="section"><li class="expanded "><a href="binary/od.html"><strong aria-hidden="true">4.1.</strong> od</a></li><li class="expanded "><a href="binary/xxd.html"><strong aria-hidden="true">4.2.</strong> xxd</a></li><li class="expanded "><a href="binary/readelf.html"><strong aria-hidden="true">4.3.</strong> readelf</a></li><li class="expanded "><a href="binary/objdump.html"><strong aria-hidden="true">4.4.</strong> objdump</a></li><li class="expanded "><a href="binary/nm.html"><strong aria-hidden="true">4.5.</strong> nm</a></li></ol></li><li class="expanded "><a href="development/index.html"><strong aria-hidden="true">5.</strong> Development</a></li><li><ol class="section"><li class="expanded "><a href="development/c++filt.html"><strong aria-hidden="true">5.1.</strong> c++filt</a></li><li class="expanded "><a href="development/c++.html"><strong aria-hidden="true">5.2.</strong> c++</a></li><li class="expanded "><a href="development/glibc.html"><strong aria-hidden="true">5.3.</strong> glibc</a></li><li class="expanded "><a href="development/gcc.html"><strong aria-hidden="true">5.4.</strong> gcc</a></li><li class="expanded "><a href="development/make.html"><strong aria-hidden="true">5.5.</strong> make</a></li><li class="expanded "><a href="development/ld.so.html"><strong aria-hidden="true">5.6.</strong> ld.so</a></li></ol></li><li class="expanded "><a href="arch/index.html"><strong aria-hidden="true">6.</strong> Arch</a></li><li><ol class="section"><li class="expanded "><a href="arch/x86_64.html"><strong aria-hidden="true">6.1.</strong> x86_64</a></li><li class="expanded "><a href="arch/arm64.html"><strong aria-hidden="true">6.2.</strong> arm64</a></li></ol></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav>
@@ -165,6 +165,7 @@
<li><a href="tools/./gpg.html">gpg</a></li>
<li><a href="tools/./gdb.html">gdb</a></li>
<li><a href="tools/./radare2.html">radare2</a></li>
+<li><a href="tools/./qemu.html">qemu</a></li>
</ul>
<h1><a class="header" href="#zsh1" id="zsh1">zsh(1)</a></h1>
<h2><a class="header" href="#keybindings" id="keybindings">Keybindings</a></h2>
@@ -1533,6 +1534,93 @@ executed. To workaround that bug one can create a wrapper function which calls
<pre><code class="language-markdown"> &gt; r2 -B &lt;baddr&gt; &lt;exe&gt; # open &lt;exe&gt; mapped to addr &lt;baddr&gt;
oob &lt;addr&gt; # reopen current file at &lt;baddr&gt;
</code></pre>
+<h1><a class="header" href="#qemu1" id="qemu1">qemu(1)</a></h1>
+<p>All the examples &amp; notes use <code>qemu-system-x86_64</code> but in most cases
+this can be swapped with the system emulator for other architectures.</p>
+<h2><a class="header" href="#keybindings-1" id="keybindings-1">Keybindings</a></h2>
+<pre><code class="language-markdown">Ctrl+Alt+g release mouse capture from VM
+
+Ctrl+Alt+1 switch to display of VM
+Ctrl+Alt+2 switch to qemu monitor
+</code></pre>
+<h2><a class="header" href="#vm-config-snippet" id="vm-config-snippet">VM config snippet</a></h2>
+<p>Following command-line gives a good starting point to assemble a VM:</p>
+<pre><code class="language-bash">qemu-system-x86_64 \
+ -cpu host -enable-kvm -smp 4 \
+ -m 8G \
+ -vga virtio -display sdl,gl=on \
+ -boot menu=on \
+ -cdrom &lt;iso&gt; \
+ -hda &lt;disk&gt; \
+ -device qemu-xhci,id=xhci \
+ -device usb-host,bus=xhci.0,vendorid=0x05e1,productid=0x0408,id=capture-card
+</code></pre>
+<h3><a class="header" href="#cpu--ram" id="cpu--ram">CPU &amp; RAM</a></h3>
+<ul>
+<li><code>-cpu host</code> emulate host CPU in guest VM</li>
+<li><code>-enable-kvm</code> use KVM instead software models (requires KVM on host machine)</li>
+<li><code>-smp &lt;N&gt;</code> number of guest CPUs</li>
+</ul>
+<blockquote>
+<p>List available CPUs <code>qemu-system-x86_64 -cpu help</code>.</p>
+</blockquote>
+<ul>
+<li><code>-m 8G</code> size of guest RAM</li>
+</ul>
+<h3><a class="header" href="#graphic--display" id="graphic--display">Graphic &amp; Display</a></h3>
+<ul>
+<li><code>-vga virtio</code> use virtio as 3D video graphic accelerator (requires virgl in guest)</li>
+<li><code>-display sdl,gl=on</code> use sdl window and enable openGL context</li>
+</ul>
+<h3><a class="header" href="#boot-menu" id="boot-menu">Boot Menu</a></h3>
+<ul>
+<li><code>-boot menu=on</code> enables boot menu to select boot device (enter with <code>ESC</code>)</li>
+</ul>
+<h3><a class="header" href="#block-devices" id="block-devices">Block devices</a></h3>
+<ul>
+<li><code>-cdrom &lt;iso&gt;</code> attach cdrom drive with iso to a VM</li>
+<li><code>-hda &lt;disk&gt;</code> attach disk drive to a VM</li>
+<li><code>-drive file=&lt;file&gt;,format=qcow2</code> generic way to configure &amp; attach a drive to a VM</li>
+</ul>
+<h4><a class="header" href="#create-a-disk-with-a-hrefhttpsqemureadthedocsioenlatesttoolsqemu-imghtmlqemu-imga" id="create-a-disk-with-a-hrefhttpsqemureadthedocsioenlatesttoolsqemu-imghtmlqemu-imga">Create a disk with <a href="https://qemu.readthedocs.io/en/latest/tools/qemu-img.html"><code>qemu-img</code></a></a></h4>
+<p>To create a <code>qcow2</code> disk (qemu copy-on-write) of size <code>10G</code>:</p>
+<pre><code class="language-bash">qemu-img create -f qcow2 disk.qcow2 10G
+</code></pre>
+<p>The disk does not contain any <code>partitions</code> or a <code>partition table</code>.
+We can format the disk from <strong>within the <strong>guest</strong></strong> as following example:</p>
+<pre><code class="language-bash"># Create `gpt` partition table.
+sudo parted /dev/sda mktable gpt
+
+# Create two equally sized primary partitions.
+sudo parted /dev/sda mkpart primary 0% 50%
+sudo parted /dev/sda mkpart primary 50% 100%
+
+# Create filesystem on each partition.
+sudo mkfs.ext3 /dev/sda1
+sudo mkfs.ext4 /dev/sda2
+
+lsblk -f /dev/sda
+ NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
+ sda
+ ├─sda1 ext3 ....
+ └─sda2 ext4 ....
+</code></pre>
+<h3><a class="header" href="#usb" id="usb">USB</a></h3>
+<h4><a class="header" href="#host-controller" id="host-controller">Host Controller</a></h4>
+<ul>
+<li><code>-device qemu-xhci,id=xhci</code> add XHCI USB controller to the VM (supports USB 3.0, 2.0, 1.1). <code>id=xhci</code> creates a usb bus named <code>xhci</code>.</li>
+</ul>
+<h4><a class="header" href="#usb-device" id="usb-device">USB Device</a></h4>
+<ul>
+<li><code>-device usb-host,bus=xhci.0,vendorid=0x05e1,productid=0x0408</code> pass-through USB device from host identified by vendorid &amp; productid and attach to usb bus <code>xhci.0</code> (defined with controller <code>id</code>)</li>
+</ul>
+<h2><a class="header" href="#references" id="references">References</a></h2>
+<ul>
+<li><a href="https://github.com/qemu/qemu/blob/master/docs/usb2.txt">QEMU USB</a></li>
+<li><a href="https://qemu.readthedocs.io/en/latest/tools/qemu-img.html">QEMU IMG</a></li>
+<li><a href="https://qemu.readthedocs.io/en/latest/tools/index.html">QEMU Tools</a></li>
+<li><a href="https://www.qemu.org/docs/master/system/index.html">QEMU System</a></li>
+</ul>
<h1><a class="header" href="#resource-analysis--monitor" id="resource-analysis--monitor">Resource analysis &amp; monitor</a></h1>
<ul>
<li><a href="monitor/./lsof.html">lsof</a></li>
@@ -2382,7 +2470,7 @@ greeting_len:
<pre><code class="language-bash">&gt; gcc -o greet greet.s -nostartfiles -nostdlib &amp;&amp; ./greet
Hi ASM-World!
</code></pre>
-<h2><a class="header" href="#references" id="references">References</a></h2>
+<h2><a class="header" href="#references-1" id="references-1">References</a></h2>
<ul>
<li><a href="https://www.uclibc.org/docs/psABI-x86_64.pdf">SystemV AMD64 ABI</a></li>
<li><a href="https://www.amd.com/system/files/TechDocs/24592.pdf">AMD64 Vol1: Application Programming</a></li>
@@ -2586,7 +2674,7 @@ Hi ASM-World!
<p>Cross-compiling on <code>Ubuntu 20.04</code>, paths might differ on other distributions.
Compiling natively on arm64, specifying the dynamic linker should not be required.</p>
</blockquote>
-<h2><a class="header" href="#references-1" id="references-1">References</a></h2>
+<h2><a class="header" href="#references-2" id="references-2">References</a></h2>
<ul>
<li><a href="https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst">Procedure Call Standard ARM64</a></li>
<li><a href="https://developer.arm.com/documentation/den0024/a">ARMv8 Programmer's Guide</a></li>