Skip to content

Commit 575b255

Browse files
valdiskbonzini
authored andcommitted
KVM: x86: allow compiling as non-module with W=1
Compile error with CONFIG_KVM_INTEL=y and W=1: CC arch/x86/kvm/vmx/vmx.o arch/x86/kvm/vmx/vmx.c:68:32: error: 'vmx_cpu_id' defined but not used [-Werror=unused-const-variable=] 68 | static const struct x86_cpu_id vmx_cpu_id[] = { | ^~~~~~~~~~ cc1: all warnings being treated as errors When building with =y, the MODULE_DEVICE_TABLE macro doesn't generate a reference to the structure (or any code at all). This makes W=1 compiles unhappy. Wrap both in a #ifdef to avoid the issue. Signed-off-by: Valdis Kletnieks <[email protected]> [Do the same for CONFIG_KVM_AMD. - Paolo] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 8a9442f commit 575b255

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

arch/x86/kvm/svm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@
5757
MODULE_AUTHOR("Qumranet");
5858
MODULE_LICENSE("GPL");
5959

60+
#ifdef MODULE
6061
static const struct x86_cpu_id svm_cpu_id[] = {
6162
X86_FEATURE_MATCH(X86_FEATURE_SVM),
6263
{}
6364
};
6465
MODULE_DEVICE_TABLE(x86cpu, svm_cpu_id);
66+
#endif
6567

6668
#define IOPM_ALLOC_ORDER 2
6769
#define MSRPM_ALLOC_ORDER 1

arch/x86/kvm/vmx/vmx.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@
6464
MODULE_AUTHOR("Qumranet");
6565
MODULE_LICENSE("GPL");
6666

67+
#ifdef MODULE
6768
static const struct x86_cpu_id vmx_cpu_id[] = {
6869
X86_FEATURE_MATCH(X86_FEATURE_VMX),
6970
{}
7071
};
7172
MODULE_DEVICE_TABLE(x86cpu, vmx_cpu_id);
73+
#endif
7274

7375
bool __read_mostly enable_vpid = 1;
7476
module_param_named(vpid, enable_vpid, bool, 0444);

0 commit comments

Comments
 (0)