x86/altcall: allow compound types to be passed
authorJan Beulich <jbeulich@suse.com>
Thu, 4 Nov 2021 16:04:05 +0000 (17:04 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 29 Nov 2021 13:53:05 +0000 (13:53 +0000)
commit5c7c78d0be86e3ce0f96f0000f9462e1cafbdb6e
tree2fdaa4c0ce01057ae31db7c6cb10306546f8c884
parent0e6c87b93e1d35fedf9cebd65395c2f79b4af11a
x86/altcall: allow compound types to be passed

Replace the conditional operator in ALT_CALL_ARG(), which was intended
to limit usable types to scalar ones, by a size check. Some restriction
here is necessary to make sure we don't violate the ABI's calling
conventions, but limiting to scalar types was both too restrictive
(disallowing e.g. guest handles) and too permissive (allowing e.g.
__int128_t).

Note that there was some anomaly with that conditional operator anyway:
Something - I don't recall what - made it impossible to omit the middle
operand.

Code-generation-wise this has the effect of removing certain zero- or
sign-extending in some altcall invocations. This ought to be fine as the
ABI doesn't require sub-sizeof(int) values to be extended, except when
passed through an ellipsis. No functions subject to altcall patching has
a variable number of arguments, though.

Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Unfortunately this triggers -Werror=sizeof-array-argument on some versions of
GCC, so alter xsm_{alloc,free}_security_evtchns() to use a pointer rather than
array parameter.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Daniel P. Smith <dpsmith@apertussolutions.com>
xen/include/asm-x86/alternative.h
xen/include/xsm/xsm.h