From 8e5646f08416a3c9dccc793b67d08ef6f4f516b7 Mon Sep 17 00:00:00 2001 From: Noel Date: Fri, 6 Mar 2026 13:49:09 +0100 Subject: [PATCH] fix(xenevtchn): correct ioctl numbers for bind_unbound_port, unbind, and reset Three bugs in xenevtchn ioctl definitions, verified against linux/xen/evtchn.h kernel headers: 1. bind_unbound_port used nr=3 (0x44503), kernel defines nr=2 (0x44502) 2. unbind used nr=2 (0x44502), kernel defines nr=3 (0x44503) These two were swapped. 3. reset used ioctl_none!(reset, 0x4505, 5) but nix's ioctl_none! applies TYPEMASK (0xFF) to the type argument, truncating 0x4505 to 0x05 and producing ioctl number 0x0505 instead of 0x4505. Fixed by switching to ioctl_none_bad! which passes the value through. Kernel header reference (linux/xen/evtchn.h): IOCTL_EVTCHN_BIND_UNBOUND_PORT = _IOC(_IOC_NONE, 'E', 2, sizeof(...)) IOCTL_EVTCHN_UNBIND = _IOC(_IOC_NONE, 'E', 3, sizeof(...)) IOCTL_EVTCHN_RESET = _IOC(_IOC_NONE, 'E', 5, 0) --- crates/xen/xenevtchn/src/sys.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/xen/xenevtchn/src/sys.rs b/crates/xen/xenevtchn/src/sys.rs index 67dbef1f..81302360 100644 --- a/crates/xen/xenevtchn/src/sys.rs +++ b/crates/xen/xenevtchn/src/sys.rs @@ -1,4 +1,4 @@ -use nix::{ioctl_none, ioctl_readwrite_bad}; +use nix::{ioctl_none_bad, ioctl_readwrite_bad}; use std::ffi::c_uint; #[repr(C)] @@ -29,7 +29,7 @@ pub struct NotifyRequest { ioctl_readwrite_bad!(bind_virq, 0x44500, BindVirqRequest); ioctl_readwrite_bad!(bind_interdomain, 0x84501, BindInterdomainRequest); -ioctl_readwrite_bad!(bind_unbound_port, 0x44503, BindUnboundPortRequest); -ioctl_readwrite_bad!(unbind, 0x44502, UnbindPortRequest); +ioctl_readwrite_bad!(bind_unbound_port, 0x44502, BindUnboundPortRequest); +ioctl_readwrite_bad!(unbind, 0x44503, UnbindPortRequest); ioctl_readwrite_bad!(notify, 0x44504, NotifyRequest); -ioctl_none!(reset, 0x4505, 5); +ioctl_none_bad!(reset, 0x4505);