From: "Jan Beulich" Subject: linux-2.6.18/x86: fix context switch on debug hypervisor after 1183:5e3c342a325e Date: Wed, 01 Aug 2012 10:18:03 +0100 Message-ID: <5019106B0200007800091D22@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part8FBECA5B.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part8FBECA5B.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Looking at anything but the result field of a multicall structure after issuing the multicall is invalid - the debug hypervisor intentionally clobbers all other fields. On i386 also remove some left over debugging code. Signed-off-by: Jan Beulich --- a/arch/i386/kernel/process-xen.c +++ b/arch/i386/kernel/process-xen.c @@ -548,7 +548,7 @@ struct task_struct fastcall * __switch_t { struct thread_struct *prev =3D &prev_p->thread, *next =3D &next_p->thread; - int cpu =3D smp_processor_id(); + int cpu =3D smp_processor_id(), cr0_ts; #ifndef CONFIG_X86_NO_TSS struct tss_struct *tss =3D &per_cpu(init_tss, cpu); #endif @@ -575,9 +575,6 @@ struct task_struct fastcall * __switch_t mcl->args[0] =3D 1; mcl++; } -#if 0 /* lazy fpu sanity check */ - else BUG_ON(!(read_cr0() & 8)); -#endif =20 /* * Reload esp0. @@ -639,11 +636,14 @@ struct task_struct fastcall * __switch_t BUG_ON(pdo > _pdo + ARRAY_SIZE(_pdo)); #endif BUG_ON(mcl > _mcl + ARRAY_SIZE(_mcl)); - if (_mcl->op =3D=3D __HYPERVISOR_fpu_taskswitch) + if (_mcl->op =3D=3D __HYPERVISOR_fpu_taskswitch) { __get_cpu_var(xen_x86_cr0_upd) =3D X86_CR0_TS; + cr0_ts =3D 1; + } else + cr0_ts =3D 0; if (unlikely(HYPERVISOR_multicall_check(_mcl, mcl - _mcl, NULL))) BUG(); - if (_mcl->op =3D=3D __HYPERVISOR_fpu_taskswitch) { + if (cr0_ts) { __get_cpu_var(xen_x86_cr0) |=3D X86_CR0_TS; xen_clear_cr0_upd(); } --- a/arch/x86_64/kernel/process-xen.c +++ b/arch/x86_64/kernel/process-xen.c @@ -486,7 +486,7 @@ __switch_to(struct task_struct *prev_p,=20 { struct thread_struct *prev =3D &prev_p->thread, *next =3D &next_p->thread; - int cpu =3D smp_processor_id(); =20 + int cpu =3D smp_processor_id(), cr0_ts; #ifndef CONFIG_X86_NO_TSS struct tss_struct *tss =3D &per_cpu(init_tss, cpu); #endif @@ -572,11 +572,14 @@ __switch_to(struct task_struct *prev_p,=20 BUG_ON(pdo > _pdo + ARRAY_SIZE(_pdo)); #endif BUG_ON(mcl > _mcl + ARRAY_SIZE(_mcl)); - if (_mcl->op =3D=3D __HYPERVISOR_fpu_taskswitch) + if (_mcl->op =3D=3D __HYPERVISOR_fpu_taskswitch) { __get_cpu_var(xen_x86_cr0_upd) =3D X86_CR0_TS; + cr0_ts =3D 1; + } else + cr0_ts =3D 0; if (unlikely(HYPERVISOR_multicall_check(_mcl, mcl - _mcl, NULL))) BUG(); - if (_mcl->op =3D=3D __HYPERVISOR_fpu_taskswitch) { + if (cr0_ts) { __get_cpu_var(xen_x86_cr0) |=3D X86_CR0_TS; xen_clear_cr0_upd(); } --=__Part8FBECA5B.0__= Content-Type: text/plain; name="xen-x86-cr0-fix.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xen-x86-cr0-fix.patch" x86: fix context switch on debug hypervisor after 1183:5e3c342a325e=0A=0ALo= oking at anything but the result field of a multicall structure after=0Aiss= uing the multicall is invalid - the debug hypervisor intentionally=0Aclobbe= rs all other fields.=0A=0AOn i386 also remove some left over debugging = code.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = a/arch/i386/kernel/process-xen.c=0A+++ b/arch/i386/kernel/process-xen.c=0A@= @ -548,7 +548,7 @@ struct task_struct fastcall * __switch_t=0A {=0A = struct thread_struct *prev =3D &prev_p->thread,=0A = *next =3D &next_p->thread;=0A- int cpu =3D smp_processor_id();=0A+ = int cpu =3D smp_processor_id(), cr0_ts;=0A #ifndef CONFIG_X86_NO_TSS=0A = struct tss_struct *tss =3D &per_cpu(init_tss, cpu);=0A #endif=0A@@ -575,9 = +575,6 @@ struct task_struct fastcall * __switch_t=0A mcl->args[0= ] =3D 1;=0A mcl++;=0A }=0A-#if 0 /* lazy fpu sanity = check */=0A- else BUG_ON(!(read_cr0() & 8));=0A-#endif=0A =0A = /*=0A * Reload esp0.=0A@@ -639,11 +636,14 @@ struct task_struct = fastcall * __switch_t=0A BUG_ON(pdo > _pdo + ARRAY_SIZE(_pdo));=0A = #endif=0A BUG_ON(mcl > _mcl + ARRAY_SIZE(_mcl));=0A- if = (_mcl->op =3D=3D __HYPERVISOR_fpu_taskswitch)=0A+ if (_mcl->op = =3D=3D __HYPERVISOR_fpu_taskswitch) {=0A __get_cpu_var(xen_x= 86_cr0_upd) =3D X86_CR0_TS;=0A+ cr0_ts =3D 1;=0A+ } else=0A+ = cr0_ts =3D 0;=0A if (unlikely(HYPERVISOR_multicall_check(_mc= l, mcl - _mcl, NULL)))=0A BUG();=0A- if (_mcl->op = =3D=3D __HYPERVISOR_fpu_taskswitch) {=0A+ if (cr0_ts) {=0A = __get_cpu_var(xen_x86_cr0) |=3D X86_CR0_TS;=0A xen_clear_cr0_upd()= ;=0A }=0A--- a/arch/x86_64/kernel/process-xen.c=0A+++ b/arch/x86_64/kern= el/process-xen.c=0A@@ -486,7 +486,7 @@ __switch_to(struct task_struct = *prev_p, =0A {=0A struct thread_struct *prev =3D &prev_p->thread,=0A = *next =3D &next_p->thread;=0A- int cpu = =3D smp_processor_id(); =0A+ int cpu =3D smp_processor_id(), cr0_ts;=0A = #ifndef CONFIG_X86_NO_TSS=0A struct tss_struct *tss =3D &per_cpu(init_ts= s, cpu);=0A #endif=0A@@ -572,11 +572,14 @@ __switch_to(struct task_struct = *prev_p, =0A BUG_ON(pdo > _pdo + ARRAY_SIZE(_pdo));=0A #endif=0A = BUG_ON(mcl > _mcl + ARRAY_SIZE(_mcl));=0A- if (_mcl->op =3D=3D = __HYPERVISOR_fpu_taskswitch)=0A+ if (_mcl->op =3D=3D __HYPERVISOR_fp= u_taskswitch) {=0A __get_cpu_var(xen_x86_cr0_upd) =3D = X86_CR0_TS;=0A+ cr0_ts =3D 1;=0A+ } else=0A+ = cr0_ts =3D 0;=0A if (unlikely(HYPERVISOR_multicall_check(_mcl, mcl = - _mcl, NULL)))=0A BUG();=0A- if (_mcl->op =3D=3D = __HYPERVISOR_fpu_taskswitch) {=0A+ if (cr0_ts) {=0A = __get_cpu_var(xen_x86_cr0) |=3D X86_CR0_TS;=0A xen_clear_cr0_upd()= ;=0A }=0A --=__Part8FBECA5B.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part8FBECA5B.0__=--