Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp627920rdb; Thu, 18 Jan 2024 13:54:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpq/p49p+JEPEu0vcb5UQOG6jNYtS+HjVTtNH5XbZf+m/5l4cMG1U5yAOBd/oLyN5ODy8V X-Received: by 2002:a05:6a00:9a9:b0:6d9:b09c:5087 with SMTP id u41-20020a056a0009a900b006d9b09c5087mr4274378pfg.16.1705614871184; Thu, 18 Jan 2024 13:54:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705614871; cv=pass; d=google.com; s=arc-20160816; b=abVRfGSTQZ0SgJaiMOQbh40ngBu9UoPO4fK7Y36W0h3Ldh8mU/8KwJngPWUCoXVqKs 85DYbzv59Kq5fT3kIUOOtf8DtSv5krxaw8Fw9hl3/V2eidU9roRW4OxqYCGzLSWaGICn d/O/S1wHsTcsHV8n66KLZJaxXvmM83QRh8rxGxiOAkGsj44q67X8mBgMLJp+g75EdlKy 4CrwbzKPv4s28Rme684cH8ENWp9135Ip/9X95TpbQU4Cw7TzabotYrkoTAZ0Bf3MB//0 q+6zcxn52DrJxKjz75Z2JnG6eYkgQn+d3WaifScHW9L5IqO03hfUIMcx7EnTsyfqlKCI ccZg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from:dkim-signature; bh=1ykJGA57/c6XjRX+/wiozqy8iJ6Vsrt2RLKtiLpKiLM=; fh=Q3S7ZgH7Zm5APQA66CHOxj7VLxBfQoZXcjv40qXT1hk=; b=OhgPhwbZUO5297KEYTfBGEORXus0EOYi2jf6e4f/MLKMRvmYYzOoieNfAVo9fBZH2q kkhRBdQ8u3kZIi0Sfe8PF68VXOQXs9jJDnsgNP9m2M/+fYlcZvOtQsy5Jbq7B1xHd0Zd nFnfB5lkDYFvYolRtnwPZ2anIgh0xL2sT7YqUZusTAHfvG+pcwcZvr5cWrvYeXrueYry K9MSklf85y+DPrchZnrN1FQL57pf7ygblcMgt2fmPwLhBB5ao4ZFRyUD34nlBv/sNFg7 OWAPsgBJg9KI+7dgoD+lWwfBo5lrCqmMLG+L83MgT5J+pwey8PCy8PhPifAOVk5rV80T hCXg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=C8u3bvO7; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-30587-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30587-linux.lists.archive=gmail.com@vger.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 k36-20020a635624000000b005cde41fb132si2081609pgb.625.2024.01.18.13.54.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 13:54:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30587-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=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=C8u3bvO7; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-30587-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30587-linux.lists.archive=gmail.com@vger.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 EF1FE28AC6A for ; Thu, 18 Jan 2024 21:54:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 254303174D; Thu, 18 Jan 2024 21:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="C8u3bvO7" Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A8692EAF9 for ; Thu, 18 Jan 2024 21:54:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705614844; cv=none; b=ULR8wSQ+Ktoa3AcavWe/AcqUgC/wVYhIS15J5Vp8hfjfCBQAHS4eiLHDLwM/TPsya4NmEj50i+8CxoSQE11wWKSxjrPBgkCKRyIA3d9HHXimufvtwouiWz9soWsWOOSCqEXwDkcl1KnGdut6qFkyYFJVc53pqcKI6qMjSSej4E8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705614844; c=relaxed/simple; bh=0OLoge7JRZVK/JTs8M53rSZCOS6zKNIvbnryNlKfkNs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=fNUlYKFjQibfXmAYTXPDe6M9KCpz7kVIhnIXdBjTl+5sieQ+cgsO+66lMwG06lEtOJ8YCCIWUCWoJhikirZVUHCQBstVDD1RuAlraX6rBVpGTMRQTcHZbcV2VGJbf+YpedlxAlAacPs2p0xmQRFJTq9hgSaa2U3wQWLhpA6PJdU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=C8u3bvO7; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6d9b37f4804so828399b3a.1 for ; Thu, 18 Jan 2024 13:54:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1705614841; x=1706219641; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=1ykJGA57/c6XjRX+/wiozqy8iJ6Vsrt2RLKtiLpKiLM=; b=C8u3bvO7oxhgginUEjQzW+277qLH3R4XqiYXdi4z+KsPPXPEq7lceJzx1p1os6UKFt zUaGS53pZUomjlGD4JAUIcV4DQH/KW5XaF6cSOqqzxVqgTk8r09FDyKi3nE+NSCllQw7 wueWI6E42J/rwk4Ca07/cZm7rVJ7p5NLjQxtfJOKk8dWYSPIIxGOMsbbzb2+MUru5asx OMq1/yJvjyHwxWe1JS80uDYOJPBckJcphpEJj5z6QLVcCKOxkyOtVbK5F/er37Rs2GaF TW9wNwZtHum51NvCM7HvkDUFNtPLFuuasFs4kckwwtkguU6ibJFZxpMy5Ml7ql3Zy6Oe NXUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705614841; x=1706219641; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1ykJGA57/c6XjRX+/wiozqy8iJ6Vsrt2RLKtiLpKiLM=; b=ewXDKk4E/eIRlFrMyOqomaUfz/6w1SNTfVEbo8odr4SIXpY9DPai1bSHeLWt9XZea2 HNK/noHBNyUvKPRfV3f5G1SCGim1Aa+/OC3Qd/HDiUgb/sSAAMRKBLG23zOazuzrNAAd R56G5S1qejRLyw5R+MnsPTmhO9akvgK1wdAV1sCgu378B+Zs21GIzsA7DuLjz4pB+vE/ KV7oHnPiUPrIF+pNG7w6wlh/Z/m9xK9odjmLYxPo7uSVoGsX5TRXbFLGfbNLsKgGrpKA DVYL+paZdaycHmjVlwSHGFBRR5sIpDZTN0QgJGi/uxw+/HM+X3vOkjwkKVmOo5ebv0hT TM+Q== X-Gm-Message-State: AOJu0Yz1mHcuGolKCQDltshopWMSsiIbkHakrcLIGFYAGqnX1wG27B/m jV17qEjOdaQ3x7YAgdGEEUMQgNoOghFhz8lWcm4ESE6Hylh26dq4YwIknxwMG92QahwLedICtFT j X-Received: by 2002:a05:6a20:2dc:b0:19b:1da4:8dc with SMTP id 28-20020a056a2002dc00b0019b1da408dcmr18728pzb.34.1705614841620; Thu, 18 Jan 2024 13:54:01 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id j15-20020aa78d0f000000b006d9c7f2840bsm3771459pfe.57.2024.01.18.13.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 13:54:01 -0800 (PST) From: Charlie Jenkins Date: Thu, 18 Jan 2024 13:53:59 -0800 Subject: [PATCH] riscv: lib: Support csum on GCC <11 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240118-csum_remove_output_operands_asm_goto-v1-1-47c672bb9d4b@rivosinc.com> X-B4-Tracking: v=1; b=H4sIAPadqWUC/x3NQQrDIBBA0auEWVfIiNCmVylFxEzTWeiIoyEQc vdKl2/z/wlKlUnhOZ1QaWdlyQN4myB+Q97I8DoMdrZuRnyYqD35Skl28tJb6c1LoRryqj5o8ps 0MW5ZrI3oMNIdRqpU+vDx37ze1/UDe5WzqHYAAAA= To: Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Charlie Jenkins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705614840; l=2787; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=0OLoge7JRZVK/JTs8M53rSZCOS6zKNIvbnryNlKfkNs=; b=dJpuJl1dFpZjTsUOyTWIxBNNNkZvncdUMycB4TzPg8EkchYbaXeZWzM0gJrYusU4KUPaoHcVO XLWURTe24UwBbkRTIcQdUzshBpJFlZdeoMxWOC8rVKRzmO3g1hoiBq2 X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= 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. 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. --- arch/riscv/lib/csum.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) 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, int len) : no_zbb); #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] "=&r" (fold_temp) - : [offset] "r" (offset) - : - : end); + : [offset] "r" (offset)); + + if (offset == 0) + goto end; + + asm (".option push \n\ + .option arch, +zbb \n\ + rev8 %[csum], %[csum] \n\ + .option pop" + : [csum] "+r" (csum)); 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, int 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] "=&r" (fold_temp) - : [offset] "r" (offset) - : - : end); + : [offset] "r" (offset)); + + if (offset == 0) + goto end; + + asm (".option push \n\ + .option arch, +zbb \n\ + rev8 %[csum], %[csum] \n\ + .option pop" + : [csum] "+r" (csum)); return (csum << 16) >> 48; #endif /* !CONFIG_32BIT */ --- base-commit: 080c4324fa5e81ff3780206a138223abfb57a68e change-id: 20240118-csum_remove_output_operands_asm_goto-49922c141ce7 -- - Charlie