There is a regression been found for xen hyper due to the commit:
f615f8fab7bf ("Fix "irq -a" exceeding the memory range issue").
The reason is for xen hyper, kt->cpu is not initialized due to
kernel_init() won't be called. So 0 would be assigned to cpulen and
fails the GETBUF().
Before:
crash> bt -c 2
bt: zero-size memory allocation! (called from 51f168)
After:
crash> bt -c 2
PCPU: 0 VCPU: ffff8300001b8080
#0 [ffff8300001bfe00] machine_crash_kexec at ffff83000010de72
#1 [ffff8300001bfe10] do_kexec_op at ffff83000010e3cb
#2 [ffff8300001bfe50] do_console_io at ffff83000011aff4
#3 [ffff8300001bfe90] mod_l1_entry at ffff830000129045
#4 [ffff8300001bfea0] toggle_guest_mode at ffff8300001641bf
#5 [ffff8300001bfeb0] do_iret at ffff830000164888
#6 [ffff8300001bff20] syscall_enter at ffff8300001633d2
Since xen hyper will initialize its own cpumask_t, this patch will reuse
it for XEN_HYPER_MODE. In addition, this patch won't modify the similar
code hunk in generic_get_irq_affinity(), because for xen, there is no
"irq" cmd, so the regression won't be triggered.
Cc: Sourabh Jain <sourabhjain(a)linux.ibm.com>
Cc: Hari Bathini <hbathini(a)linux.ibm.com>
Cc: Mahesh J Salgaonkar <mahesh(a)linux.ibm.com>
Cc: Naveen N. Rao <naveen.n.rao(a)linux.vnet.ibm.com>
Cc: Lianbo Jiang <lijiang(a)redhat.com>
Cc: HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab(a)nec.com>
Cc: Tao Liu <ltao(a)redhat.com>
Cc: Alexey Makhalov <alexey.makhalov(a)broadcom.com>
Cc: Aditya Gupta <adityag(a)linux.ibm.com>
Signed-off-by: Tao Liu <ltao(a)redhat.com>
---
tools.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools.c b/tools.c
index 2b78b95..dec6e5b 100644
--- a/tools.c
+++ b/tools.c
@@ -16,6 +16,7 @@
*/
#include "defs.h"
+#include "xen_hyper_defs.h"
#include <ctype.h>
#ifdef VALGRIND
@@ -6720,6 +6721,11 @@ get_cpumask_buf(void)
{
int cpulen, len_cpumask;
+#ifdef XEN_HYPERVISOR_ARCH
+ if (XEN_HYPER_MODE() && XEN_HYPER_VALID_SIZE(cpumask_t))
+ return (ulong *)GETBUF(XEN_HYPER_SIZE(cpumask_t));
+#endif
+
cpulen = DIV_ROUND_UP(kt->cpus, BITS_PER_LONG) * sizeof(ulong);
len_cpumask = STRUCT_SIZE("cpumask_t");
if (len_cpumask > 0)
--
2.40.1