xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Tim Deegan <tim@xen.org>, Keir Fraser <keir@xen.org>,
	Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH RFC] x86/traps: Make the main trap handlers safe for use early during Xen boot
Date: Tue, 13 May 2014 17:13:06 +0100	[thread overview]
Message-ID: <53724492.2090106@citrix.com> (raw)
In-Reply-To: <537255BC0200007800011D03@mail.emea.novell.com>

On 13/05/14 16:26, Jan Beulich wrote:
>>>> On 13.05.14 at 16:51, <andrew.cooper3@citrix.com> wrote:
>> Most of this patch is an analysis of the safety of the trap handlers.
>>
>> Traps 0, 4, 5, 9-12, 16, 17 and 19 all end up in do_trap().  do_trap() is
>> mostly safe, performing an exception table search and possibly panic()s.
>>
>> There is one complication with traps 16 and 19 which will see about calling
>> the fpu_exception_callback.  This involves following current which is not
>> valid early on boot.  The has_hvm_container_vcpu(curr) check is preceeded 
>> with
>> a system_state check, so in the exceedingly unlikely case that Xen takes an
>> x87/SIMP trap while booting, it will panic() instead of following a bogus
>> current vcpu.
>>
>> Traps 1, 3, 6-8, 13 and 15 are completely safe with respect to running during
>> early boot.  They all have well formed and obvious differences between faults
>> in Xen and faults in guests, with the Xen faults doing little more than
>> exception table walks or panic()s.
> I think 15 should be moved into the undefined / reserved category too.
> Nothing should be generating this.
>
> I would similarly question 9 (TRAP_copro_seg), which supposedly is
> valid only for old 32-bit CPUs.

Agreed - I was going to move them into the reserved-exception category
with a later patch in the series, but their current handling is safe
with respect to their current handling.

>
>> I would appreciate some careful review of this.  As part of developing the
>> other early init fixes, I will test what I can of this, but doubt it will be
>> comprehensive testing.
> The main thing I wonder is why you submit this separately - this is
> going to become useful only once these get wired up earlier than
> they are right now.

For some early review, especially if there were glaring holes in my
logic.  I am currently working on the bsp changes.

>
>> --- a/xen/arch/x86/traps.c
>> +++ b/xen/arch/x86/traps.c
>> @@ -561,7 +561,8 @@ static void do_trap(struct cpu_user_regs *regs, int use_error_code)
>>      }
>>  
>>      if ( ((trapnr == TRAP_copro_error) || (trapnr == TRAP_simd_error)) &&
>> -         has_hvm_container_vcpu(curr) && curr->arch.hvm_vcpu.fpu_exception_callback )
>> +         system_state == SYS_STATE_active && has_hvm_container_vcpu(curr) &&
> This seems too specific a check - I think this ought to be "system_state >=
> SYS_STATE_active".
>
> Jan
>

I considered that, but the valid values greater than active are suspend
and resume, which absolutely shouldn't be running x86_emulate
codepaths.  I don't think it is safe to assume that any future values
greater than active will be safe contexts for this.

~Andrew

  reply	other threads:[~2014-05-13 16:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13 14:51 [PATCH RFC] x86/traps: Make the main trap handlers safe for use early during Xen boot Andrew Cooper
2014-05-13 15:26 ` Jan Beulich
2014-05-13 16:13   ` Andrew Cooper [this message]
2014-05-14  7:00     ` Jan Beulich

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=53724492.2090106@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=keir@xen.org \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.org \
    /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;
as well as URLs for NNTP newsgroup(s).