x86/domctl: Improve XEN_DOMCTL_hypercall_init error handling
PATCH 1/1 x86/domctl: Improve XEN_DOMCTL_hypercall_init error handling
EACCES cannot be distinguished against an incorrect DOMCTL_INTERFACE_VERSION, and will cause an incorrect "need to rebuild the user-space tool set?" message from libxc. EINVAL is a perfectly reasonable alternative.
On the libxc side, put the useful piece of information in the error message, rathe than the -1 from do_domctl().
--- tools/libxc/xc_dom_boot.c | 6 +++--- xen/arch/x86/domctl.c | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-)
tools/libxc/xc_dom_boot.c +3 -3
@@ -57,9 +57,9 @@ static int setup_hypercall_page(struct xc_dom_image *dom) domctl.u.hypercall_init.gmfn =xc_dom_p2m_guest (dom, pfn); rc =do_domctl (dom->xch, &domctl);if ( rc !=0 ) -xc_dom_panic (dom->xch, -XC_INTERNAL_ERROR ,"%s: HYPERCALL_INIT failed (rc=%d)" , - __FUNCTION__, rc); +xc_dom_panic (dom->xch,XC_INTERNAL_ERROR , +"%s: HYPERCALL_INIT failed: %d - %s)" , + __FUNCTION__, errno,strerror (errno));return rc; }
xen/arch/x86/domctl.c +1 -3
@@ -386,16 +386,14 @@ long arch_do_domctl( page =get_page_from_gfn (d, gmfn,NULL ,P2M_ALLOC ); - ret = -EACCES ;if ( !page || !get_page_type (page, PGT_writable_page) ) { + ret = -EINVAL ;if ( page )put_page (page);break ; } - ret =0 ; - hypercall_page =__map_domain_page (page);hypercall_page_initialise (d, hypercall_page);unmap_domain_page (hypercall_page);
Signature · 1 line
1.7.10.4
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 11.03.15 at 13:56, <[email protected]> wrote:
EACCES cannot be distinguished against an incorrect
DOMCTL_INTERFACE_VERSION, and will cause an incorrect "need to rebuild the user-space tool set?" message
from libxc. EINVAL is a perfectly reasonable alternative.
I'm okay with this for the !page case, but I think -EPERM or some such would be better suited when the page is non-writable but otherwise valid.
Jan
PATCH v2 1/6 tools/libxl: Introduce min and max macros
This is the same set used by libxc.
---
v2: Don't use reserved identifiers in min_t/max_t
--- tools/libxl/libxl_internal.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
tools/libxl/libxl_internal.h +16 -0
@@ -108,6 +108,22 @@#define ARRAY_SIZE (a) (sizeof(a) / sizeof(a[0])) +#define min (X ,Y ) ({ \ + const typeof (X) _x = (X); \ + const typeof (Y) _y = (Y); \ + (void) (&_x == &_y); \ + (_x < _y) ? _x : _y; }) +#define max (X ,Y ) ({ \ + const typeof (X) _x = (X); \ + const typeof (Y) _y = (Y); \ + (void) (&_x == &_y); \ + (_x > _y) ? _x : _y; }) + +#define min_t (type, x, y) \ + ({ const type _x = (x); const type _y = (y); _x < _y ? _x: _y; }) +#define max_t (type, x, y) \ + ({ const type _x = (x); const type _y = (y); _x > _y ? _x: _y; }) +#define LIBXL__LOGGING_ENABLED #ifdef LIBXL__LOGGING_ENABLED
Signature · 1 line
1.7.10.4
Re: [PATCH v2 1/6] tools/libxl: Introduce min and max macros
Quoted 2 lines · Andrew Cooper
This is the same set used by libxc.
Please ignore this - I had an accident with git-send-email.
~Andrew
PATCH v2 1/1 x86/domctl: Improve XEN_DOMCTL_hypercall_init error handling
In reply to Jan BeulichEACCES cannot be distinguished against an incorrect DOMCTL_INTERFACE_VERSION, and will cause an incorrect "need to rebuild the user-space tool set?" message from libxc.
On the libxc side, put the useful piece of information in the error message, rathe than the -1 from do_domctl().
---
v2: Split error between "no such frame" and "bad type"
--- tools/libxc/xc_dom_boot.c | 6 +++--- xen/arch/x86/domctl.c | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-)
tools/libxc/xc_dom_boot.c +3 -3
@@ -57,9 +57,9 @@ static int setup_hypercall_page(struct xc_dom_image *dom) domctl.u.hypercall_init.gmfn =xc_dom_p2m_guest (dom, pfn); rc =do_domctl (dom->xch, &domctl);if ( rc !=0 ) -xc_dom_panic (dom->xch, -XC_INTERNAL_ERROR ,"%s: HYPERCALL_INIT failed (rc=%d)" , - __FUNCTION__, rc); +xc_dom_panic (dom->xch,XC_INTERNAL_ERROR , +"%s: HYPERCALL_INIT failed: %d - %s)" , + __FUNCTION__, errno,strerror (errno));return rc; }
xen/arch/x86/domctl.c +5 -3
@@ -386,16 +386,18 @@ long arch_do_domctl( page =get_page_from_gfn (d, gmfn,NULL ,P2M_ALLOC ); - ret = -EACCES ;if ( !page || !get_page_type (page, PGT_writable_page) ) {if ( page ) + { + ret = -EPERM ;put_page (page); + } +else + ret = -EINVAL ;break ; } - ret =0 ; - hypercall_page =__map_domain_page (page);hypercall_page_initialise (d, hypercall_page);unmap_domain_page (hypercall_page);
Signature · 1 line
1.7.10.4
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 12.03.15 at 12:03, <[email protected]> wrote:
EACCES cannot be distinguished against an incorrect
DOMCTL_INTERFACE_VERSION, and will cause an incorrect "need to rebuild the user-space tool set?" message
from libxc.On the libxc side, put the useful piece of information in the error message, rathe than the -1 from
do_domctl().Signed-off-by Andrew Cooper <[email protected]>
Quoted 4 lines · Andrew Cooper
EACCES cannot be distinguished against an incorrect
DOMCTL_INTERFACE_VERSION, and will cause an incorrect "need to rebuild the user-space tool set?" message from libxc.
Quoted 9 lines
On the libxc side, put the useful piece of information in the error message, rathe than the -1 from
do_domctl().Signed-off-by Andrew Cooper <[email protected]>CC Jan Beulich <[email protected]>CC Ian Campbell <[email protected]>CC Ian Jackson <[email protected]>CC Wei Liu <[email protected]>