From patchwork Thu Jun 20 16:23:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 806003 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp378983wrt; Thu, 20 Jun 2024 09:27:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUTV6UHLmQOQGDybRTByiAkg6ppDljMlsfvKeinvj+GU38YBDyokkXsGWfQ6u0RfdhYRI5XvW7x6qQaTtZJ90CE X-Google-Smtp-Source: AGHT+IGhgdOn/H1xLUWRgbT8Wm8QlAMH+vLm5p+C/YU9k06aleElR42A+ogIHLos2gHrYjoUpeJ/ X-Received: by 2002:a05:620a:24d4:b0:795:5f38:7de3 with SMTP id af79cd13be357-79bb3e1a4a2mr653985285a.6.1718900838539; Thu, 20 Jun 2024 09:27:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718900838; cv=pass; d=google.com; s=arc-20160816; b=qrwgKJxN0GfWxWdBI9x7jBz342EMLAio9jyf7YwCyJ8CXDffHAHEe8emxAUbo2WxVv ntC4c/VeLtHXOFCbbTciL80xOhdIbWONI3yQ/9fkedsTHwY2rRGbQsWupaWN1Gek5uX2 pw7mt74ZaS5dgWiBG5z1esunmVFbFG1fY2ZIcIruEdKBCH0divADj82RInjR4hD5iN47 Eh+YtxO9OTyqyZTeiVEXD5k7/wQPUSJuJ8/6DkzedxvdCfEqXQczXXLm1ydK4kS1SElK cfHMq9yPuGUvAGDMgQ3j5OCGv/ML4xths3fjqiBLZyctRsCSKiba3upcsTmBN72UYN0V H8oA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=dKegY/NCuvP1qGpTty+zi/gABRoEOsmvI2xLwKAI2tY=; fh=z7WBpRnpEcajsi+eCrB9be3IBpnFpuOD2qMP8Shfqmo=; b=f2HT20OkhRMwOpZVjvYMAMSgkEZUgqEta3p7vtRcFDyzGx8YyH/AhHcYbR6gZ66XNm WaqFZWjSG2CVg4RI0jwJGbC8zXuwmBgzJVk5BvJioi3ol8NxeyiB9LiDZ3kzldiW1lhV 5LG4aFosL8D86xo1n1UTY5KSDfRhgh7QNTB5R1krAkOsGpkdF9ATMZHutEy70YAm6uzs qewrJYCfe7/NEpXWbBA1kHxX86Hs/JC8iLPBIdmwJyJD/PGrwHoOPTu4c2loxnxp15At B5x/1oI7ZG4E3cBt3hgVjDbOjRCSrMTRYakY4du5+yfI3ncT4DPKpYLLlpNq9R2TZ3QX bV2w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RQ6euKiK; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id af79cd13be357-798ac096db7si1694377185a.752.2024.06.20.09.27.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 09:27:18 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RQ6euKiK; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 030C83893675 for ; Thu, 20 Jun 2024 16:27:18 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by sourceware.org (Postfix) with ESMTPS id 43374389000C for ; Thu, 20 Jun 2024 16:24:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 43374389000C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 43374389000C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=139.178.84.217 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718900682; cv=none; b=evnkpBSAW5lgnqebLIME5jklN0GPdjW3NUfJGjZyc/x2eykD5K0wFMAhXXOPsX78wIRc86x/YwvgT0z6i5ndv2lVFdoh8AgDSvDY0TpoL7XOd6TPeY9Rr8/8Rj5DwUvnCmFTByoVeARG0Y4mS6imrpLxMpyYkNUOwXb31DENSgc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718900682; c=relaxed/simple; bh=xqTHXBiOiQ4J4f1sokB8ZtOD8QdaqRy5yeb7o2jjiqA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=rvp/dUayjMU8XZtGl5XkZUDiOEJHBB7hDbChoXgNrnhb/uVGxK6FfOT9bDW0XNv6Ulxt7Ar0HeTPOORo509DC6CMp4lR/Tm9ejsURavbVpWTVtE8i0qqxY159vbBH8txxdjrVXupXeMLzaGOXMwpCyNSazLejbMcC8OJkd2u/qw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D9CFC621C5; Thu, 20 Jun 2024 16:24:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C1EEC4AF07; Thu, 20 Jun 2024 16:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718900677; bh=xqTHXBiOiQ4J4f1sokB8ZtOD8QdaqRy5yeb7o2jjiqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RQ6euKiK6VwJDxRKXDYXKkMxwqA9niEIEbzdfAQwitBbSpJdGv45x6KaIQuMDG4bV kwbXvrBf8QrSE5d30scR0+5bbzMw9uHigxaxVLi6uPpj4Wg4PNJsysp3vr3oEQW8BR ub66lfagcFK6JB/7wBvTbSTD9mXLYE0/FZ8A6pQmsu2V0i07+pv7D50QprJCKwG2Jd KOyYM0IDo1Y+GFVBlpz0+pnklNWjIUgVB5MXwc/c7ELXo3x/qgau81tHvAiJE2pmvu AZh3B0fhn3iyeuhMXaEkwLVifgpTrpmYF0iwoRQqsVYYQ3pVoqyR2S++1ru65GiGD7 Lh2JFlkaIi1UQ== From: Arnd Bergmann To: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Thomas Bogendoerfer , linux-mips@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, "David S. Miller" , Andreas Larsson , sparclinux@vger.kernel.org, Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Naveen N . Rao" , linuxppc-dev@lists.ozlabs.org, Brian Cain , linux-hexagon@vger.kernel.org, Guo Ren , linux-csky@vger.kernel.org, Heiko Carstens , linux-s390@vger.kernel.org, Rich Felker , John Paul Adrian Glaubitz , linux-sh@vger.kernel.org, "H. Peter Anvin" , Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org, libc-alpha@sourceware.org, musl@lists.openwall.com, ltp@lists.linux.it, stable@vger.kernel.org Subject: [PATCH 09/15] sh: rework sync_file_range ABI Date: Thu, 20 Jun 2024 18:23:10 +0200 Message-Id: <20240620162316.3674955-10-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240620162316.3674955-1-arnd@kernel.org> References: <20240620162316.3674955-1-arnd@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org From: Arnd Bergmann The unusual function calling conventions on superh ended up causing sync_file_range to have the wrong argument order, with the 'flags' argument getting sorted before 'nbytes' by the compiler. In userspace, I found that musl, glibc, uclibc and strace all expect the normal calling conventions with 'nbytes' last, so changing the kernel to match them should make all of those work. In order to be able to also fix libc implementations to work with existing kernels, they need to be able to tell which ABI is used. An easy way to do this is to add yet another system call using the sync_file_range2 ABI that works the same on all architectures. Old user binaries can now work on new kernels, and new binaries can try the new sync_file_range2() to work with new kernels or fall back to the old sync_file_range() version if that doesn't exist. Cc: stable@vger.kernel.org Fixes: 75c92acdd5b1 ("sh: Wire up new syscalls.") Signed-off-by: Arnd Bergmann --- arch/sh/kernel/sys_sh32.c | 11 +++++++++++ arch/sh/kernel/syscalls/syscall.tbl | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/sh/kernel/sys_sh32.c b/arch/sh/kernel/sys_sh32.c index 9dca568509a5..d5a4f7c697d8 100644 --- a/arch/sh/kernel/sys_sh32.c +++ b/arch/sh/kernel/sys_sh32.c @@ -59,3 +59,14 @@ asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1, (u64)len0 << 32 | len1, advice); #endif } + +/* + * swap the arguments the way that libc wants it instead of + * moving flags ahead of the 64-bit nbytes argument + */ +SYSCALL_DEFINE6(sh_sync_file_range6, int, fd, SC_ARG64(offset), + SC_ARG64(nbytes), unsigned int, flags) +{ + return ksys_sync_file_range(fd, SC_VAL64(loff_t, offset), + SC_VAL64(loff_t, nbytes), flags); +} diff --git a/arch/sh/kernel/syscalls/syscall.tbl b/arch/sh/kernel/syscalls/syscall.tbl index bbf83a2db986..c55fd7696d40 100644 --- a/arch/sh/kernel/syscalls/syscall.tbl +++ b/arch/sh/kernel/syscalls/syscall.tbl @@ -321,7 +321,7 @@ 311 common set_robust_list sys_set_robust_list 312 common get_robust_list sys_get_robust_list 313 common splice sys_splice -314 common sync_file_range sys_sync_file_range +314 common sync_file_range sys_sh_sync_file_range6 315 common tee sys_tee 316 common vmsplice sys_vmsplice 317 common move_pages sys_move_pages @@ -395,6 +395,7 @@ 385 common pkey_alloc sys_pkey_alloc 386 common pkey_free sys_pkey_free 387 common rseq sys_rseq +388 common sync_file_range2 sys_sync_file_range2 # room for arch specific syscalls 393 common semget sys_semget 394 common semctl sys_semctl