From: Ian Campbell Subject: Re: [PATCH V2 0/6] mini-os: check and fix up against nested events in x86-64 kernel entry Date: Wed, 17 Apr 2013 16:14:51 +0100 Message-ID: <1366211691.25579.61.camel@zakaz.uk.xensource.com> References: <1365655620-30177-1-git-send-email-xzhang@cs.uic.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1365655620-30177-1-git-send-email-xzhang@cs.uic.edu> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xu Zhang , George Dunlap Cc: "samuel.thibault@ens-lyon.org" , "jeremy@goop.org" , Stefano Stabellini , "gm281@cam.ac.uk" , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Thu, 2013-04-11 at 05:46 +0100, Xu Zhang wrote: > mini-os almost always use direct iret to return from interrupt. > But this operation is not atomic because Xen uses event mask to > enable/disable event delivery. So there is a window for nested > events to happen after re-enabling event delivery and before > a direct iret. > > The issues come with such non-atomicity have been discussed in: > http://lists.xen.org/archives/html/xen-devel/2007-06/msg00142.html > > And also on Xen-devel: > http://markmail.org/message/jkzhzy6fyes6igcf > > This patch checks and fixes up against nested events in a similar > fashion of Linux 32bit pvops. > It checks against re-entrant of critical section in event handling > callback. Try to fix up by coalescing the two stack frames into > one when the a nested event came. > It then resumes execution as if the second event never happened. > > It also refactors mini-os's x86-64 kernel entry assembly code. Samuel are you now happy with this? The un-acked changes look to be mostly cleanups and refactoring rather than substantive changes. The very last patch has meat in it and is unacked. WRT making a case for a freeze exception it seems like this is fixing a pretty obvious bug in x86_64 mini-os event handling? Ian. > > Xu Zhang (6): > mini-os/x86-64 entry: code clean-ups; no functional changes > mini-os/x86-64 entry: define macros for registers partial save and > restore; no functional changes > mini-os/x86-64 entry: code refactoring; no functional changes > mini-os/x86-64 entry: remove unnecessary event blocking > mini-os/x86-64 entry: defer RESTORE_REST until return > mini-os/x86-64 entry: check against nested events and try to fix up > > extras/mini-os/arch/x86/x86_64.S | 245 ++++++++++++++++++++++++-------------- > 1 files changed, 156 insertions(+), 89 deletions(-) > > --- > Changed since v1: > * Drop the chunky lookup table; use Linux x86-32's fixup strategy instead, > as suggested by Jeremy Fitzhardinge; > * Reflect Samuel Thibault's comments. >