Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp417563pxb; Thu, 23 Sep 2021 03:03:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzp7cCDelgdWA+esLZEyu7uM9cXThT+vUDrIXGdW9D4klxLVRJjmOuJyYqh1nvxS2obayER X-Received: by 2002:a05:6402:c96:: with SMTP id cm22mr4425314edb.314.1632391413511; Thu, 23 Sep 2021 03:03:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632391413; cv=none; d=google.com; s=arc-20160816; b=cEDXDzADIVNjaC78nyeZ0oNKcT0594gcuJZr6Q1g/3HpLsY59ma1/tn0yTxSXBk37E mI+uxnkUjlv7OgS/yeJQ8418Q/1faYAtDIFiLQAl34FIkQ3oytGu00rYsYmgrx2dXOTZ LU4DhXigIr59C6LS9fTxeJC/77h1py+y32Z3L0IVWXzIxGR1n+vwMYXf6khrIneFCmPU 5I1adoWW8EtslsEIbbwXBVFT5mSQjqggkcEe2cb6DH+oDxUlfy9HBR9/o3oLLYbYrCQ0 pmrofqust6JALkU3fbZbIqbMrjU7bwT5n53cf2uWoP4KDrn/L4JtiBk4z4oESCf0cE5D 6xcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:in-reply-to :reply-to:subject:cc:to:from:user-agent:references:dkim-signature :dkim-signature; bh=UzJP1NacuRrgyoFRt4Ocp3ynHeVYoUlVZdZtaHi2uBE=; b=YrtLQttIlmyAnI0EjedVpvfrKDx91LgswmwUDG4s4z54AIMuHbS0Owfr08RMigsXVy yAoTKgQhl9yfnw9CAEdPlEEfZ2rzxG+KHlfqxyAubG4MmHhQRMtFv+2R9Xv35aroBh0L A/pD2Ho9wo85eXT7M3lXn/KJkE66n46pAtMXKJL9LTAVvQn4ZV/BFnqNqWD8Xj3EdNBB du3/ZirAhD3L2N2zOEa4v7WVSdnhVdSlbP/iuLE2z4bGlDdAuD9WptxIqjfL6ipiZp4R 8bbZd7f8MyxXE8Z07zm697GCYxJ+7XDXFwoi/oDGVh+gn1BTe2BmNPGRnGai8dKnQjKN nhGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=iKFB2v0l; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s8si1831932edh.267.2021.09.23.03.03.08; Thu, 23 Sep 2021 03:03:33 -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=@suse.de header.s=susede2_rsa header.b=iKFB2v0l; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240270AbhIWKCt (ORCPT + 99 others); Thu, 23 Sep 2021 06:02:49 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:40026 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240186AbhIWKCp (ORCPT ); Thu, 23 Sep 2021 06:02:45 -0400 Received: from relay1.suse.de (relay1.suse.de [149.44.160.133]) by smtp-out1.suse.de (Postfix) with ESMTP id 9655622308; Thu, 23 Sep 2021 10:01:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1632391273; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UzJP1NacuRrgyoFRt4Ocp3ynHeVYoUlVZdZtaHi2uBE=; b=iKFB2v0lDs03sugqu0Q8wHXo3HNjI9ogoEkYBh7xRrfRqEAtOfWbd2+4O8e+1PXbOlQh6j X9kBnJ+m9TluSiKGzk/1iXGV11ptPNYTLtku1zq+CQTxYL95l+ND8ulHSPuEj+3ZzBV2Mn pikn9ttaONfoVNQJyeSPSEapY90g+RA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1632391273; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UzJP1NacuRrgyoFRt4Ocp3ynHeVYoUlVZdZtaHi2uBE=; b=As0XRGUSDMSN0X6e0YkkmOOs1WrEAm2X429Mo3aBaWRx8duMlnAXU3N22wHQFkMVACE5L2 3m5uyfsRfzuh4MAw== Received: from g78 (rpalethorpe.udp.ovpn1.nue.suse.de [10.163.24.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay1.suse.de (Postfix) with ESMTPS id 8DCA525D3C; Thu, 23 Sep 2021 10:01:12 +0000 (UTC) References: <20210921130127.24131-1-rpalethorpe@suse.com> <87o88mkor1.fsf@suse.de> <87lf3qkk72.fsf@suse.de> <87ilytkngp.fsf@suse.de> User-agent: mu4e 1.4.15; emacs 27.2 From: Richard Palethorpe To: Arnd Bergmann Cc: Linux FS-devel Mailing List , Linux API , linux-aio , y2038 Mailman List , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , the arch/x86 maintainers , "H. Peter Anvin" , Deepa Dinamani , Linux Kernel Mailing List , LTP List Subject: Re: ia32 signed long treated as x64 unsigned int by __ia32_sys* Reply-To: rpalethorpe@suse.de In-reply-to: Date: Thu, 23 Sep 2021 11:01:09 +0100 Message-ID: <87fstvlifu.fsf@suse.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Arnd, Arnd Bergmann writes: > On Wed, Sep 22, 2021 at 10:46 AM Richard Palethorpe wrote: >> Richard Palethorpe writes: > >> > >> > Then the output is: >> > >> > [ 11.252268] io_pgetevents(f7f19000, 4294967295, 1, ...) >> > [ 11.252401] comparing 4294967295 <= 1 >> > io_pgetevents02.c:114: TPASS: invalid min_nr: io_pgetevents() failed as expected: EINVAL (22) >> > [ 11.252610] io_pgetevents(f7f19000, 1, 4294967295, ...) >> > [ 11.252748] comparing 1 <= 4294967295 >> > io_pgetevents02.c:103: TFAIL: invalid max_nr: io_pgetevents() passed unexpectedly >> >> and below is the macro expansion for the automatically generated 32bit to >> 64bit io_pgetevents. I believe it is casting u32 to s64, which appears >> to mean there is no sign extension. I don't know if this is the expected >> behaviour? > > Thank you for digging through this, I meant to already reply once more yesterday > but didn't get around to that. Thanks, no problem. I suppose this will effect other systemcalls as well. Which if nothing else is a pain for testing. > >> __typeof(__builtin_choose_expr( >> (__builtin_types_compatible_p(typeof((long)0), typeof(0LL)) || >> __builtin_types_compatible_p(typeof((long)0), typeof(0ULL))), >> 0LL, 0L)) min_nr, >> __typeof(__builtin_choose_expr( >> (__builtin_types_compatible_p(typeof((long)0), typeof(0LL)) || >> __builtin_types_compatible_p(typeof((long)0), typeof(0ULL))), >> 0LL, 0L)) nr, > > The part that I remembered is in arch/s390/include/asm/syscall_wrapper.h, > which uses this version instead: > > #define __SC_COMPAT_CAST(t, a) \ > ({ \ > long __ReS = a; \ > \ > BUILD_BUG_ON((sizeof(t) > 4) && !__TYPE_IS_L(t) && \ > !__TYPE_IS_UL(t) && !__TYPE_IS_PTR(t) && \ > !__TYPE_IS_LL(t)); \ > if (__TYPE_IS_L(t)) \ > __ReS = (s32)a; \ > if (__TYPE_IS_UL(t)) \ > __ReS = (u32)a; \ > if (__TYPE_IS_PTR(t)) \ > __ReS = a & 0x7fffffff; \ > if (__TYPE_IS_LL(t)) \ > return -ENOSYS; \ > (t)__ReS; \ > }) > > This also takes care of s390-specific pointer conversion, which is the > reason for needing an architecture-specific wrapper, but I suppose the > handling of signed arguments as done in s390 should also be done > everywhere else. > > I also noticed that only x86 and s390 even have separate entry > points for normal syscalls when called in compat mode, while > the others all just zero the upper halves of the registers in the > low-level entry code and then call the native entry point. > > Arnd It looks to me like aarch64 also has something similar? At any rate, I can try to fix it for x86 and investigate what else might be effected. -- Thank you, Richard.