Debugging Xen in Qubes 4

44 views
Skip to first unread message

awokd

unread,
Jan 6, 2018, 10:20:44 AM1/6/18
to qubes...@googlegroups.com
Trying to debug an HVM PCI pass-through crash coming from:

https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/arch/x86/hvm/svm/svm.c;h=8edc846a2ed4aec6a5711d272adbb10aaa741c27;hb=5e4598106ed02ae4b43abcb29889969eb12867b7
1536 /* Everything else is an error. */
1537 mfn = __get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, 0, NULL, 0);
1538 gdprintk(XENLOG_ERR,
1539 "SVM violation gpa %#"PRIpaddr", mfn %#lx, type %i\n",
1540 gpa, mfn_x(mfn), p2mt);
1541 domain_crash(v->domain);

Which results in:

(XEN) domain_crash called from svm.c:1541
(XEN) Domain 10 (vcpu#0) crashed on cpu#2:
(XEN) ------[ Xen-4.8.2 x86_64 debug=n Not tainted ]------
(XEN) CPU: 2
(XEN) RIP: 0010:[<ffffffff97405f4e>]
(XEN) RFLAGS: 0000000000000296 CONTEXT: hvm guest (d10v0)
(XEN) rax: 0000000000000000 rbx: ffff97c946eb95c0 rcx: 0000000000000005
(XEN) rdx: 0000000000000040 rsi: ffffaf5580700040 rdi: 0000000000000000
(XEN) rbp: ffffaf55806cb8f8 rsp: ffffaf55806cb8c8 r8: 0000000000000000
(XEN) r9: 00000000ffffff90 r10: 000000000000003f r11: 0000000000000000
(XEN) r12: 0000000000000000 r13: ffffffffc04fb7d0 r14: 0000000000000100
(XEN) r15: ffff97c946eb4028 cr0: 0000000080050033 cr4: 00000000000406f0
(XEN) cr3: 0000000012e30000 cr2: 0000000000000000
(XEN) ds: 0000 es: 0000 fs: 0000 gs: 0000 ss: 0018 cs: 0010

Here's where I get lost. Can't find the output from that gdprintk
anywhere, with both loglvl=all and guest_loglvl=all. I think I want to
either change it to a printk and/or enable Xen debugging, which means a
recompile. What is the most newbish/straight-forward way to do that? Looks
like Qubes-builder compiles Xen in
chroot-fc25/home/user/rpmbuild/BUILD/xen-4.8.2. I can find and edit svm.c,
but can't figure out where I should enable Xen debugging and what to do
next.

awokd

unread,
Jan 6, 2018, 11:45:08 AM1/6/18
to aw...@danwin1210.me, qubes...@googlegroups.com
P.S. Posting this here instead of one of the Xen lists because this
pass-through works without crashing on a stock Fedora 26/Xen 4.8.2 boot on
the same hardware. There are more details in my Qubes-users thread
(https://mail-archive.com/qubes...@googlegroups.com/msg17452.html) but
I'm hoping I can get this narrowed down a bit more myself!


Marek Marczykowski-Górecki

unread,
Jan 6, 2018, 12:23:02 PM1/6/18
to aw...@danwin1210.me, qubes...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Yes, gdprintk is noop in non-debug build.

> What is the most newbish/straight-forward way to do that? Looks
> like Qubes-builder compiles Xen in
> chroot-fc25/home/user/rpmbuild/BUILD/xen-4.8.2. I can find and edit svm.c,
> but can't figure out where I should enable Xen debugging and what to do
> next.

You need to chroot into chroot-fc25 and switch to 'user' to compile it.
There you have all build dependencies installed. You can enable debug
using menuconfig. So, the easiest way to get Xen debug build is:

sudo chroot chroot-fc25 su -c 'make -C rpmbuild/BUILD/xen-4.8.2/xen menuconfig' - user
sudo chroot chroot-fc25 su -c 'make -C rpmbuild/BUILD/xen-4.8.2/xen' - user

Then get compiled Xen binary from
chroot-fc25/home/user/rpmbuild/BUILD/xen-4.8.2/xen/xen.{gz,efi}

- --
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEhrpukzGPukRmQqkK24/THMrX1ywFAlpRBd8ACgkQ24/THMrX
1yzVvwgAiBE+Gb+OGfgJtZDvDMh1HjLm4srQozp7yXLlcMeTDK/9Ev0wLHnqNoHT
prZFVfPjNZOguQRBEG0kLPWat/pqRJmnDpgnfkElJMpmBO6teooLVfbwF/pENohM
/ZRJ/v+ew/Wz7bL79FKErAYBOigL4QKw7syF4TlgBcdYFqHtohWaogvkoSuUxZUJ
BaenqIOf7bzU1mGcY8rtJxHhv6bkeL8dXbowALTs630z2gSljk5JOJIY7oB7aCaX
Z/n97RFxuvmHO1exRQEGMj4EGAmouFJNrHy5S/Lwm0zeQhBTV3UESGSgdDQg3pDR
AGPzTdHYN9/a0BsExoSEb1OKLx3haw==
=bkIu
-----END PGP SIGNATURE-----

awokd

unread,
Jan 6, 2018, 12:55:14 PM1/6/18
to qubes...@googlegroups.com
On Sat, January 6, 2018 5:22 pm, Marek Marczykowski-Górecki wrote:

> You need to chroot into chroot-fc25 and switch to 'user' to compile it.
> There you have all build dependencies installed. You can enable debug
> using menuconfig. So, the easiest way to get Xen debug build is:
>
> sudo chroot chroot-fc25 su -c 'make -C rpmbuild/BUILD/xen-4.8.2/xen
> menuconfig' - user sudo chroot chroot-fc25 su -c 'make -C
> rpmbuild/BUILD/xen-4.8.2/xen' - user
>
> Then get compiled Xen binary from
> chroot-fc25/home/user/rpmbuild/BUILD/xen-4.8.2/xen/xen.{gz,efi}

Thank you, compiling now!

Reply all
Reply to author
Forward
0 new messages