|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] libxc: Pause & unpause the domain in xc_mem_event_enable based on its initial state.
In an attempt to mitigate XSA-99, xc_mem_event_enable ensures that the domain
is paused
for the duration of the event ring setup. However, it disregards the initial
state of
the domain, which might already be paused, resulting in 1) an uneccessary
hypercall to
pause it again and 2) unpauses it unconditionally which is an opaque and
potentially
unwanted side-effect. This patch fixes both issues.
Signed-off-by: Tamas K Lengyel <tamas.k.lengyel@xxxxxx>
---
tools/libxc/xc_mem_event.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/tools/libxc/xc_mem_event.c b/tools/libxc/xc_mem_event.c
index 0b2eecb..5cf74d0 100644
--- a/tools/libxc/xc_mem_event.c
+++ b/tools/libxc/xc_mem_event.c
@@ -62,6 +62,7 @@ void *xc_mem_event_enable(xc_interface *xch, domid_t
domain_id, int param,
void *ring_page = NULL;
unsigned long pfn;
xen_pfn_t ring_pfn, mmap_pfn;
+ xc_domaininfo_t dom_info;
unsigned int op, mode;
int rc1, rc2, saved_errno;
@@ -71,14 +72,24 @@ void *xc_mem_event_enable(xc_interface *xch, domid_t
domain_id, int param,
return NULL;
}
- /* Pause the domain for ring page setup */
- rc1 = xc_domain_pause(xch, domain_id);
- if ( rc1 != 0 )
+ rc1 = xc_domain_getinfolist(xch, domain_id, 1, &dom_info);
+ if ( rc1 != 1 || dom_info.domain != domain_id )
{
- PERROR("Unable to pause domain\n");
+ PERROR("Error getting domain info\n");
return NULL;
}
+ /* Pause the domain for ring page setup if it isn't already */
+ if( !(dom_info.flags & XEN_DOMINF_paused) )
+ {
+ rc1 = xc_domain_pause(xch, domain_id);
+ if ( rc1 != 0 )
+ {
+ PERROR("Unable to pause domain\n");
+ return NULL;
+ }
+ }
+
/* Get the pfn of the ring page */
rc1 = xc_get_hvm_param(xch, domain_id, param, &pfn);
if ( rc1 != 0 )
@@ -154,7 +165,16 @@ void *xc_mem_event_enable(xc_interface *xch, domid_t
domain_id, int param,
out:
saved_errno = errno;
- rc2 = xc_domain_unpause(xch, domain_id);
+ /* Only unpause the domain if it was running originally */
+ if( !(dom_info.flags & XEN_DOMINF_paused) )
+ {
+ rc2 = xc_domain_unpause(xch, domain_id);
+ }
+ else
+ {
+ rc2 = 0;
+ }
+
if ( rc1 != 0 || rc2 != 0 )
{
if ( rc2 != 0 )
--
2.0.0
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |