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: 131301 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2244829lja; Sat, 10 Mar 2018 07:23:10 -0800 (PST) X-Google-Smtp-Source: AG47ELvRPR+KWYkWbGL5GFR4TSeM1RDtmSjiEMqa+vqiKZgseNwuCkKymf0uhi4+ELK4m8uUskvs X-Received: by 10.99.96.84 with SMTP id u81mr1372017pgb.231.1520695390223; Sat, 10 Mar 2018 07:23:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520695390; cv=none; d=google.com; s=arc-20160816; b=QMG2dXIIVRd5r8ICFtsfQpOaP+Zk5TRRsPB8PbGwxPY9wdqvLjRIRBqfZWgjxLoFgJ pk4s+8SJ8TlVAd3c8u+J3B8QSdDxE1DrqsTEa4QOxh7YDYuvl0QJ+WBqhgYTJnRVpdLU 3JSlSqGmBL26hqeJEB6xAq5wmtvrUaYbxBySh+ekwhO5hkqVov8AfsH6YZ/pCctS66Rl 8o6AduXJjN++4h/oDGnjx+XxpQTsyM7FXeQrDijHefZEWLrt/w0lPWIKRXxFYw2Xlb22 9D+6VcPkRN6kMbWMkrCjLDD4HLXLDszVPPPmY8byfPgddpeNMXUHbfDmc3oduRuVEGX0 YX3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=igH9KImZTLC7b3FEy2vhduXKBfEy6hhH3sJVJ6VEP8Q=; b=sP1ISq2h/HbZqN/gXewN7sGVtyChO1rlFzECNknCzUesKUkXcnOsPNLDvV78CibZNB B6bydKwSAwgmOx18IbkA8WcbwNgm9QiJC5Jeg+yqPGRS74EHWonc3xa3anOfhQ/pl20R moVF8kwnK4gwXQJ7iLC4c9dP5gWaCnA762BzIq+r8+uBnqrGXaFLrv2OaLyF+oVmDOIv cpxMTubpBdNQ+7M5qatOOMIKHouUz8gaEVtBb2ihDXGfTxPEiW9nhAfluzsvgu5CXDl6 j/nouIhmCmRJAatg06WWZ71lhfr1oz1h6mOUhWOaSJNqspMjIpdH+eUu/g/nSKkPAJvn CSDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FVsvPWHi; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q16si2824191pfg.221.2018.03.10.07.23.10; Sat, 10 Mar 2018 07:23:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FVsvPWHi; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932338AbeCJPXH (ORCPT + 1 other); 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-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 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(+) -- 2.15.1 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