From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 1BA833858422 for ; Mon, 17 Apr 2023 21:20:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1BA833858422 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681766442; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GqinhCm6/laQq8Y7vGTYum2iSmN3JT/vb/7qgG7EqqY=; b=TNlw9miIbeni9MGJ9Irig+Fdjhhn/UWOe7GdBjODbz0fMQPCdBDATITM4gETMf7lVbpfXN 9U2NriP7I4gr79r5Fk2blNzh+B7/u7iyp+JeM4GtMc9f2CpiaumSiWxiUuVPrnjLB3d4hn QQ2/A2f0S+Ud1cbZ2bCF8Z/QEubKGL0= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-145-Z6bDT4zlMg6pPcoPdCOjKQ-1; Mon, 17 Apr 2023 17:20:41 -0400 X-MC-Unique: Z6bDT4zlMg6pPcoPdCOjKQ-1 Received: by mail-qk1-f199.google.com with SMTP id t65-20020ae9df44000000b0074ac7436042so6715889qkf.4 for ; Mon, 17 Apr 2023 14:20:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681766441; x=1684358441; 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=GqinhCm6/laQq8Y7vGTYum2iSmN3JT/vb/7qgG7EqqY=; b=i8RQACnkhTl0Aq6izRk0YJAZo++qViRTZ+GbCEoFOW8jI6/6sIOBSHVhMiNc76jeH0 mj+02IQaouldh3BkCCLte70LGQ2YgPqAf/K2jbd4dw6QdRXda7/M6BcNhSN7wZKILKWC kbfBosqpRcPTcIDSCEhPjlDHy4xh0zBcWEyM1UZorCE1+ChjseStnK0DDd14lcik8PGR TQrj9mRbSDyegJfpj40FGP13OQ+r0oje1maf7+h3TceORDtz2/9y1lP9/9ev6kLojYTW Of/B+qVCtDL8nduIze/C0vl7BP6UikH+DAtrwOEODijPksefbCvi1INbQH2QQB2xL2J5 yB9Q== X-Gm-Message-State: AAQBX9fGGGI0gNqShW749RyLD7jf6yMOaoUgHzCWFEifMr9SdcI+SzET 1x7pWxvRGZ1TFygoELUkw1YcAg01BWqeIVhH0+VRJp7okWUngH0PdA9iYAv3cezVoDw9vWk3my3 lgDINTPxxoLzuoDX/mfFo+jETojJ9++sJMXGEYM+7z7Rap/5K9vdt/wJXqENFGfZZT1wnFpGPjq YZ7Vfl X-Received: by 2002:a05:6214:400b:b0:5ef:741a:6c0b with SMTP id kd11-20020a056214400b00b005ef741a6c0bmr7837184qvb.29.1681766440801; Mon, 17 Apr 2023 14:20:40 -0700 (PDT) X-Google-Smtp-Source: AKy350YenhwBQzA8CD6rXBKnlD0/vPUlJEByxjZZf+ZXexS+XxL2V3UI01SBlIcUMR7hFCkv5HtGUg== X-Received: by 2002:a05:6214:400b:b0:5ef:741a:6c0b with SMTP id kd11-20020a056214400b00b005ef741a6c0bmr7837157qvb.29.1681766440421; Mon, 17 Apr 2023 14:20:40 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 14:20:39 -0700 (PDT) From: Joe Simmons-Talbott To: libc-alpha@sourceware.org Cc: Joe Simmons-Talbott Subject: [PATCH v4 2/2] aarch64: Set the syscall register right before doing the syscall. Date: Mon, 17 Apr 2023 17:20:34 -0400 Message-Id: <20230417212034.3890596-3-josimmon@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417212034.3890596-1-josimmon@redhat.com> References: <20230411133004.2268170-1-josimmon@redhat.com> <20230417212034.3890596-1-josimmon@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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 List-Id: To make identifying syscalls easier during call tree analysis load the syscall number just before performing the syscall. 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. --- sysdeps/unix/sysv/linux/aarch64/sysdep.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h index e94d1703ad..b91656fdff 100644 --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h @@ -167,14 +167,28 @@ # define HAVE_CLONE3_WRAPPER 1 +# define MSTR_HELPER(x) # x +# define MSTR(x) MSTR_HELPER(x) + # undef INTERNAL_SYSCALL_RAW # define INTERNAL_SYSCALL_RAW(name, nr, args...) \ ({ long _sys_result; \ { \ LOAD_ARGS_##nr (args) \ - register long _x8 asm ("x8") = (name); \ - asm volatile ("svc 0 // syscall " # name \ - : "=r" (_x0) : "r"(_x8) ASM_ARGS_##nr : "memory"); \ + if (__builtin_constant_p(name)) \ + asm volatile ("mov x8, %1\n" \ + "svc 0 // syscall " # name \ + : "=r" (_x0) \ + : "i" (name) ASM_ARGS_##nr \ + : "x8", "memory"); \ + else \ + { \ + register long _x8 asm ("x8") = (name); \ + asm volatile ("svc 0 // syscall " # name \ + : "=r" (_x0) \ + : "r"(_x8) ASM_ARGS_##nr \ + : "memory"); \ + } \ _sys_result = _x0; \ } \ _sys_result; }) -- 2.39.2