Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753646AbeAJHks (ORCPT + 1 other); Wed, 10 Jan 2018 02:40:48 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:3762 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753371AbeAJHko (ORCPT ); Wed, 10 Jan 2018 02:40:44 -0500 Subject: Re: [PATCH 04/18] arm: implement nospec_ptr() To: Laura Abbott , Dan Williams , , Mark Rutland CC: , , , , , , , Justin Forbes References: <151520099201.32271.4677179499894422956.stgit@dwillia2-desk3.amr.corp.intel.com> <151520101463.32271.9320376934909324865.stgit@dwillia2-desk3.amr.corp.intel.com> <32f6f9de-1f8f-f459-d9e4-c9a7044cf8af@redhat.com> From: Hanjun Guo Message-ID: Date: Wed, 10 Jan 2018 15:40:20 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <32f6f9de-1f8f-f459-d9e4-c9a7044cf8af@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.177.223.23] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 2018/1/10 10:04, Laura Abbott wrote: > On 01/05/2018 05:10 PM, Dan Williams wrote: >> From: Mark Rutland >> >> This patch implements nospec_ptr() for arm, following the recommended >> architectural sequences for the arm and thumb instruction sets. >> > Fedora picked up the series and it fails on arm: > > In file included from ./include/linux/compiler.h:242:0, >                  from ./include/uapi/linux/swab.h:6, >                  from ./include/linux/swab.h:5, >                  from ./arch/arm/include/asm/opcodes.h:89, >                  from ./arch/arm/include/asm/bug.h:7, >                  from ./include/linux/bug.h:5, >                  from ./include/linux/mmdebug.h:5, >                  from ./include/linux/gfp.h:5, >                  from ./include/linux/slab.h:15, >                  from kernel/fork.c:14: > ./include/linux/fdtable.h: In function '__fcheck_files': > ./arch/arm/include/asm/barrier.h:112:41: error: expected declaration specifiers or '...' before numeric constant >   __load_no_speculate(&__np_ptr, lo, hi, 0, __np_ptr);  \ >                                          ^ > ./arch/arm/include/asm/barrier.h:68:32: note: in definition of macro '__load_no_speculate_n' >    (typeof(*ptr)(unsigned long)(failval));  \ >                                 ^~~~~~~ > ./arch/arm/include/asm/barrier.h:112:2: note: in expansion of macro '__load_no_speculate' >   __load_no_speculate(&__np_ptr, lo, hi, 0, __np_ptr);  \ >   ^~~~~~~~~~~~~~~~~~~ > ./include/asm-generic/barrier.h:122:2: note: in expansion of macro 'nospec_ptr' >   nospec_ptr(__arr + __idx, __arr, __arr + __sz);   \ >   ^~~~~~~~~~ > ./include/linux/fdtable.h:86:13: note: in expansion of macro 'nospec_array_ptr' >   if ((fdp = nospec_array_ptr(fdt->fd, fd, fdt->max_fds))) >              ^~~~~~~~~~~~~~~~ > ./arch/arm/include/asm/barrier.h:112:41: error: expected declaration specifiers or '...' before numeric constant >   __load_no_speculate(&__np_ptr, lo, hi, 0, __np_ptr);  \ >                                          ^ > ./arch/arm/include/asm/barrier.h:68:32: note: in definition of macro '__load_no_speculate_n' >    (typeof(*ptr)(unsigned long)(failval));  \ >                                 ^~~~~~~ > ./arch/arm/include/asm/barrier.h:112:2: note: in expansion of macro '__load_no_speculate' >   __load_no_speculate(&__np_ptr, lo, hi, 0, __np_ptr);  \ >   ^~~~~~~~~~~~~~~~~~~ > ./include/asm-generic/barrier.h:122:2: note: in expansion of macro 'nospec_ptr' >   nospec_ptr(__arr + __idx, __arr, __arr + __sz);   \ >   ^~~~~~~~~~ > ./include/linux/fdtable.h:86:13: note: in expansion of macro 'nospec_array_ptr' >   if ((fdp = nospec_array_ptr(fdt->fd, fd, fdt->max_fds))) >              ^~~~~~~~~~~~~~~~ > ./arch/arm/include/asm/barrier.h:112:41: error: expected declaration specifiers or '...' before numeric constant >   __load_no_speculate(&__np_ptr, lo, hi, 0, __np_ptr);  \ >                                          ^ > ./arch/arm/include/asm/barrier.h:68:32: note: in definition of macro '__load_no_speculate_n' >    (typeof(*ptr)(unsigned long)(failval));  \ >                                 ^~~~~~~ > ./arch/arm/include/asm/barrier.h:112:2: note: in expansion of macro '__load_no_speculate' >   __load_no_speculate(&__np_ptr, lo, hi, 0, __np_ptr);  \ >   ^~~~~~~~~~~~~~~~~~~ > ./include/asm-generic/barrier.h:122:2: note: in expansion of macro 'nospec_ptr' >   nospec_ptr(__arr + __idx, __arr, __arr + __sz);   \ >   ^~~~~~~~~~ > ./include/linux/fdtable.h:86:13: note: in expansion of macro 'nospec_array_ptr' >   if ((fdp = nospec_array_ptr(fdt->fd, fd, fdt->max_fds))) > > I can't puzzle out what exactly is the problem here, except that it really > does not seem to like that failval. Does the arm compiler not like doing > the typeof with the __arr + __idx? >> +#define __load_no_speculate_n(ptr, lo, hi, failval, cmpptr, sz)    \ >> +({                                \ >> +    typeof(*ptr) __nln_val;                    \ >> +    typeof(*ptr) __failval =                \ >> +        (typeof(*ptr)(unsigned long)(failval));        \ Just typo, - (typeof(*ptr)(unsigned long)(failval)); \ + (typeof(*ptr))(unsigned long)(failval); \ Please try it. Thanks Hanjun