From patchwork Wed Mar 28 12:41:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10312893 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 312A860353 for ; Wed, 28 Mar 2018 12:42:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24055285B6 for ; Wed, 28 Mar 2018 12:42:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18D1728632; Wed, 28 Mar 2018 12:42:43 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8B8EC285B6 for ; Wed, 28 Mar 2018 12:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=04i3jbHBVIb29j2W5eUEz2rhYpOQ2jUOod/y6gILcS4=; b=mwCw0GDq97B2GGsa5mNTwyyleb LKd+zweCdq5CjWhZky4lBWW28XHhX3I6MqLgLaQuUgzRTe1uIYak+MsxC/v3UjxMMegtae73skoEj Y+cReuWNeF0YHA3GurVstMJPNZrBZzjbl3d8c1uBcN7T0dI07nr+Ff9nbc/gy6r7S5uqonJfffLzm G1gyC4KMOU4LqpD+RetA22h60LMs7hlMXwE1tnBnnnsSu/GhbGN3+ZZL7TrsDFEQticrUSECOPOKX eCjhPsiPPzRubqdkIW97WaQgZ48jG0DANZhwSH23SQC7gJgjC1y2NgGQdmbiX9hw4tOE8FLy1ZalU /d3ARnBw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f1APV-0006Ve-IR; Wed, 28 Mar 2018 12:42:37 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f1AP6-0006FT-Lm for linux-arm-kernel@lists.infradead.org; Wed, 28 Mar 2018 12:42:14 +0000 Received: by mail-wr0-x244.google.com with SMTP id z8so2105242wrh.7 for ; Wed, 28 Mar 2018 05:42:09 -0700 (PDT) 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=j2G0FtWOLxF/VqQKeas/JEbGMk02PSDH7pqlBqRPHRM=; b=a04xmuHG9nTKTen8bfd5oqwcsIG9IhLKb3hlRNgQujAkOYntJg7hJyK1bg3PkgAMvC hflAPtb10Qdh0XSA4aU2Bv7ilujrY7GcnHUncFKUmLVkGuVw6y8uNhKU7m8/C/OnKPws 23ks7N2BFe5GK6t5Pqq+1Y6cfsIVdFbvB+6Y4= 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=j2G0FtWOLxF/VqQKeas/JEbGMk02PSDH7pqlBqRPHRM=; b=YFrWnBtFcl4doBZm7qUrE8ga1bg1PwnuD5CDK6Cx0l4/Kv9pLE7FSBluU/l6NJwQfS U3ydQ4ivY0GWGvz9PkQgnsQnHCnxji9rltlIZ5OwY5lD78zRLwevvjGnh8mBNIohjLBi JZC1WZWPhDso0G6FbeMf3nbbFrhaGjCYy/cYky+4y/JC/BpLerrdskRewjbG7Qov3kdj nbUCUF+9vVYrMECUauCOCkOwvaZr6MyivX0qPw42ZWT42DFJsPxH0sVO5QKq/ePO59od CGyzhUKohRyXSf4KXWMIJtSZn78nEpVGaPE8reWFbfhKmEbpsQpWBkEUm23NIRoZzKFh PGRw== X-Gm-Message-State: AElRT7FEHEpELkyUrLM4V0+DnbeLJ9B0+78zWwVYvBXjuMQ9y20lfcBT jVDKdwHK1WvbFD/j5zoV45egt6w5sRo= X-Google-Smtp-Source: AIpwx48Sm18uwBELGcIdiwTKQYxSlW6L/FjbhjMz1RdZSB/UJ8cAgfH4RgqdqoKuKxw967UF+HY36A== X-Received: by 10.223.135.115 with SMTP id 48mr2722785wrz.27.1522240927644; Wed, 28 Mar 2018 05:42:07 -0700 (PDT) Received: from localhost.localdomain ([203.88.77.60]) by smtp.gmail.com with ESMTPSA id z66sm3906592wmh.14.2018.03.28.05.42.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Mar 2018 05:42:06 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH resend 2/2] arm64: assembler: add macros to conditionally yield the NEON under PREEMPT Date: Wed, 28 Mar 2018 14:41:29 +0200 Message-Id: <20180328124129.6459-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180328124129.6459-1-ard.biesheuvel@linaro.org> References: <20180328124129.6459-1-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180328_054212_710072_13F62C6F X-CRM114-Status: GOOD ( 16.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: will.deacon@arm.com, dave.martin@arm.com, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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 Reviewed-by: Dave Martin --- 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 d354eb7f2f0c..fb11514273d9 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -623,4 +623,68 @@ USER(\label, ic ivau, \tmp2) // invalidate I line PoU .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