From patchwork Mon Apr 17 21:20:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Simmons-Talbott X-Patchwork-Id: 1769862 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=f+EMQzhN; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q0g2f2hlCz1yZr for ; Tue, 18 Apr 2023 07:20:58 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5B7F93856DF6 for ; Mon, 17 Apr 2023 21:20:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5B7F93856DF6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681766456; bh=ontGVu8UgSl3te6NU2VFf4VpP1kaRQldMmbITrB56nE=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=f+EMQzhN21PVV/jlCKtLcvAcpHbI7oaT4UHdo/pskBFXh31T3UVVBD1ivgHeamZsr 5uo/PWLQ+EpYOdB3NFC1Bw86fpTwNmWvuGbPdknkg6jD9n9qviq0iLzas8jpvDlriu 3mus185gdaDSdnhjPhdYpYin8DNosePDyHF9hTtQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id C17DB385840E for ; Mon, 17 Apr 2023 21:20:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C17DB385840E Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-65-OTA71YN_PjGIGW5NK7WdVQ-1; Mon, 17 Apr 2023 17:20:39 -0400 X-MC-Unique: OTA71YN_PjGIGW5NK7WdVQ-1 Received: by mail-qt1-f198.google.com with SMTP id 13-20020ac8570d000000b003e37d3e6de2so18932764qtw.16 for ; Mon, 17 Apr 2023 14:20:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681766438; x=1684358438; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ontGVu8UgSl3te6NU2VFf4VpP1kaRQldMmbITrB56nE=; b=L3o0s4l2SbgLUNjUfIDm7RPn8PGMj+qkAAgq0aR5m0z6fB7hEdIljABhGIgfN9lQee mpdXA2C0ddyxvtyeiji2DgOP9frdsoeJKUDonlp1we1WM8ziKKUVCZDi1GHc0ZbKvrY2 enycmvFmtq9qqtT/mxRqBLbhq05Sz8nso9JFyizNQQTHLx3U7kmGyrpjgfqdrL2lE3Ht cjXi8c9JOi6HwVjVsaHzjTTHQlRuR3l6A3F6FQT3PlYlj3vEBuWeHqkDT8bxanXErDZd eAR+ZDOVXGMav4Em3OyyhPT0CRoB3eyGEfOxWRqHGf31sjyt9jxqnFWPIjE8+3wRNuq0 kaTg== X-Gm-Message-State: AAQBX9cB+RzS4XIy3x7Z66A04RHLud1mUJGLkuSj1Yfe69WfMOviu8TD hPYmnlMYxMKpULDOsf2yu7H70dYfyzXcK7jhYyXgRzMa59wbiiHzacEj2TBWumwkesWRaqNdzIS jDcPWkO+v9Yahk1qiIFH+kB9/gpqDFdcYcBWH1FHM5NEXQ8WYwGWJKII/F+EpDYZ2MdZ/8x7fGH idBsLE X-Received: by 2002:ad4:5f49:0:b0:5ef:8c79:fe88 with SMTP id p9-20020ad45f49000000b005ef8c79fe88mr1271842qvg.2.1681766438268; Mon, 17 Apr 2023 14:20:38 -0700 (PDT) X-Google-Smtp-Source: AKy350Y+Ijf1iWKPTrwT7QUOa4TBomp/CE1HfOWcrbYn+f9nQNMbO9EevZCCbV04mNw/SD7J7wZPhg== X-Received: by 2002:ad4:5f49:0:b0:5ef:8c79:fe88 with SMTP id p9-20020ad45f49000000b005ef8c79fe88mr1271808qvg.2.1681766437968; Mon, 17 Apr 2023 14:20:37 -0700 (PDT) Received: from oak.redhat.com (c-71-206-142-238.hsd1.va.comcast.net. [71.206.142.238]) by smtp.gmail.com with ESMTPSA id q1-20020ad44341000000b005ef817d14casm668666qvs.83.2023.04.17.14.20.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 14:20:37 -0700 (PDT) To: libc-alpha@sourceware.org Cc: Joe Simmons-Talbott Subject: [PATCH v4 0/2] x86_64: aarch64: Set call number just before syscall Date: Mon, 17 Apr 2023 17:20:32 -0400 Message-Id: <20230417212034.3890596-1-josimmon@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230411133004.2268170-1-josimmon@redhat.com> References: <20230411133004.2268170-1-josimmon@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Joe Simmons-Talbott via Libc-alpha From: Joe Simmons-Talbott Reply-To: Joe Simmons-Talbott Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" To make binary call tree analysis easier place the syscall number into the register just before the syscall is made. Only do this if the syscall number is a constant integer. Compiler optimizations can place quite a few instructions between the setting of the syscall number and the syscall instruction. During call tree analysis the number of instructions between the two can lead to more difficulty for both tools and humans in properly identifying the syscall number. Having the syscall number set in the prior instruction to the syscall instruction makes this task easier and less error prone. Being able to reliably identify syscalls made by a given API will make it easier to understand and verify the safety and security of glibc. Tested on x86_64 and aarch64. Changes to v3: * x86_64: Combine two inline asms into one. - Suggested by "H.J. Lu" Changes to v2: * Add a more detailed commit message. Changes to v1: * aarch64: Combine two inline asms into one. Avoid loading name twice. Joe Simmons-Talbott (2): x86_64: Set the syscall register right before doing the syscall. aarch64: Set the syscall register right before doing the syscall. sysdeps/unix/sysv/linux/aarch64/sysdep.h | 20 +++++++++++++++--- sysdeps/unix/sysv/linux/x86_64/sysdep.h | 27 +++++++++++++----------- 2 files changed, 32 insertions(+), 15 deletions(-)