From: Tim Deegan Subject: Re: [PATCH v2 2/2] x86/HVM: fix ID handling of x2APIC emulation Date: Thu, 18 Sep 2014 14:59:28 +0200 Message-ID: <20140918125928.GA81607@deinos.phlegethon.org> References: <541070390200007800033519@mail.emea.novell.com> <541071DF0200007800033534@mail.emea.novell.com> <5411CDBA.2090401@citrix.com> <5412C3740200007800034564@mail.emea.novell.com> <20140918105329.GA64996@deinos.phlegethon.org> <541AEA1502000078000362D7@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XUbJJ-0002ls-L9 for xen-devel@lists.xenproject.org; Thu, 18 Sep 2014 12:59:45 +0000 Content-Disposition: inline In-Reply-To: <541AEA1502000078000362D7@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: Ian Campbell , Andrew Cooper , Keir Fraser , IanJackson , xen-devel List-Id: xen-devel@lists.xenproject.org At 13:20 +0100 on 18 Sep (1411042805), Jan Beulich wrote: > >>> On 18.09.14 at 12:53, wrote: > > At 08:57 +0100 on 12 Sep (1410508628), Jan Beulich wrote: > >> >> @@ -1254,6 +1255,29 @@ HVM_REGISTER_SAVE_RESTORE(LAPIC, lapic_s > >> >> HVM_REGISTER_SAVE_RESTORE(LAPIC_REGS, lapic_save_regs, lapic_load_regs, > >> >> 1, HVMSR_PER_VCPU); > >> >> > >> >> +void vlapic_domain_unpause(const struct domain *d) > >> >> +{ > >> >> + /* > >> >> + * Following lapic_load_hidden()/lapic_load_regs() we may need to > >> >> + * correct ID and LDR when they come from an old, broken hypervisor. > >> >> + */ > >> > > >> > This seems like aweful overhead for the domain_{,un}pause() path. > >> > >> It's the best I could think of (and domain un-pausing shouldn't be that > >> frequent an operation I would hope), since ... > >> > >> > Why can't it be fixed up once in lapic_load_{regs,hidden}(), > >> > >> ... both of these would have to have got carried out and ... > > > > You're already tracking whether either of them happens so you could > > track whether both have happened and do the fixup then. Loading a VM > > with only the hidden state and not the register state is not something > > we care about (and in that case, by construction, LDR won't be 1). > > I had considered that, but dropped the idea because the two pieces > are independent, and hence I don't think we should (implicitly) disallow > it. We wouldn't be disallowing it; we'd just fail to magically fix vlapic state for that one case. And since the fix assumes that it's dealing with a save record from an older Xen I think that's OK. After all, the fix also implicitly disallows deliberately setting up a vcpu that looks like an old-fashioned HVM vcpu. It would, I think, be reasonable to abandon the fix altogether and just let upgraded VMs continue with their bogus state -- after all it can't be that much of a problem for them or they'd have failed on the old box. > Nor do I think we should (implicitly) disallow restoring the same > state more than once before resuming the guest (or vCPU). True, but that's true whether we do the fix at unpause or beforehand. > I.e. if I > was to go that route, we should then first formally (even if just > verbally) tighten the requirements on these context load operations. I have no objection to that; I think a comment in save.h would suffice. Tim.