Skip to content
This repository was archived by the owner on Jan 28, 2023. It is now read-only.

Fix NetBSD build and add support for HAX_VCPU_IOCTL_SET_CPUID #281

Merged
merged 2 commits into from
Mar 27, 2020

Conversation

krytarowski
Copy link
Contributor

No description provided.

@@ -58,6 +58,40 @@ struct cdevsw hax_vcpu_cdevsw = {
.d_flag = D_OTHER | D_MPSAFE
};

#define load_user_data(dest, src, body_len, body_max, arg_t, body_t) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not create a function? My ioctl will use it too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A function is better.. but I want to avoid divergence with other kernels.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does a function lead to divergence?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux + Darwin use macro here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not create a function?

This pair of function-like macros are designed for all interfaces with variable-length arguments. As there are types, struct members in the macro parameters, it is hard to define a real function to handle these cases. But I agree to bring the definition to a common place, such as hax.h, instead of duplicating the codes here.

Linux + Darwin use macro here.

As for the minor difference between NetBSD/Darwin and Linux, should we merge them into one macro by platform switch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to keep the macro in private files of kernels as there are OS-specific differences.

cpuid_t hax_supported; // Hypervisor supported features
bool initialized;
uint32_t data[CPUID_CACHE_SIZE]; // Host cached features
hax_cpuid_t host_supported; // Physical CPU supported features
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is cpuid_t present in NetBSD headers and renaming is to resolve intersection issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to HAXM current naming rules, the types leading by hax_ are used for external IOCTLs, while types ending with _t are used for internal storage. Most recent codes follow this rule. Could you consider to rename the type present in NetBSD rather than replacing in the common places?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no option to rename this. _t is a reserved namespace for POSIX/implementation and third party code must not reuse it for internal purposes.

Copy link
Contributor Author

@krytarowski krytarowski Mar 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were also several other namespace conflicts in the past, such as vaddr_t. They were patched accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. That makes sense. Could you help to update the patch fe1524c to ensure the code line length not exceed column 80? After replacing string, some lines exceed column 80 and need to format. Then how about reordering the patch sequence as fe1524c first and 9417d38 last? Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will do it.

Copy link
Contributor

@wcwang wcwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your quick contribution. Please see my review inline.

cpuid_t hax_supported; // Hypervisor supported features
bool initialized;
uint32_t data[CPUID_CACHE_SIZE]; // Host cached features
hax_cpuid_t host_supported; // Physical CPU supported features
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to HAXM current naming rules, the types leading by hax_ are used for external IOCTLs, while types ending with _t are used for internal storage. Most recent codes follow this rule. Could you consider to rename the type present in NetBSD rather than replacing in the common places?

@@ -58,6 +58,40 @@ struct cdevsw hax_vcpu_cdevsw = {
.d_flag = D_OTHER | D_MPSAFE
};

#define load_user_data(dest, src, body_len, body_max, arg_t, body_t) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not create a function?

This pair of function-like macros are designed for all interfaces with variable-length arguments. As there are types, struct members in the macro parameters, it is hard to define a real function to handle these cases. But I agree to bring the definition to a common place, such as hax.h, instead of duplicating the codes here.

Linux + Darwin use macro here.

As for the minor difference between NetBSD/Darwin and Linux, should we merge them into one macro by platform switch?

Signed-off-by: Kamil Rytarowski <n54@gmx.com>
Signed-off-by: Kamil Rytarowski <n54@gmx.com>
@krytarowski
Copy link
Contributor Author

Done.

@wcwang
Copy link
Contributor

wcwang commented Mar 27, 2020

Thanks for your update. Your pull request is ready to merge.

@wcwang wcwang merged commit 396bba3 into intel:master Mar 27, 2020
@wcwang
Copy link
Contributor

wcwang commented Apr 7, 2021

@krytarowski, HAXM has introduced the new API HAX_VCPU_IOCTL_GET_CPUID, would you implement it for NetBSD before the next release? Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CI:Build Pass CI:Build Pass CI:Mac Test Pass CI:Mac Test Pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants