Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6669796rwl; Wed, 22 Mar 2023 13:52:58 -0700 (PDT) X-Google-Smtp-Source: AK7set+rsDQQn3SdaaYuk66p8pMf2gP/jerU8oiV1xiDzl4EDUDWluWVRJDY8cO3IWl30mklio8C X-Received: by 2002:a17:902:db12:b0:1a1:ab92:5c88 with SMTP id m18-20020a170902db1200b001a1ab925c88mr5353240plx.13.1679518378699; Wed, 22 Mar 2023 13:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679518378; cv=none; d=google.com; s=arc-20160816; b=kEwNDJv7mHmRlmI67s2sZLYVJC9gnADBsd1cEj4caOtiZNtrMc+T/g4AT7d3cYSatC OJ1P2oMWhzB8ngeFJeTcTMaLEZrYgMfETtqOAoZ0MO+g6Rr1LESyWtCPEt3YsV4Ol1jh ErEXEOnqJCgrb5FvYjMzX0TP03xLQ3kPaNAmZCZYATu/TyQPQgfg9xJIBANNMcD63Kql t5IHuziYrQ2Dr0TuKHvYkzNr14V84XglYOxOuzXx5GzKIDQFjYDYZj+J0dNd62tjGCDJ HWZM1e3qPMagLSZwR3MW1O0uduOe73OM8m2NqU5FSVu1T9xPzEUSMP5qbC6BUQoa4SYW SQHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=MPANpQo2pbBjv7bN+m6aSZeybQN0T9mXhbFUpa61TPQ=; b=ZMwspxB3F8q3gzBBvvln4XPYEwNkyDlN90wbFXRDOvw/ZvRlO8qMSoOgSxcHxXN9mp lb+VKUDH4ZNXmstQwWehNekMzRK8gipaGVWbb0YTj4TXSCfPxZK0pSyRsN4KmxsTDgb9 x4+EzAhsuRMnbkRSHW1D1uZJOVv8nXcOWFkjNQSAijD5FV5kwxbgpXuN60o2WYrLPd60 37el0v6N0YUCTMYkiLelSZp9I7Wshf8OyhjEhRRKe17tj8/NMeJLjFjaf/SGolvJDaDE 0rw5RvpBum5WHGPaNuaGV/HC1raS5keGgSOlaao2pTUxuIT9DLQASY5IxCOwgGDCst5B MYmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fx9hdW6p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u14-20020a170902e5ce00b001a1878af626si15809732plf.594.2023.03.22.13.52.45; Wed, 22 Mar 2023 13:52:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fx9hdW6p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230429AbjCVUvZ (ORCPT + 99 others); Wed, 22 Mar 2023 16:51:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbjCVUvB (ORCPT ); Wed, 22 Mar 2023 16:51:01 -0400 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26E5912BC4; Wed, 22 Mar 2023 13:48:57 -0700 (PDT) Received: by mail-oi1-x22e.google.com with SMTP id bj20so5216946oib.3; Wed, 22 Mar 2023 13:48:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679518136; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=MPANpQo2pbBjv7bN+m6aSZeybQN0T9mXhbFUpa61TPQ=; b=fx9hdW6p0dQdtSIlZNZVy26SYG5ERPukARJpRq4EZ12B/ilaMyklpkLz3p7498u1ZP zkKaBNEiOwxxqaHEn0DdRQQwxjYO8fSCzYCpT1Q4hn26Ps1v4J55dK2f4sPtW61yf8Eo OLliIc20a9ml5L+Z6oQiuhKfLNvBmTpq51k+8V9lL/i64RxIutVo/LOaogcjkgNJYIZX kk60XrmYuDM/OimXwdTNdasE8+NlQAAhO9M9VU8QHJGL7nXcaKpXDrcaeHXEatPnDqKQ Z1btLvtCIdHOOk4yEmoY67WSIhz22y/Xm49IztnbYrLMkExi9Btd593xkfo+GFFOKTUJ 9lTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679518136; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MPANpQo2pbBjv7bN+m6aSZeybQN0T9mXhbFUpa61TPQ=; b=23qK7scEi9kd2mx6M0FM2LPdbpXps+3ufP0jVSss00or8i9CtZmWv5KBLWCdK/R6OY xeYi2jpvwdO9BDO17sCMtLfX3QSaziPvzDL/RFQO4uZyJe0YTULz7sw9z30iWAqVhSRJ D3JjL5ANtaMEkHXbUp6LT9B0caGsv2aJPKSzvqLWM7sjV5aDCX1cT8bdUxMCXD1fEBFV BwcbIAyGi57QxGiMOgVK9kOUnQXotTdEqwWThYXJZZ5E7unUdbRQ3yWJ8w32+uMwzMWU mxJHAwnGeTBblNAIZa2Vtdy34LdELl3ik5JVPYPcTSgo+ZZ29rC7LIrMUnfVuniI24yF EWgQ== X-Gm-Message-State: AO0yUKVNouzjFdTiKxHai7iTjgoRTEIkBGJkrUTNrBT6n+9tHjaLn6Ew S3j6qrtfUEhWg8dacudmXAL4pcyahAwS2JVakLQ= X-Received: by 2002:aca:1010:0:b0:384:6d14:c707 with SMTP id 16-20020aca1010000000b003846d14c707mr1304761oiq.5.1679518136556; Wed, 22 Mar 2023 13:48:56 -0700 (PDT) MIME-Version: 1.0 References: <20230306090633.65918-1-geert+renesas@glider.be> In-Reply-To: From: Rob Clark Date: Wed, 22 Mar 2023 13:48:45 -0700 Message-ID: Subject: Re: [PATCH] drm/msm/dpu: Fix bit-shifting UB in DPU_HW_VER() macro To: Randy Dunlap Cc: Geert Uytterhoeven , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , David Airlie , Daniel Vetter , Vinod Koul , Konrad Dybcio , Bjorn Andersson , Neil Armstrong , Kuogee Hsieh , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 21, 2023 at 8:08=E2=80=AFAM Randy Dunlap wrote: > > > > On 3/6/23 01:06, Geert Uytterhoeven wrote: > > With gcc-5 and CONFIG_UBSAN_SHIFT=3Dy: > > > > drivers/gpu/drm/msm/msm_mdss.c: In function 'msm_mdss_enable': > > drivers/gpu/drm/msm/msm_mdss.c:296:2: error: case label does not re= duce to an integer constant > > case DPU_HW_VER_800: > > ^ > > drivers/gpu/drm/msm/msm_mdss.c:299:2: error: case label does not re= duce to an integer constant > > case DPU_HW_VER_810: > > ^ > > drivers/gpu/drm/msm/msm_mdss.c:300:2: error: case label does not re= duce to an integer constant > > case DPU_HW_VER_900: > > ^ > > > > This happens because for major revisions 8 or greather, the non-sign bi= t > > of the major revision number is shifted into bit 31 of a signed integer= , > > which is undefined behavior. > > > > Fix this by casting the major revision number to unsigned int. > > > > Fixes: efcd0107727c4f04 ("drm/msm/dpu: add support for SM8550") > > Fixes: 4a352c2fc15aec1e ("drm/msm/dpu: Introduce SC8280XP") > > Fixes: 100d7ef6995d1f86 ("drm/msm/dpu: add support for SM8450") > > Signed-off-by: Geert Uytterhoeven > > Reviewed-by: Randy Dunlap Reviewed-by: Rob Clark > > Thanks. > > > --- > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h b/drivers/g= pu/drm/msm/disp/dpu1/dpu_hw_catalog.h > > index ddab9caebb18c40d..bbd3cbdd77956c5d 100644 > > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h > > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h > > @@ -19,8 +19,9 @@ > > */ > > #define MAX_BLOCKS 12 > > > > -#define DPU_HW_VER(MAJOR, MINOR, STEP) (((MAJOR & 0xF) << 28) |\ > > - ((MINOR & 0xFFF) << 16) |\ > > +#define DPU_HW_VER(MAJOR, MINOR, STEP) \ > > + ((((unsigned int)MAJOR & 0xF) << 28) | \ > > + ((MINOR & 0xFFF) << 16) | \ > > (STEP & 0xFFFF)) > > > > #define DPU_HW_MAJOR(rev) ((rev) >> 28) > > -- > ~Randy