<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/kernel/module/decompress.c, branch v6.1.149</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v6.1.149</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v6.1.149'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2023-11-20T10:52:03Z</updated>
<entry>
<title>module/decompress: use vmalloc() for gzip decompression workspace</title>
<updated>2023-11-20T10:52:03Z</updated>
<author>
<name>Andrea Righi</name>
<email>andrea.righi@canonical.com</email>
</author>
<published>2023-08-30T15:58:20Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f20c4b0c015c54cef46c78f952a917882fd1d079'/>
<id>urn:sha1:f20c4b0c015c54cef46c78f952a917882fd1d079</id>
<content type='text'>
[ Upstream commit 3737df782c740b944912ed93420c57344b1cf864 ]

Use a similar approach as commit a419beac4a07 ("module/decompress: use
vmalloc() for zstd decompression workspace") and replace kmalloc() with
vmalloc() also for the gzip module decompression workspace.

In this case the workspace is represented by struct inflate_workspace
that can be fairly large for kmalloc() and it can potentially lead to
allocation errors on certain systems:

$ pahole inflate_workspace
struct inflate_workspace {
	struct inflate_state       inflate_state;        /*     0  9544 */
	/* --- cacheline 149 boundary (9536 bytes) was 8 bytes ago --- */
	unsigned char              working_window[32768]; /*  9544 32768 */

	/* size: 42312, cachelines: 662, members: 2 */
	/* last cacheline: 8 bytes */
};

Considering that there is no need to use continuous physical memory,
simply switch to vmalloc() to provide a more reliable in-kernel module
decompression.

Fixes: b1ae6dc41eaa ("module: add in-kernel support for decompressing")
Signed-off-by: Andrea Righi &lt;andrea.righi@canonical.com&gt;
Signed-off-by: Luis Chamberlain &lt;mcgrof@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>module: Fix NULL vs IS_ERR checking for module_get_next_page</title>
<updated>2022-12-31T12:32:10Z</updated>
<author>
<name>Miaoqian Lin</name>
<email>linmq006@gmail.com</email>
</author>
<published>2022-11-10T02:58:34Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7a779e84b3c451ce4713456a413d3300143747a7'/>
<id>urn:sha1:7a779e84b3c451ce4713456a413d3300143747a7</id>
<content type='text'>
[ Upstream commit 45af1d7aae7d5520d2858f8517a1342646f015db ]

The module_get_next_page() function return error pointers on error
instead of NULL.
Use IS_ERR() to check the return value to fix this.

Fixes: b1ae6dc41eaa ("module: add in-kernel support for decompressing")
Signed-off-by: Miaoqian Lin &lt;linmq006@gmail.com&gt;
Reviewed-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com
Signed-off-by: Luis Chamberlain &lt;mcgrof@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>module/decompress: generate sysfs string at compile time</title>
<updated>2022-09-09T00:00:43Z</updated>
<author>
<name>David Disseldorp</name>
<email>ddiss@suse.de</email>
</author>
<published>2022-09-06T08:03:18Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=77d6354bd422c8a451ef7d2235322dbf33e7427b'/>
<id>urn:sha1:77d6354bd422c8a451ef7d2235322dbf33e7427b</id>
<content type='text'>
compression_show() before (with noinline):
   0xffffffff810b5ff0 &lt;+0&gt;:     mov    %rdx,%rdi
   0xffffffff810b5ff3 &lt;+3&gt;:     mov    $0xffffffff81b55629,%rsi
   0xffffffff810b5ffa &lt;+10&gt;:    mov    $0xffffffff81b0cde2,%rdx
   0xffffffff810b6001 &lt;+17&gt;:    call   0xffffffff811b8fd0 &lt;sysfs_emit&gt;
   0xffffffff810b6006 &lt;+22&gt;:    cltq
   0xffffffff810b6008 &lt;+24&gt;:    ret

After:
   0xffffffff810b5ff0 &lt;+0&gt;:     mov    $0xffffffff81b0cde2,%rsi
   0xffffffff810b5ff7 &lt;+7&gt;:     mov    %rdx,%rdi
   0xffffffff810b5ffa &lt;+10&gt;:    call   0xffffffff811b8fd0 &lt;sysfs_emit&gt;
   0xffffffff810b5fff &lt;+15&gt;:    cltq
   0xffffffff810b6001 &lt;+17&gt;:    ret

Signed-off-by: David Disseldorp &lt;ddiss@suse.de&gt;
Reviewed-by: Aaron Tomlin &lt;atomlin@redhat.com&gt;
Reviewed-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;
Signed-off-by: Luis Chamberlain &lt;mcgrof@kernel.org&gt;
</content>
</entry>
<entry>
<title>module: Replace kmap() with kmap_local_page()</title>
<updated>2022-07-20T21:27:46Z</updated>
<author>
<name>Fabio M. De Francesco</name>
<email>fmdefrancesco@gmail.com</email>
</author>
<published>2022-07-20T16:19:32Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=554694ba120b87e39cf732ed632e6a0c52fafb7c'/>
<id>urn:sha1:554694ba120b87e39cf732ed632e6a0c52fafb7c</id>
<content type='text'>
kmap() is being deprecated in favor of kmap_local_page().

Two main problems with kmap(): (1) It comes with an overhead as mapping
space is restricted and protected by a global lock for synchronization and
(2) it also requires global TLB invalidation when the kmap’s pool wraps
and it might block when the mapping space is fully utilized until a slot
becomes available.

With kmap_local_page() the mappings are per thread, CPU local, can take
page faults, and can be called from any context (including interrupts).
Tasks can be preempted and, when scheduled to run again, the kernel
virtual addresses are restored and still valid.

kmap_local_page() is faster than kmap() in kernels with HIGHMEM enabled.

Since the use of kmap_local_page() in module_gzip_decompress() and in
module_xz_decompress() is safe (i.e., it does not break the strict rules
of use), it should be preferred over kmap().

Therefore, replace kmap() with kmap_local_page().

Tested on a QEMU/KVM x86_32 VM with 4GB RAM, booting kernels with
HIGHMEM64GB enabled. Modules compressed with XZ or GZIP decompress
properly.

Cc: Matthew Wilcox &lt;willy@infradead.com&gt;
Suggested-by: Ira Weiny &lt;ira.weiny@intel.com&gt;
Signed-off-by: Fabio M. De Francesco &lt;fmdefrancesco@gmail.com&gt;
Signed-off-by: Luis Chamberlain &lt;mcgrof@kernel.org&gt;
</content>
</entry>
<entry>
<title>module: Make internal.h and decompress.c more compliant</title>
<updated>2022-04-05T15:42:35Z</updated>
<author>
<name>Aaron Tomlin</name>
<email>atomlin@redhat.com</email>
</author>
<published>2022-03-22T14:03:33Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=5aff4dfdb4ae2741cfff759d917f597f2c7f70aa'/>
<id>urn:sha1:5aff4dfdb4ae2741cfff759d917f597f2c7f70aa</id>
<content type='text'>
This patch will address the following warning and style violations
generated by ./scripts/checkpatch.pl in strict mode:

  WARNING: Use #include &lt;linux/module.h&gt; instead of &lt;asm/module.h&gt;
  #10: FILE: kernel/module/internal.h:10:
  +#include &lt;asm/module.h&gt;

  CHECK: spaces preferred around that '-' (ctx:VxV)
  #18: FILE: kernel/module/internal.h:18:
  +#define INIT_OFFSET_MASK (1UL &lt;&lt; (BITS_PER_LONG-1))

  CHECK: Please use a blank line after function/struct/union/enum declarations
  #69: FILE: kernel/module/internal.h:69:
  +}
  +static inline void module_decompress_cleanup(struct load_info *info)
						   ^
  CHECK: extern prototypes should be avoided in .h files
  #84: FILE: kernel/module/internal.h:84:
  +extern int mod_verify_sig(const void *mod, struct load_info *info);

  WARNING: Missing a blank line after declarations
  #116: FILE: kernel/module/decompress.c:116:
  +               struct page *page = module_get_next_page(info);
  +               if (!page) {

  WARNING: Missing a blank line after declarations
  #174: FILE: kernel/module/decompress.c:174:
  +               struct page *page = module_get_next_page(info);
  +               if (!page) {

  CHECK: Please use a blank line after function/struct/union/enum declarations
  #258: FILE: kernel/module/decompress.c:258:
  +}
  +static struct kobj_attribute module_compression_attr = __ATTR_RO(compression);

Note: Fortunately, the multiple-include optimisation found in
include/linux/module.h will prevent duplication/or inclusion more than
once.

Fixes: f314dfea16a0 ("modsign: log module name in the event of an error")
Reviewed-by: Christophe Leroy &lt;christophe.leroy@csgroup.eu&gt;
Signed-off-by: Aaron Tomlin &lt;atomlin@redhat.com&gt;
Signed-off-by: Luis Chamberlain &lt;mcgrof@kernel.org&gt;
</content>
</entry>
<entry>
<title>module: Move all into module/</title>
<updated>2022-04-04T19:57:54Z</updated>
<author>
<name>Aaron Tomlin</name>
<email>atomlin@redhat.com</email>
</author>
<published>2022-03-22T14:03:31Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=cfc1d277891eb499b3b5354df33b30f598683e90'/>
<id>urn:sha1:cfc1d277891eb499b3b5354df33b30f598683e90</id>
<content type='text'>
No functional changes.

This patch moves all module related code into a separate directory,
modifies each file name and creates a new Makefile. Note: this effort
is in preparation to refactor core module code.

Reviewed-by: Christophe Leroy &lt;christophe.leroy@csgroup.eu&gt;
Signed-off-by: Aaron Tomlin &lt;atomlin@redhat.com&gt;
Signed-off-by: Luis Chamberlain &lt;mcgrof@kernel.org&gt;
</content>
</entry>
</feed>
