Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp120377pxb; Mon, 18 Oct 2021 22:20:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPE/5tD4Sluyev2mWmuJMLCB7GUU5P0UODuFgD2BR2MHeYUmIRXTxQV7ScgVhomtXcK9g5 X-Received: by 2002:a17:906:ad98:: with SMTP id la24mr36599838ejb.383.1634620800780; Mon, 18 Oct 2021 22:20:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634620800; cv=none; d=google.com; s=arc-20160816; b=vRDOz4/r8StC0+W6s0qmi3Jsy2mPh/EiRpocyEaW7V03Cw1fF2p/fv7JnFdF+zV8N0 /HgaMVCrOxDteu5LtJN+ohvGmJppLkZfpv461OosfwCHB96iZRaF++5XG8Ws3gKBkNVC V2uBWY6On6OrzIJJ+y7izR9xMJPKzn2oDWarEcsrs1UYgozyBYpdVjKqyiAXbSOVU0C1 O1xuRSpop22QIQ0eHWU85lyt9Wb1o6xlt31Hrseah4HOBi55las2TEXkuGpc28SHQB/9 2q81tvFJ56Pk+LYchDjCa0n5f39HcwXG6TIrq0F8R0vHd5bFItoxiCfuWbzWjyDiicrI rrcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=E97yT8hy4yQjsz2siz81ZUOBpPmnI0CI1OEE09TeSxw=; b=JwzF5J42978oYfxuhfjncn5zsc/kE6GeteO0ypfNvYlnGbA3m+XfAdhlDBqfqBez9b ta3cHpVebHgoSMFXb1I0uYDR3JxcRy6XzdTFgeBSsgYaDNY0TBD21RhTp7gvFHCVCEUy dsq3ZZxcrIGeykWSXE7oTzGaHD7/L2XjPwaU4fK5Qsda/BJQ4dXas2rNjusBKFtMhQwg X17bN4b2R2H4z52mDC+cuHJ99ygtzpDI1YYrZfS8tD4+VG+gz4lin8hIOVlo5hNwK1NU UU1xk6nnPNRAvFNkonm12SRI3hekJf3O9BR8Fqea9jcBQ8PqSL4fJqE49x1VtNsBOP7C 1AyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pSTuv1nB; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg17si32236702ejc.576.2021.10.18.22.19.37; Mon, 18 Oct 2021 22:20:00 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pSTuv1nB; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233395AbhJSFT5 (ORCPT + 99 others); Tue, 19 Oct 2021 01:19:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233119AbhJSFTw (ORCPT ); Tue, 19 Oct 2021 01:19:52 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31ABCC06161C for ; Mon, 18 Oct 2021 22:17:40 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id d9so9399507pfl.6 for ; Mon, 18 Oct 2021 22:17:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E97yT8hy4yQjsz2siz81ZUOBpPmnI0CI1OEE09TeSxw=; b=pSTuv1nBD7aA6HBo4K3ES1BRFTFzfoV4odvOZ3VAyeWD11GEpz46koZHh0LaOShJrr TEzhJO3Ai1dA7Cz/mZPKYIychasyBupTwZRjFzeh1qF/wjksr8nJkiUApyZNKe19Tfw5 9Dry3bRTTrhuCyxJ7torA8ow/Q8berMLr7FkwZCavJk6wjh0I+WJDtqSCnNxXOaV/63C 7cRQmJZqFp97UE0AmsA2IhW3QCIEwWLngVN29L0q3fU+Vg3u/6edKk7jKOSR1gOgwl69 kgLylwyNCWAqUUnuj5QOc3ILZyo8ugrWiHNTOVOvRTdPZ0j9dFrzkw0aK5SbAPAIY0vk B6xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E97yT8hy4yQjsz2siz81ZUOBpPmnI0CI1OEE09TeSxw=; b=crWwcXd/t1X3KWr11K18AD4uF0OVSod58OdBjCoZkwqthFe7gfPtCkBQXXOBBlWmqa /aUjeJKoM9GuZDw2gVPehUz6Rl7U4ZY0vdxogegMnrey0m7SQ5JkiY1FmZTJyHcCK7cB 1WANWFQuhGhcklbCI/IiSMFzPg/bgiTmS5Mvf7k9+39Unue+r5by3EUsFBcZBbsy8zof 2h5HWGHiWQScOdp1IFhkk0b7enkm/O51Q0wL0XeSdM420OxWelyl9x++ya3vd6a/Qkm3 4KK7L/ARgltzIobmimpqUwlctqa4bBQ9aobfR7EJ2IZMP3NBtHVVJRbH7/jr7H8TC/hN /1dw== X-Gm-Message-State: AOAM530xNhfSOFRMvf1baP5YJW0PF4LfTfklP6qFLh3ii2vhh93B0hq1 Mae7pgDRGTgPx5+B1YI1ZR0ZxVM1aTE= X-Received: by 2002:a05:6a00:2181:b0:44c:f4bc:2f74 with SMTP id h1-20020a056a00218100b0044cf4bc2f74mr33061725pfi.68.1634620659820; Mon, 18 Oct 2021 22:17:39 -0700 (PDT) Received: from octofox.hsd1.ca.comcast.net ([2601:641:401:1d20:4171:83c2:8384:24c5]) by smtp.gmail.com with ESMTPSA id me12sm1168844pjb.27.2021.10.18.22.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 22:17:39 -0700 (PDT) From: Max Filippov To: linux-xtensa@linux-xtensa.org Cc: Chris Zankel , linux-kernel@vger.kernel.org, Max Filippov Subject: [PATCH 04/10] xtensa: don't use a12 in __xtensa_copy_user in call0 ABI Date: Mon, 18 Oct 2021 22:17:10 -0700 Message-Id: <20211019051716.4173-5-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211019051716.4173-1-jcmvbkbc@gmail.com> References: <20211019051716.4173-1-jcmvbkbc@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org a12 is callee-saved register in xtensa call0 ABI, so a function must not change it. The main unaligned copy loop of __xtensa_copy_user uses all low-numbered registers, so a register must be spilled to avoid using a12 as a loop counter. Signed-off-by: Max Filippov --- arch/xtensa/lib/usercopy.S | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/arch/xtensa/lib/usercopy.S b/arch/xtensa/lib/usercopy.S index a0aa4047f94a..16128c094c62 100644 --- a/arch/xtensa/lib/usercopy.S +++ b/arch/xtensa/lib/usercopy.S @@ -60,7 +60,12 @@ .text ENTRY(__xtensa_copy_user) - abi_entry_default +#if !XCHAL_HAVE_LOOPS && defined(__XTENSA_CALL0_ABI__) +#define STACK_SIZE 4 +#else +#define STACK_SIZE 0 +#endif + abi_entry(STACK_SIZE) # a2/ dst, a3/ src, a4/ len mov a5, a2 # copy dst so that a2 is return value mov a11, a4 # preserve original len for error case @@ -75,7 +80,7 @@ ENTRY(__xtensa_copy_user) __ssa8 a3 # set shift amount from byte offset bnez a4, .Lsrcunaligned movi a2, 0 # return success for len==0 - abi_ret_default + abi_ret(STACK_SIZE) /* * Destination is unaligned @@ -127,7 +132,7 @@ EX(10f) s8i a6, a5, 0 #endif /* !XCHAL_HAVE_LOOPS */ .Lbytecopydone: movi a2, 0 # return success for len bytes copied - abi_ret_default + abi_ret(STACK_SIZE) /* * Destination and source are word-aligned. @@ -187,7 +192,7 @@ EX(10f) l8ui a6, a3, 0 EX(10f) s8i a6, a5, 0 .L5: movi a2, 0 # return success for len bytes copied - abi_ret_default + abi_ret(STACK_SIZE) /* * Destination is aligned, Source is unaligned @@ -205,8 +210,14 @@ EX(10f) l32i a6, a3, 0 # load first word loopnez a7, .Loop2done #else /* !XCHAL_HAVE_LOOPS */ beqz a7, .Loop2done +#if defined(__XTENSA_CALL0_ABI__) + s32i a10, a1, 0 + slli a10, a7, 4 + add a10, a10, a3 # a10 = end of last 16B source chunk +#else slli a12, a7, 4 add a12, a12, a3 # a12 = end of last 16B source chunk +#endif #endif /* !XCHAL_HAVE_LOOPS */ .Loop2: EX(10f) l32i a7, a3, 4 @@ -224,7 +235,12 @@ EX(10f) s32i a8, a5, 8 EX(10f) s32i a9, a5, 12 addi a5, a5, 16 #if !XCHAL_HAVE_LOOPS +#if defined(__XTENSA_CALL0_ABI__) + blt a3, a10, .Loop2 + l32i a10, a1, 0 +#else blt a3, a12, .Loop2 +#endif #endif /* !XCHAL_HAVE_LOOPS */ .Loop2done: bbci.l a4, 3, .L12 @@ -264,7 +280,7 @@ EX(10f) l8ui a6, a3, 0 EX(10f) s8i a6, a5, 0 .L15: movi a2, 0 # return success for len bytes copied - abi_ret_default + abi_ret(STACK_SIZE) ENDPROC(__xtensa_copy_user) @@ -281,4 +297,4 @@ ENDPROC(__xtensa_copy_user) 10: sub a2, a5, a2 /* a2 <-- bytes copied */ sub a2, a11, a2 /* a2 <-- bytes not copied */ - abi_ret_default + abi_ret(STACK_SIZE) -- 2.20.1