<div dir="ltr">I recently read about upcoming features from Intel[0]. One of those features are of EPT subpage permission, which is essentially another "EPT" table, with 128-bytes granularity, allowing you to set extra permissions for a certain part of a page.<div><br></div><div>Then, I remembered my old question, and realized I now have some sort-of answer.<br><div><br></div><div>This feature allows one to get more-or-less hardware breakpoint for a KVM guest, giving you effectively infinite number of breakpoints to any guest physical address (with a slightly larger granularity than "real" debug registers).</div><div><br></div><div>In fact KVM API is gaining the additional ioctls these days[1], and if I were maintaining the QEMU, I'd add to gdb-stub.c the ability to break on a HW address by using special, non-cannonical virtual prefix. Say hbr *0x80007....<phys-addr> would break when executing <phys-addr>, by recognizing the special prefix.</div><div><br></div><div>[0] <a href="https://software.intel.com/sites/default/files/managed/c5/15/architecture-instruction-set-extensions-programming-reference.pdf">https://software.intel.com/sites/default/files/managed/c5/15/architecture-instruction-set-extensions-programming-reference.pdf</a><br></div><div>[1] <a href="https://patchwork.kernel.org/patch/10007161/">https://patchwork.kernel.org/patch/10007161/</a></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 30, 2015 at 7:58 AM, Muli Ben-Yehuda <span dir="ltr"><<a href="mailto:mulix@mulix.org" target="_blank">mulix@mulix.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Sat, Aug 29, 2015 at 10:44:17PM +0300, Elazar Leibovich wrote:<br>
<br>
> Oh, and the idea of the KVM patch is, for each physical HW bp, add a<br>
> relevant entry in the spt, and set the hardware breakpoint<br>
> there. This is assuming KVM HW bp works like I think they do.<br>
<br>
</span>I'm not sure I follow what you are trying to do. But assuming you are<br>
working on a guest OS where some code running in guest context is<br>
modifying the page tables, assuming you always see the same PTE or the<br>
same range of PTEs being modified, I would just set the PTE mapping<br>
that PTE page to RO in KVM and wait for the inevitable exit. The stack<br>
trace should then point to the culprit. This crude but simple<br>
technique has served me well while writing nom (my operating<br>
system). Several time when it hadn't, it turned out that my network<br>
adapter was DMA'ing directly into memory it wasn't supposed to.<br>
<br>
Cheers,<br>
Muli<br>
</blockquote></div><br></div>