Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4198474pxb; Mon, 27 Sep 2021 11:25:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFFoFJ+AMQr6iym30Sy2+ggM6F6LJ2ZdDekkJiqmE0U70KztzL9of+G129OBuSU1N8tzPd X-Received: by 2002:a05:6402:319a:: with SMTP id di26mr1842603edb.84.1632767141161; Mon, 27 Sep 2021 11:25:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632767141; cv=none; d=google.com; s=arc-20160816; b=xsg8ntKVq0pNLMtzu4IaxA7tEzz+H3sVAAyUXjqAF7Nx0W/nikLaa0SXDOCWbjINgu r6hTjPeZDlj3O3AespuYUZzntB8KXIYor3QdJzkRhKJiH1BrldqgHBVjlNRbNV0iT1Yx 2TWmlSjmlWJv5UvF5/0orPK6Th1kfXXxs/kwzsj2zRFZeT6DCWV5JQNx2PCUq8NUP/Ww Hk6KozGb5MkTLHr2MSnNPBTuO3QKc4AxAiNv17cw4F9kNehMKnC+0jkcnVUwRgziyZ0+ Woa9du05syCixhT3ILzLF8lRMAEipULcVPnvhsV4qIWRzcmcRdpNCr2EHpD4rdg+c7B9 3VgQ== 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; bh=trKa/+y++PJDCF4UwNfrG62CNp3KfrUdZ2rtE1brgVI=; b=FI/hc/u+P/dAFphHRxhQzH6Wpz46MKOl2Ok2J5UjtgO5eZUtsq2a4EVZT0r6E8fhW1 /EvaId9FYPaWUPS5rkHudi4wzjUSiTqt7IfK2ZX0jzeLTs8JMPfiyZPbKUpF/+PqVX5b KoMLVqL874js0aqGL7pL348mZ4hgGDJqvUU0aydxdsMv3o1lCVF/2dC7SjwrDFm3+jnH wnX5MoVb3/A26ym6xQrbqH7Mmc/+S+cnSxGpsg3UfWIZ9WVa0qdSZD/HR2SedQrC0IDU 5nyazMHWIkg6SYXb8NDP3GqNpYiWpydxci7yXb4M9ClUuxAmtI/uzjn1Qg5lE5aY0Ton bg3Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y15si18809801edj.517.2021.09.27.11.25.16; Mon, 27 Sep 2021 11:25:41 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235991AbhI0SYU (ORCPT + 99 others); Mon, 27 Sep 2021 14:24:20 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:33291 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbhI0SYT (ORCPT ); Mon, 27 Sep 2021 14:24:19 -0400 Received: from mail-wm1-f46.google.com ([209.85.128.46]) by mrelayeu.kundenserver.de (mreue106 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MKt3r-1mGxh702wv-00LAyB; Mon, 27 Sep 2021 20:22:40 +0200 Received: by mail-wm1-f46.google.com with SMTP id d207-20020a1c1dd8000000b00307e2d1ec1aso678300wmd.5; Mon, 27 Sep 2021 11:22:39 -0700 (PDT) X-Gm-Message-State: AOAM530J5gGUJ3kichtFZSMe8S7JTGFfH8GGB6J4rlEoeUD/lwy6dD7v IEQx3/UXhV0U+Y4pWXaISvYZe7TBwknNJ+30nBo= X-Received: by 2002:a05:600c:22d4:: with SMTP id 20mr539812wmg.82.1632766959604; Mon, 27 Sep 2021 11:22:39 -0700 (PDT) MIME-Version: 1.0 References: <20210927161955.28494-1-rpalethorpe@suse.com> In-Reply-To: <20210927161955.28494-1-rpalethorpe@suse.com> From: Arnd Bergmann Date: Mon, 27 Sep 2021 20:22:23 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86/entry/ia32: Ensure s32 is sign extended to s64 To: Richard Palethorpe Cc: "the arch/x86 maintainers" , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , linux-s390 , Linux Kernel Mailing List , Linux API , Arnd Bergmann , rpalethorpe@richiejp.com, Dominik Brodowski , LTP List Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:EOEOhVKtXUW4bSdluaJa5jihN3589/mpHa7f+YvsokOLqhtrBK+ ghODJDGHdSQi5x1i/T/lHKYWRaJ+OKr47H+oeodVaP5BSnlQwv2ehsp9S2RCP0e4Udhlbu+ rr47ttfDRhc+rUBdfwyW1+e3OXiDLW5biH1tsUJ18Rd22XRzzTbcgZTZ45YPPJMlV1KEH4R hH4CZ2+A7U2vI4kwzU7hg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:i0ktgu2KnJM=:siyWKkDyvqhadWIMT55pOL NDQrUHMbAyvtQx1LJ+wMKv1hEUmH6EyrbYQt6YqTDk42wmO/Dx81EN4EaGSiiCyD/0lHmuyl6 /VynQi0QtmajQk+Abn83HMr6uU91cs8cxBqNw1kaa3PtrPMewKPN20OjdMRzINX158InN5oDn 0TR0NmVUs7teGDDVoCoa31+VEM6iOdmXyyjQqQCy1uJD9kDJIoYBKb8Pl+mTs/+bpQ9JfJWpz M1Ez3FWYZzZswY0ZIq7aGTVc7sxyaaL47sURFxNW0ZaJ4ibKy2bx3WCP3JT0iajcUIpzi3xyZ eGHzkBR1GbgePRJdViyzXfayWV1VhCNAZtp074bHVE3lUxv9HV9ZYVFd1Yh/DEm9q9nrL4D7x I2CsZUU1ttTVfdj4eN1u+X4xeEL9BD14e5+T9KrI8jzc+MAVwF+DJ2lkPjGrx9t++eJApuix7 x5suKZtQjPaxAUADRKJfMU+x0wf3sjbDsEI5v1jfRCOwMtikjL2yswKKpyAfY0bSw6KfH64X0 +7udwvN24pD3flPZF0OKfpg82KzEeybzUxTZ6uxNd+vngKnAckp6fjDv6Cdnsr/SRqLMGitTr 1CU7t7YTZObAbCSW1pdZTJtBjXvH9vjcdzrEeX5zZnOrCNS27vFxOWZIQl68z8vFQyo4r0NoF UTff00gGnWO8z1Y1vFegdLpdWA1th9A2x4yymX+dOgXkxJ+07vw6IIyWqNSMqqmWMZOtigEyv fUjs0ZnxgXpxfQd1oQ+OSMV/kLr1h+2RGP62O24iJLH75bnNleFK1SMxspC4vhbhpfiFyzaxA zibAB6Q3VeKjyM2ZR19NUaGigkGkoEpuizuS9xUCHzr1fvqPDB5NQ63fPjW62HU7uRGane36t NEGQl+ZzPHIUdaEGCFoQ== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 27, 2021 at 6:21 PM Richard Palethorpe wrote: > > Presently ia32 registers stored in ptregs are unconditionally cast to > unsigned int by the ia32 stub. They are then cast to long when passed > to __se_sys*, but will not be sign extended. > > This takes the sign of the syscall argument into account in the ia32 > stub. It still casts to unsigned int to avoid implementation specific > behavior. However then casts to int or unsigned int as necessary. So > that the following cast to long sign extends the value. > > This fixes the io_pgetevents02 LTP test when compiled with > -m32. Presently the systemcall io_pgetevents_time64 unexpectedly > accepts -1 for the maximum number of events. It doesn't appear other > systemcalls with signed arguments are effected because they all have > compat variants defined and wired up. A less general solution is to > wire up the systemcall: > https://lore.kernel.org/ltp/20210921130127.24131-1-rpalethorpe@suse.com/ > > Fixes: ebeb8c82ffaf ("syscalls/x86: Use 'struct pt_regs' based syscall calling for IA32_EMULATION and x32") > Signed-off-by: Richard Palethorpe > Suggested-by: Arnd Bergmann Looks good to me, thanks for following through with this part, and for checking the other syscalls! Reviewed-by: Arnd Bergmann I've added this to my randconfig build tree as well, to see if it causes any unexpected compile-time issues, though I don't expect any problems here. There are a few things that I think we should do as a follow-up: - do the same thing in the generic syscall wrapper, to ensure the other architectures also do the sign-extension. - Fix the big-endian architectures (ppc64be, mips64be, sparc, s390 parisc) so they pass the correct signal mask, either using your original approach, or by reworking the syscall to detect compat syscalls at runtime, killing off the separate entry point - Go through the compat syscalls to see if any of them can be removed once all architectures do sign-extension correctly. Are you motivated to help out with one or more of these as well? Arnd