From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752575AbbFDI6q (ORCPT ); Thu, 4 Jun 2015 04:58:46 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:44137 "EHLO SMTP02.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbbFDI6k (ORCPT ); Thu, 4 Jun 2015 04:58:40 -0400 X-IronPort-AV: E=Sophos;i="5.13,552,1427760000"; d="scan'208";a="271587817" Message-ID: <5570131C.1000704@citrix.com> Date: Thu, 4 Jun 2015 09:58:04 +0100 From: Andrew Cooper User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0 MIME-Version: 1.0 To: "H. Peter Anvin" , Xen-devel CC: David Vrabel , Rusty Russell , Thomas Gleixner , Ingo Molnar , , , "Konrad Rzeszutek Wilk" , Boris Ostrovsky , , Subject: Re: [PATCH] x86/cpu: Fix SMAP check in PVOPS environments References: <1433323874-6927-1-git-send-email-andrew.cooper3@citrix.com> <556FF270.5060306@zytor.com> In-Reply-To: <556FF270.5060306@zytor.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-DLP: MIA1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/06/15 07:38, H. Peter Anvin wrote: > On 06/03/2015 02:31 AM, Andrew Cooper wrote: >> There appears to be no formal statement of what pv_irq_ops.save_fl() is >> supposed to return precisely. Native returns the full flags, while lguest and >> Xen only return the Interrupt Flag, and both have comments by the >> implementations stating that only the Interrupt Flag is looked at. This may >> have been true when initially implemented, but no longer is. >> >> To make matters worse, the Xen PVOP leaves the upper bits undefined, making >> the BUG_ON() undefined behaviour. Experimentally, this now trips for 32bit PV >> guests on Broadwell hardware. The BUG_ON() is consistent for an individual >> build, but not consistent for all builds. It has also been a sitting timebomb >> since SMAP support was introduced. >> >> Use native_save_fl() instead, which will obtain an accurate view of the AC >> flag. > Could we fix the Xen pvops wrapper instead to not do things like this? > > -hpa > > We could, and I have a patch for that, but the check would still then be broken in lguest, and it makes a hotpath rather longer. Either pv_irq_ops.save_fl() gets defined to handle all flags, and Xen & lguest need correcting in this regard, or save_fl() gets defined to handle the interrupt flag only, and this becomes the single problematic caller in the codebase. The problem with expanding save_fl() to handle all flags is that restore_fl() should follow suit, and there are a number of system flags are inapplicable in such a situation. ~Andrew