-
Notifications
You must be signed in to change notification settings - Fork 75
arm64: add KVM_REG_ARM64_SVE_VLS const #89
base: main
Are you sure you want to change the base?
Conversation
For using SVE scenario, KVM_REG_ARM64_SVE_VLS is used by set_one_reg/get_one_reg ioctls, which allows the set of vector lengths supported by the vcpu to be discovered and configured by userspace. See https://www.kernel.org/doc/html/latest/virt/kvm/api.html#kvm-set-one-reg When using bindgen, this const is missing, so add it according to the definition in linux. Signed-off-by: xuejun-xj <[email protected]>
Hi! This PR adds missing macro "KVM_REG_ARM64_SVE_VLS", which is used to customize vector length selector of SVE extension. Is there anyone help to review this PR? |
arm64: add KVM_REG_ARM64_SVE_VLS const Signed-off-by: xuejun-xj <[email protected]>
Hey, sorry for missing this one. Do we know why this constant is missing when using bindgen? I'd prefer if we could fix our bindgen invocation to include this constant, instead of manually modifying the generated code (as if we do this, we need to write it down as a step to do everytime we regenerate, to prevent the constant from getting lost again). |
Yes, I doubt it may be caused by the definition format in C code macros. When I found this const missing, I looked it in kernel code and it is defined in multiple lines linked with "\". Like this: #define KVM_REG_ARM64_SVE_VLS (KVM_REG_ARM64 | KVM_REG_ARM64_SVE | \
KVM_REG_SIZE_U512 | 0xffff) I also looked for other multi-line macros and didn't find them in bindgen.rs. Therefore, I guess maybe bindgen skips macros defined with multiple lines? Can you have a check whether bindgen can handle this kind of macros? |
Mh, I don't think its the multi-line definition, I copied the relevant defines into a stand-alone header and everything worked. However if I try to generate bindings from |
Yeah, thanks @roypat . |
I have checked all the places which use |
Mh, does this explain it though? Because |
For C compilation, gcc will include headers and replace const value defined by macro "#define" during pre-process procedure, which won't truly compile the code and just do the replacement. That means we just need to ensure all the symbols can be found in the same file(after expanding "#include" and "#define"...) and binary will be correctly compiled later. |
Ahh, thanks for explaining! I managed to reproduce this outside of the linux tree with this info:
In fact, this already happens if two constants are defined out of order in just a single header:
I'll file a bug report with bindgen-rs :) |
Accidentally pressed "close", sorry |
Yeah, thanks! I think we have found the bug indeed. |
Summary of the PR
For using SVE scenario, KVM_REG_ARM64_SVE_VLS is used by set_one_reg/get_one_reg ioctls, which allows the set of vector lengths supported by the vcpu to be discovered and configured by userspace.
See https://www.kernel.org/doc/html/latest/virt/kvm/api.html#kvm-set-one-reg
When using bindgen, this const is missing, so add it according to the definition in linux.