Bug 153081

Summary: CRASH kernel 4.7.3/stable + Xen on UEFI boot OOPS. patch ID'd & tested
Product: Platform Specific/Hardware Reporter: lssl (lists)
Component: x86-64Assignee: EFI Virtual User (efi)
Status: NEW ---    
Severity: high CC: dvrabel, ijc, jbeulich, jeffm, konrad.wilk, lists, matt, tiwai, virtualization_xen
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.7.3-1.g7ad9c1d Subsystem:
Regression: Yes Bisected commit-id:

Description lssl 2016-08-14 15:14:08 UTC
Running kernel 4.7.0/stable, boot PANICs when booting Xen 4.7 on UEFI hardware

References are

	@xen-devel

		 [Xen-devel] Xen 4.7.0 boot PANIC on kernel 4.7.0-4 + UEFI ?
			https://lists.xenproject.org/archives/html/xen-devel/2016-08/msg00747.html

	@opensuse-kernel

		[opensuse-kernel] kernel:stable PANIC with latest virtualization:xen. upstream PATCH included.
			https://lists.opensuse.org/opensuse-kernel/2016-08/msg00008.html

	@lkml

		[BUG] kernel 4.7 + Xen on UEFI boot crash.  patch ID'd & tested, just need to verify & get it into upstream
			https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1203213.html

As referenced in

	https://lists.xenproject.org/archives/html/xen-devel/2016-07/msg02758.html

the current kernel causes a crash when booting Xen 4.7 on UEFI.  

In hunting down the problem, this specific code was asked about @ 'xen-devel' ML,

	@ https://lists.xenproject.org/archives/html/xen-devel/2016-07/msg02928.html

		While I see that you're running linux-4.7 could you please double-check
		that it has the following:

		commit 55f1ea15216a5a14c96738bd5284100a00ffa9dc
		Author: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
		Date:   Tue May 31 11:23:43 2016 +0100

		    efi: Fix for_each_efi_memory_desc_in_map() for empty memmaps

A patch to the patch was proposed @ 'xen-devel' ML,

	https://lists.xen.org/archives/html/xen-devel/2016-08/msg00399.html

It looks like the patch needs to be patched. Specifically

 		-	     (md) <= (efi_memory_desc_t *)((m)->map_end - (m)->desc_size); \
-		+	     ((void *)(md) + (m)->desc_size) <= (m)->map_end;		   \
+		+	     ((void *)(md) + (m)->desc_size - 1) < (m)->map_end;		   \

Testing as of latest kernel-stable packages, the problem still exists.
Comment 1 lssl 2016-08-17 15:03:43 UTC
Noting

	http://news.softpedia.com/news/linux-kernel-4-7-gets-its-first-point-release-brings-ext4-and-x86-improvements-507359.shtml
		"I'm announcing the release of the 4.7.1 kernel. All users of the 4.7 kernel series must upgrade," says Greg Kroah-Hartman

upgrading from

	Loading Xen 4.7.0_10-455 with Linux 4.7.0-8.gb560f9f-default (no patch)

to

	Loading Xen 4.7.0_10-455 with Linux 4.7.1-1.g61bf3f1-default (no patch)

the crash persists.

otoh,

	boot without Xen to Linux 4.7.1-1.g61bf3f1-default (no patch)

is OK.
Comment 2 lssl 2016-08-17 17:54:50 UTC
verifying that a locally-patched kernel

	Loading Xen 4.7.0_10-455 with Linux 4.7.1-2.g61bf3f1-default (patched)

works

	xl list
		Name                 ID   Mem VCPUs      State   Time(s)
		Domain-0              0  2048     1     r-----     306.1
		test                  1  2049     1     -b----      22.8
Comment 3 lssl 2016-08-20 15:28:46 UTC
Confirming that kernel

	4.7.1-5.4.g61bf3f1

patched with a yet again slightly modified patch

	[PATCH 1/6] efi: Make for_each_efi_memory_desc_in_map() cope with running on Xen
	https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1213847.html


		diff --git a/include/linux/efi.h b/include/linux/efi.h
		index 7f5a58225385..23cd3ced8c1a 100644
		--- a/include/linux/efi.h
		+++ b/include/linux/efi.h
		@@ -946,7 +946,7 @@ extern int efi_memattr_apply_permissions(struct mm_struct *mm,
		 /* Iterate through an efi_memory_map */
		 #define for_each_efi_memory_desc_in_map(m, md)				   \
			for ((md) = (m)->map;						   \
		-	     ((void *)(md) + (m)->desc_size) <= (m)->map_end;		   \
		+	     (md) && ((void *)(md) + (m)->desc_size) <= (m)->map_end;	   \
			     (md) = (void *)(md) + (m)->desc_size)

		 /**


also works

it'd be helpful to get this backported into 4.7.x/stable sources
Comment 4 lssl 2016-08-22 01:39:32 UTC
upgrade to kernel 4.7.2-4.g34ba8d6

still requires the patch to boot xen

patch applies, with offset, & works
Comment 5 lssl 2016-09-09 18:29:46 UTC
same for 4.7.3.

Is this going to be backported to 4.7 branch by upstream?

It's not being addressed by the distro.

Should we just write off using "stable" kernel 4.7 branch as WONTFIX, and wait for 4.8?