Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp475706pxk; Wed, 2 Sep 2020 06:50:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhDlgZTh15dfokcHqGNx8Wi/YWM18WIXHWCJDVIhtpUhQAktkggjR+usOrM5xI05yv7LLm X-Received: by 2002:a17:906:388b:: with SMTP id q11mr153173ejd.100.1599054652265; Wed, 02 Sep 2020 06:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599054652; cv=none; d=google.com; s=arc-20160816; b=SE5e+XyzmQq2bS8Uf5E4eN4vy/NWsQj4XmlyuZ0GgionW/709wzhP0Uqd2azys6Ugz /a6vlY4ogPSeBfUJiXj/X7dqOW4ytYtwC2+DlovWgHSxrKEwjszM6ZSPVR/Hzac6CmYM mn6vtk/g4ywrm8MBdQV5ydPjfwENd2llXSVFY+ty/yFc33B+oESsc7oMY+s+InxEEDjI 04cFSyTME4hmwXV4IPjCdx/zVlXmdDJaV6BxMRtLh2UlvjirSMJf9i5k8eBSHuC3WJMq Ze7RyvopQtgEgV5953ty7LbS1ijKl2waBmfgfBMc1CjRgepJyQKmKRUIISE6ktoaXALf +sgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:subject:cc:to :from:date:user-agent:message-id:dkim-signature; bh=HLJQCZHx6poAziNUgEdGRzGFUk3q15Hg/3SXsnWe/Zo=; b=Gas82Yi52U+06KDc7ulM53RAxC/gGkACq/6s95YsbVFFm3WT+KAO/imKZa6usO/3i2 Ad8Itvq+UdZtTjuCRRMEuQvq1AhX71D0BK6pE74DueH/jNMNn6WKIrxDcJ8RvE9v3jfr j3EeXUW+NzDRnZUldktHVhWcZdGsv2f0paVgotY+hY6KLAL6JTAO03DAX9stNq/jhQqY zbTB7U5rXTIy1o0nRtani8CMD2HlkKMtNoDxl7e4uUrPLSb+EuCkUN+tYsvULhjuSbKE D8+JiVc3wdfzERkIRQqEXeSuJEjVRTrEVbfspb/YxIbDFRLMsIADjvuFhEePCYILzzgg IrNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=MfWWEdwY; 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 d9si1377310edv.452.2020.09.02.06.50.28; Wed, 02 Sep 2020 06:50:52 -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=MfWWEdwY; 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 S1726966AbgIBNtr (ORCPT + 99 others); Wed, 2 Sep 2020 09:49:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727024AbgIBNlC (ORCPT ); Wed, 2 Sep 2020 09:41:02 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1789BC06123B for ; Wed, 2 Sep 2020 06:38:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=HLJQCZHx6poAziNUgEdGRzGFUk3q15Hg/3SXsnWe/Zo=; b=MfWWEdwYq0knADT+MsiPZXiJub 7eVu6bk577u/zpj5cOmG3zltjwUbJO183eW3qS0VHaAH5HkC0vDxFLnUisfgBBCpmN1lRZjCgkylB 0NHToSfJNVc+ma2vGWtSQG8BErKFtRC2HeV6kUMl9oc4VXB/zhM2Ufg45Uv2vmheufbXj2olW0cev KVBkNHsNFvhNMLaUXmTR1reyY2UxvP7zScZ9MpYB9D4gmu6szvwkv5rmynLp5j5CBCdXY/nS1JD6R qIDals+GBf7qhGWVxp8BsQioPeFrF8of8qoMsVDU3HYrphlnqSOMUhxvVkxNI0ezXXesXwAsiZbf8 4bTn5PVA==; 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 1kDSxr-0002dd-EB; Wed, 02 Sep 2020 13:38:15 +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 D3D203062BA; Wed, 2 Sep 2020 15:38:11 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id AE88020104617; Wed, 2 Sep 2020 15:38:11 +0200 (CEST) Message-ID: <20200902133200.666781610@infradead.org> User-Agent: quilt/0.66 Date: Wed, 02 Sep 2020 15:25:50 +0200 From: Peter Zijlstra To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, 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 , Juergen Gross , Brian Gerst , Andy Lutomirski , Josh Poimboeuf , Daniel Thompson , Peter Zijlstra , Andrew Cooper Subject: [PATCH 01/13] x86/entry: Fix AC assertion References: <20200902132549.496605622@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; + + WARN_ON_ONCE(flags & mask); /* We think we came from user mode. Make sure pt_regs agrees. */ WARN_ON_ONCE(!user_mode(regs));