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

Re: [PATCH v3 3/8] gzip: refactor the gunzip window into common state


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Date: Wed, 24 Apr 2024 17:34: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=1713994460; h=Content-Type: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=2k8RVogP7dx5rkFarQCu/NLm6n+smyW2lq6fEtmcn+c=; b=VJV5PzOXrVxSK/KiNKOBfudYHdtcmPPDxcB56cEIlVE0+gZKpiGVq9vAntXxU2hyV8x5cgylHhS4K1BWqXed8y010oI1Y7E23tbrLzSTx3Vjps/5XEzSJ7+icp61uXuNTyeeMTe3+KasMadKpmYnI7gBC7k735iYWJuEpArrlm8=
  • Arc-seal: i=1; a=rsa-sha256; t=1713994460; cv=none; d=zohomail.com; s=zohoarc; b=GPsB64+RwGqNUgkfDJ/OcnRBZ6Gc9gI/J6e8OrE0Ef68AWWj8qf9evII4ggKHtO4wlMWf0d02z+rpnJzBQeTmNin91waOya953v1hjb+MNsAo51F0BYDWjKSVV+9GH6I6bUiIar0yT0X0thIqjjousGMHr3ps5XZEcodfo1pMTg=
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Wed, 24 Apr 2024 21:34:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 4/24/24 12:34, Daniel P. Smith wrote:
Begin moving core state, in this case the gunzip window, into struct
gunzip_state to allow a per decompression instance. In doing so, drop the
define aliasing of window to slide.

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

diff --git a/xen/common/gzip/gunzip.c b/xen/common/gzip/gunzip.c
index b7cadadcca8b..e47f10ae19ad 100644
--- a/xen/common/gzip/gunzip.c
+++ b/xen/common/gzip/gunzip.c
@@ -4,10 +4,12 @@
  #include <xen/lib.h>
  #include <xen/mm.h>
-static unsigned char *__initdata window;
-
  #define WSIZE           0x80000000U
+struct gunzip_state {
+    unsigned char *window;
+};
+
  static unsigned char *__initdata inbuf;
  static unsigned int __initdata insize;
@@ -43,7 +45,7 @@ typedef unsigned long ulg;
  #endif
static long __initdata bytes_out;
-static void flush_window(void);
+static void flush_window(struct gunzip_state *s);
static __init void error(const char *x)
  {
@@ -62,7 +64,7 @@ static __init uch get_byte(void) {
#include "inflate.c" -static __init void flush_window(void)
+static __init void flush_window(struct gunzip_state *s)
  {
      /*
       * The window is equal to the output buffer therefore only need to
@@ -72,7 +74,7 @@ static __init void flush_window(void)
      unsigned int n;
      unsigned char *in, ch;
- in = window;
+    in = s->window;
      for ( n = 0; n < outcnt; n++ )
      {
          ch = *in++;
@@ -99,12 +101,17 @@ __init int gzip_check(char *image, unsigned long image_len)
__init int perform_gunzip(char *output, char *image, unsigned long image_len)
  {
+    struct gunzip_state *s;
      int rc;
if ( !gzip_check(image, image_len) )
          return 1;
- window = (unsigned char *)output;
+    s = (struct gunzip_state *)malloc(sizeof(struct gunzip_state));

Looks like I inadvertently dropped the corresponding free when breaking up the monolithic patch.

v/r,
dps



 


Rackspace

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