From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [patch 0/2] Handle multiple exceptions (fixes Win2003 reboot by triple fault) Date: Sun, 15 Nov 2009 14:54:40 +0200 Message-ID: <4AFFFA10.9020407@redhat.com> References: <20091111192947.348198723@localhost.localdomain> <20091112122124.GB7392@redhat.com> <4AFC027B.1090101@siemens.com> <20091112130542.GD7392@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Jan Kiszka , Marcelo Tosatti , kvm@vger.kernel.org, joerg.roedel@amd.com To: Gleb Natapov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:65470 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752532AbZKOMyi (ORCPT ); Sun, 15 Nov 2009 07:54:38 -0500 In-Reply-To: <20091112130542.GD7392@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 11/12/2009 03:05 PM, Gleb Natapov wrote: > On Thu, Nov 12, 2009 at 01:41:31PM +0100, Jan Kiszka wrote: > >> Gleb Natapov wrote: >> >>> On Wed, Nov 11, 2009 at 05:29:47PM -0200, Marcelo Tosatti wrote: >>> >>>> I suppose a complete fix would be to follow the "Conditions for >>>> Generating a Double Fault" with support for handling exceptions >>>> serially. >>>> >>>> But this works for me. >>>> >>>> >>> I prefer proper solution. Like one attached (this is combination of ths >>> patch by Eddie Dong and my fix): >>> >> Nice, preferred here as well. I only have a minor comment below. >> >> > Move Double-Fault generation logic out of page fault > exception generating function to cover more generic case. > > Signed-off-by: Eddie Dong > Signed-off-by: Gleb Natapov > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 76c8375..88c4490 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -248,12 +248,61 @@ void kvm_set_apic_base(struct kvm_vcpu *vcpu, u64 data) > } > EXPORT_SYMBOL_GPL(kvm_set_apic_base); > > +#define EXCPT_BENIGN 0 > +#define EXCPT_CONTRIBUTORY 1 > +#define EXCPT_PF 2 > + > +static int exception_class(int vector) > +{ > + if (vector == 14) > + return EXCPT_PF; > + else if (vector == DE_VECTOR || (vector>= TS_VECTOR&& vector<= GP_VECTOR)) > + return EXCPT_CONTRIBUTORY; > + else > + return EXCPT_BENIGN; > +} > It's actually less readable. I know 11 is between 10 and 13, but is NP_VECTOR between TS_VECTOR and GP_VECTOR? This is better as a switch, or even: u8 exception_class[] = { [PF_VECTOR] EXPT_PF, etc. -- error compiling committee.c: too many arguments to function