From patchwork Mon Jun 30 10:26:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 32686 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 655F1203C0 for ; Mon, 30 Jun 2014 10:36:21 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id b6sf17962468yha.4 for ; Mon, 30 Jun 2014 03:36:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:in-reply-to:references :date:message-id:subject:from:to:cc:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=gMMQJYptLigJYbJPxSagevnsHjcs+0DDf0u8S1QjVeM=; b=csCRT8/gJwykXzbyS/Pd/HEPUEYdQgvmkSwMQrH1/o1XoNGk8WuykS5W2u9oSjp/KF l3MIIfP/3eDWv8XRNETnQoGIG9kA9sDsUIRoEkcUECF4kSl4PIT2T+jJWtu45sQSr50s kKpxvdWv0hpVNU5Bu94HXyob/zLRK92Gg6RLqw9Ffn7qwGuOkJI5ySARfKlV9ndL593g cO+pFnfbtixKOqaV1Qev/MMENK4De3vPK7bXZtZuesOBHf4/S49llxtlsiPj9qHSMYcp kmT1IRW8UqG8Ag3U4o0d9Um3Ncmnj7GsDTwEYqLEGppE7eKChpIF+UJOHADMB5WuEeW2 jWng== X-Gm-Message-State: ALoCoQkyv+dk0pxWz/GMd31UML6KFXiCtUISknyZleNdW+5QNaGjhuOyD1FEK5d7ZfbmCjzdwF17 X-Received: by 10.52.121.13 with SMTP id lg13mr18708876vdb.8.1404124581157; Mon, 30 Jun 2014 03:36:21 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.201 with SMTP id z67ls1482448qgd.94.gmail; Mon, 30 Jun 2014 03:36:21 -0700 (PDT) X-Received: by 10.58.243.1 with SMTP id wu1mr38384794vec.27.1404124581076; Mon, 30 Jun 2014 03:36:21 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id qi1si9859655veb.60.2014.06.30.03.36.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Jun 2014 03:36:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id la4so7327517vcb.14 for ; Mon, 30 Jun 2014 03:36:21 -0700 (PDT) X-Received: by 10.220.15.8 with SMTP id i8mr102461vca.45.1404124580974; Mon, 30 Jun 2014 03:36:20 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp125821vcb; Mon, 30 Jun 2014 03:36:20 -0700 (PDT) X-Received: by 10.67.21.205 with SMTP id hm13mr51096083pad.112.1404124580162; Mon, 30 Jun 2014 03:36:20 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id sj10si22649394pab.159.2014.06.30.03.36.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jun 2014 03:36:20 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X1YvM-0007hd-HQ; Mon, 30 Jun 2014 10:35:00 +0000 Received: from mail-la0-f47.google.com ([209.85.215.47]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X1YvJ-0007YT-UJ for linux-arm-kernel@lists.infradead.org; Mon, 30 Jun 2014 10:34:58 +0000 Received: by mail-la0-f47.google.com with SMTP id s18so4636564lam.20 for ; Mon, 30 Jun 2014 03:34:35 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.112.16.230 with SMTP id j6mr765921lbd.90.1404124014518; Mon, 30 Jun 2014 03:26:54 -0700 (PDT) Received: by 10.112.33.66 with HTTP; Mon, 30 Jun 2014 03:26:54 -0700 (PDT) In-Reply-To: <20140630090318.GB24879@arm.com> References: <1403884399-16359-1-git-send-email-will.deacon@arm.com> <20140630090318.GB24879@arm.com> Date: Mon, 30 Jun 2014 12:26:54 +0200 Message-ID: Subject: Re: [PATCH v2] arm64: fpsimd: avoid restoring fpcr if the contents haven't changed From: Ard Biesheuvel To: Will Deacon X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140630_033458_160005_476D2EE7 X-CRM114-Status: GOOD ( 12.33 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.215.47 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.215.47 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Catalin Marinas , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 On 30 June 2014 11:03, Will Deacon wrote: > On Fri, Jun 27, 2014 at 06:33:58PM +0100, Ard Biesheuvel wrote: >> On 27 June 2014 17:53, Will Deacon wrote: >> > Writing to the FPCR is commonly implemented as a self-synchronising >> > operation in the CPU, so avoid writing to the register when the saved >> > value matches that in the hardware already. > > [...] > >> > .macro fpsimd_restore_partial state, tmpnr1, tmpnr2 >> > ldp w\tmpnr1, w\tmpnr2, [\state] >> > msr fpsr, x\tmpnr1 >> > - msr fpcr, x\tmpnr2 >> > + fpsimd_restore_fpcr x\tmpnr1, x\tmpnr2 >> >> Ehm, isn't this the wrong way around? > > Yup, well spotted. I'll give the crypto selftests a run to test this path > with the fix (I was just running paranoia in userspace before). > That won't cut it, I'm afraid. What I used is and run my [lengthy] userland benchmark while doing 'modprobe tcrypt mode=x' a number of times in another terminal (with only 1 CPU up). [with x=2 for SHA1 and x=6 for SHA256, for instance] The first iteration of the interrupt context NEON series had an ARM counterpart which I was able to test using iperf over a WPA2/CCMP link (with the bit-sliced AES in CTR mode). No such luck [yet] on arm64, unfortunately, so I had to improvise a bit. --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -221,6 +221,8 @@ void fpsimd_flush_task_state(struct task_struct *t) static DEFINE_PER_CPU(struct fpsimd_partial_state, hardirq_fpsimdstate); static DEFINE_PER_CPU(struct fpsimd_partial_state, softirq_fpsimdstate); +#define in_interrupt() (1) + /* * Kernel-side NEON support functions */