From patchwork Sat Mar 10 15:21:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10273619 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2188160594 for ; Sat, 10 Mar 2018 15:23:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 126F029563 for ; Sat, 10 Mar 2018 15:23:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0703C29577; Sat, 10 Mar 2018 15:23:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7029929563 for ; Sat, 10 Mar 2018 15:23:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932338AbeCJPXH (ORCPT ); Sat, 10 Mar 2018 10:23:07 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33338 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932324AbeCJPXD (ORCPT ); Sat, 10 Mar 2018 10:23:03 -0500 Received: by mail-wm0-f65.google.com with SMTP id s206so7245065wme.0 for ; Sat, 10 Mar 2018 07:23:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=igH9KImZTLC7b3FEy2vhduXKBfEy6hhH3sJVJ6VEP8Q=; b=FVsvPWHitHJSBOohv0LlBjibo2VrwyfVHxbYh4IhXPj6AMPo41FiXMR2a8MlyBIYyU xKJgA5UQzEAHOAeVWumMh/oPI3S8vy+QeSuxNYdzc7rgXz9AXQfR5a/W9ZUNYTwnD/Qa NBTMgEPCUbHkANZHWDzeqJql6L01j2f+pOWPk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=igH9KImZTLC7b3FEy2vhduXKBfEy6hhH3sJVJ6VEP8Q=; b=Ai7ZHH/A4kwSjBZGbAp6CeXgea3sIQUj4gGvLMiGcNOE3/9ynfX3auDnk90zbCjpk1 xvUeRwauwFSEQTkd9G6n5lYvjbQhlOloGNmna3M/ZKM3Gu/DDElOPZIli2MRvzfMdbVA LN3lJkSglSUXAlKx0IktNKLxCsfK7S9erGEsTE4Mh5yavv/Zpc7GBqZqmwRchvl6m7kQ QrN0bW7nRkz2OtCH2Apsm1GNaOjLEVdRiNMMzSDSq3rTt2yf8ChQQMWFaacZX8md3bKY uJZZuyGRO7VD538oHZp6ReJ97V8DhebcegWeAxnn41q9nEoxQa8m/X2iwz/BNq5gOo+w /j1g== X-Gm-Message-State: AElRT7EniOszoLXva/KesPRymVh4ETMuZe068DfbDcwFGtum1nVnEcHr kyJ3phHIj9QVJjsJNX0Qd+46bOVQAx8= X-Google-Smtp-Source: AG47ELtzELQ4cKetyIfFr0GGdNeUsKqF14vBzJe5E08bRgRR9TmrDyyliG+qbMdpKRGj8LZ7lknbpw== X-Received: by 10.28.191.138 with SMTP id o10mr1328691wmi.26.1520695381839; Sat, 10 Mar 2018 07:23:01 -0800 (PST) Received: from localhost.localdomain ([105.148.128.186]) by smtp.gmail.com with ESMTPSA id m9sm7027531wrf.13.2018.03.10.07.22.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Mar 2018 07:23:01 -0800 (PST) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Dave Martin , Russell King - ARM Linux , Sebastian Andrzej Siewior , Mark Rutland , linux-rt-users@vger.kernel.org, Peter Zijlstra , Catalin Marinas , Will Deacon , Steven Rostedt , Thomas Gleixner Subject: [PATCH v5 11/23] arm64: assembler: add macros to conditionally yield the NEON under PREEMPT Date: Sat, 10 Mar 2018 15:21:56 +0000 Message-Id: <20180310152208.10369-12-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180310152208.10369-1-ard.biesheuvel@linaro.org> References: <20180310152208.10369-1-ard.biesheuvel@linaro.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support macros to conditionally yield the NEON (and thus the CPU) that may be called from the assembler code. In some cases, yielding the NEON involves saving and restoring a non trivial amount of context (especially in the CRC folding algorithms), and so the macro is split into three, and the code in between is only executed when the yield path is taken, allowing the context to be preserved. The third macro takes an optional label argument that marks the resume path after a yield has been performed. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/assembler.h | 64 ++++++++++++++++++++ arch/arm64/kernel/asm-offsets.c | 2 + 2 files changed, 66 insertions(+) diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index eef1fd2c1c0b..61168cbe9781 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -635,4 +635,68 @@ alternative_else_nop_endif .endif .endm +/* + * Check whether to yield to another runnable task from kernel mode NEON code + * (which runs with preemption disabled). + * + * if_will_cond_yield_neon + * // pre-yield patchup code + * do_cond_yield_neon + * // post-yield patchup code + * endif_yield_neon