Received: by 10.192.165.148 with SMTP id m20csp835376imm; Fri, 27 Apr 2018 08:15:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpwjjMrd9GOOsJ4xP2+GfaGCsbRRo9S7y9vnSeB3AU99PfhyCO9l3H+0sK/pleKZKP79lWn X-Received: by 2002:a63:3ec9:: with SMTP id l192-v6mr2474890pga.318.1524842122777; Fri, 27 Apr 2018 08:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524842122; cv=none; d=google.com; s=arc-20160816; b=ChZ0Cgy9fBjXzCCqu4dWAZipdsDDiA/+azCC3U3k7qtE7zr6yhcKcjebceD8v+Gliq CPaqRuUGE+m/XDVSh2Y/J3SwgW1lVLZDoQNRyg09mYGi6IuK7nXKt7aWSpDwbyDKoT1Y e1t8px0dGidTpNi1DCfdah78yqrXIBCVnsYqmlYC2KJDotxO4kg6+rwIlcMxnh+w2eCg 3STiVu6LIbQphfVFMT5mV5mJs9seuCzZawPWxVhmra7lSMgWSlBiuRqSwJ+6amrKvoWO NSNo7M2QFyP+pC2LaaD47ODAzY0ryBEnD+wiq7E5jkhTlm1EJJBkgDvN0YjkIUP0DAPN GG1A== 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=IR/uUjWld5nN2o/P5IFi7h8V0iGDV1KCFkJ4nLhDHHc=; b=D1n3mikYa7JZNdZXR1lEQgaCaxpv3YSQTN6gUOsqVricySVo62akh/n+uFFlUqnEwP 3o11hijDyA1UYx5PI7Qyq4zyy9xeBzCCwuh3rZSZ4XDsD14KDNxoJoHALunnEc06tK+T S2AujiZU8TvlFAP4BM1paetbNZgaDaDz22nVefqdvp3AjdTAfyTEcfauSj3CS5FClyYt HvZ/KI0ZEl6rxE9UVdCtWSG1V9jFXaxSDB+qZuaEEl2n/t0/rmft6FjFyKZ5Bax4FGB3 0E5eynFJHZayDVjvKK8A7c8ub0psWAKG6dF03u4Kr6mtMEXfcHTH2BPwdLbLjm6o5c93 /MOg== 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 l7-v6si1485917plt.197.2018.04.27.08.15.09; Fri, 27 Apr 2018 08:15:22 -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 S933119AbeD0ODx (ORCPT + 99 others); Fri, 27 Apr 2018 10:03:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:50290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933188AbeD0ODu (ORCPT ); Fri, 27 Apr 2018 10:03:50 -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 38DED2189D; Fri, 27 Apr 2018 14:03:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38DED2189D 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.9 32/74] s390: add optimized array_index_mask_nospec Date: Fri, 27 Apr 2018 15:58:22 +0200 Message-Id: <20180427135711.259829079@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135709.899303463@linuxfoundation.org> References: <20180427135709.899303463@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.9-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 @@ -48,6 +48,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 */