Re: [PATCH 1/3] kexec_file: fix incorrect end value passed to kimage_is_destination_range()

2023-12-15 Thread Eric W. Biederman
Yuntao Wang writes: > The end parameter received by kimage_is_destination_range() should be the > last valid byte address of the target memory segment plus 1. However, in > the locate_mem_hole_bottom_up() and locate_mem_hole_top_down() functions, > the corresponding value passed to

Re: [PATCH 3/3] crash_core: fix and simplify the logic of crash_exclude_mem_range()

2023-12-15 Thread Baoquan He
On 12/15/23 at 12:38am, Yuntao Wang wrote: > The purpose of crash_exclude_mem_range() is to remove all memory ranges > that overlap with [mstart-mend]. However, the current logic only removes > the first overlapping memory range. > > Commit a2e9a95d2190 ("kexec: Improve & fix

Re: [PATCHv4 04/14] cpu/hotplug, x86/acpi: Disable CPU offlining for ACPI MADT wakeup

2023-12-15 Thread Thomas Gleixner
On Tue, Dec 05 2023 at 03:45, Kirill A. Shutemov wrote: > ACPI MADT doesn't allow to offline CPU after it got woke up. > > Currently hotplug prevented based on the confidential computing Currently CPU hotplug is prevented... Other than that: Reviewed-by: Thomas Gleixner

Re: [PATCHv4 03/14] cpu/hotplug: Add support for declaring CPU offlining not supported

2023-12-15 Thread Thomas Gleixner
On Tue, Dec 05 2023 at 03:44, Kirill A. Shutemov wrote: > > +static bool cpu_hotplug_offline_disabled; __ro_after_init? Other than that: Reviewed-by: Thomas Gleixner ___ kexec mailing list kexec@lists.infradead.org

Re: [PATCHv4 13/14] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case

2023-12-15 Thread Thomas Gleixner
On Tue, Dec 05 2023 at 03:45, Kirill A. Shutemov wrote: > ACPI MADT doesn't allow to offline CPU after it got woke up. It limits to offline a CPU after it was onlined. This limits kexec: ... > kexec: the second kernel won't be able to use more than one CPU. ... one CPU, which is enough to cover

Re: [PATCHv4 14/14] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

2023-12-15 Thread Thomas Gleixner
On Tue, Dec 05 2023 at 03:45, Kirill A. Shutemov wrote: > MADT Multiprocessor Wakeup structure version 1 brings support of CPU > offlining: BIOS provides a reset vector where the CPU has to jump to > offline itself. CPU has to jump to for offlining itself. > The new TEST mailbox command can be

Re: [PATCH 1/3] kexec_file: fix incorrect end value passed to kimage_is_destination_range()

2023-12-15 Thread Baoquan He
On 12/15/23 at 11:46am, Eric W. Biederman wrote: > Yuntao Wang writes: > > > The end parameter received by kimage_is_destination_range() should be the > > last valid byte address of the target memory segment plus 1. However, in > > the locate_mem_hole_bottom_up() and locate_mem_hole_top_down()

[PATCH v3 0/7] ima: kexec: measure events between kexec load and execute

2023-12-15 Thread Tushar Sugandhi
The current Kernel behavior is IMA measurements snapshot is taken at kexec 'load' and not at kexec 'execute'. IMA log is then carried over to the new Kernel after kexec 'execute'. New events can be measured after the IMA log snapshot at kexec 'load' and before the system boots to the new Kernel.

[PATCH v3 1/7] ima: define and call ima_alloc_kexec_file_buf

2023-12-15 Thread Tushar Sugandhi
Refactor ima_dump_measurement_list() to move the memory allocation part to a separate function ima_alloc_kexec_file_buf() to allocate buffer of size 'kexec_segment_size' at kexec 'load'. Make the local variables in function ima_dump_measurement_list() global, so that they can be accessed from

[PATCH v3 5/7] ima: suspend measurements during buffer copy at kexec execute

2023-12-15 Thread Tushar Sugandhi
If the new measurements are added to the IMA log while it is being being copied to the kexec buffer during kexec 'execute', it can miss copying those new measurements to the kexec buffer, and the buffer can go out of sync with TPM PCRs. This could result in breaking the integrity of the

[PATCH v3 3/7] ima: kexec: map IMA buffer source pages to image after kexec load

2023-12-15 Thread Tushar Sugandhi
Implement kimage_map_segment() to enable mapping of IMA buffer source pages to the kimage structure post kexec 'load'. This function, accepting a kimage pointer, an address, and a size, will gather the source pages within the specified address range, create an array of page pointers, and map these

[PATCH v3 6/7] ima: configure memory to log events between kexec load and execute

2023-12-15 Thread Tushar Sugandhi
IMA currently allocates half a PAGE_SIZE for the extra events that would be measured between kexec 'load' and 'execute'. Depending on the IMA policy and the system state, that memory may not be sufficient to hold the extra IMA events measured after kexec 'load'. The memory requirements vary from

[PATCH v3 4/7] kexec: update kexec_file_load syscall to alloc ima buffer after load

2023-12-15 Thread Tushar Sugandhi
Implement function kimage_file_post_load() to call ima_kexec_post_load() This ensures the IMA buffer allocated at kexec 'load' is mapped to a segment in the next loaded Kernel image. Modify the kexec_file_load() syscall to call kimage_file_post_load() after the image has been loaded and prepared

Re: [PATCH v14 6/6] powerpc: add crash memory hotplug support

2023-12-15 Thread Baoquan He
On 12/15/23 at 11:29am, Sourabh Jain wrote: .. > > > +static void update_crash_elfcorehdr(struct kimage *image, struct > > > memory_notify *mn) > > > +{ > > > + int ret; > > > + struct crash_mem *cmem = NULL; > > > + struct kexec_segment *ksegment; > > > + void *ptr, *mem, *elfbuf = NULL; > >

[PATCH v3 7/7] ima: measure kexec load and exec events as critical data

2023-12-15 Thread Tushar Sugandhi
There could be a potential mismatch between IMA measurements and TPM PCR quotes caused by the indeterminate interval between kexec 'load' and 'execute'. Memory allocated at kexec 'load' for IMA log buffer may run out. It can lead to missing events in the IMA log after a soft reboot to the new

[PATCH v3 2/7] ima: kexec: move ima log copy from kexec load to execute

2023-12-15 Thread Tushar Sugandhi
ima_dump_measurement_list() is called from ima_add_kexec_buffer() during kexec 'load', which may result in loss of IMA measurements between kexec 'load' and 'execute'. It needs to be called during kexec 'execute'. Implement ima_update_kexec_buffer(), to be called during kexec 'execute'. Move

Re: [PATCH 3/3] crash_core: fix and simplify the logic of crash_exclude_mem_range()

2023-12-15 Thread Yuntao Wang
On Fri, 15 Dec 2023 23:15:10 +0800, Baoquan He wrote: > On 12/15/23 at 12:38am, Yuntao Wang wrote: > > The purpose of crash_exclude_mem_range() is to remove all memory ranges > > that overlap with [mstart-mend]. However, the current logic only removes > > the first overlapping memory range. > > >

Re: [PATCH 3/3] crash_core: fix and simplify the logic of crash_exclude_mem_range()

2023-12-15 Thread Baoquan He
On 12/16/23 at 09:54am, Yuntao Wang wrote: > On Fri, 15 Dec 2023 23:15:10 +0800, Baoquan He wrote: > > On 12/15/23 at 12:38am, Yuntao Wang wrote: > > > The purpose of crash_exclude_mem_range() is to remove all memory ranges > > > that overlap with [mstart-mend]. However, the current logic only

[PATCH 1/3 v2] kexec: modify the meaning of the end parameter in kimage_is_destination_range()

2023-12-15 Thread Yuntao Wang
The end parameter received by kimage_is_destination_range() should be the last valid byte address of the target memory segment plus 1. However, in the locate_mem_hole_bottom_up() and locate_mem_hole_top_down() functions, the corresponding value passed to kimage_is_destination_range() is the last

[PATCH 1/3] kexec_file: fix incorrect end value passed to kimage_is_destination_range()

2023-12-15 Thread Yuntao Wang
The end parameter received by kimage_is_destination_range() should be the last valid byte address of the target memory segment plus 1. However, in the locate_mem_hole_bottom_up() and locate_mem_hole_top_down() functions, the corresponding value passed to kimage_is_destination_range() is the last

[PATCH 3/3] x86/kexec: use pr_err() instead of pr_debug() when an error occurs

2023-12-15 Thread Yuntao Wang
When an error is detected, use pr_err() instead of pr_debug() to output log message. In addition, remove the unnecessary return from set_page_address(). Signed-off-by: Yuntao Wang --- arch/x86/kernel/kexec-bzimage64.c | 2 +- mm/highmem.c | 2 -- 2 files changed, 1

[PATCH 0/3] Some bug fixes and cleanups related to kexec

2023-12-15 Thread Yuntao Wang
This series includes some bug fixes and cleanups for kexec. Yuntao Wang (3): kexec_file: fix incorrect end value passed to kimage_is_destination_range() kexec_file: fix incorrect temp_start value in locate_mem_hole_top_down() x86/kexec: use pr_err() instead of pr_debug() when an

[PATCH 2/3] kexec_file: fix incorrect temp_start value in locate_mem_hole_top_down()

2023-12-15 Thread Yuntao Wang
temp_end represents the address of the last available byte. Therefore, the starting address of the memory segment with temp_end as its last available byte and a size of `kbuf->memsz`, that is, the value of temp_start, should be `temp_end - kbuf->memsz + 1` instead of `temp_end - kbuf->memsz`.

[PATCH] crash_core: remove duplicated including of kexec.h

2023-12-15 Thread Wang Jinchao
remove second include of linux/kexec.h Signed-off-by: Wang Jinchao --- kernel/crash_core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/crash_core.c b/kernel/crash_core.c index efe87d501c8c..d72985222b16 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -13,7 +13,6 @@

Re: [PATCH] crash_core: remove duplicated including of kexec.h

2023-12-15 Thread Baoquan He
On 12/15/23 at 04:54pm, Wang Jinchao wrote: > remove second include of linux/kexec.h Good catch. Acked-by: Baoquan He > > Signed-off-by: Wang Jinchao > --- > kernel/crash_core.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/kernel/crash_core.c b/kernel/crash_core.c > index