From: "Jan Beulich" Subject: Re: [PATCH 8/8] xen/x86: Additional SMAP modes to work around buggy 32bit PV guests Date: Fri, 26 Jun 2015 07:33:22 +0100 Message-ID: <558D0E520200007800089FBA@mail.emea.novell.com> References: <1435163500-10589-1-git-send-email-andrew.cooper3@citrix.com> <1435163500-10589-9-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1435163500-10589-9-git-send-email-andrew.cooper3@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: Xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 24.06.15 at 18:31, wrote: > @@ -784,6 +791,11 @@ unsigned long pv_guest_cr4_to_real_cr4(const struct vcpu *v) > if ( v->domain->arch.vtsc ) > cr4 |= X86_CR4_TSD; > > + /* Disable SMAP behind unaware 32bit PV guests. */ > + if ( (smap_mode == smap_mode_compat) && is_pv_32bit_vcpu(v) && > + ((v->arch.pv_vcpu.ctrlreg[4] & X86_CR4_SMAP) == 0) ) > + cr4 &= ~X86_CR4_SMAP; There's actually another problem here: The function you modify is used by paravirt_ctxt_switch_to(). Obviously you will want to make sure to re-enable SMAP when switching away from the guest, and not only at the point you finally switch to a suitable other non-idle vCPU. And then there's the question whether the above fixup wouldn't better be deferred until compat_restore_all_guest, minimizing the "damage" to Xen? Jan