Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp4321882ybg; Mon, 8 Jun 2020 05:05:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw3gLWj5LU3cze2Vdy++zPCLVfqZgJ9nGh6rGMHPjrPrRTLC0eBtwzXJ6Leq9GxzutHn91 X-Received: by 2002:a50:d0dc:: with SMTP id g28mr8917448edf.71.1591617946208; Mon, 08 Jun 2020 05:05:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591617946; cv=none; d=google.com; s=arc-20160816; b=Vta6dMV+hhKLPrqUyU56ezh3KhvfGh/ZdO83H1LR+g32CrvQsu7BvneIOPEvTwCvIr QGPcfVjGsp5laJN6XGQi8LKKX1jSFKkFy6AFAwNhlUdAi+UHFPJAXTN/xXMLU8N6O6+q P9oUi7oDwYe9VsHDDW77XWTXu3y6JjB8eUcoYs9avyY9sAL3rQutaEQ0AVxuLbiBOm1e 4iZi70MRCCQyX+LwFNTiGEWHfwlJS9RcFLEQVnAw8p4mlduTkHKy5YMISKduTMD8nsSE 0JX6hVPLzn7RDeUMjs64BamtcNENS07nxKtyfWzvjTAvOJ08nzflOOZ5/QBMkxpMDjgw dDwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=pM5X2YtapFWuSkDwXFYHOUc12hO3c2lItIisPiXHQGY=; b=v7ZApU7YxZV6T99YvI3RG2Aerplp24XLMVkDSK+tAXUuAoRA8m4BJenBa28fWV5L5N T65ZLr3O8RTqEqvm9ttXKcwKKTav9MsgK+w3L/WP3uJebW8tyaQ7PYWLrIrT8Sothv22 ZKcEdqAqg5HS4mLJrWkarRXKYdvsDXifgFVD7QdAgQXx9L7jj3YvG/sfPsidp1Wxkr38 siMknKMQ8svD6+1DAvKdC/zp/baaAptdCaqcU8PMq/nTuLgAiZUoSq2nKK4m/UjazzN2 X6LMOyGUOG5INi4NrYMrJCy8BJsCpwjwuWQVtos3C5nEHh3C1EXfa6bLZGEggdgIxpVz IZ3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="hlaI/X2B"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n15si9203213edt.88.2020.06.08.05.05.19; Mon, 08 Jun 2020 05:05:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="hlaI/X2B"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1729695AbgFHMDT (ORCPT + 99 others); Mon, 8 Jun 2020 08:03:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbgFHMDS (ORCPT ); Mon, 8 Jun 2020 08:03:18 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A36BBC08C5C2; Mon, 8 Jun 2020 05:03:18 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id t16so6573384plo.7; Mon, 08 Jun 2020 05:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pM5X2YtapFWuSkDwXFYHOUc12hO3c2lItIisPiXHQGY=; b=hlaI/X2BEdu5DgSxAm6kB07OPe7M25Gvh52cfold8MS6AFOumejiu9RPBd5jcVPDTg 2pt5Ihb8e+UJUm042qK+Wch8QmNHdF1RJQpe9lh6SVMe97OWd0QiduR/hXS+wWgyDOvP AKOvCNve69T9GXxz2aMRXRIozw8kkWrtRSipFStp5SYG5lO4K0oT9qFXsl/2jkBVKaU7 OmOnFW/Pbaxgl/KZP1HzbQ4ArzR1YJLVihKRvjHD/SMJZNirBsrzJYMKCq13Eft5gsU/ HTZ0E2/sgsj1TJbmiE68ZnMteRg0odb/O0fYprG6bWydeoH5IM+LEJjIFnvjK/3SfP+3 y/AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pM5X2YtapFWuSkDwXFYHOUc12hO3c2lItIisPiXHQGY=; b=e/zjVNw3g86UhG+Jcxg5DfpDWLT2+FKTh6a35H+vaQslaIHZ1bg3cvOcbNbMbE3/kK cPx3mpHETVj6utjl8GTaI/XP4Svwig64bU87+CBeBu94/WWdLHgz8tyV7v2Mu+GLRKhK 0dMCsgfaM+F+fYTGw7y3a3mA5gSGX6HS+WUYs/W5KF58xbP92pw3tgVbmCZYFBCNmmAo h5MRIiej2GTZgGvakby505guTnbwyqI18zCYEeB15ct25mA769dEa0jGyCVyUDSuvj2T iFHY4Q2/cHR0vNeXYA5XBFjFxWVndDWUEZ4miqgAWnnNnGVaCo6C7zqdh8827Kk4hwHn RBTw== X-Gm-Message-State: AOAM530bhfy9t+tjBMKBsMsX1Y5Fc7NUSI4w1ENI9ImbNRQg7j3UVD8F Ec03pLHym7X7qxvoFGWf144SLl7+3rmC49ogYJQ= X-Received: by 2002:a17:90a:ac05:: with SMTP id o5mr17147126pjq.228.1591617797903; Mon, 08 Jun 2020 05:03:17 -0700 (PDT) MIME-Version: 1.0 References: <1591611829-23071-1-git-send-email-agordeev@linux.ibm.com> In-Reply-To: <1591611829-23071-1-git-send-email-agordeev@linux.ibm.com> From: Andy Shevchenko Date: Mon, 8 Jun 2020 15:03:05 +0300 Message-ID: Subject: Re: [PATCH RESEND2] lib: fix bitmap_parse() on 64-bit big endian archs To: Alexander Gordeev Cc: Linux Kernel Mailing List , linux-s390@vger.kernel.org, Stable , Andrew Morton , Yury Norov , Andy Shevchenko , Amritha Nambiar , Arnaldo Carvalho de Melo , Chris Wilson , Kees Cook , Matthew Wilcox , Miklos Szeredi , Rasmus Villemoes , Steffen Klassert , "Tobin C . Harding" , Vineet Gupta , Will Deacon , Willem de Bruijn 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 On Mon, Jun 8, 2020 at 1:26 PM Alexander Gordeev wrote: > > Commit 2d6261583be0 ("lib: rework bitmap_parse()") does not > take into account order of halfwords on 64-bit big endian > architectures. As result (at least) Receive Packet Steering, > IRQ affinity masks and runtime kernel test "test_bitmap" get > broken on s390. ... > +#if defined(__BIG_ENDIAN) && defined(CONFIG_64BIT) I think it's better to re-use existing patterns. ipc/sem.c:1682:#if defined(CONFIG_64BIT) && defined(__BIG_ENDIAN) > +static void save_x32_chunk(unsigned long *maskp, u32 chunk, int chunk_idx) > +{ > + maskp += (chunk_idx / 2); > + ((u32 *)maskp)[(chunk_idx & 1) ^ 1] = chunk; > +} > +#else > +static void save_x32_chunk(unsigned long *maskp, u32 chunk, int chunk_idx) > +{ > + ((u32 *)maskp)[chunk_idx] = chunk; > +} > +#endif See below. ... > - end = bitmap_get_x32_reverse(start, end, bitmap++); > + end = bitmap_get_x32_reverse(start, end, &chunk); > if (IS_ERR(end)) > return PTR_ERR(end); > + > + save_x32_chunk(maskp, chunk, chunk_idx++); Can't we simple do int chunk_index = 0; ... do { #if defined(CONFIG_64BIT) && defined(__BIG_ENDIAN) end = bitmap_get_x32_reverse(start, end, bitmap[chunk_index ^ 1]); #else end = bitmap_get_x32_reverse(start, end, bitmap[chunk_index]); #endif ... } while (++chunk_index); ? -- With Best Regards, Andy Shevchenko