Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp588452pxk; Wed, 2 Sep 2020 09:27:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqZ4hf5AdVEnAfcfHStz1XbJUIz6qt339xtNoh1bDvvvs2ISpFfnsTE6NyM9m2+4lSb1/g X-Received: by 2002:a17:906:bfcb:: with SMTP id us11mr806649ejb.502.1599064061730; Wed, 02 Sep 2020 09:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599064061; cv=none; d=google.com; s=arc-20160816; b=wBfdr43t/jIhQx21CFs4JlG+b//UcKXH8hTFT0PxQvLjp6Sj+QEhO0qPzS+QZ61E/D fX5cdDSJxTku3Tg+L2nUqIU50ud2XbV+Wzoav8B0wqts2Qlq3jEEVhZJ+JuRfaMMkc2F /za1jAWy92QWKZ1hl9d/R/LrLR/kgyUEP4YGYpG8ep0KJ3cH5Z/D1pV6FVEth7Z4ceio 75dOtBuAckm3Wo70cuHnk8oiP7EG6I3tmB4V3P/VCT299D/x98gOdyJnfA3etNTARe6b juYaWlpNY87+xSV4QNrgOb7MdyTPC70z8iJ5zRxcCeHaxqnweg689BLOMPy9b7+1QImQ SBHw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=j/iGTLnHGIU4GdivNvJXuj2CuJwUgMWQMpXazgRIuHY=; b=x+QgRmSgADoXuNBnusOq1hOuYiKhsTEJzdgwK3KKYoZWiWL7wLZlP16NpIqNWlxquQ E8nWOjGAq/1ewdTgn5E/hK9n6lBD6x6ms1iw/E5HqRfwmoIbME5etXzkU9MCWMy1EoZU O2LIPbCNlIgxdahhWavDNLdp7KGSQQSIgaHlXNf7hoZ3QTjpWA0oESO3ovh0ZiieNoIB sxHGnpUtm6bTrYMz0VnNWfPRPDoI7r/dFYJobOMpDh/1L7+EcbEBXpsBAjcQL/OiRY+b CbKH6mWdpFC2crp/A6uhkHkWySDQfmoj3lHtzfOYuJ4xVIVBfJoVAxCiNy4qv5iKdjVk j2nw== ARC-Authentication-Results: i=1; mx.google.com; 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 ca20si2856401edb.445.2020.09.02.09.27.18; Wed, 02 Sep 2020 09:27:41 -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; 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 S1727784AbgIBQYb (ORCPT + 99 others); Wed, 2 Sep 2020 12:24:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:49004 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726310AbgIBQYa (ORCPT ); Wed, 2 Sep 2020 12:24:30 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id BD49CAD03; Wed, 2 Sep 2020 16:24:29 +0000 (UTC) Subject: Re: [PATCH 01/13] x86/entry: Fix AC assertion To: Brian Gerst , Peter Zijlstra Cc: 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 References: <20200902132549.496605622@infradead.org> <20200902133200.666781610@infradead.org> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: Date: Wed, 2 Sep 2020 18:24:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Juergen