[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/5] gzip: move crc state into consilidated gzip state


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Date: Thu, 11 Apr 2024 11:25:17 -0400
  • Arc-authentication-results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@xxxxxxxxxxxxxxxxxxxx; dmarc=pass header.from=<dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1712849135; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=CnTjEaX3hnuMjXMsnX980kERulKrcznM7VftSyLKlZI=; b=GuYjC4zciGnSsOPeFDqwQgL2tlRlCGJIVqU5ky6RK0AvmqVp1fii5FS5cpYgNY+Mlg74uTscyhKxc7PVgzRkzuzeH0455ajJxtPdg4nvZRL4YZvVTRuDXTMppehD6e1sIFWroTNHIvR/IGJlJNy6Ui/kKtVDCrbKHCkUq+D6lR0=
  • Arc-seal: i=1; a=rsa-sha256; t=1712849135; cv=none; d=zohomail.com; s=zohoarc; b=AM1W3oM3/jBer+uk2dAhpydvxPiQ/v639/VYDawNR1+WcWCzQka2JHvEHLQE+yi+DY2nqF+p1fM8y3exUvlX9JFP06AUQfHRWy3og01fGgJ/lGg1OGwrOrJJEgje7wbiw0kgAdCaxG38cKrCgOeAYEBLk+AP8DaPr23U1Qe8JVw=
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivered-to: dpsmith@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 11 Apr 2024 15:38:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Signed-off-by: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>
---
 xen/common/gzip/gunzip.c  | 11 +++++++----
 xen/common/gzip/inflate.c | 12 +++++-------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/xen/common/gzip/gunzip.c b/xen/common/gzip/gunzip.c
index 9b4891731b8b..a1b516b925c9 100644
--- a/xen/common/gzip/gunzip.c
+++ b/xen/common/gzip/gunzip.c
@@ -28,6 +28,9 @@ struct gzip_data {
 
     unsigned long bb;      /* bit buffer */
     unsigned bk;           /* bits in bit buffer */
+
+    unsigned long crc_32_tab[256];
+    unsigned long crc;
 };
 
 #define OF(args)        args
@@ -78,7 +81,7 @@ static __init void flush_window(struct gzip_data *gd)
      * The window is equal to the output buffer therefore only need to
      * compute the crc.
      */
-    unsigned long c = crc;
+    unsigned long c = gd->crc;
     unsigned int n;
     unsigned char *in, ch;
 
@@ -86,9 +89,9 @@ static __init void flush_window(struct gzip_data *gd)
     for ( n = 0; n < gd->outcnt; n++ )
     {
         ch = *in++;
-        c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
+        c = gd->crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
     }
-    crc = c;
+    gd->crc = c;
 
     gd->bytes_out += (unsigned long)gd->outcnt;
     gd->outcnt = 0;
@@ -129,7 +132,7 @@ __init int perform_gunzip(char *output, char *image, 
unsigned long image_len)
     gd.inptr = 0;
     gd.bytes_out = 0;
 
-    makecrc();
+    makecrc(&gd);
 
     if ( gunzip(&gd) < 0 )
     {
diff --git a/xen/common/gzip/inflate.c b/xen/common/gzip/inflate.c
index c8dd35962abb..6c8c7452a31f 100644
--- a/xen/common/gzip/inflate.c
+++ b/xen/common/gzip/inflate.c
@@ -1125,16 +1125,14 @@ static int __init inflate(struct gzip_data *gd)
  *
  **********************************************************************/
 
-static ulg __initdata crc_32_tab[256];
-static ulg __initdata crc;  /* initialized in makecrc() so it'll reside in bss 
*/
-#define CRC_VALUE (crc ^ 0xffffffffUL)
+#define CRC_VALUE (gd->crc ^ 0xffffffffUL)
 
 /*
  * Code to compute the CRC-32 table. Borrowed from
  * gzip-1.0.3/makecrc.c.
  */
 
-static void __init makecrc(void)
+static void __init makecrc(struct gzip_data *gd)
 {
 /* Not copyrighted 1990 Mark Adler */
 
@@ -1151,7 +1149,7 @@ static void __init makecrc(void)
     for (i = 0; i < sizeof(p)/sizeof(int); i++)
         e |= 1L << (31 - p[i]);
 
-    crc_32_tab[0] = 0;
+    gd->crc_32_tab[0] = 0;
 
     for (i = 1; i < 256; i++)
     {
@@ -1162,11 +1160,11 @@ static void __init makecrc(void)
             if (k & 1)
                 c ^= e;
         }
-        crc_32_tab[i] = c;
+        gd->crc_32_tab[i] = c;
     }
 
     /* this is initialized here so this code could reside in ROM */
-    crc = (ulg)0xffffffffUL; /* shift register contents */
+    gd->crc = (ulg)0xffffffffUL; /* shift register contents */
 }
 
 /* gzip flag byte */
-- 
2.30.2




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.