Skip to contentSkip to conversation

kexec: Set KEXEC_TYPE_CRASH before sanity_check_segment_list()

PATCH In review Xunlei Pang 2 participants 2 messages Dec 2, 2015 – Dec 11, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kexec: Set KEXEC_TYPE_CRASH before sanity_check_segment_list()

sanity_check_segment_list() checks KEXEC_TYPE_CRASH flag to ensure all the segments of the loaded crash kernel are winthin the kernel crash resource limits, so set the flag beforehand.

---
v1 -> v2:
Improved some comments.

 kernel/kexec.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
kernel/kexec.c +5 -5
index d873b64..ee70aef 100644
@@ -63,16 +63,16 @@ static int kimage_alloc_init(struct kimage **rimage, unsigned long entry,
 	if (ret)
 		goto out_free_image;
 
-	ret = sanity_check_segment_list(image);
-	if (ret)
-		goto out_free_image;
-
-	 /* Enable the special crash kernel control page allocation policy. */
 	if (kexec_on_panic) {
+		/* Enable special crash kernel control page alloc policy. */
 		image->control_page = crashk_res.start;
 		image->type = KEXEC_TYPE_CRASH;
 	}
 
+	ret = sanity_check_segment_list(image);
+	if (ret)
+		goto out_free_image;
+
 	/*
 	 * Find a location for the control code buffer, and add it
 	 * the vector of segments so that it's pages will also be
Signature · 1 line
2.5.0
Acked-by on v2 1/1
#1 lore raw
Quoted 21 lines · Xunlei Pang

sanity_check_segment_list() checks KEXEC_TYPE_CRASH flag to ensure all the segments of the loaded crash kernel are winthin the kernel crash resource limits, so set the flag beforehand.

---
v1 -> v2:
Improved some comments.

 kernel/kexec.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
kernel/kexec.c +0 -0
index d873b64..ee70aef 100644
@@ -63,16 +63,16 @@ static int kimage_alloc_init(struct kimage **rimage, unsigned long entry,
 	if (ret)
 		goto out_free_image;
 

kernel/kexec.c static int kimage_alloc_init(struct kimage **rimage, unsigned long entry, · line 70

Quoted 10 lines
kernel/kexec.c +1 -5
-	ret = sanity_check_segment_list(image);
-	if (ret)
-		goto out_free_image;
-
-	 /* Enable the special crash kernel control page allocation policy. */
 	if (kexec_on_panic) {
+		/* Enable special crash kernel control page alloc policy. */
 		image->control_page = crashk_res.start;
 		image->type = KEXEC_TYPE_CRASH;
 	}

Good catch. This is hard to be found because kexec-tools user space utility has make sure it's well located. It must be a code reviewing finding. Ack it.

Thanks
Baoquan

Quoted 16 lines
kernel/kexec.c +4 -0
+	ret = sanity_check_segment_list(image);
+	if (ret)
+		goto out_free_image;
+
 	/*
 	 * Find a location for the control code buffer, and add it
 	 * the vector of segments so that it's pages will also be
Signature · 7 lines
2.5.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec