Received: by 10.192.165.148 with SMTP id m20csp846179imm; Fri, 27 Apr 2018 08:25:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZre8r1eyBuYjNRg7DXOuhZc3pPaegdvuh96I+FvL0p6hItmgBO0TrWsQHghUMe9ekXOw25g X-Received: by 2002:a17:902:7611:: with SMTP id k17-v6mr2708537pll.244.1524842748965; Fri, 27 Apr 2018 08:25:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524842748; cv=none; d=google.com; s=arc-20160816; b=EaOIqhCfjzC6lB+bjITkDoZcFhYGKjgJ26MvHHbZaoDaIWKq7KOxnIlsw+L9aG5m/0 MneLu0K8TzsoMOP0M3IQ0KUxPXY+qQ3dVIBuIrIKFJWYW54bmMQMqgpCQacfBgRgWaWk piPty6Ge6aiZ5aOyZRCZRlMq4ocA7FLXVz87/OZIlvyFRSiE9m2+UxQby9unyQW72k+w LmkpJgcp30KTINk2dRKQODZRcIZ9ABQsF7C+Oj4fLkVnfMkxwEFjUVzHWxPd2RjtsGIQ 941Cgse+Ww9FlOKB5F3Ano9f5r5H2cumty5TaERu+Hk82ob4R7h7Qkw1ZZrNMrT3g5MD GuWA== 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=89zKIG0dVRw8+HZAr+ooEd2Z68tnfk1tf0o3ngvaXmc=; b=c/mygssuSpJiv+P5N8N411873/uJp97SYhvyuTY7lzb6vwhucTYsWJX5wRQN3HKyPv p/KJ7LTsULwEEpJQbspxZ6PRUXbS+tceKo34zLbGzeioADzpRcvg2uADfxWNWeRFh/zd DCRvTcRj/LZvBa6SVHykkTE8FUnbbFcVLr+OiB1n9QYqfq2YCTjHMvwwlK3PTXCrBj2p /+KtuzLQFce006O1frHUc5JtiMfMi8tIrOllZKG+b0bD6saMWk366e/iGhEHq6Clkg4w u+3j5yutNNjnaCqg3yrxmPYVk0mqp6Pe2pb0LdZP2EfntflF8fx9Ae0ReZX3If2aoNvs JYow== 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 f3-v6si1416397pld.513.2018.04.27.08.25.35; Fri, 27 Apr 2018 08:25:48 -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 S933379AbeD0PYg (ORCPT + 99 others); Fri, 27 Apr 2018 11:24:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:49080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933317AbeD0OCT (ORCPT ); Fri, 27 Apr 2018 10:02:19 -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 71C6621897; Fri, 27 Apr 2018 14:02:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 71C6621897 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.4 14/50] s390: add optimized array_index_mask_nospec Date: Fri, 27 Apr 2018 15:58:16 +0200 Message-Id: <20180427135656.542157500@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135655.623669681@linuxfoundation.org> References: <20180427135655.623669681@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.4-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 @@ -53,4 +53,28 @@ do { \ ___p1; \ }) +/** + * 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; +} + #endif /* __ASM_BARRIER_H */