Blame SOURCES/0001-Fix-pvops-Xen-detection-for-arm-machine.patch

e64a0b
From 7eba220e1a7d443cad6716dd83d4953ffd62d566 Mon Sep 17 00:00:00 2001
e64a0b
From: Qi Zheng <zhengqi.arch@bytedance.com>
e64a0b
Date: Tue, 21 Dec 2021 15:40:31 +0800
e64a0b
Subject: [PATCH 1/2] Fix pvops Xen detection for arm machine
e64a0b
e64a0b
Since the xen_start_info on the arm/arm64 platform points to a static
e64a0b
variable '_xen_start_info'(see its definition as below), which makes
e64a0b
that the address of xen_start_info will never be null.
e64a0b
e64a0b
arch/arm/xen/enlighten.c:40:static struct start_info _xen_start_info;
e64a0b
arch/arm/xen/enlighten.c:41:struct start_info *xen_start_info = &_xen_start_info;
e64a0b
arch/arm/xen/enlighten.c:42:EXPORT_SYMBOL(xen_start_info);
e64a0b
e64a0b
As a result, the is_pvops_xen() in commit 4badc6229c69 ("Fix pvops
e64a0b
Xen detection for kernels >= v4.20") always returns TRUE because it
e64a0b
can always read out the non-null address of xen_start_info, finally
e64a0b
the following error will be reported on arm/arm64 platform(non-Xen
e64a0b
environment) because p2m_mid_missing and xen_p2m_addr are not defined:
e64a0b
e64a0b
        crash: cannot resolve "p2m_top"
e64a0b
e64a0b
For the arm/arm64 platform, fix it by using xen_vcpu_info instead of
e64a0b
xen_start_info to detect Xen dumps.
e64a0b
e64a0b
In addition, also explicitly narrow the scope of the xen_start_info
e64a0b
check to x86 with the machine_type(), there is no need to check it on
e64a0b
other architectures.
e64a0b
e64a0b
Fixes: 4badc6229c69 ("Fix pvops Xen detection for kernels >= v4.20")
e64a0b
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
e64a0b
Acked-by: Kazuhito Hagio <k-hagio-ab@nec.com>
e64a0b
---
e64a0b
 kernel.c | 20 +++++++++++++++-----
e64a0b
 1 file changed, 15 insertions(+), 5 deletions(-)
e64a0b
e64a0b
diff --git a/kernel.c b/kernel.c
e64a0b
index f4598ea217a3..37b7af74ed2e 100644
e64a0b
--- a/kernel.c
e64a0b
+++ b/kernel.c
e64a0b
@@ -10757,11 +10757,21 @@ is_pvops_xen(void)
e64a0b
 	     STREQ(sym, "paravirt_patch_default")))
e64a0b
 		return TRUE;
e64a0b
 
e64a0b
-	if (symbol_exists("xen_start_info") &&
e64a0b
-	    readmem(symbol_value("xen_start_info"), KVADDR, &addr,
e64a0b
-	    sizeof(void *), "xen_start_info", RETURN_ON_ERROR) &&
e64a0b
-	    addr != 0)
e64a0b
-		return TRUE;
e64a0b
+	if (machine_type("X86") || machine_type("X86_64")) {
e64a0b
+		if (symbol_exists("xen_start_info") &&
e64a0b
+		    readmem(symbol_value("xen_start_info"), KVADDR, &addr,
e64a0b
+		    sizeof(void *), "xen_start_info", RETURN_ON_ERROR) &&
e64a0b
+		    addr != 0)
e64a0b
+			return TRUE;
e64a0b
+	}
e64a0b
+
e64a0b
+	if (machine_type("ARM") || machine_type("ARM64")) {
e64a0b
+		if (symbol_exists("xen_vcpu_info") &&
e64a0b
+		    readmem(symbol_value("xen_vcpu_info"), KVADDR, &addr,
e64a0b
+		    sizeof(void *), "xen_vcpu_info", RETURN_ON_ERROR) &&
e64a0b
+		    addr != 0)
e64a0b
+			return TRUE;
e64a0b
+	}
e64a0b
 
e64a0b
 	return FALSE;
e64a0b
 }
e64a0b
-- 
e64a0b
2.20.1
e64a0b