* [PATCH] kexec: Replace kmap() with kmap_local_page()
@ 2022-07-07 23:14 Fabio M. De Francesco
2022-07-07 23:50 ` Fabio M. De Francesco
0 siblings, 1 reply; 4+ messages in thread
From: Fabio M. De Francesco @ 2022-07-07 23:14 UTC (permalink / raw)
To: Eric Biederman, kexec, linux-kernel; +Cc: Fabio M. De Francesco, Ira Weiny
The use of kmap() and kmap_atomic() are being deprecated in favor of
kmap_local_page().
With kmap_local_page(), the mappings are per thread, CPU local and not
globally visible. Furthermore, the mappings can be acquired from any
context (including interrupts).
Therefore, use kmap_local_page() in kexec_core.c because these mappings are
per thread, CPU local, and not globally visible.
Tested on a QEMU + KVM 32-bits VM booting a kernel with HIGHMEM64GB
enabled.
Suggested-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
---
v1->v2: A sentence of the commit message contained an error due to a
mistake in copy-pasting from a previous patch. Replace "aio.c" with
"kexec_core.c".
kernel/kexec_core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index 4d34c78334ce..6f98274765d4 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -814,7 +814,7 @@ static int kimage_load_normal_segment(struct kimage *image,
if (result < 0)
goto out;
- ptr = kmap(page);
+ ptr = kmap_local_page(page);
/* Start with a clear page */
clear_page(ptr);
ptr += maddr & ~PAGE_MASK;
@@ -827,7 +827,7 @@ static int kimage_load_normal_segment(struct kimage *image,
memcpy(ptr, kbuf, uchunk);
else
result = copy_from_user(ptr, buf, uchunk);
- kunmap(page);
+ kunmap_local(ptr);
if (result) {
result = -EFAULT;
goto out;
@@ -878,7 +878,7 @@ static int kimage_load_crash_segment(struct kimage *image,
goto out;
}
arch_kexec_post_alloc_pages(page_address(page), 1, 0);
- ptr = kmap(page);
+ ptr = kmap_local_page(page);
ptr += maddr & ~PAGE_MASK;
mchunk = min_t(size_t, mbytes,
PAGE_SIZE - (maddr & ~PAGE_MASK));
@@ -894,7 +894,7 @@ static int kimage_load_crash_segment(struct kimage *image,
else
result = copy_from_user(ptr, buf, uchunk);
kexec_flush_icache_page(page);
- kunmap(page);
+ kunmap_local(ptr);
arch_kexec_pre_free_pages(page_address(page), 1);
if (result) {
result = -EFAULT;
--
2.36.1
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] kexec: Replace kmap() with kmap_local_page()
2022-07-07 23:14 [PATCH] kexec: Replace kmap() with kmap_local_page() Fabio M. De Francesco
@ 2022-07-07 23:50 ` Fabio M. De Francesco
0 siblings, 0 replies; 4+ messages in thread
From: Fabio M. De Francesco @ 2022-07-07 23:50 UTC (permalink / raw)
To: Eric Biederman, kexec, linux-kernel; +Cc: Ira Weiny
On venerdì 8 luglio 2022 01:14:12 CEST Fabio M. De Francesco wrote:
> The use of kmap() and kmap_atomic() are being deprecated in favor of
> kmap_local_page().
>
> With kmap_local_page(), the mappings are per thread, CPU local and not
> globally visible. Furthermore, the mappings can be acquired from any
> context (including interrupts).
>
> Therefore, use kmap_local_page() in kexec_core.c because these mappings
are
> per thread, CPU local, and not globally visible.
>
> Tested on a QEMU + KVM 32-bits VM booting a kernel with HIGHMEM64GB
> enabled.
>
> Suggested-by: Ira Weiny <ira.weiny@intel.com>
> Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> ---
>
> v1->v2: A sentence of the commit message contained an error due to a
> mistake in copy-pasting from a previous patch. Replace "aio.c" with
> "kexec_core.c".
>
> kernel/kexec_core.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
Sorry, another error... Please discard this patch because the version
number is missing in the subject.
The second version, hopefully final and correct, is at
https://lore.kernel.org/lkml/20220707231550.1484-1-fmdefrancesco@gmail.com/
Thank you,
Fabio
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] kexec: Replace kmap() with kmap_local_page()
@ 2022-07-07 18:49 Fabio M. De Francesco
2022-07-07 23:40 ` Fabio M. De Francesco
0 siblings, 1 reply; 4+ messages in thread
From: Fabio M. De Francesco @ 2022-07-07 18:49 UTC (permalink / raw)
To: Eric Biederman, kexec, linux-kernel; +Cc: Fabio M. De Francesco, Ira Weiny
The use of kmap() and kmap_atomic() are being deprecated in favor of
kmap_local_page().
With kmap_local_page(), the mappings are per thread, CPU local and not
globally visible. Furthermore, the mappings can be acquired from any
context (including interrupts).
Therefore, use kmap_local_page() in aio.c because these mappings are per
thread, CPU local, and not globally visible.
Tested on a QEMU + KVM 32-bits VM booting a kernel with HIGHMEM64GB
enabled.
Suggested-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
---
kernel/kexec_core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index 4d34c78334ce..6f98274765d4 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -814,7 +814,7 @@ static int kimage_load_normal_segment(struct kimage *image,
if (result < 0)
goto out;
- ptr = kmap(page);
+ ptr = kmap_local_page(page);
/* Start with a clear page */
clear_page(ptr);
ptr += maddr & ~PAGE_MASK;
@@ -827,7 +827,7 @@ static int kimage_load_normal_segment(struct kimage *image,
memcpy(ptr, kbuf, uchunk);
else
result = copy_from_user(ptr, buf, uchunk);
- kunmap(page);
+ kunmap_local(ptr);
if (result) {
result = -EFAULT;
goto out;
@@ -878,7 +878,7 @@ static int kimage_load_crash_segment(struct kimage *image,
goto out;
}
arch_kexec_post_alloc_pages(page_address(page), 1, 0);
- ptr = kmap(page);
+ ptr = kmap_local_page(page);
ptr += maddr & ~PAGE_MASK;
mchunk = min_t(size_t, mbytes,
PAGE_SIZE - (maddr & ~PAGE_MASK));
@@ -894,7 +894,7 @@ static int kimage_load_crash_segment(struct kimage *image,
else
result = copy_from_user(ptr, buf, uchunk);
kexec_flush_icache_page(page);
- kunmap(page);
+ kunmap_local(ptr);
arch_kexec_pre_free_pages(page_address(page), 1);
if (result) {
result = -EFAULT;
--
2.36.1
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] kexec: Replace kmap() with kmap_local_page()
2022-07-07 18:49 Fabio M. De Francesco
@ 2022-07-07 23:40 ` Fabio M. De Francesco
0 siblings, 0 replies; 4+ messages in thread
From: Fabio M. De Francesco @ 2022-07-07 23:40 UTC (permalink / raw)
To: Eric Biederman, kexec, linux-kernel; +Cc: Ira Weiny
On giovedì 7 luglio 2022 20:49:39 CEST Fabio M. De Francesco wrote:
> The use of kmap() and kmap_atomic() are being deprecated in favor of
> kmap_local_page().
>
> With kmap_local_page(), the mappings are per thread, CPU local and not
> globally visible. Furthermore, the mappings can be acquired from any
> context (including interrupts).
>
> Therefore, use kmap_local_page() in aio.c because these mappings are per
> thread, CPU local, and not globally visible.
>
> Tested on a QEMU + KVM 32-bits VM booting a kernel with HIGHMEM64GB
> enabled.
>
> Suggested-by: Ira Weiny <ira.weiny@intel.com>
> Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> ---
> kernel/kexec_core.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
Please discard this version because there is a small error in the commit
message due to bad copy and paste. Version 2 is at
https://lore.kernel.org/lkml/20220707231550.1484-1-fmdefrancesco@gmail.com/
Thanks,
Fabio
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-07-07 23:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-07 23:14 [PATCH] kexec: Replace kmap() with kmap_local_page() Fabio M. De Francesco
2022-07-07 23:50 ` Fabio M. De Francesco
-- strict thread matches above, loose matches on Subject: below --
2022-07-07 18:49 Fabio M. De Francesco
2022-07-07 23:40 ` Fabio M. De Francesco
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).