Allow chnaging of external varibles in the hypervisor
cover Allow chnaging of external varibles in the hypervisor
The 1st patch just skips calling rcu_lock_domain_by_id() for XEN_DOMCTL_gdbsx_guestmemio.
The code that handles XEN_DOMCTL_gdbsx_guestmemio, does not use d and has it's own domain checking code.
The 2nd patch is an example tool thats uses XEN_DOMCTL_gdbsx_guestmemio to read and modify the Hymbervisor's memeory.
Don Slutz (2):
gdbsx_guestmemio: Allow it to check domain.
Add xen-hyp-rw
.gitignore | 1 + tools/debugger/gdbsx/Makefile | 7 +- tools/debugger/gdbsx/xen-hyp-rw.c | 209 ++++++++++++++++++++++++++++++++++++ tools/debugger/gdbsx/xg/xg_main.c | 28 +++++ tools/debugger/gdbsx/xg/xg_public.h | 2 + xen/common/domctl.c | 1 + 6 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 tools/debugger/gdbsx/xen-hyp-rw.c
Signature · 1 line
1.8.4
PATCH 1/2 gdbsx_guestmemio: Allow it to check domain.
gdbsx_guest_mem_io() does not get d passed, it expects to handle the domain lookup itself.
--- xen/common/domctl.c | 1 + 1 file changed, 1 insertion(+)
xen/common/domctl.c +1 -0
@@ -443,6 +443,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)case XEN_DOMCTL_createdomain:case XEN_DOMCTL_getdomaininfo:case XEN_DOMCTL_test_assign_device: +case XEN_DOMCTL_gdbsx_guestmemio: d =NULL ;break ;default :
Signature · 1 line
1.8.4
Re: [PATCH 1/2] gdbsx_guestmemio: Allow it to check domain.
Quoted 5 lines · Don Slutz
gdbsx_guest_mem_io()does not get d passed, it expects to handle the domain lookup itself.Signed-off-by Don Slutz <[email protected]>CC Don Slutz <[email protected]>
As for the change itself, Reviewed-by: Andrew Cooper <[email protected]>
However, I think the commit message needs improving. Specifically, the caller of XEN_DOMCTL_gdbsx_guestmemio is expected to use DOMID_IDLE to interact with the hypervisor, rather than a domain, which doesn't interact well with with the domain rcu lock.
Quoted 16 lines
--- xen/common/domctl.c | 1 + 1 file changed, 1 insertion(+)xen/common/domctl.c +1
-0@@ -443,6 +443,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)case XEN_DOMCTL_createdomain:case XEN_DOMCTL_getdomaininfo:case XEN_DOMCTL_test_assign_device: +case XEN_DOMCTL_gdbsx_guestmemio: d =NULL ;break ;default :
Re: [PATCH 1/2] gdbsx_guestmemio: Allow it to check domain.
Quoted 7 lines · Andrew Cooper
Quoted 5 lines · Don Slutz
gdbsx_guest_mem_io()does not get d passed, it expects to handle the domain lookup itself.Signed-off-by Don Slutz <[email protected]>CC Don Slutz <[email protected]>
Quoted 7 lines
As for the change itself, Reviewed-by: Andrew Cooper <[email protected]>
However, I think the commit message needs improving. Specifically, the caller of
XEN_DOMCTL_gdbsx_guestmemiois expected to useDOMID_IDLEto interact with the hypervisor, rather than a domain, which doesn't interact well with with the domain rcu lock.
I am happy to change it to:
Specifically, the caller of XEN_DOMCTL_gdbsx_guestmemio is expected to use DOMID_IDLE to interact with the hypervisor, rather than a domain, which doesn't interact well with with the domain rcu lock.
Do you want me to add:
(h/t to Andrew Cooper for the patch summary.)
-Don Slutz
Quoted 18 lines
Quoted 17 lines
--- xen/common/domctl.c | 1 + 1 file changed, 1 insertion(+)xen/common/domctl.c +1
-0@@ -443,6 +443,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)case XEN_DOMCTL_createdomain:case XEN_DOMCTL_getdomaininfo:case XEN_DOMCTL_test_assign_device: +case XEN_DOMCTL_gdbsx_guestmemio: d =NULL ;break ;default :
PATCH 2/2 Add xen-hyp-rw
In reply to Don SlutzThis allows reading and writing of variables in the hypervisor.
for example (read case -- default 4 bytes):
xen-hyp-rw /boot/System.map-xen* opt_hvm_debug_level opt_hvm_debug_level @ 0xffff82d080285610 is 0x0(0)
Write case:
xen-hyp-rw /boot/System.map-xen* opt_hvm_debug_level 4 -1 opt_hvm_debug_level @ 0xffff82d080285610 is 0x0(0) opt_hvm_debug_level @ 0xffff82d080285610 set to 0xffffffff(4294967295)
--- .gitignore | 1 + tools/debugger/gdbsx/Makefile | 7 +- tools/debugger/gdbsx/xen-hyp-rw.c | 209 ++++++++++++++++++++++++++++++++++++ tools/debugger/gdbsx/xg/xg_main.c | 28 +++++ tools/debugger/gdbsx/xg/xg_public.h | 2 + 5 files changed, 246 insertions(+), 1 deletion(-) create mode 100644 tools/debugger/gdbsx/xen-hyp-rw.c
.gitignore +1 -0
@@ -104,6 +104,7 @@ tools/debugger/gdb/gdb-6.2.1-linux-i386-xen/* tools/debugger/gdb/gdb-6.2.1/* tools/debugger/gdb/gdb-6.2.1.tar.bz2 tools/debugger/gdbsx/gdbsx +tools/debugger/gdbsx/xen-hyp-rw tools/debugger/xenitp/xenitp tools/firmware/*/biossums tools/firmware/*.bin
tools/debugger/gdbsx/Makefile +6 -1
@@ -6,10 +6,11 @@ all: $(MAKE) -C gx $(MAKE) -C xg $(MAKE) gdbsx + $(MAKE) xen-hyp-rw .PHONY: clean clean: - rm -f xg_all.a gx_all.a gdbsx + rm -f xg_all.a gx_all.a gdbsx xen-hyp-rw set -e; for d in xg gx; do $(MAKE) -C $$d clean; done .PHONY: distclean
@@ -20,10 +21,14 @@ distclean: clean install: all [ -d $(DESTDIR)$(sbindir) ] || $(INSTALL_DIR) $(DESTDIR)$(sbindir) $(INSTALL_PROG) gdbsx $(DESTDIR)$(sbindir)/gdbsx + $(INSTALL_PROG) xen-hyp-rw $(DESTDIR)$(sbindir)/xen-hyp-rw gdbsx: gx/gx_all.a xg/xg_all.a $(CC) -o $@ $^ +xen-hyp-rw: xen-hyp-rw.c gx/gx_all.a xg/xg_all.a + $(CC) $(CFLAGS) $(CFLAGS_xeninclude) -o $@ $^ + xg/xg_all.a: $(MAKE) -C xg gx/gx_all.a:
tools/debugger/gdbsx/xen-hyp-rw.c new file +209 -0
209 lines not on this page · raw message
tools/debugger/gdbsx/xg/xg_main.c +28 -0
@@ -340,6 +340,7 @@ xg_detach_deinit(void)_unpause_domain ();close (_dom0_fd); +munlock (&domctl,sizeof (domctl)); }/*
@@ -829,6 +830,33 @@ xg_write_mem(uint64_t guestva, char *frombuf, int buflen, uint64_t pgd3val) }/* +* Attach to xen for debugging. +*/ +int +hyp_attach (int domid) +{ +XGTRC ("E:domid:%d\n" , domid); + + _dom_id = domctl.domain = domid; + domctl.interface_version =XEN_DOMCTL_INTERFACE_VERSION ; + +if (mlock (&domctl,sizeof (domctl))) { +XGERR ("Unable to pin domctl in memory. errno:%d\n" , errno); +return -1 ; + } + +return 0 ; +} + +/* Detach from xen for debugger exit */ +void +hyp_detach (void ) +{ +close (_dom0_fd); +munlock (&domctl,sizeof (domctl)); +} + +/* * Local variables: * mode: C * c-file-style: "BSD"
tools/debugger/gdbsx/xg/xg_public.h +2 -0
@@ -108,3 +108,5 @@ int xg_read_mem(uint64_t, char *, int, uint64_t);int xg_write_mem (uint64_t ,char *,int ,uint64_t );void xgprt (const char *fn,const char *fmt, ...);void xgtrc (const char *fn,const char *fmt, ...); +int hyp_attach (int ); +void hyp_detach (void );
Signature · 1 line
1.8.4
Re: [PATCH 2/2] Add xen-hyp-rw
Quoted 7 lines · Don Slutz
This allows reading and writing of variables in the hypervisor.
for example (read case -- default 4 bytes):
xen-hyp-rw
/boot/System.map-xen*opt_hvm_debug_levelopt_hvm_debug_level@0xffff82d080285610is 0x0(0)
Quoted 8 lines
Write case:
xen-hyp-rw
/boot/System.map-xen*opt_hvm_debug_level4 -1opt_hvm_debug_level@0xffff82d080285610is 0x0(0)opt_hvm_debug_level@0xffff82d080285610set to 0xffffffff(4294967295)Signed-off-by Don Slutz <[email protected]>CC Don Slutz <[email protected]>
As a crazy thought...
Would it not be easier to modify gdbsx to allow gdb to connect remotely to the hypervisor context?
That way, any gdb-like tools could consume an appropriate xen-syms and make changes like this.
~Andrew
Re: [PATCH 2/2] Add xen-hyp-rw
Quoted 14 lines · Andrew Cooper
Quoted 13 lines · Don Slutz
This allows reading and writing of variables in the hypervisor.
for example (read case -- default 4 bytes):
xen-hyp-rw
/boot/System.map-xen*opt_hvm_debug_levelopt_hvm_debug_level@0xffff82d080285610is 0x0(0)Write case:
xen-hyp-rw
/boot/System.map-xen*opt_hvm_debug_level4 -1opt_hvm_debug_level@0xffff82d080285610is 0x0(0)opt_hvm_debug_level@0xffff82d080285610set to 0xffffffff(4294967295)
Quoted 7 lines
Quoted 2 lines
Signed-off-by Don Slutz <[email protected]>CC Don Slutz <[email protected]>As a crazy thought...
Would it not be easier to modify gdbsx to allow gdb to connect remotely to the hypervisor context?
I tried this to start, but kept running into issues. A lot of them were about pausing and unpausing the target domain.
Quoted 4 lines
That way, any gdb-like tools could consume an appropriate xen-syms and make changes like this.
Yes. This code was a lot faster to get working.
I used a lot of the xg "library" of gdbsx to do the work. Only 2 new
routines: hyp_attach() and hyp_detach() in that code.
-Don Slutz
Quoted 2 lines
~Andrew