From xen-devel-bounces@lists.xen.org Wed Nov 06 09:31:53 2013 Received: (at maildrop) by bugs.xenproject.org; 6 Nov 2013 09:31:53 +0000 Received: from lists.xen.org ([50.57.142.19]) by bugs.xenproject.org with esmtp (Exim 4.80) (envelope-from ) id 1VdzSr-000761-Bc for xen-devel-maildrop-Eithu9ie@bugs.xenproject.org; Wed, 06 Nov 2013 09:31:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VdzPP-0002Io-PY; Wed, 06 Nov 2013 09:28:19 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VdzPO-0002IN-Kq for xen-devel@lists.xenproject.org; Wed, 06 Nov 2013 09:28:18 +0000 Received: from [85.158.137.68:6300] by server-8.bemta-3.messagelabs.com id 49/0B-06638-1BB0A725; Wed, 06 Nov 2013 09:28:17 +0000 X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1383730096!1889009!1 X-Originating-IP: [130.57.49.28] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTMwLjU3LjQ5LjI4ID0+IDQ4MDU=\n X-StarScan-Received: X-StarScan-Version: 6.9.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21000 invoked from network); 6 Nov 2013 09:28:17 -0000 Received: from nat28.tlf.novell.com (HELO nat28.tlf.novell.com) (130.57.49.28) by server-16.tower-31.messagelabs.com with DHE-RSA-AES256-SHA encrypted SMTP; 6 Nov 2013 09:28:17 -0000 Received: from EMEA1-MTA by nat28.tlf.novell.com with Novell_GroupWise; Wed, 06 Nov 2013 09:28:16 +0000 Message-Id: <527A19BB02000078000FFFE8@nat28.tlf.novell.com> X-Mailer: Novell GroupWise Internet Agent 12.0.2 Date: Wed, 06 Nov 2013 09:28:11 +0000 From: "Jan Beulich" To: "Zhu Yanhai" References: <1383720072-6242-1-git-send-email-gaoyang.zyh@taobao.com> <527A113C02000078000FFF99@nat28.tlf.novell.com> In-Reply-To: Mime-Version: 1.0 Content-Disposition: inline Cc: Charles Wang , Ian Campbell , George Dunlap , Andrew Cooper , Zhu Yanhai , Shen Yiben , David Vrabel , xen-devel , Boris Ostrovsky , Wan Jia Subject: Re: [Xen-devel] [PATCH] x86/fpu: CR0.TS should be set before trap into PV guest's #NM exception handler X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org >>> On 06.11.13 at 10:15, Zhu Yanhai wrote: > 2013/11/6 Jan Beulich : >> May I direct your attention to the XenoLinux one: >> >> asmlinkage void math_state_restore(void) >> { >> struct task_struct *me = current; >> >> /* NB. 'clts' is done for us by Xen during virtual trap. */ >> __get_cpu_var(xen_x86_cr0) &= ~X86_CR0_TS; >> if (!used_math()) >> init_fpu(me); >> restore_fpu_checking(&me->thread.i387.fxsave); >> task_thread_info(me)->status |= TS_USEDFPU; >> } >> >> Note the comment close to the beginning - the fact that CR0.TS >> is clear at exception handler entry is actually part of the PV ABI, >> i.e. by altering hypervisor behavior here you break all forward >> ported kernels. > > I see, XenoLinux kernel doesn't sleep in init_fpu() so it doesn't have > this issue. But I wonder why PV ABI decide to clear this bit for the > guest kernel, isn't it better for the guest kernel itself to see bit > set? Since it's more similar with the hardware. I know the ABI cannot > be changed, just for curious. Quite obvious - performance. Since (as you also confirmed) it is (almost) guaranteed for the handler to want to clear the bit, we can save it from having to do another hypercall here. In the forward ported XenoLinux the change is quite trivial (leaving aside any optimization, as we're on a rarely used path here anyway - it's being taken only the first time a process accesses the FPU): stts() before the local_irq_enable(), and clts() after the local_irq_disable(). But the x86 maintainers probably won't like this for pvops... Jan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel