From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2e.google.com (mail-oa1-x2e.google.com [IPv6:2001:4860:4864:20::2e]) by sourceware.org (Postfix) with ESMTPS id AF5CD3858D28 for ; Tue, 11 Apr 2023 16:39:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AF5CD3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-1845f865452so5213256fac.12 for ; Tue, 11 Apr 2023 09:39:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681231175; x=1683823175; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=9LKTRcfVvKswuPq4EWZM4kHeJfmUCv4tgUv9nLKxCNg=; b=J8m5HzO68XWWDZ2ds8iTzGu6Y7hyxWYfechZWoTkp9iryBaKlJkgR83uhXptYkh5Jy kLfK+5liobBAq5ZSXF/Bnsb/raqPvph9YgUhCMzR7hrtM60sOFYomGQpKAVk+EDOxULV YKLY7zhLziKuKiC1ToTGeukO+5uD/4LbZfXEVQQRLOsbbOYhuc/fevNTTAyxS8M/HxOB +Q7+OEPV9UCeGny3B+xU3VD8A2GJWzUhoYDs7LksYzPtcxjh9Fs7UIXN3gEC7AeRj9xx IEuflqHN95Snns0IOYZVO91hUPVYHCGmevpEBNce+hAWrmTgTCfEHtbPZ0sSC6xdOffE s+Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681231175; x=1683823175; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9LKTRcfVvKswuPq4EWZM4kHeJfmUCv4tgUv9nLKxCNg=; b=0LCnYc+3sAfmqZIE/XjgHj6Teygov4hg6E0zqxqjg99aHop8vxt0Q13Xw7TLF07AvD 1hy1u9BWbIITzoh/8mNHrCkAoWwJrx5OG76QC2IQ2B2Lp/EoXsxVmS1xR9B3uXVuo+VR nT7tTUQw5Y6H+jws7ZTepdqiM1lReI6IHE2LgZbZqOhn/K2sZUrSW+g4fyLi1wduEsgQ bM+ojyqV5NzhPpdGZyw0kMN3vHt9sZzrz76gV0gTw5GH8aHCYDUs51VEDAOycpVZ07FX RbmiCMTar8kaqmRpno1/GIO/HVX9KxTVWWoigeA1unBOWfC0irCSI4RHE+rLcmmmoSus x47w== X-Gm-Message-State: AAQBX9exUNoB1UCgePDis2z+g8hgeBk7k5HvPCnR00Ohfno4GYQOfSob WRsYpaE11hNOTCQYZl/CEIUJw4mboMDKImHmgtp5QQ== X-Google-Smtp-Source: AKy350bxi+hkAkUDOIXbc3ISVWSoMlJ+/yEJkgAjREaDhzr0mtTeNG1ZtzPlfwP/0qdjs/TV2E158g== X-Received: by 2002:a05:6870:c18a:b0:184:4:3038 with SMTP id h10-20020a056870c18a00b0018400043038mr6084082oad.24.1681231174963; Tue, 11 Apr 2023 09:39:34 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c2:55a1:7428:425e:4ee7:30b6? ([2804:1b3:a7c2:55a1:7428:425e:4ee7:30b6]) by smtp.gmail.com with ESMTPSA id x17-20020a4a97d1000000b00541cb3cf2d2sm2738521ooi.13.2023.04.11.09.39.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Apr 2023 09:39:34 -0700 (PDT) Message-ID: Date: Tue, 11 Apr 2023 13:39:31 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH 2/2] aarch64: Set the syscall register right before doing the syscall. Content-Language: en-US To: Florian Weimer Cc: Joe Simmons-Talbott via Libc-alpha , Joe Simmons-Talbott References: <20230411133004.2268170-1-josimmon@redhat.com> <20230411133004.2268170-3-josimmon@redhat.com> <87h6tmil4j.fsf@oldenburg.str.redhat.com> <87a5zeieym.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <87a5zeieym.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 11/04/23 13:03, Florian Weimer wrote: > * Adhemerval Zanella Netto: > >> On 11/04/23 10:50, Florian Weimer via Libc-alpha wrote: >>> * Joe Simmons-Talbott via Libc-alpha: >>> >>>> ({ long _sys_result; \ >>>> { \ >>>> LOAD_ARGS_##nr (args) \ >>>> register long _x8 asm ("x8") = (name); \ >>>> + if (__builtin_constant_p(name)) \ >>>> + asm volatile ("mov x8, " MSTR(name) ";" \ >>>> + : /* no output */ : "i" (name) : "x8"); \ >>>> asm volatile ("svc 0 // syscall " # name \ >>>> : "=r" (_x0) : "r"(_x8) ASM_ARGS_##nr : "memory"); \ >>>> _sys_result = _x0; \ >>> >>> I think you should do this in a single assembler statement, load the >>> constant only once. >> >> Is this required because compiler is free to reorganize the argument >> list? I think it should me it clear on the commit message. > > Yes, that's the reason. It's a bit tricky to recover the system call > number using static analysis otherwise. I suggested to Joe that we > should put something into glibc, rather than improving that static > analysis tool so that it's fully reliable. Direct syscalls are done by different projects, like sanitizer, libgomp, etc; so imho improving the static analysis tool could potentially catch a wide range of usages than trying to fix only on glibc.