Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp593288pxk; Wed, 2 Sep 2020 09:34:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuzLDGkTa6ke5G1eAYu+ObnGq459eG1wlPy4Qlxbtm8YOMi82SE/Ep9Q+RkRzqRndzgXIH X-Received: by 2002:a50:9e4c:: with SMTP id z70mr875893ede.384.1599064489103; Wed, 02 Sep 2020 09:34:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599064489; cv=none; d=google.com; s=arc-20160816; b=jwultCd+CaXkS2qnnL04xXNIAxqn3oAyjHtxrfKMmsOTRT5Ol04FQOM4gLnEotfV03 3TJs4YCW7Aic9k5iO/kg+x9jKxSr13oZhk5UjWPReBadKtsezNzRDkrQgR4IAfbVdN/8 oCzZQ2d25Dgnr5dmRJnvZzk97hjxOA37yQV+VLzxyZepHN1OaAgLNi2PIRMucADff9sb 2e2hPt1EFI6S4xKkKAJ3crPLXT1bYTyq+787tjxd9vB6HF+cclRMCiKwsrIErmlM/TuB NNe7gNSQbieJAANOXEIryPxiw/aZ5zcdf5P4bZOhdHtKl/8iJ4aDbwz1P1cuxAlVekjx DI3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=88Vj/Wc6X7MjJr1tlbjOd/wr3LMbx0W4hoJRs4r17rM=; b=qbaSQ3MdSb8WUPEpc1F4PSYaGnKYP8FThWP0hH9VtKJAlGN0QlpYgg8gMlPM7vnPLL F+SKJKWiM9s7O3nMUKZnxb5FpaFr1Q1LVvii4LkcoOgPrfCwBp7LGPJMyulxnPec0PjE RZaIpnKldOhCHMkvaSrCBjt5LudBbT2Bh0u92dhnjKPPAdQMKsaqWjZ3PorT2gsX+peB TCvh7p64shgBZWDGGMKISvaU7QR0/KR+MLt/XXmHgbhN6F7Fb9CP9QjdCNp6Ksa8znBs VQfngGiUlE9Z0/7N3xW+mxk7YtNytlS+MrQHOqvX/bIAsTtjfBGldeRglJ+rJxq10dy5 DNQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="ilhlIq/k"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si3205447edi.348.2020.09.02.09.34.26; Wed, 02 Sep 2020 09:34:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="ilhlIq/k"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728073AbgIBQbo (ORCPT + 99 others); Wed, 2 Sep 2020 12:31:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726247AbgIBQbn (ORCPT ); Wed, 2 Sep 2020 12:31:43 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3F0FC061244 for ; Wed, 2 Sep 2020 09:31:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=88Vj/Wc6X7MjJr1tlbjOd/wr3LMbx0W4hoJRs4r17rM=; b=ilhlIq/kZOPPyT38R6jlJ7rJ3A 9iuCnGJB3LsiAD0hDpw2cCUGEpnk2w8wt23fdNfudswwFqdpqmTfPHwfXlsp05bkbt/qi/ebjkaFK qD3XkFlC/QpqWLp33qU4i2p2JENJ0uho3yrtLxH8MwAdUWGlSBSR5uGk4fsP56pkZvaPLumz8mjAK vyAxHdj22u3OGEi+Ejiogy3rUJAM6hmlClk3IesBu5k/ESFga2c/LeRb7rKlfAwH/IJ8jl8HueSZg ttmVpFQehAS8FgrXkiik9ti1X6SU3tixeT0yPXO825g88za5Q8+TSj2iPf2TneTVEgKerRm6I6blq sPKPn4ZQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDVfJ-0006xj-I9; Wed, 02 Sep 2020 16:31:17 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 7BBAF3011C6; Wed, 2 Sep 2020 18:31:15 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 639EE2B98F973; Wed, 2 Sep 2020 18:31:15 +0200 (CEST) Date: Wed, 2 Sep 2020 18:31:15 +0200 From: peterz@infradead.org To: =?iso-8859-1?Q?J=FCrgen_Gro=DF?= Cc: Brian Gerst , the arch/x86 maintainers , Linux Kernel Mailing List , Kyle Huey , Alexandre Chartre , Robert O'Callahan , "Paul E. McKenney" , Frederic Weisbecker , Paolo Bonzini , Sean Christopherson , Masami Hiramatsu , Petr Mladek , Steven Rostedt , Joel Fernandes , Boris Ostrovsky , Andy Lutomirski , Josh Poimboeuf , Daniel Thompson , Andrew Cooper Subject: Re: [PATCH 01/13] x86/entry: Fix AC assertion Message-ID: <20200902163115.GM1362448@hirez.programming.kicks-ass.net> References: <20200902132549.496605622@infradead.org> <20200902133200.666781610@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 02, 2020 at 06:24:27PM +0200, J?rgen Gro? wrote: > On 02.09.20 17:58, Brian Gerst wrote: > > On Wed, Sep 2, 2020 at 9:38 AM Peter Zijlstra wrote: > > > > > > From: Peter Zijlstra > > > > > > The WARN added in commit 3c73b81a9164 ("x86/entry, selftests: Further > > > improve user entry sanity checks") unconditionally triggers on my IVB > > > machine because it does not support SMAP. > > > > > > For !SMAP hardware we patch out CLAC/STAC instructions and thus if > > > userspace sets AC, we'll still have it set after entry. > > > > > > Fixes: 3c73b81a9164 ("x86/entry, selftests: Further improve user entry sanity checks") > > > Signed-off-by: Peter Zijlstra (Intel) > > > Acked-by: Andy Lutomirski > > > --- > > > arch/x86/include/asm/entry-common.h | 11 +++++++++-- > > > 1 file changed, 9 insertions(+), 2 deletions(-) > > > > > > --- a/arch/x86/include/asm/entry-common.h > > > +++ b/arch/x86/include/asm/entry-common.h > > > @@ -18,8 +18,16 @@ static __always_inline void arch_check_u > > > * state, not the interrupt state as imagined by Xen. > > > */ > > > unsigned long flags = native_save_fl(); > > > - WARN_ON_ONCE(flags & (X86_EFLAGS_AC | X86_EFLAGS_DF | > > > - X86_EFLAGS_NT)); > > > + unsigned long mask = X86_EFLAGS_DF | X86_EFLAGS_NT; > > > + > > > + /* > > > + * For !SMAP hardware we patch out CLAC on entry. > > > + */ > > > + if (boot_cpu_has(X86_FEATURE_SMAP) || > > > + (IS_ENABLED(CONFIG_64_BIT) && boot_cpu_has(X86_FEATURE_XENPV))) > > > + mask |= X86_EFLAGS_AC; > > > > Is the explicit Xen check necessary? IIRC the Xen hypervisor will > > filter out the SMAP bit in the cpuid pvop. > > Right, and this test will nevertheless result in setting AC in the mask. > IIRC this was the main objective here. Correct, this asserts that 64bit Xen-PV will never have AC set; it had better not have it set since it runs in ring 3.