Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3879338yba; Tue, 9 Apr 2019 06:44:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVqCJjxzpdND6MqaC0O26qPIz4LoRLvW2eJCTwFe/5+bhzk/cHwEHhNcYSJa5w2VAO8S0c X-Received: by 2002:a17:902:d705:: with SMTP id w5mr37531584ply.200.1554817461587; Tue, 09 Apr 2019 06:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554817461; cv=none; d=google.com; s=arc-20160816; b=bLyLvBVTTpLscLBZuW6nAzaaP5lnnjDfp3gRb/CBafAfqFYulinou9iZ2wfescJA6d PdnTxjuNt98cYwh98bkd+qz10boZbY1eIphJgJK1NZh5znxmla9gNNCgDLYV6apeFD2v rD+Gn04I2nxssHl5I2TfZfrybpIyluV1/bNR0vbDDK5DAbsvyIUc+r29RgzsCiZwzH43 m7UP+jEdxwM6Mmx9YVw8IQZ9vJOm10bbbweEi2RLBjd15TrYwiCXkw5QYscQUU8URaly zFLdwDbpXCPeZ+KC2zqFtfCWchbUP5iBGsYBco1DPlCem+3qepuliiDOBulzzEJbis1d oA/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to :content-disposition:mime-version:references:subject:cc:to:from:date; bh=FZdsalypWIYftRSIjirDN7l98Vret5hmr8lF8YsHzXM=; b=W5kqjhH43ftyOi3ZHbLQDF416HT2DWi/hnCZBLQdpgvublI6PUBfAYXnpotGFqGQbG vAKXUE2JhMqWG4iZoRMMdspCd3s21byKZYKm8yapY9CED89W0s6RP9tAfrjjNCN8sqCs ceb4gZga3n0nyDz1WH0X/N79fc3dK072i3xIL2ICJHXPI20xTaZ35btNmR3zYkdChLjn 3wadmMF5rQS6HGhuWmzkzx6PSOdP1eMDNHBbmtNh/FWwo8Vr3t31cWDIsx7Jq2wb1kVH 5LmFuu7/z2QHaP0Xefa9evI6uwlFmhW1rTLmMZXO09X2WlNC4yFIpTToVhFQCaJ2o0Hd n/aQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bc4si19575670plb.246.2019.04.09.06.44.05; Tue, 09 Apr 2019 06:44:21 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727067AbfDINn1 (ORCPT + 99 others); Tue, 9 Apr 2019 09:43:27 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42506 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726112AbfDINn0 (ORCPT ); Tue, 9 Apr 2019 09:43:26 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x39DeXq6043845 for ; Tue, 9 Apr 2019 09:43:25 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2rruwfj9sj-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 09 Apr 2019 09:43:24 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 9 Apr 2019 14:43:22 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 9 Apr 2019 14:43:18 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x39DhHix57737368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 9 Apr 2019 13:43:18 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD57EAE05F; Tue, 9 Apr 2019 13:43:17 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 81321AE04D; Tue, 9 Apr 2019 13:43:17 +0000 (GMT) Received: from osiris (unknown [9.152.212.21]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 9 Apr 2019 13:43:17 +0000 (GMT) Date: Tue, 9 Apr 2019 15:43:16 +0200 From: Heiko Carstens To: George Spelvin Cc: Andrey Ryabinin , linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, Rasmus Villemoes , Andrew Morton Subject: Re: [PATCH v3] ubsan: Avoid unnecessary 128-bit shifts References: <201904050158.x351wr9f016512@sdf.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201904050158.x351wr9f016512@sdf.org> X-TM-AS-GCONF: 00 x-cbid: 19040913-0016-0000-0000-0000026CF29F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19040913-0017-0000-0000-000032C91C40 Message-Id: <20190409134316.GC4227@osiris> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-04-09_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904090087 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 05, 2019 at 01:58:53AM +0000, George Spelvin wrote: > If CONFIG_ARCH_SUPPORTS_INT128, s_max is 128 bits, and variable > sign-extending shifts of such a double-word data type are a non-trivial > amount of code and complexity. Do a single-word sign-extension *before* > the cast to (s_max), greatly simplifying the object code. > > Rasmus Villemoes suggested using sign_extend* from . > > On s390 (and perhaps some other arches), gcc implements variable > 128-bit shifts using an __ashrti3 helper function which the kernel > doesn't provide, causing a link error. In that case, this patch is > a prerequisite for enabling INT128 support. Andrey Ryabinin has gven > permission for any arch that needs it to cherry-pick it so they don't > have to wait for ubsan to be merged into Linus' tree. Still, this should go upstream via Andrew Morton. As soon as this gets merged I'd like to select ARCH_SUPPORTS_INT128 on s390 unconditionally. However... ;) > +static inline long sign_extend_long(unsigned long value, int index) > +{ > + if (sizeof(value) == 4) > + return sign_extend32(value); > + return sign_extend64(value); > +} > + This doesn't compile: In file included from ./include/linux/kernel.h:12, from ./arch/s390/include/asm/bug.h:5, from ./include/linux/bug.h:5, from ./include/linux/page-flags.h:10, from kernel/bounds.c:10: ./include/linux/bitops.h: In function 'sign_extend_long': ./include/linux/bitops.h:163:10: error: too few arguments to function 'sign_extend32' return sign_extend32(value); ^~~~~~~~~~~~~ ./include/linux/bitops.h:143:21: note: declared here static inline __s32 sign_extend32(__u32 value, int index) ^~~~~~~~~~~~~ ./include/linux/bitops.h:164:9: error: too few arguments to function 'sign_extend64' return sign_extend64(value); ^~~~~~~~~~~~~ ./include/linux/bitops.h:154:21: note: declared here static inline __s64 sign_extend64(__u64 value, int index) ^~~~~~~~~~~~~