Skip to contentSkip to conversation

kexec: Set KEXEC_TYPE_CRASH before sanity_check_segment_list()

PATCH Superseded Xunlei Pang 2 participants 3 messages Dec 2, 2015

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 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.

---
 kernel/kexec.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/kexec.c +8 -5
index d873b64..9624391 100644
@@ -63,16 +63,19 @@ 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. */
+	/*
+	 * Enable the special crash kernel control page allocation policy,
+	 * and set the crash type flag.
+	 */
 	if (kexec_on_panic) {
 		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 v1 1/2
#1 lore raw

Ccing Andrew since usually he monitors and picks up kexec patches.

Quoted 3 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.

Looks good except a nitpick, see comments inline.

Otherwise:

Quoted 12 lines
---
 kernel/kexec.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/kexec.c +0 -0
index d873b64..9624391 100644
@@ -63,16 +63,19 @@ static int kimage_alloc_init(struct kimage **rimage, unsigned long entry,
 	if (ret)

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

Quoted 10 lines
kernel/kexec.c +3 -5
 		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. */
+	/*
+	 * Enable the special crash kernel control page allocation policy,
+	 * and set the crash type flag.

It is obvious it is setting the crash type flag, so no need to add extra comment.

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

Quoted 2 lines
kernel/kexec.c +1 -0
+	 */
 	if (kexec_on_panic) {

Like kexec_file.c, move /* Enable ... policy */ here sounds better.

Quoted 14 lines
kernel/kexec.c +4 -0
 		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

Thanks
Dave

#2 lore raw

Hi Dave,

Quoted 35 lines · Dave Young

Ccing Andrew since usually he monitors and picks up kexec patches.

Quoted 3 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.

Looks good except a nitpick, see comments inline.

Otherwise:

Quoted 11 lines
---
 kernel/kexec.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/kexec.c +0 -0
index d873b64..9624391 100644
@@ -63,16 +63,19 @@ static int kimage_alloc_init(struct kimage **rimage, unsigned long entry,
 	if (ret)

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

Quoted 10 lines
kernel/kexec.c +3 -5
 		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. */
+	/*
+	 * Enable the special crash kernel control page allocation policy,
+	 * and set the crash type flag.

It is obvious it is setting the crash type flag, so no need to add extra comment.

Quoted 3 lines

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

Quoted 2 lines
kernel/kexec.c +1 -0
+	 */
 	if (kexec_on_panic) {

Like kexec_file.c, move /* Enable ... policy */ here sounds better.

Yea, this is better. Will do, thanks.

Regards,
Xunlei

Quoted 17 lines
Quoted 15 lines
kernel/kexec.c +4 -0
 		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

Thanks
Dave