Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp633431rdb; Thu, 18 Jan 2024 14:05:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJ8EYG0w/X+gPMCAXfJQgxjhFy2pX1dHoFt3vkUv/yPPSjDBf3E51aIDuO1Wp1dDNbDTw3 X-Received: by 2002:a17:902:fc85:b0:1d5:13b0:cf0d with SMTP id mf5-20020a170902fc8500b001d513b0cf0dmr1897978plb.5.1705615556374; Thu, 18 Jan 2024 14:05:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705615556; cv=pass; d=google.com; s=arc-20160816; b=nP2U4F2tKvlNQcJ02+e8i3EL7SkJ/IrCrcKwsrzbfDCnL1qzndgpcyBlzBsS2HVtDo fG+ODb7u+1nBKODq9GpX7H3TR3e5bqJ6CLiBBhWZBf5HFX6p548C6i/tMdMLzS95As15 2wresi2N9QYeqBXOT4WctjR5WWyQoBYj8cz0glR8wJ+vMjStlsFDLK47GTZbu7rPWrWu dW+U/Vc8tYP/ROhgJtaNgn2O+PCijatkkPMaxt3IyRkvsGQCRFN82SpjkL2F6RUrUQCv 94ECD8/waNLF4EUre4xH9Rm7ShMnwQzfuTJ2ECAhHSuT2vqRhnbkUhPC2uIyUffi/V2T iTkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ER8D3PKHf2wSWEU3C2HuPPHzj7zyOwkhraquEJlI5R0=; fh=8s5j0GxFICBycUiyRnRXXIcy2CNiwZrKO9NZ46eZW/o=; b=o/vjkcX2cjX1SyO9O+dvuJJDIqSW3dxFx8aff/Pa1+WIFk2feG31uFqo5eTXSpEiTc a2zGaxG6A0252uEwJaxIYV6t98pfnFIMkDJueOHcL1gCU6+b2cMiQuiqxGfDHaVrYfWp l+R047zcGe2GIaCUYJGl1jbLTVma+oPwn4tTj/AM2nrdyAuD9fRQ2CaPfCbONZo1pkxN FJHhSHMOEL68hQ/L/UQhPxb1poH9osAWQWXh+LF0fGqJlqgGSJtLqeEtnSqdSrJpYB0U WjCcXIaRYwl8rxKgTAw49h7ORa/oNvMIQ1CwCL1tEe25aLK3cJjM86zk6PZ8TaaeNjkB Y1sw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="CNbE/DSA"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-30592-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30592-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j14-20020a170903024e00b001d6ed187e0dsi2133452plh.371.2024.01.18.14.05.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 14:05:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30592-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="CNbE/DSA"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-30592-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30592-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 099BF28331D for ; Thu, 18 Jan 2024 22:05:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C8AB831759; Thu, 18 Jan 2024 22:05:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CNbE/DSA" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F35482E848 for ; Thu, 18 Jan 2024 22:05:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705615549; cv=none; b=qNWrkPlNPWtiVotUhh8CMC5yeD/UZ6LruN0QzjS4TKauTix6OPqEol1WLNsJ/nZsqNzhH+jlUi8T0EL5c+k+WhGpmgMA9WKRW3+JeSJJSnBf+BVnoNUUA5XD8u5qVsVuQw6flis+g4pucZS1A88UAaC/7gv7jgojtY+InFCqJ/I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705615549; c=relaxed/simple; bh=Q+pX89EmEj04h50yCe1VL5XHOahd2MD8MrvKmiempYg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HVRK5woQnR7hqgtdEuv/HF98n2WkZK5Fern+RsMEI1gLF7jpjaPDViaBZjSB2BUYi5ISdEpmxESrsQQz5v56075OzWh3ADujQ4HJSquiJdZR3LimhrWjBKYVKfVm1ZpLF+mc+fgm/LUVxIjUEj5nEw8OtblKEcw316+MY+HhTNE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CNbE/DSA; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F037FC433F1; Thu, 18 Jan 2024 22:05:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705615548; bh=Q+pX89EmEj04h50yCe1VL5XHOahd2MD8MrvKmiempYg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CNbE/DSA1PztMn+pO4MdBoIICDaUBsbIzCzZ5Ac2UfyLf55lezcOOFY7ENy72YJpg MhPRW9MlcVv7fNBgw8f79OkTk1f2hhznZ8mRS7I5NCTZRGNvj2y1PnpA+zat0ixpY/ sbc2viqRM4rc3odbhaV1BzoU4sBZInarilSrdEbWjZFc7tbpJetoB+mWJO0Q/tAbZI UNWoim7wx/kNmm1Zm063ZwaptO0ZqPIWd/CKQhmdFfA+h+1WjdL+s4eqmhyBNlxuEX /Jv6nGR599BKQcVdICb/tSbvW2QUlRMAEdpquDX94FkGKC2XeF01l2KIzUfCdYzYLL 24vWRWGr/YFHg== Date: Thu, 18 Jan 2024 22:05:44 +0000 From: Conor Dooley To: Charlie Jenkins Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] riscv: lib: Support csum on GCC <11 Message-ID: <20240118-museum-ample-11d649f95de8@spud> References: <20240118-csum_remove_output_operands_asm_goto-v1-1-47c672bb9d4b@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="pl1prUg+ekIn2nNV" Content-Disposition: inline In-Reply-To: <20240118-csum_remove_output_operands_asm_goto-v1-1-47c672bb9d4b@rivosinc.com> --pl1prUg+ekIn2nNV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jan 18, 2024 at 01:53:59PM -0800, Charlie Jenkins wrote: > The OutputOperands field for asm goto statements is only supported > starting from GCC 11. Split the asm goto to remove the use of this > feature. >=20 > Signed-off-by: Charlie Jenkins > Fixes: a04c192eabfb ("riscv: Add checksum library") > --- > The OutputOperands field for asm goto statements is only supported > starting from GCC 11. Split the asm goto to remove the use of this > feature. Maybe this is a super naive question, but is it possible to just not use the custom csum code for gcc older than 11? > --- > arch/riscv/lib/csum.c | 42 ++++++++++++++++++++++++++++++------------ > 1 file changed, 30 insertions(+), 12 deletions(-) >=20 > diff --git a/arch/riscv/lib/csum.c b/arch/riscv/lib/csum.c > index 06ce8e7250d9..23be289f52b6 100644 > --- a/arch/riscv/lib/csum.c > +++ b/arch/riscv/lib/csum.c > @@ -177,22 +177,35 @@ do_csum_with_alignment(const unsigned char *buff, i= nt len) > : no_zbb); > =20 > #ifdef CONFIG_32BIT > - asm_volatile_goto(".option push \n\ > + /* > + * OutputOperands in asm goto is not supported until GCC 11, so > + * this asm has to be split to be compatible. > + */ > + asm (".option push \n\ > .option arch,+zbb \n\ > rori %[fold_temp], %[csum], 16 \n\ > andi %[offset], %[offset], 1 \n\ > add %[csum], %[fold_temp], %[csum] \n\ > - beq %[offset], zero, %l[end] \n\ > - rev8 %[csum], %[csum] \n\ > .option pop" > : [csum] "+r" (csum), [fold_temp] "=3D&r" (fold_temp) > - : [offset] "r" (offset) > - : > - : end); > + : [offset] "r" (offset)); > + > + if (offset =3D=3D 0) > + goto end; > + > + asm (".option push \n\ > + .option arch, +zbb \n\ > + rev8 %[csum], %[csum] \n\ > + .option pop" > + : [csum] "+r" (csum)); > =20 > return (unsigned short)csum; > #else /* !CONFIG_32BIT */ > - asm_volatile_goto(".option push \n\ > + /* > + * OutputOperands in asm goto is not supported until GCC 11, so > + * this asm has to be split to be compatible. > + */ > + asm (".option push \n\ > .option arch,+zbb \n\ > rori %[fold_temp], %[csum], 32 \n\ > add %[csum], %[fold_temp], %[csum] \n\ > @@ -200,13 +213,18 @@ do_csum_with_alignment(const unsigned char *buff, i= nt len) > roriw %[fold_temp], %[csum], 16 \n\ > addw %[csum], %[fold_temp], %[csum] \n\ > andi %[offset], %[offset], 1 \n\ > - beq %[offset], zero, %l[end] \n\ > - rev8 %[csum], %[csum] \n\ > .option pop" > : [csum] "+r" (csum), [fold_temp] "=3D&r" (fold_temp) > - : [offset] "r" (offset) > - : > - : end); > + : [offset] "r" (offset)); > + > + if (offset =3D=3D 0) > + goto end; > + > + asm (".option push \n\ > + .option arch, +zbb \n\ > + rev8 %[csum], %[csum] \n\ > + .option pop" > + : [csum] "+r" (csum)); > =20 > return (csum << 16) >> 48; > #endif /* !CONFIG_32BIT */ >=20 > --- > base-commit: 080c4324fa5e81ff3780206a138223abfb57a68e > change-id: 20240118-csum_remove_output_operands_asm_goto-49922c141ce7 > --=20 > - Charlie >=20 >=20 --pl1prUg+ekIn2nNV Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZamguAAKCRB4tDGHoIJi 0piAAP43AO2qeJIkMIMNCYDRVUHlOx4Fd4fKJBeaGX7Pc1EjlQD+Klh3LfS4rMLi BXwU/T016C4F2KPCyItXgiwTbGy4SwU= =Yi8l -----END PGP SIGNATURE----- --pl1prUg+ekIn2nNV--