Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp614395pxk; Wed, 2 Sep 2020 10:06:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzftsyjbswuMOutqprRwt1OvwT1xReJ9HcazcEIObC90Dh12ayrfLi3y/GgXIXSkgTzHXci X-Received: by 2002:a50:cd5e:: with SMTP id d30mr1031681edj.190.1599066395526; Wed, 02 Sep 2020 10:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599066395; cv=none; d=google.com; s=arc-20160816; b=ufzTCf7lWakF+tiKMD9o6kR2r8JqaXDQ8t/TR1lPgBfwMRMh7tEisp29d45xoNQ5Ng C31XNy4X5u7UbtFtvrGEATSqsRbNELLAWSUmt8GlghfEFQR5ASBHPWmMWFkHxmAxvoLO xM+DPW16Se+MKY38iEZ/F1hga7aLubeQU0bX19L/fHQWe+KYPBhe4pV+j07uviUmi2tc LD5fFUCDmNLrufg9UoWNIuFGwLL3iK1OXES7t+/60UrZP99MlO6zU/rm5iGqoyiZzsyX m2tIEiGsisC/TXEG5IsN8bncsx9pmxnyaui5OYIxv5imQas8qU87FUjx0UiasdXtG6LV fYgQ== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=xYcoL6IB0Wq6/qeVTU/n5lnOlUSrCMA6TFnZUgAyGsE=; b=GlTM0ZXbYbVzLJhQ5xiLSTDEzRmNC7TJ/47Kff1an6P8AsDdP7jiKk009WKs2SmXvY SQh84EJQHaiEFEsKezZoGf1sR0Hu9LNwolewPclgP4far9vwUGvfuSRQHEGTaVu+TN18 sNuEQOOPsNLHEbWPh6fZRoPmwUC6LOqZ+KjG31aHNTIO1n7euMidtrql6HUJn3DnzENT THOtV8yDOwIIQgTfmsa6CqI1KVDy+VV4O5RQ4t0qeRmvmbG03yvicWx84YNB90tNJqyN G1Pbtz6ntT9WXJ9Oe9DF9pPUzZG2D3cmMcPB6BhVUw8B6L0fZXz0PVnxkRbxiD2XtCih /yXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dSW58hqu; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q3si2945083edg.429.2020.09.02.10.06.11; Wed, 02 Sep 2020 10:06:35 -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=pass header.i=@gmail.com header.s=20161025 header.b=dSW58hqu; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728203AbgIBRC1 (ORCPT + 99 others); Wed, 2 Sep 2020 13:02:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726293AbgIBRCU (ORCPT ); Wed, 2 Sep 2020 13:02:20 -0400 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B932C061244 for ; Wed, 2 Sep 2020 10:02:19 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id u126so6511716iod.12 for ; Wed, 02 Sep 2020 10:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=xYcoL6IB0Wq6/qeVTU/n5lnOlUSrCMA6TFnZUgAyGsE=; b=dSW58hqu76qgwVPU3bA+u5m6uUoMYTaMSISCeNMZijC0E/BRbjoLIFnWiV9GKxGejJ 1uZ7r5kcVM7ddnfrNnVjI94iOPgjMtUX+Z/H1svxvnBct646Ukya0wm+E7Zx9iGy+7Ez 6LYzcixO7WEcQY4+/Iu8VQLw10Fx2tK/1ZqqnKAl7zT980iodfPlTS8Fub3xc30/aLO1 QsQqkRyB065CW1u3f0CCnUsj5xnrjIJ75UVIrWGI0b05RCM7K5ONP6eubMZGWRJWclXK Q2LSVhFzMECHyI/FltfQmijEWApqa2H0cJXGlxLpAkqV29ap9APkUEI2awS/E47QWD9b 2NMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=xYcoL6IB0Wq6/qeVTU/n5lnOlUSrCMA6TFnZUgAyGsE=; b=VnLn2SIm3xTwMLRmWxY72uqbbr40N0tojAj9TnEamxIf+q/4a9lhePj26QC4242NGo ffMX2qnkDpP0MN7Sx0IEF15H9Wwnbd+grPAVBvZ9SOoOoB1wmJSzieeanfNbKPVhUzJh 0/EJbRMbilZa8Q35VwITxTqt5qSdn9XKFMHGXbHpCUQ+D6a21aWKaNA+r1qKk3xgZimz 9CYig4W1tQScdAxDN88YGOAOIZYm0ry31cVBkTFlDAhswu6tPYj0E+R5oBGK6XK0VNr7 WRNEaY4dYGaRLI92w/WDfzb8SopdJqm83lf98mUtGCwqcR+ATEL3pLJUo9eQ8mXkrrIG 4B9A== X-Gm-Message-State: AOAM531qtDet9Z1/XLOvzvBTK3sHK3RiHle8G9UN0rPTztALTy017+mS HgWg/erLgczzNabuU3jTvzsiVfrhFxE/ngh9vw== X-Received: by 2002:a5d:841a:: with SMTP id i26mr4167807ion.144.1599066138555; Wed, 02 Sep 2020 10:02:18 -0700 (PDT) MIME-Version: 1.0 References: <20200902132549.496605622@infradead.org> <20200902133200.666781610@infradead.org> <20200902163115.GM1362448@hirez.programming.kicks-ass.net> In-Reply-To: <20200902163115.GM1362448@hirez.programming.kicks-ass.net> From: Brian Gerst Date: Wed, 2 Sep 2020 13:02:07 -0400 Message-ID: Subject: Re: [PATCH 01/13] x86/entry: Fix AC assertion To: Peter Zijlstra Cc: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= , "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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 2, 2020 at 12:31 PM wrote: > > On Wed, Sep 02, 2020 at 06:24:27PM +0200, J=C3=BCrgen Gro=C3=9F 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: Furth= er > > > > improve user entry sanity checks") unconditionally triggers on my I= VB > > > > 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 en= try 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 X= en. > > > > */ > > > > unsigned long flags =3D native_save_fl(); > > > > - WARN_ON_ONCE(flags & (X86_EFLAGS_AC | X86_EFLAGS_DF= | > > > > - X86_EFLAGS_NT)); > > > > + unsigned long mask =3D X86_EFLAGS_DF | X86_EFLAGS_N= T; > > > > + > > > > + /* > > > > + * 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 |=3D 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. Ok. That should be added to the comment to avoid confusion. -- Brian Gerst