Received: by 10.192.165.148 with SMTP id m20csp808051imm; Fri, 27 Apr 2018 07:51:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp/1eBkx9KXbmhO2AfbPLS1SIeQGRxbd/bLhQZLsD6PC9HlkjaW5hV0urH0OZLXjPV5YK+c X-Received: by 2002:a63:950a:: with SMTP id p10-v6mr2371658pgd.217.1524840685890; Fri, 27 Apr 2018 07:51:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524840685; cv=none; d=google.com; s=arc-20160816; b=LZ6R2k0lBweIcFQkUUYyZVUmzx/mSAUtzwNp+41SCM/zPYbSnn6bvAQoYkgxp4Sbbi 1+rcdLLrmrPaGOIng68hffRzdIu1S0sZ5cUXQQ+RSh00MeoElsm/ufuUWqR4Kz77MI/t 0I99U7xsnBQoR7MQXyhR6mWrJFheTEUVI3v5ue3k/NcleEM2+eNMc2QOZTyo+b/UWOah Q4iJ7nLQPvon/ig1ul6PxgPlIbsIVhXXQ9CCHQEjlKj3G2G5zGA1yKbDFDyZFK7KWRMn diXB0ZaODFgM93uopK1WA38zHJya1LyqlprXAeHnzYjCLJlw4CKU7vc/zZ0fi/bkhkbD cR0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=ztAZr44WfGQi9Pfd+JUd4ERPlKqN6jvI2CV+kGlQRl0=; b=BcV7YbwO6Gr6HLj0e0owVri1F3I627Gsqs1SEJyD5hz5bQZwErKW5JSHRvx/DkMoci QETjJm6Kx8IxOUxSAx+iKKqwc7SFOFkCwvMsLQnLbVDGBIFWLdYUeT1YnN2noiIvZoyO MAq2Dqw7Qzjv3UADfauxOa9KFaTr6LMdlzXPNYQPokX17lYWLkCf5i8Vr3/Bk2Fhtz7N fyUUjSOeOBIN9sL2BHZFu0OyKTaVeNfeVFk7g/SYS0Zpa0iuUzwMZrOw8bFg5swiwv57 2viv5d4dq9d+Q5nmM6UP5jWla2yww3Y9gb/AMBE3Jur7NkFedPgWaPldvdx692TbYSeW xSLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p15-v6si1383060pgf.358.2018.04.27.07.51.11; Fri, 27 Apr 2018 07:51:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934402AbeD0OtE (ORCPT + 99 others); Fri, 27 Apr 2018 10:49:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:53446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934306AbeD0OHj (ORCPT ); Fri, 27 Apr 2018 10:07:39 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 904C2218C5; Fri, 27 Apr 2018 14:07:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 904C2218C5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Schwidefsky Subject: [PATCH 4.14 46/80] s390: add optimized array_index_mask_nospec Date: Fri, 27 Apr 2018 15:58:39 +0200 Message-Id: <20180427135735.290504187@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135732.928644313@linuxfoundation.org> References: <20180427135732.928644313@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Martin Schwidefsky [ Upstream commit e2dd833389cc4069a96b57bdd24227b5f52288f5 ] Add an optimized version of the array_index_mask_nospec function for s390 based on a compare and a subtract with borrow. Signed-off-by: Martin Schwidefsky Signed-off-by: Greg Kroah-Hartman --- arch/s390/include/asm/barrier.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) --- a/arch/s390/include/asm/barrier.h +++ b/arch/s390/include/asm/barrier.h @@ -49,6 +49,30 @@ do { \ #define __smp_mb__before_atomic() barrier() #define __smp_mb__after_atomic() barrier() +/** + * array_index_mask_nospec - generate a mask for array_idx() that is + * ~0UL when the bounds check succeeds and 0 otherwise + * @index: array element index + * @size: number of elements in array + */ +#define array_index_mask_nospec array_index_mask_nospec +static inline unsigned long array_index_mask_nospec(unsigned long index, + unsigned long size) +{ + unsigned long mask; + + if (__builtin_constant_p(size) && size > 0) { + asm(" clgr %2,%1\n" + " slbgr %0,%0\n" + :"=d" (mask) : "d" (size-1), "d" (index) :"cc"); + return mask; + } + asm(" clgr %1,%2\n" + " slbgr %0,%0\n" + :"=d" (mask) : "d" (size), "d" (index) :"cc"); + return ~mask; +} + #include #endif /* __ASM_BARRIER_H */