From owner-svn-src-head@freebsd.org Sat Jan 13 23:54:18 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A4552E60BA5 for ; Sat, 13 Jan 2018 23:54:18 +0000 (UTC) (envelope-from mw@semihalf.com) Received: from mail-io0-x235.google.com (mail-io0-x235.google.com [IPv6:2607:f8b0:4001:c06::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6BBCD7EA79 for ; Sat, 13 Jan 2018 23:54:18 +0000 (UTC) (envelope-from mw@semihalf.com) Received: by mail-io0-x235.google.com with SMTP id v30so9613332iov.7 for ; Sat, 13 Jan 2018 15:54:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=8q70L55Qnofs8yiwA2St2ejFBfUDxh+C35ITTLUAZIQ=; b=MjPDyXSpkN66cfhTK1iOZ0RAnR9zQOoPd/7TV0E4NY+5MR/TlHfR0nMUSSD184c6Xz mHKtLMGaNkzZg8b8BFnxlvGdDDcXKDkYF9l/SqzP6QUFfiyVF0nl0E2r+QCMkJ7J7fei hZ9ELD1g0WCWYFtlZhBlIIrsOMoZuTVYJHahjwGcbfc9uq5UxRbSChnK2vj0sjTek9VL Lvd0wk4FEUncTZEpwZsLcmVpww0oVfEyudpaxHx9SUpzit07wPKnDy34eaaO/pmQ7vV2 MX+m+nJh2eRbRytpn2up8lLZ9CGmL7s/EmbPXQOFpXRx/zaGwbKZoJACpw3ODnbWIEMa Pkeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=8q70L55Qnofs8yiwA2St2ejFBfUDxh+C35ITTLUAZIQ=; b=jQpSzYtiTf3dMjyQJpX4/WcttIkdUkHecGs0wL+dH/x/Jv1l51dERnvsdV1HYP4PMk IGsMCcqk6TiTyHb9uo5eE3jG155xtGT4njSJ0ntmtVNSO1K4w4nlYwwyHjJBgiRyjPbO Z7E+S2WYMeFr2SIChTpaGMsmbbe2SDk//juo4rrOMB/2UXcejJ1tzdgL9T0DKvd956uD 8OJUgtSSs+m7TIs7u0NNh78P3ap4QkKKy4+BwDRt7UfrRqO7Ekxnh04k42l0hwFnYkkT KQ/tTS085RJeOz+QFufeII4VU/f1RfIKZrPWyDuAnrmxuiIynR1nD30usJk7bXT7CN6k h3yQ== X-Gm-Message-State: AKwxytfHHmqL+5vN2JTSAdYqk11uV/C3LAENrRTMFFvyGApy4JmOpDmB QwQqulpdIY4grlaKQwJL0Iu2OnZOi1VcJEZTWXUWy6lyg5M= X-Google-Smtp-Source: ACJfBosS5JPIw/xIDFc7rE8cRsmcxWvCyFySD+iwqImACJx9X3yscFlLXvB0vYENmnSJ01xo6BQrH5whn+DHjhZCxtA= X-Received: by 10.107.112.7 with SMTP id l7mr3097736ioc.178.1515887657632; Sat, 13 Jan 2018 15:54:17 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.37.13 with HTTP; Sat, 13 Jan 2018 15:54:17 -0800 (PST) In-Reply-To: <187e75c7-343f-aea6-cb59-61c77fd64023@freebsd.org> References: <201801121401.w0CE1cW4058239@repo.freebsd.org> <187e75c7-343f-aea6-cb59-61c77fd64023@freebsd.org> From: Marcin Wojtas Date: Sun, 14 Jan 2018 00:54:17 +0100 Message-ID: Subject: Re: svn commit: r327876 - in head/sys/arm64: arm64 include To: mmel@freebsd.org Cc: Warner Losh , Andrew Turner , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jan 2018 23:54:18 -0000 Hi Michal, 2018-01-12 18:15 GMT+01:00 Michal Meloun : > > > On 12.01.2018 15:54, Warner Losh wrote: >> >> >> >> On Fri, Jan 12, 2018 at 7:52 AM, Andrew Turner > > wrote: >> >> >> >>> On 12 Jan 2018, at 14:37, Warner Losh >> > wrote: >>> >>> >>> >>> On Fri, Jan 12, 2018 at 7:15 AM, Andrew Turner >> > wrote: >>> >>> >>> >>>> On 12 Jan 2018, at 14:10, Marcin Wojtas >>> > wrote: >>>> >>>> Hi Andrew, >>>> >>>> >>>> >>>> 2018-01-12 15:01 GMT+01:00 Andrew Turner >>> >: >>>> >>>>> Author: andrew >>>>> Date: Fri Jan 12 14:01:38 2018 >>>>> New Revision: 327876 >>>>> URL: https://svnweb.freebsd.org/changeset/base/327876 >>>>> >>>>> >>>>> Log: >>>>> Workaround Spectre Variant 2 on arm64. >>>>> >>>>> We need to handle two cases: >>>>> >>>>> 1. One process attacking another process. >>>>> 2. A process attacking the kernel. >>>>> >>>>> For the first case we clear the branch predictor state on >>>>> context switch >>>>> between different processes. For the second we do this when >>>>> taking an >>>>> instruction abort on a non-userspace address. >>>>> >>>>> To clear the branch predictor state a per-CPU function >>>>> pointer has been >>>>> added. This is set by the new cpu errata code based on if >>>>> the CPU is >>>>> known to be affected. >>>>> >>>>> On Cortex-A57, A72, A73, and A75 we call into the PSCI >>>>> firmware as newer >>>>> versions of this will clear the branch predictor state for us. >>>>> >>>>> It has been reported the ThunderX is unaffected, however >>>>> the ThunderX2 is >>>>> vulnerable. The Qualcomm Falkor core is also affected. As >>>>> FreeBSD doesn't >>>>> yet run on the ThunderX2 or Falkor no workaround is >>>>> included for these CPUs. >>>> >>>> >>>> Regardless ThunderX2 / Falkor work-arounds, do I understand >>>> correctly >>>> that pure CA72 machines, such as Marvell Armada 7k/8k are >>>> immune to >>>> Variant 2 now? >>> >>> >>> It is my understanding that the A72 will be immune with this >>> patch and an updated Arm Trusted Firmware as documented in [1]. >>> >>> Andrew >>> >>> [1] >>> >>> https://github.com/ARM-software/arm-trusted-firmware/wiki/ARM-Trusted-Firmware-Security-Advisory-TFV-6 >>> >>> >>> >>> >>> Are you also working on aarch32 mitigation? >> >> >> No. I think a similar technique could be used, however as aarch32 >> has instructions to invalidate the branch predictor these can be >> used directly. >> >> >> That's my reading as well. It looks fairly easy to do it always, but I've >> not researched it sufficiently. >> > > I work on patches for armv6/7. But for aarch32, there is, unfortunately, > much less information available about affective mitigation of variant 2. > BPIALL while switching pmap is clear and we have it in code for years > (well, BPIALL is effectively NOP for A15/A17, it must be explicitly > enabled). > But is not clear for me for which trap is branch predictor flush necessary. > As for armv7, I believe the brand new patches on top of this branch could be helpful: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/log/?h=kpti Best regards, Marcin