Skip to contentSkip to conversation

kvm: Add missing EXPORT_SYMBOL when CONFIG_KVM=m

PATCH In review Sedat Dilek 4 participants 15 messages Jan 23, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvm: Add missing EXPORT_SYMBOL when CONFIG_KVM=m

With CONFIG_KVM=m my build with 3.8-rc4-nohz3 breaks like this:

ERROR: "guest_enter" [arch/x86/kvm/kvm.ko] undefined!
ERROR: "guest_exit" [arch/x86/kvm/kvm.ko] undefined!

Fix this by adding the missing EXPORT_SYMBOL for guest_enter() and guest_exit() in kernel/context_tracking.c as suggested by Frederic.

This issue was introduced with commit 8eebafe9be58 ("kvm: Prepare to add generic guest entry/exit callbacks").

---
 kernel/context_tracking.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/context_tracking.c +3 -1
index bbb2c2c..950f30a 100644
@@ -111,14 +111,16 @@ void guest_enter(void)
 	else
 		__guest_enter();
 }
+EXPORT_SYMBOL(guest_enter);
 
 void guest_exit(void)
-{
+{i
 	if (vtime_accounting_enabled())
 		vtime_guest_exit(current);
 	else
 		__guest_exit();
 }
+EXPORT_SYMBOL(guest_exit);
 #endif
 
 
Signature · 1 line
1.8.1.1
#1 lore raw
Quoted 21 lines · Sedat Dilek

With CONFIG_KVM=m my build with 3.8-rc4-nohz3 breaks like this:

ERROR: "guest_enter" [arch/x86/kvm/kvm.ko] undefined!
ERROR: "guest_exit" [arch/x86/kvm/kvm.ko] undefined!

Fix this by adding the missing EXPORT_SYMBOL for guest_enter() and guest_exit() in kernel/context_tracking.c as suggested by Frederic.

This issue was introduced with commit 8eebafe9be58 ("kvm: Prepare to add generic guest entry/exit callbacks").

---
 kernel/context_tracking.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/context_tracking.c +0 -0
index bbb2c2c..950f30a 100644

kernel/context_tracking.c void guest_enter(void) · line 117

Quoted 8 lines
kernel/context_tracking.c +2 -1
@@ -111,14 +111,16 @@ void guest_enter(void)
        else
                __guest_enter();
 }
+EXPORT_SYMBOL(guest_enter);
 
 void guest_exit(void)
-{
+{i

compilation fails with that?

Quoted 17 lines
kernel/context_tracking.c +1 -1
        if (vtime_accounting_enabled())
                vtime_guest_exit(current);
        else
                __guest_exit();
 }
+EXPORT_SYMBOL(guest_exit);
 #endif
 
 
--

1.8.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
Quoted 27 lines · devendra.aaru
Quoted 26 lines · Sedat Dilek

With CONFIG_KVM=m my build with 3.8-rc4-nohz3 breaks like this:

ERROR: "guest_enter" [arch/x86/kvm/kvm.ko] undefined!
ERROR: "guest_exit" [arch/x86/kvm/kvm.ko] undefined!

Fix this by adding the missing EXPORT_SYMBOL for guest_enter() and guest_exit() in kernel/context_tracking.c as suggested by Frederic.

This issue was introduced with commit 8eebafe9be58 ("kvm: Prepare to add generic guest entry/exit callbacks").

---
 kernel/context_tracking.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/context_tracking.c +1 -0
index bbb2c2c..950f30a 100644
@@ -111,14 +111,16 @@ void guest_enter(void)
        else
                __guest_enter();
 }
+EXPORT_SYMBOL(guest_enter);
 
Quoted 6 lines

kernel/context_tracking.c void guest_enter(void) · line 117

Quoted 3 lines
kernel/context_tracking.c +1 -1
 void guest_exit(void)
-{
+{i

compilation fails with that?

Hmmm, yes, but why, clueless, CONFIG_KVM=y as a workaround!

- Sedat -

Quoted 18 lines
Quoted 18 lines
kernel/context_tracking.c +1 -1
        if (vtime_accounting_enabled())
                vtime_guest_exit(current);
        else
                __guest_exit();
 }
+EXPORT_SYMBOL(guest_exit);
 #endif
 
 
--

1.8.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#3 lore raw

2013/1/23 Sedat Dilek <[email protected]>:

Quoted 28 lines · devendra.aaru
Quoted 27 lines · Sedat Dilek
Quoted 26 lines

With CONFIG_KVM=m my build with 3.8-rc4-nohz3 breaks like this:

ERROR: "guest_enter" [arch/x86/kvm/kvm.ko] undefined!
ERROR: "guest_exit" [arch/x86/kvm/kvm.ko] undefined!

Fix this by adding the missing EXPORT_SYMBOL for guest_enter() and guest_exit() in kernel/context_tracking.c as suggested by Frederic.

This issue was introduced with commit 8eebafe9be58 ("kvm: Prepare to add generic guest entry/exit callbacks").

---
 kernel/context_tracking.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/context_tracking.c +1 -0
index bbb2c2c..950f30a 100644
@@ -111,14 +111,16 @@ void guest_enter(void)
        else
                __guest_enter();
 }
+EXPORT_SYMBOL(guest_enter);
 
Quoted 8 lines
Quoted 6 lines

kernel/context_tracking.c void guest_enter(void) · line 117

Quoted 3 lines
kernel/context_tracking.c +1 -1
 void guest_exit(void)
-{
+{i

compilation fails with that?

Hmmm, yes, but why, clueless, CONFIG_KVM=y as a workaround!

I believe he pointed out the "{i" to you. Typing mistake?

#4 lore raw
Quoted 3 lines · Frederic Weisbecker
Quoted 1 line

Hmmm, yes, but why, clueless, CONFIG_KVM=y as a workaround!

I believe he pointed out the "{i" to you. Typing mistake?

In which case the CONFIG_KVM=y is a work around if that {i is within a #ifndef CONFIG_KVM ;-)

-- Steve

#5 lore raw

2013/1/23 Steven Rostedt <[email protected]>:

Quoted 8 lines · Frederic Weisbecker
Quoted 4 lines
Quoted 2 lines

Hmmm, yes, but why, clueless, CONFIG_KVM=y as a workaround!

I believe he pointed out the "{i" to you. Typing mistake?

In which case the CONFIG_KVM=y is a work around if that {i is within a #ifndef CONFIG_KVM ;-)

No it's in #ifdef CONFIG_KVM so the right fix is:

kernel/context_tracking.c +5 -0
index bbb2c2c..a13b8a3 100644
@@ -111,14 +111,19 @@ void guest_enter(void)
        else
                __guest_enter();
 }
+EXPORT_SYMBOL_GPL(guest_enter);
 
 void guest_exit(void)
 {
+#ifndef CONFIG_KVM
+i
+#endif
        if (vtime_accounting_enabled())
                vtime_guest_exit(current);
        else
                __guest_exit();
 }
+EXPORT_SYMBOL_GPL(guest_exit);
 #endif
#6 lore raw
Quoted 24 lines · Frederic Weisbecker

2013/1/23 Steven Rostedt <[email protected]>:

Quoted 8 lines · Frederic Weisbecker
Quoted 4 lines
Quoted 2 lines

Hmmm, yes, but why, clueless, CONFIG_KVM=y as a workaround!

I believe he pointed out the "{i" to you. Typing mistake?

In which case the CONFIG_KVM=y is a work around if that {i is within a #ifndef CONFIG_KVM ;-)

No it's in #ifdef CONFIG_KVM so the right fix is:

kernel/context_tracking.c +1 -0
index bbb2c2c..a13b8a3 100644
@@ -111,14 +111,19 @@ void guest_enter(void)
        else
                __guest_enter();
 }
+EXPORT_SYMBOL_GPL(guest_enter);
 
 void guest_exit(void)
 {

kernel/context_tracking.c void guest_enter(void) · line 127

Quoted 10 lines
kernel/context_tracking.c +4 -0
+#ifndef CONFIG_KVM
+i
+#endif
        if (vtime_accounting_enabled())
                vtime_guest_exit(current);
        else
                __guest_exit();
 }
+EXPORT_SYMBOL_GPL(guest_exit);
 #endif

With and without the magic "i" hack the warning still remains! Dropped the coffee on my t-shirt, damn Frederic.

- Sedat -

#7 lore raw
In reply to Frederic Weisbecker
Quoted 24 lines · Frederic Weisbecker

2013/1/23 Steven Rostedt <[email protected]>:

Quoted 8 lines · Frederic Weisbecker
Quoted 4 lines
Quoted 2 lines

Hmmm, yes, but why, clueless, CONFIG_KVM=y as a workaround!

I believe he pointed out the "{i" to you. Typing mistake?

In which case the CONFIG_KVM=y is a work around if that {i is within a #ifndef CONFIG_KVM ;-)

No it's in #ifdef CONFIG_KVM so the right fix is:

kernel/context_tracking.c +1 -0
index bbb2c2c..a13b8a3 100644
@@ -111,14 +111,19 @@ void guest_enter(void)
        else
                __guest_enter();
 }
+EXPORT_SYMBOL_GPL(guest_enter);
 
 void guest_exit(void)
 {

kernel/context_tracking.c void guest_enter(void) · line 127

Quoted 10 lines
kernel/context_tracking.c +4 -0
+#ifndef CONFIG_KVM
+i
+#endif
        if (vtime_accounting_enabled())
                vtime_guest_exit(current);
        else
                __guest_exit();
 }
+EXPORT_SYMBOL_GPL(guest_exit);
 #endif

So, what's the real fix for this issue?

- Sedat -

#8 lore raw

2013/1/23 Sedat Dilek <[email protected]>:

Quoted 23 lines · Frederic Weisbecker
Quoted 22 lines

2013/1/23 Steven Rostedt <[email protected]>:

Quoted 8 lines · Frederic Weisbecker
Quoted 4 lines
Quoted 2 lines

Hmmm, yes, but why, clueless, CONFIG_KVM=y as a workaround!

I believe he pointed out the "{i" to you. Typing mistake?

In which case the CONFIG_KVM=y is a work around if that {i is within a #ifndef CONFIG_KVM ;-)

No it's in #ifdef CONFIG_KVM so the right fix is:

kernel/context_tracking.c +1 -0
index bbb2c2c..a13b8a3 100644
@@ -111,14 +111,19 @@ void guest_enter(void)
        else
                __guest_enter();
 }
+EXPORT_SYMBOL_GPL(guest_enter);
 
Quoted 14 lines

kernel/context_tracking.c void guest_enter(void) · line 127

Quoted 12 lines
kernel/context_tracking.c +4 -0
 void guest_exit(void)
 {
+#ifndef CONFIG_KVM
+i
+#endif
        if (vtime_accounting_enabled())
                vtime_guest_exit(current);
        else
                __guest_exit();
 }
+EXPORT_SYMBOL_GPL(guest_exit);
 #endif

So, what's the real fix for this issue?

So CONFIG_SOMETHING doesn't work when it's a module. Hence we need to remove the ifdef CONFIG_KVM around guest_enter(), guest_exit(), vtime_guest_enter() and vtime_guest_exit(). Also it seems we need <linux/export.h> in context_tracking.c

#9 lore raw
Quoted 39 lines · Frederic Weisbecker

2013/1/23 Sedat Dilek <[email protected]>:

Quoted 23 lines · Frederic Weisbecker
Quoted 22 lines

2013/1/23 Steven Rostedt <[email protected]>:

Quoted 8 lines · Frederic Weisbecker
Quoted 4 lines
Quoted 2 lines

Hmmm, yes, but why, clueless, CONFIG_KVM=y as a workaround!

I believe he pointed out the "{i" to you. Typing mistake?

In which case the CONFIG_KVM=y is a work around if that {i is within a #ifndef CONFIG_KVM ;-)

No it's in #ifdef CONFIG_KVM so the right fix is:

kernel/context_tracking.c +1 -0
index bbb2c2c..a13b8a3 100644
@@ -111,14 +111,19 @@ void guest_enter(void)
        else
                __guest_enter();
 }
+EXPORT_SYMBOL_GPL(guest_enter);
 
Quoted 14 lines

kernel/context_tracking.c void guest_enter(void) · line 127

Quoted 12 lines
kernel/context_tracking.c +4 -0
 void guest_exit(void)
 {
+#ifndef CONFIG_KVM
+i
+#endif
        if (vtime_accounting_enabled())
                vtime_guest_exit(current);
        else
                __guest_exit();
 }
+EXPORT_SYMBOL_GPL(guest_exit);
 #endif

So, what's the real fix for this issue?

Quoted 4 lines

So CONFIG_SOMETHING doesn't work when it's a module. Hence we need to remove the ifdef CONFIG_KVM around guest_enter(), guest_exit(), vtime_guest_enter() and vtime_guest_exit(). Also it seems we need <linux/export.h> in context_tracking.c

You mean sth. like this?

- Sedat -

kernel/context_tracking.c +3 -4
index bbb2c2c..8802a66 100644
@@ -19,7 +19,7 @@
 #include <linux/rcupdate.h>
 #include <linux/sched.h>
 #include <linux/hardirq.h>
-
+#include <linux/export.h>
 
 DEFINE_PER_CPU(struct context_tracking, context_tracking) = {
 #ifdef CONFIG_CONTEXT_TRACKING_FORCE
@@ -103,7 +103,6 @@ void user_exit(void)
 	local_irq_restore(flags);
 }
 
-#ifdef CONFIG_KVM
 void guest_enter(void)
 {
 	if (vtime_accounting_enabled())
@@ -111,6 +110,7 @@ void guest_enter(void)
 	else
 		__guest_enter();
 }
+EXPORT_SYMBOL_GPL(guest_enter);
 
 void guest_exit(void)
 {
@@ -119,8 +119,7 @@ void guest_exit(void)
 	else
 		__guest_exit();
 }
-#endif
-
+EXPORT_SYMBOL_GPL(guest_exit);
 
 /**
  * context_tracking_task_switch - context switch the syscall callbacks
kernel/sched/cputime.c +2 -2
index 5500a81..dc66cba 100644
@@ -677,7 +677,6 @@ void vtime_user_enter(struct task_struct *tsk)
 	write_sequnlock(&tsk->vtime_seqlock);
 }
 
-#ifdef CONFIG_KVM
 void vtime_guest_enter(struct task_struct *tsk)
 {
 	write_seqlock(&tsk->vtime_seqlock);
@@ -685,6 +684,7 @@ void vtime_guest_enter(struct task_struct *tsk)
 	current->flags |= PF_VCPU;
 	write_sequnlock(&tsk->vtime_seqlock);
 }
+EXPORT_SYMBOL_GPL(vtime_guest_enter);
 
 void vtime_guest_exit(struct task_struct *tsk)
 {
@@ -693,7 +693,7 @@ void vtime_guest_exit(struct task_struct *tsk)
 	current->flags &= ~PF_VCPU;
 	write_sequnlock(&tsk->vtime_seqlock);
 }
-#endif
+EXPORT_SYMBOL_GPL(vtime_guest_exit);
 
 void vtime_account_idle(struct task_struct *tsk)
 {
#10 lore raw
Quoted 40 lines · Sedat Dilek
Quoted 39 lines · Frederic Weisbecker

2013/1/23 Sedat Dilek <[email protected]>:

Quoted 37 lines · Frederic Weisbecker
Quoted 24 lines

2013/1/23 Steven Rostedt <[email protected]>:

Quoted 8 lines · Frederic Weisbecker
Quoted 4 lines
Quoted 2 lines

Hmmm, yes, but why, clueless, CONFIG_KVM=y as a workaround!

I believe he pointed out the "{i" to you. Typing mistake?

In which case the CONFIG_KVM=y is a work around if that {i is within a #ifndef CONFIG_KVM ;-)

No it's in #ifdef CONFIG_KVM so the right fix is:

kernel/context_tracking.c +1 -0
index bbb2c2c..a13b8a3 100644
@@ -111,14 +111,19 @@ void guest_enter(void)
        else
                __guest_enter();
 }
+EXPORT_SYMBOL_GPL(guest_enter);
 
 void guest_exit(void)
 {

kernel/context_tracking.c void guest_enter(void) · line 127

Quoted 10 lines
kernel/context_tracking.c +4 -0
+#ifndef CONFIG_KVM
+i
+#endif
        if (vtime_accounting_enabled())
                vtime_guest_exit(current);
        else
                __guest_exit();
 }
+EXPORT_SYMBOL_GPL(guest_exit);
 #endif

So, what's the real fix for this issue?

Quoted 7 lines
Quoted 4 lines

So CONFIG_SOMETHING doesn't work when it's a module. Hence we need to remove the ifdef CONFIG_KVM around guest_enter(), guest_exit(), vtime_guest_enter() and vtime_guest_exit(). Also it seems we need <linux/export.h> in context_tracking.c

You mean sth. like this?

Isn't vtime.h missing in kvm_host.h as an include?

- Sedat -

Quoted 1 line

- Sedat -

#12 lore raw
In reply to Sedat Dilek

2013/1/23 Sedat Dilek <[email protected]>:

Quoted 6 lines
Quoted 4 lines

So CONFIG_SOMETHING doesn't work when it's a module. Hence we need to remove the ifdef CONFIG_KVM around guest_enter(), guest_exit(), vtime_guest_enter() and vtime_guest_exit(). Also it seems we need <linux/export.h> in context_tracking.c

You mean sth. like this?

Almost. vtime_guest_enter/exit don't need to be exported because they are not referenced by module code: guest_enter/exit are builtin code.

#13 lore raw
In reply to Frederic Weisbecker
Quoted 5 lines · Frederic Weisbecker
kernel/context_tracking.c +0 -0
index bbb2c2c..a13b8a3 100644

kernel/context_tracking.c void guest_enter(void) · line 120

Quoted 10 lines
kernel/context_tracking.c +4 -0
@@ -111,14 +111,19 @@ void guest_enter(void)
        else
                __guest_enter();
 }
+EXPORT_SYMBOL_GPL(guest_enter);
 
 void guest_exit(void)
 {
+#ifndef CONFIG_KVM
+i
+#endif

I don't like #ifdefs in .c files. They belong in headers. Could you convert this to be:

include/linux/context_tracking.h:

#ifdef CONFIG_KVM
#define add_vi_i_typo()
#else
#define add_vi_i_typo() i
#endif

and then in context_tracking.c:

void guest_exit(void)

{
	add_vi_typo();

[...]

-- Steve

Quoted 7 lines
kernel/context_tracking.c +1 -0
        if (vtime_accounting_enabled())
                vtime_guest_exit(current);
        else
                __guest_exit();
 }
+EXPORT_SYMBOL_GPL(guest_exit);
 #endif
#14 lore raw

2013/1/23 Steven Rostedt <[email protected]>:

Quoted 29 lines · Frederic Weisbecker
Quoted 6 lines
kernel/context_tracking.c +0 -0
index bbb2c2c..a13b8a3 100644

kernel/context_tracking.c void guest_enter(void) · line 120

Quoted 10 lines
kernel/context_tracking.c +4 -0
@@ -111,14 +111,19 @@ void guest_enter(void)
        else
                __guest_enter();
 }
+EXPORT_SYMBOL_GPL(guest_enter);
 
 void guest_exit(void)
 {
+#ifndef CONFIG_KVM
+i
+#endif

I don't like #ifdefs in .c files. They belong in headers. Could you convert this to be:

include/linux/context_tracking.h:

#ifdef CONFIG_KVM
#define add_vi_i_typo()
#else
#define add_vi_i_typo() i
#endif

Quoted 7 lines

and then in context_tracking.c:

void guest_exit(void)

{
        add_vi_typo();

[...]

Much cleaner indeed! And this way it's more generally available for further users.

Will do the change, thanks!