make error codes a formal part of the ABI
RFC PATCH 1/1 make error codes a formal part of the ABI
Now that we have two cases where patches against hvmloader got submitted needing to include the hypervisor's errno.h (for the host's system header not necessarily reflecting the correct numbers), take this as a strong sign that we need to make the error return values part of the hypervisor ABI (which de-fact they've always been).
---
There's on small block commented with TBD left in the public header. This is the main reason for the submission being RFC. While we don't currently use these error codes, I'm not sure if we should leave all or some of them out for the time being.
xen/include/asm-arm/page.h +1 -1
@@ -2,7 +2,6 @@#define __ARM_PAGE_H__#include <xen/config.h> -#include <xen/errno.h> #include <public/xen.h> #include <asm/processor.h>
@@ -83,6 +82,7 @@#ifndef __ASSEMBLY__ +#include <xen/errno.h> #include <xen/types.h> #include <xen/lib.h>
xen/include/asm-x86/multicall.h +6 -4
@@ -24,7 +24,7 @@" callq *%%rax; " \"1: movq %%rax,%c4(%0)\n" \".section .fixup,\"ax\"\n" \ - "2: movq $-"STR(ENOSYS)",%%rax\n" \ +"2: movq %5,%%rax\n" \" jmp 1b\n" \".previous\n" \ : \
@@ -32,7 +32,8 @@ "i" (offsetof(__typeof__(*_call), op)), \ "i" (offsetof(__typeof__(*_call), args)), \ "i" (sizeof(*(_call)->args)), \ - "i" (offsetof(__typeof__(*_call), result)) \ + "i" (offsetof(__typeof__(*_call), result)), \ + "i" (-ENOSYS) \ /* all the caller-saves registers */ \ : "rax", "rcx", "rdx", "rsi", "rdi", \ "r8", "r9", "r10", "r11" ); \
@@ -54,7 +55,7 @@" callq *%%rax; " \"1: movl %%eax,%c4(%0)\n" \".section .fixup,\"ax\"\n" \ - "2: movl $-"STR(ENOSYS)",%%eax\n" \ +"2: movl %5,%%eax\n" \" jmp 1b\n" \".previous\n" \ : \
@@ -62,7 +63,8 @@ "i" (offsetof(__typeof__(*_call), op)), \ "i" (offsetof(__typeof__(*_call), args)), \ "i" (sizeof(*(_call)->args)), \ - "i" (offsetof(__typeof__(*_call), result)) \ + "i" (offsetof(__typeof__(*_call), result)), \ + "i" (-ENOSYS) \ /* all the caller-saves registers */ \ : "rax", "rcx", "rdx", "rsi", "rdi", \ "r8", "r9", "r10", "r11" ) \
xen/include/public/errno.h new file +94 -0
94 lines not on this page · raw message
xen/include/xen/errno.h +15 -132
152 lines not on this page · raw message
make error codes a formal part of the ABI
Now that we have two cases where patches against hvmloader got submitted needing to include the hypervisor's errno.h (for the host's system header not necessarily reflecting the correct numbers), take this as a strong sign that we need to make the error return values part of the hypervisor ABI (which de-fact they've always been).
---
There's on small block commented with TBD left in the public header. This is the main reason for the submission being RFC. While we don't currently use these error codes, I'm not sure if we should leave all or some of them out for the time being.
xen/include/asm-arm/page.h +1 -1
@@ -2,7 +2,6 @@#define __ARM_PAGE_H__#include <xen/config.h> -#include <xen/errno.h> #include <public/xen.h> #include <asm/processor.h>
@@ -83,6 +82,7 @@#ifndef __ASSEMBLY__ +#include <xen/errno.h> #include <xen/types.h> #include <xen/lib.h>
xen/include/asm-x86/multicall.h +6 -4
@@ -24,7 +24,7 @@" callq *%%rax; " \"1: movq %%rax,%c4(%0)\n" \".section .fixup,\"ax\"\n" \ - "2: movq $-"STR(ENOSYS)",%%rax\n" \ +"2: movq %5,%%rax\n" \" jmp 1b\n" \".previous\n" \ : \
@@ -32,7 +32,8 @@ "i" (offsetof(__typeof__(*_call), op)), \ "i" (offsetof(__typeof__(*_call), args)), \ "i" (sizeof(*(_call)->args)), \ - "i" (offsetof(__typeof__(*_call), result)) \ + "i" (offsetof(__typeof__(*_call), result)), \ + "i" (-ENOSYS) \ /* all the caller-saves registers */ \ : "rax", "rcx", "rdx", "rsi", "rdi", \ "r8", "r9", "r10", "r11" ); \
@@ -54,7 +55,7 @@" callq *%%rax; " \"1: movl %%eax,%c4(%0)\n" \".section .fixup,\"ax\"\n" \ - "2: movl $-"STR(ENOSYS)",%%eax\n" \ +"2: movl %5,%%eax\n" \" jmp 1b\n" \".previous\n" \ : \
@@ -62,7 +63,8 @@ "i" (offsetof(__typeof__(*_call), op)), \ "i" (offsetof(__typeof__(*_call), args)), \ "i" (sizeof(*(_call)->args)), \ - "i" (offsetof(__typeof__(*_call), result)) \ + "i" (offsetof(__typeof__(*_call), result)), \ + "i" (-ENOSYS) \ /* all the caller-saves registers */ \ : "rax", "rcx", "rdx", "rsi", "rdi", \ "r8", "r9", "r10", "r11" ) \
xen/include/public/errno.h new file +94 -0
94 lines not on this page · raw message
xen/include/xen/errno.h +15 -132
152 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 5 lines · Jan Beulich
Now that we have two cases where patches against hvmloader got submitted needing to include the hypervisor's
errno.h(for the host's system header not necessarily reflecting the correct numbers), take this as a strong sign that we need to make the error return values part of the hypervisor ABI (which de-fact they've always been).
Yes, I think this is a good move.
Quoted 6 lines
Signed-off-by Jan Beulich <[email protected]>---
There's on small block commented with TBD left in the public header. This is the main reason for the submission being RFC. While we don't currently use these error codes, I'm not sure if we should leave all or some of them out for the time being.
I say lets omit any we don't use for now.
xen/include/public/errno.h line 6
Quoted 9 lines
xen/include/public/errno.h new file +6
-0@@ -0,0 +1,94 @@ +#ifndef __XEN_PUBLIC_ERRNO_H__ + +#ifndef __ASSEMBLY__ + +#define XEN_ERRNO (name, value) XEN_##name = value, +enum xen_errno {
The switch to an enum doesn't seem related to the main purpose of the patch, unless I'm missing something?
xen/include/public/errno.h line 10
Quoted 3 lines
xen/include/public/errno.h new file +3
-0+#else /* !__ASSEMBLY__ */ + +#define XEN_ERRNO (name, value) .equ XEN_##name, value
So here public/errno.h defines it's own XEN_ERRNO for ASM vs none. But then later xen/errno.h also defines it before including the public version. Also the enum xen_errno seems to be similarly duplicated. (I suspect you changed your mind and forgot to save one or the other file?). I think the includer chooses the namespace approach makes most sense.
(I suppose someone needs to patch libxc et al to actually use this)
Quoted 6 lines
xen/include/public/errno.h new file +6
-0+ +#endif /* __ASSEMBLY__ */ + +/* ` enum neg_errnoval { [ -Efoo for each Efoo in the list below ] } */ +/* ` enum errnoval { */ +
xen/include/public/errno.h line 26
Quoted 10 lines
xen/include/public/errno.h new file +10
-0+#endif /* __XEN_PUBLIC_ERRNO_H__ */ + +#ifdef XEN_ERRNO + +XEN_ERRNO(EPERM, 1) /* Operation not permitted */ +XEN_ERRNO(ENOENT, 2) /* No such file or directory */ +XEN_ERRNO(ESRCH, 3) /* No such process */ +#ifdef __XEN__ +XEN_ERRNO(EINTR, 4) /* Interrupted system call */ +#endif
I take it this is because something prevents this value ever getting exposes to userspace? (Continuations?). I think keeping that away from guest API is a good idea, but if it's completely internal perhaps we should move it up into a region which we reserve for ourselves?
Ian.
Ian Campbell writes ("Re: [PATCH RFC] make error codes a formal part of the ABI"):
Quoted 7 lines · Jan Beulich
Quoted 4 lines
There's on small block commented with TBD left in the public header. This is the main reason for the submission being RFC. While we don't currently use these error codes, I'm not sure if we should leave all or some of them out for the time being.
I say lets omit any we don't use for now.
Is it possible that anyone is using the existing header file where these values were defined ? If so their code might say
case ELOOP:
which would not compile when they switched to the new header.
I don't know whether this is likely, or a problem.
Ian.
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 13.01.15 at 17:57, <[email protected]> wrote:
Ian Campbell writes ("Re: [PATCH RFC] make error codes a formal part of the ABI"):
Quoted 6 lines · Jan Beulich
Quoted 4 lines
There's on small block commented with TBD left in the public header. This is the main reason for the submission being RFC. While we don't currently use these error codes, I'm not sure if we should leave all or some of them out for the time being.
Quoted 6 lines
Quoted 1 line
I say lets omit any we don't use for now.
Is it possible that anyone is using the existing header file where these values were defined ? If so their code might say
case ELOOP:
which would not compile when they switched to the new header.
The existing header is a hypervisor private one. Any code outside the hypervisor using it imo deserves to get broken.
Jan
Quoted 11 lines · Ian Jackson
Ian Campbell writes ("Re: [PATCH RFC] make error codes a formal part of the ABI"):
Quoted 7 lines · Jan Beulich
Quoted 4 lines
There's on small block commented with TBD left in the public header. This is the main reason for the submission being RFC. While we don't currently use these error codes, I'm not sure if we should leave all or some of them out for the time being.
I say lets omit any we don't use for now.
Is it possible that anyone is using the existing header file where these values were defined ?
It's not installed or in the regular header paths, so it seems unlikely, or at least they would have had to jump through some hoops and no doubt have a big comment about their fragile hack...
Quoted 7 lines
If so their code might say
case ELOOP:
which would not compile when they switched to the new header.I don't know whether this is likely, or a problem.
Ian.
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 13.01.15 at 17:35, <[email protected]> wrote:
xen/include/public/errno.h line 6
Quoted 9 lines · Jan Beulich
xen/include/public/errno.h new file +6
-0@@ -0,0 +1,94 @@ +#ifndef __XEN_PUBLIC_ERRNO_H__ + +#ifndef __ASSEMBLY__ + +#define XEN_ERRNO (name, value) XEN_##name = value, +enum xen_errno {The switch to an enum doesn't seem related to the main purpose of the patch, unless I'm missing something?
No, this is an integral part of the change: A macro can't be used to generate preprocessor directives (i.e. #define-s).
Quoted 10 lines
xen/include/public/errno.h line 10
Quoted 3 lines
xen/include/public/errno.h new file +3
-0+#else /* !__ASSEMBLY__ */ + +#define XEN_ERRNO (name, value) .equ XEN_##name, valueSo here
public/errno.hdefines it's ownXEN_ERRNOfor ASM vs none. But then laterxen/errno.halso defines it before including the public version. Also the enumxen_errnoseems to be similarly duplicated. (I suspect you changed your mind and forgot to save one or the other file?). I think the includer chooses the namespace approach makes most sense.
No, this again is intentional and - imo - necessary: A plain #include <public/errno.h> ought to suffice to get all XEN_E* definitions. That's not so much for Xen's internal purposes, but more for actual consumers of the public headers. For Xen's internal purposes, a plain #include <xen/errno.h> ought to suffice and produce (at least) the non-XEN_-prefixed values. Hence xen/errno.h has to double-include public/errno.h, once without overriding XEN_ERRNO() and then a second time with doing so.
Quoted 1 line
(I suppose someone needs to patch libxc et al to actually use this)
The primary consumer, as said in the description, is meant to be hvmloader. But yes, other tools parts may also want to follow that.
Quoted 11 lines
Quoted 11 lines
xen/include/public/errno.h new file +11
-0+ +#endif /* __ASSEMBLY__ */ + +/* ` enum neg_errnoval { [ -Efoo for each Efoo in the list below ] } */ +/* ` enum errnoval { */ + +#endif /* __XEN_PUBLIC_ERRNO_H__ */ + +#ifdef XEN_ERRNO + +XEN_ERRNO (EPERM ,1 )/* Operation not permitted */
Quoted 8 lines
xen/include/public/errno.h line 26
Quoted 5 lines
xen/include/public/errno.h new file +5
-0+XEN_ERRNO(ENOENT, 2) /* No such file or directory */ +XEN_ERRNO(ESRCH, 3) /* No such process */ +#ifdef __XEN__ +XEN_ERRNO(EINTR, 4) /* Interrupted system call */ +#endif I take it this is because something prevents this value ever getting exposes to userspace? (Continuations?).
Yes. The thus framed values are supposed to never reach the caller of a hypercall.
Quoted 3 lines
I think keeping that away from
guest API is a good idea, but if it's completely internal perhaps we should move it up into a region which we reserve for ourselves?
That would be at the risk of (later) creating conflicting definitions. I specifically wanted to preserve the original values and ordering.
Jan
Quoted 15 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 13.01.15 at 17:35, <[email protected]> wrote:
xen/include/public/errno.h line 6
Quoted 9 lines · Jan Beulich
xen/include/public/errno.h new file +6
-0@@ -0,0 +1,94 @@ +#ifndef __XEN_PUBLIC_ERRNO_H__ + +#ifndef __ASSEMBLY__ + +#define XEN_ERRNO (name, value) XEN_##name = value, +enum xen_errno {The switch to an enum doesn't seem related to the main purpose of the patch, unless I'm missing something?
Quoted 2 lines
No, this is an integral part of the change: A macro can't be used to generate preprocessor directives (i.e. #define-s).
Oh right, yes.
Given the ABI pitfalls of enums (size etc) perhaps make it anonymous?
Quoted 11 lines
Quoted 10 lines
xen/include/public/errno.h line 10
Quoted 3 lines
xen/include/public/errno.h new file +3
-0+#else /* !__ASSEMBLY__ */ + +#define XEN_ERRNO (name, value) .equ XEN_##name, valueSo here
public/errno.hdefines it's ownXEN_ERRNOfor ASM vs none. But then laterxen/errno.halso defines it before including the public version. Also the enumxen_errnoseems to be similarly duplicated. (I suspect you changed your mind and forgot to save one or the other file?). I think the includer chooses the namespace approach makes most sense.
Quoted 8 lines
No, this again is intentional and - imo - necessary: A plain #include <
public/errno.h> ought to suffice to get all XEN_E* definitions. That's not so much for Xen's internal purposes, but more for actual consumers of the public headers. For Xen's internal purposes, a plain #include <xen/errno.h> ought to suffice and produce (at least) the non-XEN_-prefixed values. Hencexen/errno.hhas to double-includepublic/errno.h, once without overridingXEN_ERRNO()and then a second time with doing so.
Oh I see now that you are relying on the multi-inclusion guard to also guard the definition of the default version of XEN_ERRNO macro, which is a bit tricksy (and wasn't obvious until I applied the patch and looked at the result).
Can you make this more explicit while leaving the guard with its usual semantics? e.g.
#ifndef XEN_ERRNO
#if .. Asm ...
#define ...
#else
#define ...
#endif
and in xen/errno.h:
#include <public/errno.h>
/* We explicitly want a second include with separate names. */
#undef __XEN_PUBLIC_ERRNO_H__
#if ... asm...
#define ...
#include <...>
#else
#define ...
enum {
#include <...>
}
#endifIf you don't like the #undef then perhaps move the value list into public/errno-values.h as a bare list which requires XEN_ERRNO to be defined by the includer and has no guard of its own, so it can be included from both the public and private errno.h with the correct context?
Quoted 5 lines
Quoted 1 line
(I suppose someone needs to patch libxc et al to actually use this)
The primary consumer, as said in the description, is meant to be hvmloader. But yes, other tools parts may also want to follow that.
/me wonders how libxc has been getting away with out this until now, especially on non-Linux platforms.
Fixing libxc to correctly disambiguate xen errno's from genuine syscalls ones is going to suck... Oh well, not your problem at least, lucky you ;-)
Quoted 24 lines
Quoted 12 lines
Quoted 12 lines
xen/include/public/errno.h new file +11
-0+ +#endif /* __ASSEMBLY__ */ + +/* ` enum neg_errnoval { [ -Efoo for each Efoo in the list below ] } */ +/* ` enum errnoval { */ + +#endif /* __XEN_PUBLIC_ERRNO_H__ */ + +#ifdef XEN_ERRNO + +XEN_ERRNO (EPERM ,1 )/* Operation not permitted */ Quoted 8 lines
xen/include/public/errno.h line 26
Quoted 5 lines
xen/include/public/errno.h new file +5
-0+XEN_ERRNO(ENOENT, 2) /* No such file or directory */ +XEN_ERRNO(ESRCH, 3) /* No such process */ +#ifdef __XEN__ +XEN_ERRNO(EINTR, 4) /* Interrupted system call */ +#endif I take it this is because something prevents this value ever getting exposes to userspace? (Continuations?).
Yes. The thus framed values are supposed to never reach the caller of a hypercall.
Quoted 6 lines
Quoted 3 lines
I think keeping that away from
guest API is a good idea, but if it's completely internal perhaps we should move it up into a region which we reserve for ourselves?That would be at the risk of (later) creating conflicting definitions. I specifically wanted to preserve the original values and ordering.
Good reason.
Perhaps
#ifdef __XEN__ /* Internal only, should never be exposed to the guest */ since there isn't so many of them to make that onerous.
Ian.
Hi Ian,
Quoted 8 lines · Ian Campbell
Quoted 5 lines
Quoted 1 line
(I suppose someone needs to patch libxc et al to actually use this)
The primary consumer, as said in the description, is meant to be hvmloader. But yes, other tools parts may also want to follow that.
/me wonders how libxc has been getting away with out this until now, especially on non-Linux platforms.
On FreeBSD, we translate the XEN errno to the guest one in the privcmd drivers.
Regards,
Signature · 1 line
Julien Grall
Quoted 9 lines · Julien Grall
Hi Ian,
Quoted 6 lines · Ian Campbell
Quoted 5 lines
Quoted 1 line
(I suppose someone needs to patch libxc et al to actually use this)
The primary consumer, as said in the description, is meant to be hvmloader. But yes, other tools parts may also want to follow that.
Quoted 5 lines
Quoted 2 lines
/me wonders how libxc has been getting away with out this until now, especially on non-Linux platforms.
On FreeBSD, we translate the XEN errno to the guest one in the privcmd drivers.
Ah, I looked in tools/libxc/*bsd* but didn't think to look in the kernel itself.
Quoted 2 lines
OK, so essentially the requirement is that libxc should see the guest's own ERRNO numbers and changing libxc to use xen's numbers would just be wrong.
Which is good, because making that change would be a nightmare!
Ian.
Quoted 15 lines · Ian Campbell
Quoted 11 lines · Julien Grall
Hi Ian,
Quoted 6 lines · Ian Campbell
Quoted 4 lines
Quoted 1 line
(I suppose someone needs to patch libxc et al to actually use this)
The primary consumer, as said in the description, is meant to be hvmloader. But yes, other tools parts may also want to follow that.
/me wonders how libxc has been getting away with out this until now, especially on non-Linux platforms.
On FreeBSD, we translate the XEN errno to the guest one in the privcmd drivers.
Ah, I looked in
tools/libxc/*bsd*but didn't think to look in the kernel itself.
Quoted 7 lines
Quoted 2 lines
OK, so essentially the requirement is that libxc should see the guest's own ERRNO numbers and changing libxc to use xen's numbers would just be wrong.
Which is good, because making that change would be a nightmare!
It is not so simple.
Currently, the hypercall ioctl overloads errno from both the kernel and Xen. This makes it impossible for libxc to programmaticly distinguish an kernel error from a Xen error (e.g. where did an EFAULT come from).
Ideally, the correct solution would be for the ioctl to return -1/errno for a kernel failure alone, and then have the top level stub inspect args[0] for the Xen error. This would require libxc to know about both the local errnos and Xen errnos.
~Andrew
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 14.01.15 at 11:28, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 13.01.15 at 17:35, <[email protected]> wrote:
xen/include/public/errno.h line 6
Quoted 9 lines · Jan Beulich
xen/include/public/errno.h new file +6
-0@@ -0,0 +1,94 @@ +#ifndef __XEN_PUBLIC_ERRNO_H__ + +#ifndef __ASSEMBLY__ + +#define XEN_ERRNO (name, value) XEN_##name = value, +enum xen_errno {The switch to an enum doesn't seem related to the main purpose of the patch, unless I'm missing something?
Quoted 6 lines
Quoted 2 lines
No, this is an integral part of the change: A macro can't be used to generate preprocessor directives (i.e. #define-s).
Oh right, yes.
Given the ABI pitfalls of enums (size etc) perhaps make it anonymous?
Could do, but no-one is required to use the enum as a type. I just wanted to _allow_ people using it if they want.
Quoted 28 lines
Quoted 11 lines
Quoted 10 lines
xen/include/public/errno.h line 10
Quoted 3 lines
xen/include/public/errno.h new file +3
-0+#else /* !__ASSEMBLY__ */ + +#define XEN_ERRNO (name, value) .equ XEN_##name, valueSo here
public/errno.hdefines it's ownXEN_ERRNOfor ASM vs none. But then laterxen/errno.halso defines it before including the public version. Also the enumxen_errnoseems to be similarly duplicated. (I suspect you changed your mind and forgot to save one or the other file?). I think the includer chooses the namespace approach makes most sense.Quoted 8 lines
No, this again is intentional and - imo - necessary: A plain #include <
public/errno.h> ought to suffice to get all XEN_E* definitions. That's not so much for Xen's internal purposes, but more for actual consumers of the public headers. For Xen's internal purposes, a plain #include <xen/errno.h> ought to suffice and produce (at least) the non-XEN_-prefixed values. Hencexen/errno.hhas to double-includepublic/errno.h, once without overridingXEN_ERRNO()and then a second time with doing so.Oh I see now that you are relying on the multi-inclusion guard to also guard the definition of the default version of
XEN_ERRNOmacro, which is a bit tricksy (and wasn't obvious until I applied the patch and looked at the result).Can you make this more explicit while leaving the guard with its usual semantics? e.g.
Quoted 6 lines
#ifndef
XEN_ERRNO
#if .. Asm ...
#define ...
#else
#define ...
#endif
I don't think that would work when including public/errno.h a second time. Or maybe I'm not getting how you envision things to be...
Quoted 16 lines
and in
xen/errno.h:#include <public/errno.h> /* We explicitly want a second include with separate names. */ #undef __XEN_PUBLIC_ERRNO_H__ #if ... asm... #define ... #include <...> #else #define ... enum { #include <...> } #endif
Quoted 5 lines
If you don't like the #undef then perhaps move the value list into
public/errno-values.has a bare list which requiresXEN_ERRNOto be defined by the includer and has no guard of its own, so it can be included from both the public and privateerrno.hwith the correct context?
To be honest I prefer a solution with just a single new public header, even if it ends up using some trickery (so long as it doesn't violate any language requirements).
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
I think keeping that away from
guest API is a good idea, but if it's completely internal perhaps we should move it up into a region which we reserve for ourselves?
Quoted 8 lines
Quoted 2 lines
That would be at the risk of (later) creating conflicting definitions. I specifically wanted to preserve the original values and ordering.
Good reason.
Perhaps
#ifdef__XEN__/* Internal only, should never be exposed to the guest */ since there isn't so many of them to make that onerous.
Sure, easily added.
Jan
Quoted 20 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 14.01.15 at 11:28, <[email protected]> wrote:
Quoted 17 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 13.01.15 at 17:35, <[email protected]> wrote:
xen/include/public/errno.h line 6
Quoted 9 lines · Jan Beulich
xen/include/public/errno.h new file +6
-0@@ -0,0 +1,94 @@ +#ifndef __XEN_PUBLIC_ERRNO_H__ + +#ifndef __ASSEMBLY__ + +#define XEN_ERRNO (name, value) XEN_##name = value, +enum xen_errno {The switch to an enum doesn't seem related to the main purpose of the patch, unless I'm missing something?
No, this is an integral part of the change: A macro can't be used to generate preprocessor directives (i.e. #define-s).
Quoted 6 lines
Quoted 3 lines
Oh right, yes.
Given the ABI pitfalls of enums (size etc) perhaps make it anonymous?
Could do, but no-one is required to use the enum as a type. I just wanted to _allow_ people using it if they want.
I was thinking to avoid presenting them with the temptation.
Quoted 25 lines
Quoted 25 lines
Quoted 11 lines
Quoted 10 lines
xen/include/public/errno.h line 10
Quoted 3 lines
xen/include/public/errno.h new file +3
-0+#else /* !__ASSEMBLY__ */ + +#define XEN_ERRNO (name, value) .equ XEN_##name, valueSo here
public/errno.hdefines it's ownXEN_ERRNOfor ASM vs none. But then laterxen/errno.halso defines it before including the public version. Also the enumxen_errnoseems to be similarly duplicated. (I suspect you changed your mind and forgot to save one or the other file?). I think the includer chooses the namespace approach makes most sense.Quoted 8 lines
No, this again is intentional and - imo - necessary: A plain #include <
public/errno.h> ought to suffice to get all XEN_E* definitions. That's not so much for Xen's internal purposes, but more for actual consumers of the public headers. For Xen's internal purposes, a plain #include <xen/errno.h> ought to suffice and produce (at least) the non-XEN_-prefixed values. Hencexen/errno.hhas to double-includepublic/errno.h, once without overridingXEN_ERRNO()and then a second time with doing so.Oh I see now that you are relying on the multi-inclusion guard to also guard the definition of the default version of
XEN_ERRNOmacro, which is a bit tricksy (and wasn't obvious until I applied the patch and looked at the result).
Quoted 8 lines
Quoted 8 lines
Can you make this more explicit while leaving the guard with its usual semantics? e.g.
#ifndef
XEN_ERRNO
#if .. Asm ...
#define ...
#else
#define ...
enum xen_errno {Quoted 4 lines
Quoted 1 line
#endif
I don't think that would work when including
public/errno.ha second time. Or maybe I'm not getting how you envision things to be...
I forgot the enum stuff above, I've inserted it in the quote.
The second time around XEN_ERRNO would be defined and so none of that stuff would happen, just the list of XEN_ERRNO(value..) would be evaluated (in the context of xen/errno.h's "enum {").
Thinking about it now I guess some more trickery would be needed for the closing } of the enum xen_errno, which could well end up being a cure worse than the disease.
Quoted 3 lines
To be honest I prefer a solution with just a single new public header, even if it ends up using some trickery (so long as it doesn't violate any language requirements).
I lean the other way, but not enough to continue arguing, so: ok.
Ian.
Quoted 6 lines · Jan Beulich
Now that we have two cases where patches against hvmloader got submitted needing to include the hypervisor's
errno.h(for the host's system header not necessarily reflecting the correct numbers), take this as a strong sign that we need to make the error return values part of the hypervisor ABI (which de-fact they've always been).
Quoted 6 lines
Signed-off-by Jan Beulich <[email protected]>---
There's on small block commented with TBD left in the public header. This is the main reason for the submission being RFC. While we don't currently use these error codes, I'm not sure if we should leave all or some of them out for the time being.
I would suggest that we drop any error codes not in use. We can always add them back in in the future if they are needed.
I would also suggest that we note the heritage, being taken from Linux 2.$mumble, which will act as a guide for introducing new codes in the future.
Finally, I would suggest that we assign the Xen meaning (e.g. EACCES = bad tool interface) rather than Linux meanings.
Quoted 78 lines
xen/include/asm-arm/page.h +1
-1@@ -2,7 +2,6 @@#define __ARM_PAGE_H__#include <xen/config.h> -#include <xen/errno.h> #include <public/xen.h> #include <asm/processor.h> @@ -83,6 +82,7 @@#ifndef __ASSEMBLY__ +#include <xen/errno.h> #include <xen/types.h> #include <xen/lib.h> xen/include/asm-x86/multicall.h +6
-4@@ -24,7 +24,7 @@" callq *%%rax; " \"1: movq %%rax,%c4(%0)\n" \".section .fixup,\"ax\"\n" \ - "2: movq $-"STR(ENOSYS)",%%rax\n" \ +"2: movq %5,%%rax\n" \" jmp 1b\n" \".previous\n" \ : \@@ -32,7 +32,8 @@ "i" (offsetof(__typeof__(*_call), op)), \ "i" (offsetof(__typeof__(*_call), args)), \ "i" (sizeof(*(_call)->args)), \ - "i" (offsetof(__typeof__(*_call), result)) \ + "i" (offsetof(__typeof__(*_call), result)), \ + "i" (-ENOSYS) \ /* all the caller-saves registers */ \ : "rax", "rcx", "rdx", "rsi", "rdi", \ "r8", "r9", "r10", "r11" ); \@@ -54,7 +55,7 @@" callq *%%rax; " \"1: movl %%eax,%c4(%0)\n" \".section .fixup,\"ax\"\n" \ - "2: movl $-"STR(ENOSYS)",%%eax\n" \ +"2: movl %5,%%eax\n" \" jmp 1b\n" \".previous\n" \ : \@@ -62,7 +63,8 @@ "i" (offsetof(__typeof__(*_call), op)), \ "i" (offsetof(__typeof__(*_call), args)), \ "i" (sizeof(*(_call)->args)), \ - "i" (offsetof(__typeof__(*_call), result)) \ + "i" (offsetof(__typeof__(*_call), result)), \ + "i" (-ENOSYS) \ /* all the caller-saves registers */ \ : "rax", "rcx", "rdx", "rsi", "rdi", \ "r8", "r9", "r10", "r11" ) \xen/include/public/errno.h new file +16
-0@@ -0,0 +1,94 @@ +#ifndef __XEN_PUBLIC_ERRNO_H__ + +#ifndef __ASSEMBLY__ + +#define XEN_ERRNO (name, value) XEN_##name = value, +enum xen_errno { + +#else /* !__ASSEMBLY__ */ + +#define XEN_ERRNO (name, value) .equ XEN_##name, value + +#endif /* __ASSEMBLY__ */ + +/* ` enum neg_errnoval { [ -Efoo for each Efoo in the list below ] } */ +/* ` enum errnoval { */ +
xen/include/public/errno.h line 26
Quoted 10 lines
xen/include/public/errno.h new file +10
-0+#endif /* __XEN_PUBLIC_ERRNO_H__ */ + +#ifdef XEN_ERRNO + +XEN_ERRNO(EPERM, 1) /* Operation not permitted */ +XEN_ERRNO(ENOENT, 2) /* No such file or directory */ +XEN_ERRNO(ESRCH, 3) /* No such process */ +#ifdef __XEN__ +XEN_ERRNO(EINTR, 4) /* Interrupted system call */ +#endif
Why is EINTR (and ERESTART lower) hidden from non-xen consumers but still in the public api? Would it not be better to keep these in xen/errno.h rather than public/errno.h ?
~Andrew
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 13.01.15 at 17:40, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Now that we have two cases where patches against hvmloader got submitted needing to include the hypervisor's
errno.h(for the host's system header not necessarily reflecting the correct numbers), take this as a strong sign that we need to make the error return values part of the hypervisor ABI (which de-fact they've always been).Quoted 6 lines
Signed-off-by Jan Beulich <[email protected]>---
There's on small block commented with TBD left in the public header. This is the main reason for the submission being RFC. While we don't currently use these error codes, I'm not sure if we should leave all or some of them out for the time being.
Quoted 6 lines
I would suggest that we drop any error codes not in use. We can always add them back in in the future if they are needed.
I would also suggest that we note the heritage, being taken from Linux 2.$mumble, which will act as a guide for introducing new codes in the future.
Good idea - I added a respective note.
Quoted 2 lines
Finally, I would suggest that we assign the Xen meaning (e.g. EACCES = bad tool interface) rather than Linux meanings.
Looking through the uses, EACCES isn't solely used for that purpose, and hence I'd like to keep the comment as is (assuming that it's the comments associated with each entry that your remark was about).
Quoted 4 lines
Quoted 4 lines
xen/include/public/errno.h new file +4
-0+#ifdef XEN_ERRNO + +XEN_ERRNO(EPERM, 1) /* Operation not permitted */ +XEN_ERRNO (ENOENT ,2 )/* No such file or directory */
Quoted 8 lines
xen/include/public/errno.h line 26
Quoted 4 lines
xen/include/public/errno.h new file +4
-0+XEN_ERRNO(ESRCH, 3) /* No such process */ +#ifdef __XEN__ +XEN_ERRNO(EINTR, 4) /* Interrupted system call */ +#endif Why is EINTR (and ERESTART lower) hidden from non-xen consumers but still in the public api? Would it not be better to keep these in
xen/errno.hrather thanpublic/errno.h?
As said in the reply to Ian - to avoid the risk of introducing conflicting definitions later, I'd like to keep them all in a single place.
Jan