Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2148297pxm; Thu, 24 Feb 2022 17:46:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlzohh38/aCuvKRnaTIuW3IPGNEredLT+DgjmuIUoiGHYXtFMqcsBphf87IbpUHI8tKJFX X-Received: by 2002:a17:906:3e84:b0:6cf:cd36:6316 with SMTP id a4-20020a1709063e8400b006cfcd366316mr4358266ejj.581.1645753578293; Thu, 24 Feb 2022 17:46:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645753578; cv=none; d=google.com; s=arc-20160816; b=I8IJfOYXJ93vUh3i1fnhRWNEYsPbedko4ltM0oggdm8QNOZaPr5ru4El9GZmZ4bMcW mvG4e7vAhbyoFDtGQjb56SpvYRYM4f/zPfO/5pHD/sdjQd7JWK93JiVpmCutCS0FmsgF UTWZjMyIJxdORd43mQPLG3lKEdCTXMTS0d4kADe1lBs7DVt3CF0heV7FpOdISoO0Vp02 /l7bdxTUF86qqQLBLPs3nc6C7RQJHbs1RiuZdJltC7icqc4ksrr/Fb3FxvYt0IxDsEYm 8lHXV2qNSwrzJUISh3PywJpr+XTLeVqiAYBBNVdAT0cb7nibPawwryEa9ScX47uu+TMA NNpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=h9qg7if8ql+3plBSwkT6TgAtzWlmuEyfLLgzRTJi8YQ=; b=NHcn5aybyOfBLjFghkdNoE5JVhn4GpNG/LksC3kh/MPVaOlxtxtHnj/FO/BUmLihgl mF0wV4XS8KLeYb5BGjSRu7IPf41ugqQs/IY04R5+iOMC2oSQm3wsaGX2Rl+u4dK3IJO0 CerBy6x0iUOBoiAH++BSbif/eTOww46O70uSOifaevmm0KoXtZSf94tNeJfjBfItDVpD khoa1DxZAvA45FuPLTnPR344o5f8vd+nHv7SB2szLpd9g/k0+gWrM2Ir2y/ORZnb5NZZ BN9M6hKoqi8AI2Owx/BXQZoirhwMYj/UQN5Fe+hj1Li0bwtqvd5cEDdAvY92rZeCtMa/ OOEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=f2lf04BH; 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 y22-20020a170906525600b006cee3ad5247si587621ejm.891.2022.02.24.17.45.54; Thu, 24 Feb 2022 17:46:18 -0800 (PST) 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=f2lf04BH; 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 S234041AbiBXTwV (ORCPT + 99 others); Thu, 24 Feb 2022 14:52:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233242AbiBXTwT (ORCPT ); Thu, 24 Feb 2022 14:52:19 -0500 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26CD0190B5F; Thu, 24 Feb 2022 11:51:48 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id x5so4372140edd.11; Thu, 24 Feb 2022 11:51:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=h9qg7if8ql+3plBSwkT6TgAtzWlmuEyfLLgzRTJi8YQ=; b=f2lf04BHLZAj80uYzAAwXonUGiiGREIqyP4yynLUoM3sXW+i37nMqEIqrBoPHuE691 ZzpzZhf0LjTHo3+rLKFbwhKyDZn7W1jiXSm6PtkPQvzTCg3b2HrYJDAd35saHIhjNGjV LsATq3qaKwkD6KhpjxHNaEFsLHJx7ON7c4LiNZQy5tQ/Yio1lD9Jgy4dcCjAufE8jLuo O6Vzl2HZ/5zKI6YEG3UqQc9xBN4Mvm5i//zTkz4ao5uKBWTXyKPXCjGECRjSzpGoe5oB n9fgwYMZ4MrB6v+3gQ9q4Lxox2EtzHfZODAkXLW/3wuR3nreLSk4Tfkb1aUTplGP+MwJ UG4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=h9qg7if8ql+3plBSwkT6TgAtzWlmuEyfLLgzRTJi8YQ=; b=2etRFR7umilLLYidzNaGTVe1n5SHb3xGn942y8C8Ufv762N+evRmsGhli0GUWyvDvE ROunreCKrp0/POETna8geivHmbGfvvHf6oXqlJpeb88z79qLHRsXZKSQ0hv1/ltWGrqr bcYWX9W//x2uRrx0GuIRQ45/nrcYOfEhiJ/LjSrD3/9sww4ws4lJd/wtGsDVv7ai9b6k yn3DsiAhD6dsZwe5Lo9MyFCWr6Ps6TkorqZGIDzpBuDAmFWiB3AzxBAD8c2Dkcl6Qe2w y7gKWc3MjAHHh3XWCbQYeKZXeGj5YJ9EHi17Xo7yXQAJEMhYD75AZHnYcGC92Nao6B/v tDEg== X-Gm-Message-State: AOAM532QWSVRDypSlLKJ4lZjA1crssjp8ndH230M5AFrM02S2IpKS1qv MN3ooWJjsH64IdXZ16jvvbTtKjrMvqkbd29jkOQ= X-Received: by 2002:a05:6402:198:b0:410:83e3:21d7 with SMTP id r24-20020a056402019800b0041083e321d7mr3945297edv.159.1645732306568; Thu, 24 Feb 2022 11:51:46 -0800 (PST) MIME-Version: 1.0 References: <20220223164420.45344-1-andriy.shevchenko@linux.intel.com> <20220224123620.57fd6c8b@p-imbrenda> In-Reply-To: <20220224123620.57fd6c8b@p-imbrenda> From: Andy Shevchenko Date: Thu, 24 Feb 2022 21:51:10 +0200 Message-ID: Subject: Re: [PATCH v1 1/1] KVM: s390: Don't cast parameter in bit operations To: Claudio Imbrenda Cc: Andy Shevchenko , Christian Borntraeger , "open list:VFIO DRIVER" , linux-s390@vger.kernel.org, Linux Kernel Mailing List , Janosch Frank , David Hildenbrand , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Sven Schnelle Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Thu, Feb 24, 2022 at 2:51 PM Claudio Imbrenda wrote: > > On Wed, 23 Feb 2022 18:44:20 +0200 > Andy Shevchenko wrote: > > > While in this particular case it would not be a (critical) issue, > > the pattern itself is bad and error prone in case somebody blindly > > copies to their code. > > > > Don't cast parameter to unsigned long pointer in the bit operations. > > Instead copy to a local variable on stack of a proper type and use. ... > > + struct { /* as a 256-bit bitmap */ > > + DECLARE_BITMAP(b, 256); > > + } bitmap; > > + struct { /* as a set of 64-bit words */ > > u64 word[4]; > > } u64; > > - set_bit_inv(IPM_BIT_OFFSET + gisc, (unsigned long *) gisa); > > + set_bit_inv(IPM_BIT_OFFSET + gisc, gisa->bitmap.b); > > wouldn't it be enough to pass gisa->u64.word here? > then no cast would be necessary No, it will have the same hidden bugs. As I stated in the commit message, the pattern is quite bad even if in particular code it would work. Thanks, Michael, for pointing out other places. They all need to be fixed. -- With Best Regards, Andy Shevchenko