Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1310681pxk; Fri, 4 Sep 2020 06:27:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZK/aQA3Zt0iqX9cCylErIwq1uSJqfzisQCkdGEX37u/jTRDteksS3vX3J2FeAP4sfm1Z4 X-Received: by 2002:a17:906:b0a:: with SMTP id u10mr7277449ejg.226.1599226074091; Fri, 04 Sep 2020 06:27:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599226074; cv=none; d=google.com; s=arc-20160816; b=O08eDXaL+gk48ll+GikYfNzOlwQYT1l5QFAsrUa6bkuuBAVN/cRSd8KD8pUHkgvXw2 E8WtsUSOSlevtuVujUaU3nub4v9Zh/jRELqC6Fwu6bOWDBLX+Khtsn4VoIp1YFGrzbut WWPlgx0RHYWFFrl2E7pcdxCb8nydRoEDRjik++6LxkO0y/Z6L4usLDMg7HkiGnLy7CVu lnv8ZTNVZ0OtLwnVoGEUzXpW0KQkB/QRagpfI/uWcAGFAqHuzkQKt/2xm6uJ6tn4i3eH SuvxQ/U6FujDOtYmlEGKB17rdj6pbwkLACbHWVZoZzVfYpMS+EigwhunwIqpgXjqQZ71 LVMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:dkim-signature :dkim-signature:date; bh=FYo4oWPndmPH1VpAsfPaaX5l0/5q804nP45ekBNCsvE=; b=oNn1TCJUjU1j21phnxGdab+wCRx7+mfQ6wFO/nt0HUqr2PUUtI5QYtuD64Vp84OXG9 Mg6GVmOI9x+1rGmWi0K9piCb5L2ZdqUDwtac/4S97qiY56+fvTkVZA27/v55BZr7fQIG LBI7Aeaxvs1kP/jGGDUaA8gyoSfg5B9UkCG7I8xT/Nwm3aKiiW2i4gPQaWy96GMy+gp+ JmOva5s0bWKx7aUMDl85XRcPjv0MxMSHfk9brdc2hc5+V4z+BeQJmLArfYlP47BMbSV8 Hhr8L1QzBDMB5noWgo0kjEh83yNIB3aM40qshsk6CHEAi0q8w+IHGpzCCWZ1sca+F/e2 3wYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=CXWxcJSw; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e header.b=Lt0gZDkN; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v11si3886605edx.325.2020.09.04.06.27.29; Fri, 04 Sep 2020 06:27:54 -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=@linutronix.de header.s=2020 header.b=CXWxcJSw; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e header.b=Lt0gZDkN; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730318AbgIDNUn (ORCPT + 99 others); Fri, 4 Sep 2020 09:20:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730329AbgIDNQP (ORCPT ); Fri, 4 Sep 2020 09:16:15 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC5FDC061244; Fri, 4 Sep 2020 06:16:13 -0700 (PDT) Date: Fri, 04 Sep 2020 13:16:04 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1599225365; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FYo4oWPndmPH1VpAsfPaaX5l0/5q804nP45ekBNCsvE=; b=CXWxcJSwBfNNl7/uWWf2cFw/XH3j/xrEb7IRNn2ww5+xzVxble3MmlvuoqNg/pITFTYRx7 rvtFsmi6YkDgln7ZXjDcfLBSJD74wjgaXOmUPNPkzO3llg/wisUPXGt8NZqbke9S6+FH5V /5a/r0AAZ5K0CvkWNMXKmvruZxYxeMwudWsdDO2Gf7WIh/xWXbXJJwzHailgHrJxoabVfu 3UU3zmkhs03RnHZIkLb6SwAGVDQj6eMt/NUxSNhcs6hYPh/IT5Cf8yt/QKvOTT/U4x4C+j cZ7U6URIJKmA6DKJk0SZqoql7cFVBvbLWm5w430G5aUeZZagIRVdkPUJujRLJw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1599225365; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FYo4oWPndmPH1VpAsfPaaX5l0/5q804nP45ekBNCsvE=; b=Lt0gZDkN5FP0WS3HroUN40FXymZBsCp+UjC0KJvIQLtU5U4ejFHdHUSn5/HTuv5NY26KyG 0DyRfiQqmSjo3yCg== From: "tip-bot2 for Peter Zijlstra" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/entry: Fix AC assertion Cc: "Peter Zijlstra (Intel)" , Thomas Gleixner , Daniel Thompson , Andy Lutomirski , stable@vger.kernel.org, x86 , LKML In-Reply-To: <20200902133200.666781610@infradead.org> References: <20200902133200.666781610@infradead.org> MIME-Version: 1.0 Message-ID: <159922536478.20229.11152935257298904584.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 662a0221893a3d58aa72719671844264306f6e4b Gitweb: https://git.kernel.org/tip/662a0221893a3d58aa72719671844264306f6e4b Author: Peter Zijlstra AuthorDate: Wed, 02 Sep 2020 15:25:50 +02:00 Committer: Thomas Gleixner CommitterDate: Fri, 04 Sep 2020 15:09:29 +02:00 x86/entry: Fix AC assertion The WARN added in commit 3c73b81a9164 ("x86/entry, selftests: Further improve user entry sanity checks") unconditionally triggers on a IVB machine because it does not support SMAP. For !SMAP hardware the CLAC/STAC instructions are patched out and thus if userspace sets AC, it is still have set after entry. Fixes: 3c73b81a9164 ("x86/entry, selftests: Further improve user entry sanity checks") Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Thomas Gleixner Tested-by: Daniel Thompson Acked-by: Andy Lutomirski Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20200902133200.666781610@infradead.org --- arch/x86/include/asm/entry-common.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/entry-common.h b/arch/x86/include/asm/entry-common.h index a8f9315..6fe54b2 100644 --- 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_user_regs(struct pt_regs *regs) * 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));