From owner-svn-src-all@freebsd.org Sat Jan 13 23:54:18 2018 Return-Path: Delivered-To: svn-src-all@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 A4C0DE60BA7 for ; Sat, 13 Jan 2018 23:54:18 +0000 (UTC) (envelope-from mw@semihalf.com) Received: from mail-io0-x229.google.com (mail-io0-x229.google.com [IPv6:2607:f8b0:4001:c06::229]) (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 6F6E77EA7C for ; Sat, 13 Jan 2018 23:54:18 +0000 (UTC) (envelope-from mw@semihalf.com) Received: by mail-io0-x229.google.com with SMTP id b198so6933795iof.6 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=pxEb4kkJM+xpDKUs0WrsBUnBuZhruus90QXH4KULCfuM1srkxefYdnqoQxxlnjNL8Y ggftIgX/le7wJwFxvUbdGXfC0KfgKSYKrAKzIUFk9Klk/hbAJ6gzTkmoJtsiWvLZXXaD mBo/RiRg3yyGBxN2FXQcoq2WoPRC0LFAkqUYZ7OH8uXnu7xHENIHfau6dMglIzZNavkf oO/oRDgktdDM0GglNKoqqg7NYpC9sxMw5F4ZaMvorm83MH9KX04jBBPPHwOtdLClShdJ H2jPJZCgtD3k9OFQhtRYfaQMRQ6wDRHBItNZvALVbezkpZMVl3O5h/86g/7CCCabW0mI UY7w== X-Gm-Message-State: AKwxytdbmo2zMafhwF8DMhFH46wI2Nnel32xpmngQ3h5NzS3yA+dzEYD mY5c8tY7BIxvK6oC4Kl/7vPKffneKsU6oSN9784Gww== 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-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" 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