From: Andrew Cooper Subject: [PATCH v2] x86/domctl: Improve XEN_DOMCTL_hypercall_init error handling Date: Thu, 12 Mar 2015 11:03:22 +0000 Message-ID: <1426158202-27681-1-git-send-email-andrew.cooper3@citrix.com> References: <5500544702000078000688C8@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5500544702000078000688C8@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Andrew Cooper , Ian Jackson , Ian Campbell , Jan Beulich , Wei Liu List-Id: xen-devel@lists.xenproject.org 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 CC: Jan Beulich CC: Ian Campbell CC: Ian Jackson CC: Wei Liu --- 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(-) diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c index a141eb5..f82db2d 100644 --- a/tools/libxc/xc_dom_boot.c +++ b/tools/libxc/xc_dom_boot.c @@ -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; } diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 3e5bef1..d4f6ccf 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -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); -- 1.7.10.4