From patchwork Thu Jan 26 13:14:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zaslonko Mikhail X-Patchwork-Id: 48629 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp264553wrn; Thu, 26 Jan 2023 05:17:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXtkHFICR48V0fWzgWQNrh3Ckz6xiYvMpCMpEkNO8JjRx6VDkqnP+nIxVd0ZVRynvmHXnR1n X-Received: by 2002:a17:907:2392:b0:86e:c9e2:6329 with SMTP id vf18-20020a170907239200b0086ec9e26329mr34698635ejb.12.1674739027194; Thu, 26 Jan 2023 05:17:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674739027; cv=none; d=google.com; s=arc-20160816; b=QbijY68fpehdduTEBuREYfjxIIRutiEbblgj25R8EtL4E3o3CkKFPKSFuKn2RuJdBv mkPkDDFBtLiYBnUWWEA2GMx001J2fZRDUBaYUrgEBhvSlpx/3KG0TSrj5OdW0DjKiEaj DQWTTUqrVVqT0jzjnj6A/BBMaT7Cf5lMVlLJC+Ov6HkVripBJ92V/ss1AG1Cl5JGf6qm gM5DMfPnAouQL1pH2Ya1aQee06+uhkMasuBizeOcidzsoYiSrTLViRBVO7gtPvsY/I58 23zVqJ78agyCTuJ870BFO6hhBGf6X8LEx35BpwLLPaU7eZYQ1DA2yaNZpZzpY2pbaNSF Q6lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZKOqHnDXJa7jRfwmB881p/x5nb/JTibiWGwBU+BYF4k=; b=e+DPdVXlbg2nqwyuynfF7wW6WueTjLWRKT4KfcZxoERPGzkAF7IzSebRpSX3dS6RQK 3vRx8XzF/ZuVOHbCMf11UngB4ujQrDRg1n+QnfrjGfoeirz2jtXePrZT72WsRenRCHsN ZyuX+oTQxAd25jtUOGx5YKO75wm0JxTgRxo2G6XabrAps+H2CXkpkDwwIQc7nbmCIY1W Wm/7QWIYa1Y8vFud/YNfO/1Mjsv4D+wlqCBrWcA46hnUNrhjzicxJNxNPwykLRP7Azv6 H3Yj5l/cueXOmKZCiUO2MG99hoHoVv2NpTemqfOnfYkiLrt8rCO1ICmYPbOVr3KdQE64 2Ukw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=FxlywZqu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wc13-20020a170907124d00b008779c9c6ba1si1293232ejb.43.2023.01.26.05.16.43; Thu, 26 Jan 2023 05:17:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=FxlywZqu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236729AbjAZNPZ (ORCPT + 99 others); Thu, 26 Jan 2023 08:15:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236611AbjAZNOx (ORCPT ); Thu, 26 Jan 2023 08:14:53 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9C0369507 for ; Thu, 26 Jan 2023 05:14:36 -0800 (PST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30QCkVh3000343; Thu, 26 Jan 2023 13:14:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=ZKOqHnDXJa7jRfwmB881p/x5nb/JTibiWGwBU+BYF4k=; b=FxlywZqu7WtBFFV0CJc4JlgYNlLcxtmlKcIVObhpfRYIqIR+SdduOgXH5NBFTsa6n95k +cYzlRVs8fRiCLPBlXGDPrEUMahNiLgEIYz35SFNRnWcz8ZEMmAMAziakd7TIOPukse3 qX0VBZw4m6KBCwdsrbw3YBbfEU9I9zgb3kEmXEpNbcsksKCHL/DLcT4eWQpnMJzgbDDT JWQVUKd9voc8CYokLWGzR9m9cGwFE3VpXhaQLgNYTakltOhKKCA1r3BH2vl/2ltCgy+A 4ABjSu1R9KiEhVM/Bsrdz0eZX0zLjaMNV3FFdqI0XJW/nRrJDiiKx3ESvGDYB1t5xGjI ZA== Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3nbrka2ca0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:35 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30Q2KLfI027371; Thu, 26 Jan 2023 13:14:33 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma04fra.de.ibm.com (PPS) with ESMTPS id 3n87p6ckhe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:33 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30QDETNT48693644 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Jan 2023 13:14:29 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9EDF820040; Thu, 26 Jan 2023 13:14:29 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 612EA2004B; Thu, 26 Jan 2023 13:14:29 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 26 Jan 2023 13:14:29 +0000 (GMT) From: Mikhail Zaslonko To: Andrew Morton Cc: LKML , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Mikhail Zaslonko Subject: [PATCH 1/8] lib/zlib: Adjust offset calculation for dfltcc_state Date: Thu, 26 Jan 2023 14:14:21 +0100 Message-Id: <20230126131428.1222214-2-zaslonko@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230126131428.1222214-1-zaslonko@linux.ibm.com> References: <20230126131428.1222214-1-zaslonko@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 0T-ZVNQ6r_emaLyPji3ibcq_SSxr3Ms_ X-Proofpoint-GUID: 0T-ZVNQ6r_emaLyPji3ibcq_SSxr3Ms_ X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-26_05,2023-01-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 spamscore=0 clxscore=1015 suspectscore=0 malwarescore=0 lowpriorityscore=0 mlxscore=0 mlxlogscore=700 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301260126 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756091150387366803?= X-GMAIL-MSGID: =?utf-8?q?1756091150387366803?= This commit is based on: https://github.com/zlib-ng/zlib-ng/commit/d8b67f5 Signed-off-by: Mikhail Zaslonko Acked-by: Ilya Leoshkevich --- lib/zlib_dfltcc/dfltcc.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/zlib_dfltcc/dfltcc.h b/lib/zlib_dfltcc/dfltcc.h index 2a2fac1d050a..1f63094366e9 100644 --- a/lib/zlib_dfltcc/dfltcc.h +++ b/lib/zlib_dfltcc/dfltcc.h @@ -100,8 +100,9 @@ struct dfltcc_state { char msg[64]; /* Buffer for strm->msg */ }; +#define ALIGN_UP(p, size) (__typeof__(p))(((uintptr_t)(p) + ((size) - 1)) & ~((size) - 1)) /* Resides right after inflate_state or deflate_state */ -#define GET_DFLTCC_STATE(state) ((struct dfltcc_state *)((state) + 1)) +#define GET_DFLTCC_STATE(state) ((struct dfltcc_state *)((char *)(state) + ALIGN_UP(sizeof(*state), 8))) /* External functions */ int dfltcc_can_deflate(z_streamp strm); From patchwork Thu Jan 26 13:14:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zaslonko Mikhail X-Patchwork-Id: 48628 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp264471wrn; Thu, 26 Jan 2023 05:17:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXuLPsAIcTYsu7Pv5p2RY6jH1vwKEfU+zdLdZmG9ZX0h9OAYNgFzwaJk5BIu0o7ntrZUMB7L X-Received: by 2002:a17:906:7f18:b0:877:77f5:a8e1 with SMTP id d24-20020a1709067f1800b0087777f5a8e1mr29024156ejr.35.1674739019921; Thu, 26 Jan 2023 05:16:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674739019; cv=none; d=google.com; s=arc-20160816; b=B+7LIdcatzxOVfNWHFjveBFRDxjLVTH/3v5ecxtBk6Pyumxs6SE9Sk6ROa4OZ/t9vv Lic2cbrwEjFY1yCpKzCAQsgkymDI57poSunFGyJrgj4sChzeCzR3CHqxURDiA6JSryKJ k3updcF90vSHcsVkrKMYduOSm+jnjPFE1KpPFeT/zkBYDg4akI6cZqmJnJxKwDy8TJI6 IRB14p6TuqT9hYkKzbxcLWy887pnHF4GuglEg/SU5KnCNrpI5sxZ8ET5zr4p8ew04I3w T23UFbTLASEPmZ4cbyKP7kKtbpd/NIGm5ShwCCNkRe/w9PkKaZGbkVP5N13RQRVOcRPB xLcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YgFIywuUEopc3ChgAdbXsdUgSWsLi3fA2zApwH+LBsc=; b=iIOqo2MVgsAQzqryIk8y0gkVgx4a25Pzk3i0tjk/QtxfOYrjfh7ayH05c5HgWXkvKl Ln1Njq3zZpPjZX0A+nIMmAMWST07vlSrdM8TRgeohAmXMr7hyMwrZ1LeqU03NRc5vtka /S1hCi8gAZ0jf5gVJlKj73fw5gpk6Ird1C77BHtL5+R4bswp2WlCIAml1MM2CZgpti6i o2aMXp8tkNP/3UTHbMst5dMAYsvLm+eGYobov6PG4JnZhAA15Y9uRWclCV90R5xCYuN0 fNjmsM+qay3eG8srde09AbwxTTWzoLynmxjqDKtzNqbIanE8fMMWhG1Vf9h8SofR5nOH cKYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=igncZ3Qo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a13-20020a170906684d00b00871f78c75f8si1296639ejs.182.2023.01.26.05.16.35; Thu, 26 Jan 2023 05:16:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=igncZ3Qo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236198AbjAZNPY (ORCPT + 99 others); Thu, 26 Jan 2023 08:15:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236622AbjAZNOx (ORCPT ); Thu, 26 Jan 2023 08:14:53 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81CCF66FBA for ; Thu, 26 Jan 2023 05:14:36 -0800 (PST) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30QBgG5s015214; Thu, 26 Jan 2023 13:14:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=YgFIywuUEopc3ChgAdbXsdUgSWsLi3fA2zApwH+LBsc=; b=igncZ3Qo1E3Caw3gBvpyTlODIVf7uXHq0v9mFza/OnxsHMFRy9Ai5IUHG+5a8kFXdlj/ a7evaulxVoQ6y2+b5qnw68TGXKrrDCw6v9nXvJN1q4SEom+3KZosqqW4xFhukQ36Y8wV XLfa1y/ECXFiLsR8W3cpTIRC0DwlLovKoiHnF2HettWTQPplYWBOKnsOogBldyLOfXsl a65l1AIVNdnmv3QfzwOZ2XF98cxIkOneoIE17IsHpx5B36N2fmk5MQ7ClaIzlHo3DxMR O46udSj8Wx6CYO16/s5lUN2BDcL6lB0vK9psIxUiVNf+sOFAwZmkLG1RRQS4xujyE/Vy cQ== Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nbn5b6wq4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:35 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30QAlWRh014468; Thu, 26 Jan 2023 13:14:33 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma02fra.de.ibm.com (PPS) with ESMTPS id 3n87p6cmjf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:33 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30QDETP848693646 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Jan 2023 13:14:30 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DCD3020040; Thu, 26 Jan 2023 13:14:29 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A92F120043; Thu, 26 Jan 2023 13:14:29 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 26 Jan 2023 13:14:29 +0000 (GMT) From: Mikhail Zaslonko To: Andrew Morton Cc: LKML , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Mikhail Zaslonko Subject: [PATCH 2/8] lib/zlib: Implement switching between DFLTCC and software Date: Thu, 26 Jan 2023 14:14:22 +0100 Message-Id: <20230126131428.1222214-3-zaslonko@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230126131428.1222214-1-zaslonko@linux.ibm.com> References: <20230126131428.1222214-1-zaslonko@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: bDsiIdKX97KHrIICD7h_9VtwSLHIbDVe X-Proofpoint-ORIG-GUID: bDsiIdKX97KHrIICD7h_9VtwSLHIbDVe X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-26_05,2023-01-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxscore=0 mlxlogscore=875 adultscore=0 clxscore=1011 impostorscore=0 bulkscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301260126 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756091142820117384?= X-GMAIL-MSGID: =?utf-8?q?1756091142820117384?= This commit is based on: https://github.com/zlib-ng/zlib-ng/commit/fc04275 Signed-off-by: Mikhail Zaslonko Acked-by: Ilya Leoshkevich --- lib/zlib_dfltcc/dfltcc_deflate.c | 38 ++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/lib/zlib_dfltcc/dfltcc_deflate.c b/lib/zlib_dfltcc/dfltcc_deflate.c index 6c946e8532ee..dc85ec890163 100644 --- a/lib/zlib_dfltcc/dfltcc_deflate.c +++ b/lib/zlib_dfltcc/dfltcc_deflate.c @@ -112,30 +112,36 @@ int dfltcc_deflate( int soft_bcc; int no_flush; - if (!dfltcc_can_deflate(strm)) + if (!dfltcc_can_deflate(strm)) { + /* Clear history. */ + if (flush == Z_FULL_FLUSH) + param->hl = 0; return 0; + } again: masked_avail_in = 0; soft_bcc = 0; no_flush = flush == Z_NO_FLUSH; - /* Trailing empty block. Switch to software, except when Continuation Flag - * is set, which means that DFLTCC has buffered some output in the - * parameter block and needs to be called again in order to flush it. + /* No input data. Return, except when Continuation Flag is set, which means + * that DFLTCC has buffered some output in the parameter block and needs to + * be called again in order to flush it. */ - if (flush == Z_FINISH && strm->avail_in == 0 && !param->cf) { - if (param->bcf) { - /* A block is still open, and the hardware does not support closing - * blocks without adding data. Thus, close it manually. - */ + if (strm->avail_in == 0 && !param->cf) { + /* A block is still open, and the hardware does not support closing + * blocks without adding data. Thus, close it manually. + */ + if (!no_flush && param->bcf) { send_eobs(strm, param); param->bcf = 0; } - return 0; - } - - if (strm->avail_in == 0 && !param->cf) { + /* Let one of deflate_* functions write a trailing empty block. */ + if (flush == Z_FINISH) + return 0; + /* Clear history. */ + if (flush == Z_FULL_FLUSH) + param->hl = 0; *result = need_more; return 1; } @@ -189,7 +195,7 @@ int dfltcc_deflate( param->cvt = CVT_ADLER32; if (!no_flush) /* We need to close a block. Always do this in software - when there is - * no input data, the hardware will not nohor BCC. */ + * no input data, the hardware will not hohor BCC. */ soft_bcc = 1; if (flush == Z_FINISH && !param->bcf) /* We are about to open a BFINAL block, set Block Header Final bit @@ -204,8 +210,8 @@ int dfltcc_deflate( param->sbb = (unsigned int)state->bi_valid; if (param->sbb > 0) *strm->next_out = (Byte)state->bi_buf; - if (param->hl) - param->nt = 0; /* Honor history */ + /* Honor history and check value */ + param->nt = 0; param->cv = strm->adler; /* When opening a block, choose a Huffman-Table Type */ From patchwork Thu Jan 26 13:14:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zaslonko Mikhail X-Patchwork-Id: 48630 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp264641wrn; Thu, 26 Jan 2023 05:17:17 -0800 (PST) X-Google-Smtp-Source: AK7set//PF386c4VzQf5xGmZmCRF9W80vwEfnT9XxYecgT6TBWbEkxuwFGdh2yLpoZ8vVP9YaKbX X-Received: by 2002:aa7:dd16:0:b0:4a0:a767:6138 with SMTP id i22-20020aa7dd16000000b004a0a7676138mr7250009edv.22.1674739037791; Thu, 26 Jan 2023 05:17:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674739037; cv=none; d=google.com; s=arc-20160816; b=Dvj6EgM1WBsOh44DJsFWeHQt0O9SeEx1m6gVQ4s9P9GtR9+qhChbNo2onaFqskb55+ 4QhWGmIK3qzmpxV7rDweeE1+65TopTpQfqA/7oQXnEhuIFooRH0CGO+LkHNJOai2fTlS aSLxBE+mUH27A0qqvAXHJEfb/9A0uJYEKs6NEyl9vFuG2OcrOs/j93gTOfflTxRoIyoh lVu4AxqrwGoTXBrVFs66DkfRw21SEGjYSLJ1L1afE2T3MDC5BzxEDM2HqrvIOwTQYtsT B5Bph6RjuH9zANegNXx8pGQoxHNi7FsSUGRykreY6ljghzK6O866XqPiDX14OZ9R2FRg PnCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xZnK30byH773TSlmzCY8FkqJLqxkE35ZGt5rDfbB3AQ=; b=UWmzTEq1pdsXJL1uRJnefzMFHRsvWFPxHxdyXdXBDdarwCP1F+0zZkUZ2ekQqVmeru fkPTJgWqTXHI3e93kyJY3dT1xj1nMg3gXZ5+L/rJHwmMR6HS9Oj7PxmUJ7kqafQOu0P9 JboLiQrIirogg4VdYEdkUVBs9sHjvjSXG/BUsyu2r4hzOOHBA9lOZZXBoGgDqaOMmhry p3+elM/KN7JoPWUbUn+eZzQs2BqCRzl0/8wYc4TuQ/D0XD32lxqGMvD8YRFRTupPfIAy 66bRzeyBrDLp8tBTymVEVLw9ANEq/xDVdA9RQ3PKpRGCFaeSHGES99e38IvHBcYF0zND mU+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=sjZgNM8g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j1-20020a170906104100b008779b708a5bsi1408178ejj.288.2023.01.26.05.16.53; Thu, 26 Jan 2023 05:17:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=sjZgNM8g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236740AbjAZNP3 (ORCPT + 99 others); Thu, 26 Jan 2023 08:15:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236635AbjAZNOx (ORCPT ); Thu, 26 Jan 2023 08:14:53 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6085569515 for ; Thu, 26 Jan 2023 05:14:37 -0800 (PST) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30QCvE8o024932; Thu, 26 Jan 2023 13:14:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=xZnK30byH773TSlmzCY8FkqJLqxkE35ZGt5rDfbB3AQ=; b=sjZgNM8gGykl6+aE/qeCiuyijmbNc0q6rOkgQLJxU2Ju7E6Gruz3NWZgFOMFVndwwUb8 nQJdFd3XAaMKXA8YeTmQ7BEYVHumnRN6OVaF9HwiQ+HvoS93s8aKI0hI7Q+JNBV8kWDl NnxYAwKABOJwwQrqvAHPKoJ1w8l8QVoPRSsEnZpSBsGEuz+X7CeoQDbJYiAI3uHdWazC 654+VhxB0mrUOfW9hHlK8ZRq40+b9mcTOY2dACQpmplc+wr7MZFTVp+/7Z/XNggx9IxJ Tdjis8sVU48ioO6WAqYtOdJYb1PkTe0RvSzqrai8qOw+yWZdyOJG8uz4ZSou4zr1gadW qA== Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nbsymrh0d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:36 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30QApjVV015356; Thu, 26 Jan 2023 13:14:33 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3n87afeds4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:33 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30QDEUia47251910 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Jan 2023 13:14:30 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 270F920040; Thu, 26 Jan 2023 13:14:30 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E7B512004B; Thu, 26 Jan 2023 13:14:29 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 26 Jan 2023 13:14:29 +0000 (GMT) From: Mikhail Zaslonko To: Andrew Morton Cc: LKML , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Mikhail Zaslonko Subject: [PATCH 3/8] lib/zlib: Fix DFLTCC not flushing EOBS when creating raw streams Date: Thu, 26 Jan 2023 14:14:23 +0100 Message-Id: <20230126131428.1222214-4-zaslonko@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230126131428.1222214-1-zaslonko@linux.ibm.com> References: <20230126131428.1222214-1-zaslonko@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: KLd4gjgFqewnrScAbuH9bAGRAo3XtEgo X-Proofpoint-ORIG-GUID: KLd4gjgFqewnrScAbuH9bAGRAo3XtEgo X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-26_05,2023-01-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 impostorscore=0 bulkscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=758 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301260126 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756091161278188965?= X-GMAIL-MSGID: =?utf-8?q?1756091161278188965?= This commit is based on: https://github.com/zlib-ng/zlib-ng/commit/ca99a88 Signed-off-by: Mikhail Zaslonko Acked-by: Ilya Leoshkevich --- lib/zlib_deflate/deflate.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/zlib_deflate/deflate.c b/lib/zlib_deflate/deflate.c index 8a878d0d892c..f30d6b8a69b2 100644 --- a/lib/zlib_deflate/deflate.c +++ b/lib/zlib_deflate/deflate.c @@ -451,17 +451,24 @@ int zlib_deflate( Assert(strm->avail_out > 0, "bug2"); if (flush != Z_FINISH) return Z_OK; - if (s->noheader) return Z_STREAM_END; - /* Write the zlib trailer (adler32) */ - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); + if (!s->noheader) { + /* Write zlib trailer (adler32) */ + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } flush_pending(strm); /* If avail_out is zero, the application will call deflate again * to flush the rest. */ - s->noheader = -1; /* write the trailer only once! */ - return s->pending != 0 ? Z_OK : Z_STREAM_END; + if (!s->noheader) { + s->noheader = -1; /* write the trailer only once! */ + } + if (s->pending == 0) { + Assert(s->bi_valid == 0, "bi_buf not flushed"); + return Z_STREAM_END; + } + return Z_OK; } /* ========================================================================= */ From patchwork Thu Jan 26 13:14:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zaslonko Mikhail X-Patchwork-Id: 48636 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp265952wrn; Thu, 26 Jan 2023 05:20:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXs6PXL9rY59bah5XWroIP5GrgrV6mayUwKg9Ry+jptBHAJY+qqll7Y8wx2wXumwLb/OZYwf X-Received: by 2002:aa7:de95:0:b0:497:65e6:f6e4 with SMTP id j21-20020aa7de95000000b0049765e6f6e4mr35475820edv.14.1674739227642; Thu, 26 Jan 2023 05:20:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674739227; cv=none; d=google.com; s=arc-20160816; b=Byije4Y8Q2YLB+BdxG6137vSARtNSS9uulkAx1Y0Y9jSwGDTSez5J9WkeoMrmxVutY qqf8/b7M1ExIh3/LKzs2v+YDA9b9sZtY/ysoPlov1a09MboULeCtWESfLBxlgjsmmK/d aQy44vhWfCJSgvj4yDDpnglVtpVq+XeB/TtRQklFBsGab7cuixgRKIFSe6ZoOUlY3Pxy ioW0KEzw3lgquLM6h1rOxFlsP99EJ3Q7FfoZECpvP8a8j75gqxuwBELywqADb8ykY3yL MeaIGhEug/4UvUpMcsf7BD0Ls/wgEmFCFw9LpnHoRzHxUS6uT+obMmQU8+isEwjBSuS7 e8Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PAn+dHflp2HX8qjUM0ZtsYPKZ9xsKmu5OnG1Dj3Iljk=; b=TeCYPnQQTNWs9t6QTjEljw/V1awfvsoaA2Xc50LxdCVmymx/uQHiedTgajmnIBkRP5 Z5cY/aUwLhtZQuvd/Ldl8y8NPd8dIu6z0W2Y6aha/WhA2Ndz5KqgAGuPx9CGhWpT4vCy i7NBssgCgaL5zLxanzl0uMK8bq4B2WVTTB+69nNfey8mAq4SpN+J3008/CXczOfh8SCM /IfwlIDq4HZBwOKXL3YZJrnCmuAQsmNWYFMUHaJF3t1rPwGp4e4VutTw3hHKew3WYTyU 4/L7Y1S4Veqku3Va5CLijr1NYz2l+NcAKNN7Is49m7tt0L9WOwl4Nr83tC6ZXQDafK3M 6qeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Ot5LMrGV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y6-20020a056402440600b0046b2327bf88si2597056eda.76.2023.01.26.05.20.03; Thu, 26 Jan 2023 05:20:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Ot5LMrGV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236821AbjAZNQz (ORCPT + 99 others); Thu, 26 Jan 2023 08:16:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236606AbjAZNOw (ORCPT ); Thu, 26 Jan 2023 08:14:52 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C702B67786 for ; Thu, 26 Jan 2023 05:14:36 -0800 (PST) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30QD0CJ9007255; Thu, 26 Jan 2023 13:14:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=PAn+dHflp2HX8qjUM0ZtsYPKZ9xsKmu5OnG1Dj3Iljk=; b=Ot5LMrGVIgrlue1ujEVHAqOD5mtlKm5qI4IQGKxqejck1IVobwjEYkOai+qs3BrDkjPJ VwG0OfTwagt6axZY2Mw1SdlpQ4FxcT2UjykDWvAjlxAS4ys/mNxIUClZ9yeSVC6luyEL MJNot4Zbhx+3lOyH34qJmlD7hJi768vzyvyGJXxzWISql3OvQwej7hzGkRqBeAWti20y 1KWzsnPbcryOCvsWxgEsZ12Advqn95bNMr2J/H5CbniZvY6KVTLwH9r0WyFll3otdX+4 3J6i2wdCXWIKqk+3hq/8ELRqv7oCRCZJcJzHgjfYgU2ialAzZ4e4/EnHiH6AtKq37tAI iw== Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nbsb1sdjn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:35 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30QCLmfV019104; Thu, 26 Jan 2023 13:14:33 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3n87p6pdjd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:33 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30QDEU6C47251912 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Jan 2023 13:14:30 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6DC7320040; Thu, 26 Jan 2023 13:14:30 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 30D7E20043; Thu, 26 Jan 2023 13:14:30 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 26 Jan 2023 13:14:30 +0000 (GMT) From: Mikhail Zaslonko To: Andrew Morton Cc: LKML , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Mikhail Zaslonko Subject: [PATCH 4/8] lib/zlib: Fix DFLTCC ignoring flush modes when avail_in == 0 Date: Thu, 26 Jan 2023 14:14:24 +0100 Message-Id: <20230126131428.1222214-5-zaslonko@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230126131428.1222214-1-zaslonko@linux.ibm.com> References: <20230126131428.1222214-1-zaslonko@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: SBa6gkwlLfS6xCJajZS5tvDav8CNnH8D X-Proofpoint-ORIG-GUID: SBa6gkwlLfS6xCJajZS5tvDav8CNnH8D X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-26_05,2023-01-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 impostorscore=0 clxscore=1015 bulkscore=0 malwarescore=0 priorityscore=1501 adultscore=0 mlxscore=0 mlxlogscore=709 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301260126 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756091360273311747?= X-GMAIL-MSGID: =?utf-8?q?1756091360273311747?= This commit is based on: https://github.com/zlib-ng/zlib-ng/commit/40acb3f Signed-off-by: Mikhail Zaslonko Acked-by: Ilya Leoshkevich --- lib/zlib_dfltcc/dfltcc_deflate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/zlib_dfltcc/dfltcc_deflate.c b/lib/zlib_dfltcc/dfltcc_deflate.c index dc85ec890163..211d344710d5 100644 --- a/lib/zlib_dfltcc/dfltcc_deflate.c +++ b/lib/zlib_dfltcc/dfltcc_deflate.c @@ -142,7 +142,8 @@ int dfltcc_deflate( /* Clear history. */ if (flush == Z_FULL_FLUSH) param->hl = 0; - *result = need_more; + /* Trigger block post-processing if necessary. */ + *result = no_flush ? need_more : block_done; return 1; } From patchwork Thu Jan 26 13:14:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zaslonko Mikhail X-Patchwork-Id: 48634 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp264962wrn; Thu, 26 Jan 2023 05:18:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXuWmDhoalFbT9ZL05W95DZtrh2zUBkAz1c64U9PKj8APDHOPtaK4nhtWuwHcHIHSW/D3Njd X-Received: by 2002:a17:907:c5c6:b0:877:8a55:2a26 with SMTP id ts6-20020a170907c5c600b008778a552a26mr26416532ejc.60.1674739083477; Thu, 26 Jan 2023 05:18:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674739083; cv=none; d=google.com; s=arc-20160816; b=ok00Jk4NscTB6QyrzB9zM8f4y8yMJOnaVqXTaLYNxdP+e/k2foi5ei9fjr4A355YOE ttRzxFzmwfjZJj3gT6cz79eS7elzJAiKDNK1nvrhS2U/pQvmjnd3SGBxnz2Wf1uloYpI 2fguX6j5gADuIqand4Bpuc+uHd7YF6eB1ekzWjTRgnNb/jDq/JrrchZidQe+Y26Vgq5p ZoVXjvQOEqwR83dK2eH17476cdnKHugDqD1JUYQKTieXA/+gnbyt8jBA+nJjYqOLjItp 6FYFF5TVffV2AXqBaFnpAcNViTouEoW1Apo2cj47enc8pcntR2wAL9i1WNwtehF9PiiT LvRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8gE6mK45lDqgsDNu1OfK5EkeRgwy2GF3MN9FQh0hxkI=; b=n/T9hYklDn5MEqBkzGc70B2IDOe+b68TWwgTNAANTm2GU3WiTSQSX7aGovmz5nWnPA PcHkOPqvoiLO3lIeJ/j+Hyg8ba6TcI8cMS2oODHXSAdK0XNNrKlvwXIZ+DaEBjXaoBp8 s1alHeRx5va/+O5UX71jtd2P4HPEnYzZGm3c02RnbMlK8eqYaBBttah5rhJjQ+/k5JQp wQ7rSXm4Iob5CaWUYzH/OWdGx/2tbXVS31v75jIoqYMc23uHrnBfGZCZlDdVoXxp3RdS uclv2y3gu8424s7zHofORr9G8k3pGK3bmQCrRG20vt0LDBe/vjgdOozT2ttPKy/ayKEq 7f6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=pZtHwRQJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vf17-20020a170907239100b0086fcc2f95c0si1069209ejb.455.2023.01.26.05.17.40; Thu, 26 Jan 2023 05:18:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=pZtHwRQJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236794AbjAZNPg (ORCPT + 99 others); Thu, 26 Jan 2023 08:15:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236668AbjAZNOy (ORCPT ); Thu, 26 Jan 2023 08:14:54 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2F1F6952C for ; Thu, 26 Jan 2023 05:14:39 -0800 (PST) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30QCEDhp016689; Thu, 26 Jan 2023 13:14:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=8gE6mK45lDqgsDNu1OfK5EkeRgwy2GF3MN9FQh0hxkI=; b=pZtHwRQJ13qxmLQIF3Jt8yOdeKjHKNBlW0kuSaSksP8Xo8du2RObcsem+yUyoGoqR1Fj PCRe/paPZroWbubEgQpkg2tOH/v7Wjj3tkoqBPa13WjyHh8OCV2Um/LrAYkynEJGUyv+ hgPL+KEA+Amnlszgovme7qzIPHHsF9/3njmUn2i6dcN3JJV07ZTxebUOlKCv/OVLucUn bk+WTEJMe1NaR85l8cmtrf5CK2WjXvX0sl3C3cNSm/s7LaPo2sGSmITE1afP5rfhjvkB V4mYfJLFsiyEOU4lJpUKDTfSuJBUxKmWHClODAppEtLNfyduIJ/1dYy5TLkb4b6uRIvn /A== Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3nbsbe1cay-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:38 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30PEm5SY031955; Thu, 26 Jan 2023 13:14:34 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma05fra.de.ibm.com (PPS) with ESMTPS id 3n87p64kar-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:34 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30QDEU0247448484 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Jan 2023 13:14:30 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB1D820040; Thu, 26 Jan 2023 13:14:30 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 77E6A2004E; Thu, 26 Jan 2023 13:14:30 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 26 Jan 2023 13:14:30 +0000 (GMT) From: Mikhail Zaslonko To: Andrew Morton Cc: LKML , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Mikhail Zaslonko Subject: [PATCH 5/8] lib/zlib: DFLTCC not writing header bits when avail_out == 0 Date: Thu, 26 Jan 2023 14:14:25 +0100 Message-Id: <20230126131428.1222214-6-zaslonko@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230126131428.1222214-1-zaslonko@linux.ibm.com> References: <20230126131428.1222214-1-zaslonko@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: X5Wz3b56pYRq5y1Zk6XneiEpKyjN0dl- X-Proofpoint-GUID: X5Wz3b56pYRq5y1Zk6XneiEpKyjN0dl- X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-26_05,2023-01-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 adultscore=0 clxscore=1015 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=976 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301260126 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756091209254805714?= X-GMAIL-MSGID: =?utf-8?q?1756091209254805714?= This commit is based on: https://github.com/zlib-ng/zlib-ng/commit/ce409c6 Signed-off-by: Mikhail Zaslonko Acked-by: Ilya Leoshkevich --- lib/zlib_dfltcc/dfltcc_deflate.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/zlib_dfltcc/dfltcc_deflate.c b/lib/zlib_dfltcc/dfltcc_deflate.c index 211d344710d5..d4c92f99808e 100644 --- a/lib/zlib_dfltcc/dfltcc_deflate.c +++ b/lib/zlib_dfltcc/dfltcc_deflate.c @@ -170,13 +170,18 @@ int dfltcc_deflate( param->bcf = 0; dfltcc_state->block_threshold = strm->total_in + dfltcc_state->block_size; - if (strm->avail_out == 0) { - *result = need_more; - return 1; - } } } + /* No space for compressed data. If we proceed, dfltcc_cmpr() will return + * DFLTCC_CC_OP1_TOO_SHORT without buffering header bits, but we will still + * set BCF=1, which is wrong. Avoid complications and return early. + */ + if (strm->avail_out == 0) { + *result = need_more; + return 1; + } + /* The caller gave us too much data. Pass only one block worth of * uncompressed data to DFLTCC and mask the rest, so that on the next * iteration we start a new block. From patchwork Thu Jan 26 13:14:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zaslonko Mikhail X-Patchwork-Id: 48633 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp264784wrn; Thu, 26 Jan 2023 05:17:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXvy7IDFbGBpC/E9+obVn2WO+5IYFnNsvoe7K6bdAtWg9oQ/pwx8gEtMcyOTaeQWoRFoaDgE X-Received: by 2002:a17:907:d606:b0:86f:b541:cd02 with SMTP id wd6-20020a170907d60600b0086fb541cd02mr44140331ejc.28.1674739056853; Thu, 26 Jan 2023 05:17:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674739056; cv=none; d=google.com; s=arc-20160816; b=UqN36kwzdKh4GRpI5umodA8UAqIXDfY73OZy6TGJPhiKZhmj60vY5FkqbJv38hxWuX bByyqY5HiS2HSPMEkZuzpMkpd2G3xjKGOiwFSc4nxBqtid0xJntHd6T+gZS8ggxbd4UZ 0BtAHdlI+xdk4VkCWk1gXdoj+fsF7CapIvdqp2ubORpdTMZTLay1lv27tcn7gaL9m7XN i0stJJY1XyLjPaLp2kjLasT+3rNhFpMezodr7ifH13ZaN7ieIFFNTI+dzV1KrVBOFN82 yTwzd0oedP6dKvrXdccb3ymHQ56FgBki0K4hL8RXKimihHlUXt9jHTAVAbKh7aJz/I6m bFgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=a2bA49cvuyD381/1p9ghOoEE1TksbHTn3fwVaM0YUgM=; b=0Bto/1ff+NSS3SbZb2siSHixRXKaL+1SyEDIkEE6QkQVBXLA92HeSzUiXzK2gAqdvA 1fd1TrbSTVpQj7nlWKfZXBCOY+c5tVjeFJX7tJesEIt/gK0mbioHe3SCwrG8uHw/5BQe 50KuI3S9c3mg5yeoIv8YGhC53Enxy6yzXzRmaTaP/w+NkwR3oszJDfkcfDFBbRVi+JV6 LfWIxrrtrQX3d8dsZU9g5nRo4nPgrw6rgESCzi42KRlZRcpgFAbmXFzwsmjd8lW1hLUp YhbS8/Ab7RYBXSgScQH+XlG7+z4UDQrT4X4RFnMCHo3/OpcjG4Kzai10P7BIyCVN53mA 8Dig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=X+tD3xUD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y14-20020a17090668ce00b007ae127c6c80si1416690ejr.672.2023.01.26.05.17.12; Thu, 26 Jan 2023 05:17:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=X+tD3xUD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236783AbjAZNPe (ORCPT + 99 others); Thu, 26 Jan 2023 08:15:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236669AbjAZNOy (ORCPT ); Thu, 26 Jan 2023 08:14:54 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 911AD69536 for ; Thu, 26 Jan 2023 05:14:38 -0800 (PST) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30QCux2O024619; Thu, 26 Jan 2023 13:14:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=a2bA49cvuyD381/1p9ghOoEE1TksbHTn3fwVaM0YUgM=; b=X+tD3xUD2B3Ahn2Ffjsg5LjSjuFq0yxgbuSXJPATGdtNQaQ/0gOXk62e6brKTtzWu6CE PNiiWdyoW2sbgsjG/ObeJdk+QaND5+Q3azGgbS4pVmRoflJPJtaQVdx8kfP+sqsFV0hJ i4l6Lw6sPQHGJ/DGcEzs88frVDVG3txbjO3gGJIkO9k/r9fR3rkuzHCyQKPCE9myveoL 9gNlhUiwlmA0uEKpOIgxRoH8hDksY4Z/57J365CWTohbHViyRgCNQcYjHtrixePrptNN Q0cWpQaONa/XZfRuK6ITQE2ztMC2OYjodXl5//yCLmHHW7mn9Llp0f/rkpeYHJR/6Chq ng== Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nbsymrh0r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:37 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30Q3rPFD022554; Thu, 26 Jan 2023 13:14:34 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma01fra.de.ibm.com (PPS) with ESMTPS id 3n87p6cmga-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:34 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30QDEVSd47907112 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Jan 2023 13:14:31 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EE3C420040; Thu, 26 Jan 2023 13:14:30 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B5A6120043; Thu, 26 Jan 2023 13:14:30 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 26 Jan 2023 13:14:30 +0000 (GMT) From: Mikhail Zaslonko To: Andrew Morton Cc: LKML , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Mikhail Zaslonko Subject: [PATCH 6/8] lib/zlib: Split deflate and inflate states for DFLTCC Date: Thu, 26 Jan 2023 14:14:26 +0100 Message-Id: <20230126131428.1222214-7-zaslonko@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230126131428.1222214-1-zaslonko@linux.ibm.com> References: <20230126131428.1222214-1-zaslonko@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: VRFowJ6KceT2uAYw4Ig1yUQiCA0jdj2v X-Proofpoint-ORIG-GUID: VRFowJ6KceT2uAYw4Ig1yUQiCA0jdj2v X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-26_05,2023-01-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 impostorscore=0 bulkscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301260126 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756091181429264721?= X-GMAIL-MSGID: =?utf-8?q?1756091181429264721?= Currently deflate and inflate both use a common state struct. There are several variables in this struct that we don't need for inflate, and more may be coming in the future. Therefore split them in two separate structs. Apart from that, introduce separate headers for dfltcc_deflate and dfltcc_inflate. This commit is based on: https://github.com/zlib-ng/zlib-ng/commit/c592b1b Signed-off-by: Mikhail Zaslonko Acked-by: Ilya Leoshkevich --- lib/zlib_deflate/deflate.c | 4 +-- lib/zlib_dfltcc/dfltcc.c | 25 ++------------- lib/zlib_dfltcc/dfltcc.h | 52 ++++++-------------------------- lib/zlib_dfltcc/dfltcc_deflate.c | 35 ++++++++++++++++----- lib/zlib_dfltcc/dfltcc_deflate.h | 21 +++++++++++++ lib/zlib_dfltcc/dfltcc_inflate.c | 10 +++++- lib/zlib_dfltcc/dfltcc_inflate.h | 37 +++++++++++++++++++++++ lib/zlib_inflate/inflate.c | 2 +- 8 files changed, 110 insertions(+), 76 deletions(-) create mode 100644 lib/zlib_dfltcc/dfltcc_deflate.h create mode 100644 lib/zlib_dfltcc/dfltcc_inflate.h diff --git a/lib/zlib_deflate/deflate.c b/lib/zlib_deflate/deflate.c index f30d6b8a69b2..3a1d8d34182e 100644 --- a/lib/zlib_deflate/deflate.c +++ b/lib/zlib_deflate/deflate.c @@ -54,7 +54,7 @@ /* architecture-specific bits */ #ifdef CONFIG_ZLIB_DFLTCC -# include "../zlib_dfltcc/dfltcc.h" +# include "../zlib_dfltcc/dfltcc_deflate.h" #else #define DEFLATE_RESET_HOOK(strm) do {} while (0) #define DEFLATE_HOOK(strm, flush, bstate) 0 @@ -106,7 +106,7 @@ typedef struct deflate_workspace { deflate_state deflate_memory; #ifdef CONFIG_ZLIB_DFLTCC /* State memory for s390 hardware deflate */ - struct dfltcc_state dfltcc_memory; + struct dfltcc_deflate_state dfltcc_memory; #endif Byte *window_memory; Pos *prev_memory; diff --git a/lib/zlib_dfltcc/dfltcc.c b/lib/zlib_dfltcc/dfltcc.c index 782f76e9d4da..ac6ac9739f5b 100644 --- a/lib/zlib_dfltcc/dfltcc.c +++ b/lib/zlib_dfltcc/dfltcc.c @@ -23,37 +23,18 @@ char *oesc_msg( } } -void dfltcc_reset( - z_streamp strm, - uInt size -) -{ - struct dfltcc_state *dfltcc_state = - (struct dfltcc_state *)((char *)strm->state + size); - struct dfltcc_qaf_param *param = - (struct dfltcc_qaf_param *)&dfltcc_state->param; - +void dfltcc_reset_state(struct dfltcc_state *dfltcc_state) { /* Initialize available functions */ if (is_dfltcc_enabled()) { - dfltcc(DFLTCC_QAF, param, NULL, NULL, NULL, NULL, NULL); - memmove(&dfltcc_state->af, param, sizeof(dfltcc_state->af)); + dfltcc(DFLTCC_QAF, &dfltcc_state->param, NULL, NULL, NULL, NULL, NULL); + memmove(&dfltcc_state->af, &dfltcc_state->param, sizeof(dfltcc_state->af)); } else memset(&dfltcc_state->af, 0, sizeof(dfltcc_state->af)); /* Initialize parameter block */ memset(&dfltcc_state->param, 0, sizeof(dfltcc_state->param)); dfltcc_state->param.nt = 1; - - /* Initialize tuning parameters */ - if (zlib_dfltcc_support == ZLIB_DFLTCC_FULL_DEBUG) - dfltcc_state->level_mask = DFLTCC_LEVEL_MASK_DEBUG; - else - dfltcc_state->level_mask = DFLTCC_LEVEL_MASK; - dfltcc_state->block_size = DFLTCC_BLOCK_SIZE; - dfltcc_state->block_threshold = DFLTCC_FIRST_FHT_BLOCK_SIZE; - dfltcc_state->dht_threshold = DFLTCC_DHT_MIN_SAMPLE_SIZE; dfltcc_state->param.ribm = DFLTCC_RIBM; } -EXPORT_SYMBOL(dfltcc_reset); MODULE_LICENSE("GPL"); diff --git a/lib/zlib_dfltcc/dfltcc.h b/lib/zlib_dfltcc/dfltcc.h index 1f63094366e9..b96232bdd44d 100644 --- a/lib/zlib_dfltcc/dfltcc.h +++ b/lib/zlib_dfltcc/dfltcc.h @@ -93,64 +93,32 @@ static_assert(sizeof(struct dfltcc_param_v0) == 1536); struct dfltcc_state { struct dfltcc_param_v0 param; /* Parameter block */ struct dfltcc_qaf_param af; /* Available functions */ + char msg[64]; /* Buffer for strm->msg */ +}; + +/* + * Extension of inflate_state and deflate_state for DFLTCC. + */ +struct dfltcc_deflate_state { + struct dfltcc_state common; /* Parameter block */ uLong level_mask; /* Levels on which to use DFLTCC */ uLong block_size; /* New block each X bytes */ uLong block_threshold; /* New block after total_in > X */ uLong dht_threshold; /* New block only if avail_in >= X */ - char msg[64]; /* Buffer for strm->msg */ }; #define ALIGN_UP(p, size) (__typeof__(p))(((uintptr_t)(p) + ((size) - 1)) & ~((size) - 1)) /* Resides right after inflate_state or deflate_state */ #define GET_DFLTCC_STATE(state) ((struct dfltcc_state *)((char *)(state) + ALIGN_UP(sizeof(*state), 8))) -/* External functions */ -int dfltcc_can_deflate(z_streamp strm); -int dfltcc_deflate(z_streamp strm, - int flush, - block_state *result); -void dfltcc_reset(z_streamp strm, uInt size); -int dfltcc_can_inflate(z_streamp strm); -typedef enum { - DFLTCC_INFLATE_CONTINUE, - DFLTCC_INFLATE_BREAK, - DFLTCC_INFLATE_SOFTWARE, -} dfltcc_inflate_action; -dfltcc_inflate_action dfltcc_inflate(z_streamp strm, - int flush, int *ret); +void dfltcc_reset_state(struct dfltcc_state *dfltcc_state); + static inline int is_dfltcc_enabled(void) { return (zlib_dfltcc_support != ZLIB_DFLTCC_DISABLED && test_facility(DFLTCC_FACILITY)); } -#define DEFLATE_RESET_HOOK(strm) \ - dfltcc_reset((strm), sizeof(deflate_state)) - -#define DEFLATE_HOOK dfltcc_deflate - -#define DEFLATE_NEED_CHECKSUM(strm) (!dfltcc_can_deflate((strm))) - #define DEFLATE_DFLTCC_ENABLED() is_dfltcc_enabled() -#define INFLATE_RESET_HOOK(strm) \ - dfltcc_reset((strm), sizeof(struct inflate_state)) - -#define INFLATE_TYPEDO_HOOK(strm, flush) \ - if (dfltcc_can_inflate((strm))) { \ - dfltcc_inflate_action action; \ -\ - RESTORE(); \ - action = dfltcc_inflate((strm), (flush), &ret); \ - LOAD(); \ - if (action == DFLTCC_INFLATE_CONTINUE) \ - break; \ - else if (action == DFLTCC_INFLATE_BREAK) \ - goto inf_leave; \ - } - -#define INFLATE_NEED_CHECKSUM(strm) (!dfltcc_can_inflate((strm))) - -#define INFLATE_NEED_UPDATEWINDOW(strm) (!dfltcc_can_inflate((strm))) - #endif /* DFLTCC_H */ diff --git a/lib/zlib_dfltcc/dfltcc_deflate.c b/lib/zlib_dfltcc/dfltcc_deflate.c index d4c92f99808e..80924f067c24 100644 --- a/lib/zlib_dfltcc/dfltcc_deflate.c +++ b/lib/zlib_dfltcc/dfltcc_deflate.c @@ -2,11 +2,13 @@ #include "../zlib_deflate/defutil.h" #include "dfltcc_util.h" -#include "dfltcc.h" +#include "dfltcc_deflate.h" #include #include #include +#define GET_DFLTCC_DEFLATE_STATE(state) ((struct dfltcc_deflate_state *)GET_DFLTCC_STATE(state)) + /* * Compress. */ @@ -15,7 +17,7 @@ int dfltcc_can_deflate( ) { deflate_state *state = (deflate_state *)strm->state; - struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state); + struct dfltcc_deflate_state *dfltcc_state = GET_DFLTCC_DEFLATE_STATE(state); /* Check for kernel dfltcc command line parameter */ if (zlib_dfltcc_support == ZLIB_DFLTCC_DISABLED || @@ -28,15 +30,32 @@ int dfltcc_can_deflate( return 0; /* Unsupported hardware */ - if (!is_bit_set(dfltcc_state->af.fns, DFLTCC_GDHT) || - !is_bit_set(dfltcc_state->af.fns, DFLTCC_CMPR) || - !is_bit_set(dfltcc_state->af.fmts, DFLTCC_FMT0)) + if (!is_bit_set(dfltcc_state->common.af.fns, DFLTCC_GDHT) || + !is_bit_set(dfltcc_state->common.af.fns, DFLTCC_CMPR) || + !is_bit_set(dfltcc_state->common.af.fmts, DFLTCC_FMT0)) return 0; return 1; } EXPORT_SYMBOL(dfltcc_can_deflate); +void dfltcc_reset_deflate_state(z_streamp strm) { + deflate_state *state = (deflate_state *)strm->state; + struct dfltcc_deflate_state *dfltcc_state = GET_DFLTCC_DEFLATE_STATE(state); + + dfltcc_reset_state(&dfltcc_state->common); + + /* Initialize tuning parameters */ + if (zlib_dfltcc_support == ZLIB_DFLTCC_FULL_DEBUG) + dfltcc_state->level_mask = DFLTCC_LEVEL_MASK_DEBUG; + else + dfltcc_state->level_mask = DFLTCC_LEVEL_MASK; + dfltcc_state->block_size = DFLTCC_BLOCK_SIZE; + dfltcc_state->block_threshold = DFLTCC_FIRST_FHT_BLOCK_SIZE; + dfltcc_state->dht_threshold = DFLTCC_DHT_MIN_SAMPLE_SIZE; +} +EXPORT_SYMBOL(dfltcc_reset_deflate_state); + static void dfltcc_gdht( z_streamp strm ) @@ -104,8 +123,8 @@ int dfltcc_deflate( ) { deflate_state *state = (deflate_state *)strm->state; - struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state); - struct dfltcc_param_v0 *param = &dfltcc_state->param; + struct dfltcc_deflate_state *dfltcc_state = GET_DFLTCC_DEFLATE_STATE(state); + struct dfltcc_param_v0 *param = &dfltcc_state->common.param; uInt masked_avail_in; dfltcc_cc cc; int need_empty_block; @@ -244,7 +263,7 @@ int dfltcc_deflate( } while (cc == DFLTCC_CC_AGAIN); /* Translate parameter block to stream */ - strm->msg = oesc_msg(dfltcc_state->msg, param->oesc); + strm->msg = oesc_msg(dfltcc_state->common.msg, param->oesc); state->bi_valid = param->sbb; if (state->bi_valid == 0) state->bi_buf = 0; /* Avoid accessing next_out */ diff --git a/lib/zlib_dfltcc/dfltcc_deflate.h b/lib/zlib_dfltcc/dfltcc_deflate.h new file mode 100644 index 000000000000..be44b43833b1 --- /dev/null +++ b/lib/zlib_dfltcc/dfltcc_deflate.h @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: Zlib +#ifndef DFLTCC_DEFLATE_H +#define DFLTCC_DEFLATE_H + +#include "dfltcc.h" + +/* External functions */ +int dfltcc_can_deflate(z_streamp strm); +int dfltcc_deflate(z_streamp strm, + int flush, + block_state *result); +void dfltcc_reset_deflate_state(z_streamp strm); + +#define DEFLATE_RESET_HOOK(strm) \ + dfltcc_reset_deflate_state((strm)) + +#define DEFLATE_HOOK dfltcc_deflate + +#define DEFLATE_NEED_CHECKSUM(strm) (!dfltcc_can_deflate((strm))) + +#endif /* DFLTCC_DEFLATE_H */ diff --git a/lib/zlib_dfltcc/dfltcc_inflate.c b/lib/zlib_dfltcc/dfltcc_inflate.c index fb60b5a6a1cb..a16f416c8811 100644 --- a/lib/zlib_dfltcc/dfltcc_inflate.c +++ b/lib/zlib_dfltcc/dfltcc_inflate.c @@ -2,7 +2,7 @@ #include "../zlib_inflate/inflate.h" #include "dfltcc_util.h" -#include "dfltcc.h" +#include "dfltcc_inflate.h" #include #include #include @@ -32,6 +32,14 @@ int dfltcc_can_inflate( } EXPORT_SYMBOL(dfltcc_can_inflate); +void dfltcc_reset_inflate_state(z_streamp strm) { + struct inflate_state *state = (struct inflate_state *)strm->state; + struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state); + + dfltcc_reset_state(dfltcc_state); +} +EXPORT_SYMBOL(dfltcc_reset_inflate_state); + static int dfltcc_was_inflate_used( z_streamp strm ) diff --git a/lib/zlib_dfltcc/dfltcc_inflate.h b/lib/zlib_dfltcc/dfltcc_inflate.h new file mode 100644 index 000000000000..98d4bc42e526 --- /dev/null +++ b/lib/zlib_dfltcc/dfltcc_inflate.h @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: Zlib +#ifndef DFLTCC_INFLATE_H +#define DFLTCC_INFLATE_H + +#include "dfltcc.h" + +/* External functions */ +void dfltcc_reset_inflate_state(z_streamp strm); +int dfltcc_can_inflate(z_streamp strm); +typedef enum { + DFLTCC_INFLATE_CONTINUE, + DFLTCC_INFLATE_BREAK, + DFLTCC_INFLATE_SOFTWARE, +} dfltcc_inflate_action; +dfltcc_inflate_action dfltcc_inflate(z_streamp strm, + int flush, int *ret); +#define INFLATE_RESET_HOOK(strm) \ + dfltcc_reset_inflate_state((strm)) + +#define INFLATE_TYPEDO_HOOK(strm, flush) \ + if (dfltcc_can_inflate((strm))) { \ + dfltcc_inflate_action action; \ +\ + RESTORE(); \ + action = dfltcc_inflate((strm), (flush), &ret); \ + LOAD(); \ + if (action == DFLTCC_INFLATE_CONTINUE) \ + break; \ + else if (action == DFLTCC_INFLATE_BREAK) \ + goto inf_leave; \ + } + +#define INFLATE_NEED_CHECKSUM(strm) (!dfltcc_can_inflate((strm))) + +#define INFLATE_NEED_UPDATEWINDOW(strm) (!dfltcc_can_inflate((strm))) + +#endif /* DFLTCC_DEFLATE_H */ diff --git a/lib/zlib_inflate/inflate.c b/lib/zlib_inflate/inflate.c index ee39b5eb71f7..d1efad69f02b 100644 --- a/lib/zlib_inflate/inflate.c +++ b/lib/zlib_inflate/inflate.c @@ -17,7 +17,7 @@ /* architecture-specific bits */ #ifdef CONFIG_ZLIB_DFLTCC -# include "../zlib_dfltcc/dfltcc.h" +# include "../zlib_dfltcc/dfltcc_inflate.h" #else #define INFLATE_RESET_HOOK(strm) do {} while (0) #define INFLATE_TYPEDO_HOOK(strm, flush) do {} while (0) From patchwork Thu Jan 26 13:14:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zaslonko Mikhail X-Patchwork-Id: 48632 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp264719wrn; Thu, 26 Jan 2023 05:17:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXta7fv73wz4AA5fybt9BWNvaLOAPBwtkJxxM6UbH/Wg3iqRbNvrc5wTRW2BkjuAvqYC6VGL X-Received: by 2002:a05:6402:5110:b0:499:8849:5fb3 with SMTP id m16-20020a056402511000b0049988495fb3mr48307358edd.31.1674739048998; Thu, 26 Jan 2023 05:17:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674739048; cv=none; d=google.com; s=arc-20160816; b=HKZAckIT53BibdLqHv4cXxydzixFkgsyi2rByUYfpdB+KPYX58ZBMwfOPbyLqnJbTr jMnkpZx9PuH1gEUW7zUTsZIJ6I2WCnIzwTZy9s/OD5/+1PWEK2raqRkvGBH4sI/PbY5b XQ1Vg7cHrJn5RZFEzl3Y+ZbBBt/KNn/CQPlsFH0xuUmjsnxnRW/o/IomUq/yYhBQfyOH Y8+4iCc8qo9Ko0CfMIvhSs71FBfbwNCEIbTNKBofy6ucAc/rpOboaT1M7tx0EGIMQSMt XafCTaESYdZ5kJ2Y7gj37BqqsATFjwWWgLMtnp9apatkL6UeV3XCgRvObF5WXWUtXDD0 yJrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7r2mDRtDMM+WwBgVFZDwhKhdqARVKa701LAzYRRKgZw=; b=g3AzLn0uJ4RXaB/r7xEfokbt5rFYrQDbIjbNuc+VFbW9r3JgyiO8xe1f+ZVs44xY13 WemB7m1H+2RU7+0xqT15vV2Tl8LG59gLqJqqFBh72qhQr7Ji81UM4AWn7YW/YXf3MfR0 DT71LMK3qppR684cunN2Gq7XpxLIDLUOVnLyfOaC9qq0srCyZAURjxNhwQm8LuUAd+yc gYM2VfUvUVnzucEepOGJD/Gl49FW/smBW9WK0nnLWSRRMTLMN7xk/1/E/cpKHBImgXo/ iU2hXHu+WhXpt+Wh3zs2hp+M1YkzzxPZ3C6f88wgL/otfrsmFO7OFVYC0kQakBOSOCId YQKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=qo34bdf4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h10-20020a056402280a00b004a0a8a35237si2382111ede.217.2023.01.26.05.17.04; Thu, 26 Jan 2023 05:17:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=qo34bdf4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236748AbjAZNPa (ORCPT + 99 others); Thu, 26 Jan 2023 08:15:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236656AbjAZNOx (ORCPT ); Thu, 26 Jan 2023 08:14:53 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65B8C69532 for ; Thu, 26 Jan 2023 05:14:38 -0800 (PST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30QCQbss005037; Thu, 26 Jan 2023 13:14:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=7r2mDRtDMM+WwBgVFZDwhKhdqARVKa701LAzYRRKgZw=; b=qo34bdf4FTrHDe9NgWhHP0uhlt1bHmcE27uwBdl4Zbalx2j1HlFWSiVOFKsZ4Zm2exwc vxB0gqlIHHN+J8JkKLTGwYRvfQjOxrYlSkTxneKg9WSX5iybalJJq2BkG8XfOfHv6v4w 4S2Rpmra8qPDVBDVTMywQyhTAM+129he45IDyY7kV8JFJQsdX6tEgYPqO/7yZVA6xLlU XR6snQbZuDXeMOQt7Kn7eoB/k3blyT8E5QDKdme24SkhK/rb8aqNmVJc9KKnwS38T6oj cKVOVI6/nG+jHjISm09SPzUgPukSlMvHTFv7hO3NMs1FDIgK4zaEM36RIhD04jzptMO9 rw== Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nbshdh6wb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:37 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30Q3rEOb027380; Thu, 26 Jan 2023 13:14:35 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma05fra.de.ibm.com (PPS) with ESMTPS id 3n87p64kas-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:34 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30QDEVia36700586 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Jan 2023 13:14:31 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 371AA20040; Thu, 26 Jan 2023 13:14:31 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 042402004B; Thu, 26 Jan 2023 13:14:31 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 26 Jan 2023 13:14:30 +0000 (GMT) From: Mikhail Zaslonko To: Andrew Morton Cc: LKML , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Mikhail Zaslonko Subject: [PATCH 7/8] lib/zlib: DFLTCC support inflate with small window Date: Thu, 26 Jan 2023 14:14:27 +0100 Message-Id: <20230126131428.1222214-8-zaslonko@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230126131428.1222214-1-zaslonko@linux.ibm.com> References: <20230126131428.1222214-1-zaslonko@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: qDRetewmgAVgNF7wKmpCBy68e0naAze1 X-Proofpoint-GUID: qDRetewmgAVgNF7wKmpCBy68e0naAze1 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-26_05,2023-01-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 lowpriorityscore=0 mlxscore=0 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 suspectscore=0 priorityscore=1501 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301260126 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756091173529816885?= X-GMAIL-MSGID: =?utf-8?q?1756091173529816885?= There is no hardware control for DFLTCC window size. After this change, software and hardware window formats no longer match: the software will use wbits and wsize, and the hardware will use HB_BITS and HB_SIZE. Since neither dictionary manipulation nor internal allocation functions are relevant to kernel zlib and zlib_inflate_workspacesize() always use MAX_WBITS for window size calculation, only dfltcc_can_inflate() and dfltcc_inflate() functions are affected by this patch. This commit is based on: https://github.com/zlib-ng/zlib-ng/commit/3eab317 Signed-off-by: Mikhail Zaslonko Acked-by: Ilya Leoshkevich --- lib/zlib_dfltcc/dfltcc_inflate.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/zlib_dfltcc/dfltcc_inflate.c b/lib/zlib_dfltcc/dfltcc_inflate.c index a16f416c8811..5786030c6dc2 100644 --- a/lib/zlib_dfltcc/dfltcc_inflate.c +++ b/lib/zlib_dfltcc/dfltcc_inflate.c @@ -22,10 +22,6 @@ int dfltcc_can_inflate( zlib_dfltcc_support == ZLIB_DFLTCC_DEFLATE_ONLY) return 0; - /* Unsupported compression settings */ - if (state->wbits != HB_BITS) - return 0; - /* Unsupported hardware */ return is_bit_set(dfltcc_state->af.fns, DFLTCC_XPND) && is_bit_set(dfltcc_state->af.fmts, DFLTCC_FMT0); @@ -129,8 +125,6 @@ dfltcc_inflate_action dfltcc_inflate( /* Translate stream to parameter block */ param->cvt = CVT_ADLER32; param->sbb = state->bits; - param->hl = state->whave; /* Software and hardware history formats match */ - param->ho = (state->write - state->whave) & ((1 << HB_BITS) - 1); if (param->hl) param->nt = 0; /* Honor history for the first block */ param->cv = state->check; @@ -144,8 +138,6 @@ dfltcc_inflate_action dfltcc_inflate( strm->msg = oesc_msg(dfltcc_state->msg, param->oesc); state->last = cc == DFLTCC_CC_OK; state->bits = param->sbb; - state->whave = param->hl; - state->write = (param->ho + param->hl) & ((1 << HB_BITS) - 1); state->check = param->cv; if (cc == DFLTCC_CC_OP2_CORRUPT && param->oesc != 0) { /* Report an error if stream is corrupted */ From patchwork Thu Jan 26 13:14:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zaslonko Mikhail X-Patchwork-Id: 48627 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp264467wrn; Thu, 26 Jan 2023 05:16:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXs6mQzfSi3pQ3LhXIOUCuyEcbns3F9GbEmXRhYj7VW1m4aK8Ro+6li6mLXBhdACrmL85liU X-Received: by 2002:a17:907:8c17:b0:871:38cc:7b3a with SMTP id ta23-20020a1709078c1700b0087138cc7b3amr30042317ejc.75.1674739019472; Thu, 26 Jan 2023 05:16:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674739019; cv=none; d=google.com; s=arc-20160816; b=cWbV17q6szwLlBxIh+iVYD3f3mgHf8QpmQemG7UGEXtSKO/RqIyQAL1TBwjA6gyl/q Q6odi7eaaHqbtoqnklvM1q/fd7T0Vsl9beI16TlSpwv+wJteI9CsOEKRvXf2cpjfnpdl sfFOPAioWAaZW49CB5pqDmL9OY73kg8gPS9ifHaxvVz4NnNfKN58APNCI3DFrFZJ0Qnn kTLcfwHfAGfbrZkNfQqMbekEIwscXr7IVd0WIHhHuiAhICXchLF2pgYSa9qJPcj1M9ca xSxqLQBy4ldXZXM9pzDoYCxTZNKzzQfrsLhHzKCgp88cHwrqGVjYvtWy0C2oWQOP72VP rBnw== 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=UId5/JJoZBTeG9p9A1yOZ3nWp9P6VqwANs93MgDGf0s=; b=0u8GyldTt2bMXm2RWFV10i9O7ssFK5tYg1ytaNH28/1bTsaUU9lsWu14VodARqPUf8 td2OmXQnwKqWSAXW30LuJesS7K6xmjI5STYKxA7aU7YoBq1ikJDIjfjTG5u5gMYSrMPo V3nF562g4a+SAOhJ1M0tFmlJpkUXH1EcppJd3pKUpZLThBuqHIA11ctT3uKXs3zZI+h4 /5NGPWT5843QHS7Om2nOzyZ7IF5L39nUjdOIXnw9HXX4NjhPrBqR8X5YpAwoiRU7lVLs VjxA2aUaGkuuVOBUEbuE0tMkgWBQhQuWlI6L8SN7/gDKvVkaqJ6gFH5z6/pl3QrsXSwj Iz1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=DrDxpvWz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fq38-20020a1709069da600b0087761d8cff9si1174060ejc.996.2023.01.26.05.16.35; Thu, 26 Jan 2023 05:16:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=DrDxpvWz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236710AbjAZNPU (ORCPT + 99 others); Thu, 26 Jan 2023 08:15:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236628AbjAZNOx (ORCPT ); Thu, 26 Jan 2023 08:14:53 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3FBA6952E for ; Thu, 26 Jan 2023 05:14:37 -0800 (PST) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30QCEB9n016660; Thu, 26 Jan 2023 13:14:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=UId5/JJoZBTeG9p9A1yOZ3nWp9P6VqwANs93MgDGf0s=; b=DrDxpvWzdXFvRAVauZWL2ShdoDlGGEM4vKvV959Q6Gdc6f7U3sLulnR9qdE+jWhPp9Jt J360MTu+SNADeThIgNuAg5I/df5HzKCIYnDboawVC/EAvIR72kzPVqMnTcmseZ5vubJs xCRYqQNElKq2Ykv87OVEO9m+gwgowGTJroLpyJ4SNSKNavq55BfEvG6QavOOiITKP/mL FDXm5nx6b3Qyk80XsH8taEQvdCHI23uHM/jKmv78XI0zVKVFYGkbgCHpT/SOD+esMRiV 2LpJdwGCHZ0nufOTwM2wOJ8R93nj5hxIGd+a6C1qr4xEX5cCpGMmeab0AmH7LauG+LzA eg== Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3nbsbe1cb7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:36 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30QApjVW015356; Thu, 26 Jan 2023 13:14:35 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3n87afeds5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 13:14:34 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30QDEVUj36700588 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Jan 2023 13:14:31 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 759B220040; Thu, 26 Jan 2023 13:14:31 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4173A20043; Thu, 26 Jan 2023 13:14:31 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 26 Jan 2023 13:14:31 +0000 (GMT) From: Mikhail Zaslonko To: Andrew Morton Cc: LKML , Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich , Mikhail Zaslonko Subject: [PATCH 8/8] lib/zlib: DFLTCC always switch to software inflate for Z_PACKET_FLUSH option Date: Thu, 26 Jan 2023 14:14:28 +0100 Message-Id: <20230126131428.1222214-9-zaslonko@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230126131428.1222214-1-zaslonko@linux.ibm.com> References: <20230126131428.1222214-1-zaslonko@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: fcNLZrWNVyT4SqoF1rX6CiDaPtGVV2u8 X-Proofpoint-GUID: fcNLZrWNVyT4SqoF1rX6CiDaPtGVV2u8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-26_05,2023-01-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 adultscore=0 clxscore=1015 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=874 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301260126 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756091142099079523?= X-GMAIL-MSGID: =?utf-8?q?1756091142099079523?= Since hardware inflate does not support Z_PACKET_FLUSH option (used exclusively by kernel PPP driver), always switch to software like we already do for Z_BLOCK flush option. Without this patch, PPP might get Z_DATA_ERROR return code from zlib_inflate() and disable zlib compression for the packets. Signed-off-by: Mikhail Zaslonko Acked-by: Ilya Leoshkevich --- lib/zlib_dfltcc/dfltcc_inflate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/zlib_dfltcc/dfltcc_inflate.c b/lib/zlib_dfltcc/dfltcc_inflate.c index 5786030c6dc2..437cd34c8490 100644 --- a/lib/zlib_dfltcc/dfltcc_inflate.c +++ b/lib/zlib_dfltcc/dfltcc_inflate.c @@ -95,8 +95,10 @@ dfltcc_inflate_action dfltcc_inflate( struct dfltcc_param_v0 *param = &dfltcc_state->param; dfltcc_cc cc; - if (flush == Z_BLOCK) { - /* DFLTCC does not support stopping on block boundaries */ + if (flush == Z_BLOCK || flush == Z_PACKET_FLUSH) { + /* DFLTCC does not support stopping on block boundaries (Z_BLOCK flush option) + * as well as the use of Z_PACKET_FLUSH option (used exclusively by PPP driver) + */ if (dfltcc_inflate_disable(strm)) { *ret = Z_STREAM_ERROR; return DFLTCC_INFLATE_BREAK;