-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ioctl!(none, ...)
with an argument
#781
Comments
According to the kernel docs, there should be no argument to this ioctl. This agrees with the ioctl number definition I think you have a misunderstanding of the So as far as I can tell your declaration is correct. Maybe try a |
I know, unfortunately the actual code does check for the argument. The same goes for KVM_CHECK_EXTENSION, defined as I tried Changing the kernel ABI to properly label |
I'm a little confused here. The actual system call to the kernel will always have a value for the "arg" (e.g. https://github.com/idunham/musl/blob/7e10f209fbc26a5179a4c0817c986e7c7bd327c9/src/misc/ioctl.c). I would expect the libc implementation that we call to result in a 0x00 for this argument if the C You seem to indicate that this is not the case in your tests? Please confirm in the debugger or strace the actual syscall parameters going to the kernel. |
@posborne The problem isn't with the argument being set to 0 or not, the problem is that KVM's ioctls require the mandatory argument to be something specific. E.g. a normal #define SOME_IOCTL (_IO(0, 0))
ioctl(fd, SOME_IOCTL); // not passing extra argument is OK, set to 0 automatically KVM's ioctl is special: #define KVM_CREATE_VM _IO(KVMIO, 0x03);
ioctl(fd, KVM_CREATE_VM, some_flags); // extra argument is required, and it's not 0, it's some relevant value. |
@GabrielMajeri I was thrown off by the link to the kernel for handling I think I understand the basic problem here but not sure if it is worthwhile to change nix to support kernel subsystems/drivers which do not follow the conventions properly (this is the first I have seen doing this specifically). Not being able to specify an argument for the |
Not sure if this should be reported as a bug, but it does not work if I do not pass a 0 explicitly. Indeed, the C code properly sets the default argument to 0, but Rust does not. See this Rust playground's disassembly: Rust does not clear the edx register if I do not pass an argument, meaning it will contain a random / uninitialized value.
It's alright, I ended up wrapping the
I am using that as a workaround, and have no problems. What I initially hoped for is for I don't think this is a good idea anymore, |
Why? You even linked to code that explicitly doesn't do that. |
Looking at the original commit that added |
How is this not covered by the |
It's not covered because the |
Okay, that didn't really help me understand anything. I'm unclear if people in this conversation know what the correct solution is here. It sounds like we understand the problem plenty well enough, so does anyone have a proposed solution? My main question is what's wrong with the solution of specifying 0 as the 3rd argument to |
Passing a 0 would fix my issue It would be great if Rust had function overloading (so we could have a function with an extra parameter for Adding a |
@GabrielMajeri passing 0 would not fix my issue. I need to pass an argument. @Susurrus I don't think that helps anyone. ioctls that don't require an integer argument don't care about the value passed. ioctls that do are not going to be satisfied with passing only 0. ioctls that “don't” require an integer argument but explicitly check it's 0 are really ioctls that do take an integer argument. The issue is there appear to be two ways to specify ioctls that take an integer argument (as opposed to a pointer argument).
Both ways appear to be widely used in the Linux kernel. I personally think that the I think having a |
I still don't get why |
I'm trying to make the argument that they're not bad and it is what's currently supported through Also, the |
Ignoring whether these are bad or not, you're saying that you can't use |
|
No, I meant |
Because the |
Which you can get by writing a little C program and printing it out, or you can use the |
This does have me thinking again about how we use a single |
I'm going to go ahead and close this because I don't believe that |
The KVM
ioctl
KVM_GET_API_VERSION
is of typenone
/_IO
. I've tried defining it as:However, this fails with
EINVAL
, since the code in the kernel still expects onei32
parameter, which should be 0.nix
should have some support for an additional parameter withnone
ioctl
s. Right now I am manually usinglibc::ioctl
for this, but the macro should support something likeOr perhaps add a new
ioctl
type, which is the same asnone
, but callednone_int
, which takes the second parameter.The text was updated successfully, but these errors were encountered: