public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Luis Henriques <henrix@sapo.pt>
Cc: Steven Rostedt <srostedt@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>, Ingo Molnar <mingo@elte.hu>
Subject: Re: [BUG] kvm crashes in 2.6.28-rc6-00007-ged31348
Date: Thu, 04 Dec 2008 17:36:17 +0200	[thread overview]
Message-ID: <4937F8F1.3070402@redhat.com> (raw)
In-Reply-To: <49359CDF.5060300@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 594 bytes --]

Avi Kivity wrote:
> Steven Rostedt wrote:
>> The following must be available without recursion for the function
>> tracer to work:
>>
>>   local_irq_save/restore
>>   smp_processor_id
>>   preempt_enable/disable_notrace
>>   atomic_inc/dec
>>   
>
> In arch/x86/kvm/svm.c, function svm_vcpu_run(), everything between the 
> vmrun instruction and the call to load_host_msrs() is executed without 
> a live pda, so no smp_processor_id().  Could easily be fixed by 
> rearranging things.
>
>

Luis, please try the attached patch.


-- 
error compiling committee.c: too many arguments to function


[-- Attachment #2: kvm-ftrace-peace.patch --]
[-- Type: text/plain, Size: 1731 bytes --]

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 1452851..c10857d 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -920,13 +920,6 @@ static int svm_get_irq(struct kvm_vcpu *vcpu)
 	return -1;
 }
 
-static void load_host_msrs(struct kvm_vcpu *vcpu)
-{
-#ifdef CONFIG_X86_64
-	wrmsrl(MSR_GS_BASE, to_svm(vcpu)->host_gs_base);
-#endif
-}
-
 static void save_host_msrs(struct kvm_vcpu *vcpu)
 {
 #ifdef CONFIG_X86_64
@@ -1798,10 +1791,26 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 		"mov %%r14, %c[r14](%[svm]) \n\t"
 		"mov %%r15, %c[r15](%[svm]) \n\t"
 #endif
-		"pop %%"R"bp"
+		"pop %%"R"bp \n\t"
+		/* Reload PDA early so ftrace can work */
+		"mov %[fs], %%fs \n\t"
+		"mov %[gs], %%gs \n\t"
+#ifdef CONFIG_X86_64
+		"mov %c[gsbase](%[svm]), %%edi \n\t"
+		"mov %c[gsbase]+4(%[svm]), %%edx \n\t"
+		"mov %[msr_gs_base], %%ecx \n\t"
+		"xchg %%rax, %%rdi \n\t"
+		"wrmsr \n\t"
+		"xchg %%rax, %%rdi \n\t"
+#endif
 		:
 		: [svm]"a"(svm),
 		  [vmcb]"i"(offsetof(struct vcpu_svm, vmcb_pa)),
+		  [fs]"g"(fs_selector), [gs]"g"(gs_selector),
+#ifdef CONFIG_X86_64
+		  [gsbase]"i"(offsetof(struct vcpu_svm, host_gs_base)),
+		  [msr_gs_base]"i"(MSR_GS_BASE),
+#endif
 		  [rbx]"i"(offsetof(struct vcpu_svm, vcpu.arch.regs[VCPU_REGS_RBX])),
 		  [rcx]"i"(offsetof(struct vcpu_svm, vcpu.arch.regs[VCPU_REGS_RCX])),
 		  [rdx]"i"(offsetof(struct vcpu_svm, vcpu.arch.regs[VCPU_REGS_RDX])),
@@ -1837,10 +1846,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 	write_dr7(svm->host_dr7);
 	kvm_write_cr2(svm->host_cr2);
 
-	kvm_load_fs(fs_selector);
-	kvm_load_gs(gs_selector);
 	kvm_load_ldt(ldt_selector);
-	load_host_msrs(vcpu);
 
 	reload_tss(vcpu);
 

  parent reply	other threads:[~2008-12-04 15:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-30 19:34 [BUG] kvm crashes in 2.6.28-rc6-00007-ged31348 Luis Henriques
2008-11-30 20:20 ` Avi Kivity
2008-11-30 20:38   ` Luis Henriques
2008-11-30 20:44     ` Avi Kivity
2008-11-30 21:04       ` Luis Henriques
2008-12-02 12:23         ` Avi Kivity
2008-12-02 12:25           ` Avi Kivity
2008-12-02 12:31             ` Avi Kivity
2008-12-02 19:09           ` Luis Henriques
2008-12-02 19:27             ` Avi Kivity
2008-12-02 19:30             ` Avi Kivity
2008-12-02 19:46             ` Luis Henriques
2008-12-02 20:25               ` Steven Rostedt
2008-12-02 20:38                 ` Avi Kivity
2008-12-02 20:48                   ` Steven Rostedt
2008-12-02 20:56                     ` Avi Kivity
2008-12-04 15:36                   ` Avi Kivity [this message]
2008-12-04 22:05                     ` Luis Henriques
2008-12-02 20:46                 ` Luis Henriques
2008-12-02 21:16                   ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4937F8F1.3070402@redhat.com \
    --to=avi@redhat.com \
    --cc=henrix@sapo.pt \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --cc=srostedt@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox