From: kernel test robot <lkp@intel.com>
To: Benjamin Gwin <bgwin@google.com>
Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
Will Deacon <will@kernel.org>
Subject: arch/arm64/kernel/kexec_image.c:130:16: sparse: sparse: Using plain integer as NULL pointer
Date: Mon, 9 Nov 2020 17:37:40 +0800 [thread overview]
Message-ID: <202011091736.T0zH8kaC-lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 5070 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: f8394f232b1eab649ce2df5c5f15b0e528c92091
commit: 108aa503657ee2fe8aa071dc620d96372c252ecd arm64: kexec_file: try more regions if loading segments fails
date: 4 days ago
config: arm64-randconfig-s032-20201109 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-76-gf680124b-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=108aa503657ee2fe8aa071dc620d96372c252ecd
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 108aa503657ee2fe8aa071dc620d96372c252ecd
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
"sparse warnings: (new ones prefixed by >>)"
>> arch/arm64/kernel/kexec_image.c:130:16: sparse: sparse: Using plain integer as NULL pointer
vim +130 arch/arm64/kernel/kexec_image.c
36
37 static void *image_load(struct kimage *image,
38 char *kernel, unsigned long kernel_len,
39 char *initrd, unsigned long initrd_len,
40 char *cmdline, unsigned long cmdline_len)
41 {
42 struct arm64_image_header *h;
43 u64 flags, value;
44 bool be_image, be_kernel;
45 struct kexec_buf kbuf;
46 unsigned long text_offset, kernel_segment_number;
47 struct kexec_segment *kernel_segment;
48 int ret;
49
50 /*
51 * We require a kernel with an unambiguous Image header. Per
52 * Documentation/arm64/booting.rst, this is the case when image_size
53 * is non-zero (practically speaking, since v3.17).
54 */
55 h = (struct arm64_image_header *)kernel;
56 if (!h->image_size)
57 return ERR_PTR(-EINVAL);
58
59 /* Check cpu features */
60 flags = le64_to_cpu(h->flags);
61 be_image = arm64_image_flag_field(flags, ARM64_IMAGE_FLAG_BE);
62 be_kernel = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN);
63 if ((be_image != be_kernel) && !system_supports_mixed_endian())
64 return ERR_PTR(-EINVAL);
65
66 value = arm64_image_flag_field(flags, ARM64_IMAGE_FLAG_PAGE_SIZE);
67 if (((value == ARM64_IMAGE_FLAG_PAGE_SIZE_4K) &&
68 !system_supports_4kb_granule()) ||
69 ((value == ARM64_IMAGE_FLAG_PAGE_SIZE_64K) &&
70 !system_supports_64kb_granule()) ||
71 ((value == ARM64_IMAGE_FLAG_PAGE_SIZE_16K) &&
72 !system_supports_16kb_granule()))
73 return ERR_PTR(-EINVAL);
74
75 /* Load the kernel */
76 kbuf.image = image;
77 kbuf.buf_min = 0;
78 kbuf.buf_max = ULONG_MAX;
79 kbuf.top_down = false;
80
81 kbuf.buffer = kernel;
82 kbuf.bufsz = kernel_len;
83 kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
84 kbuf.memsz = le64_to_cpu(h->image_size);
85 text_offset = le64_to_cpu(h->text_offset);
86 kbuf.buf_align = MIN_KIMG_ALIGN;
87
88 /* Adjust kernel segment with TEXT_OFFSET */
89 kbuf.memsz += text_offset;
90
91 kernel_segment_number = image->nr_segments;
92
93 /*
94 * The location of the kernel segment may make it impossible to satisfy
95 * the other segment requirements, so we try repeatedly to find a
96 * location that will work.
97 */
98 while ((ret = kexec_add_buffer(&kbuf)) == 0) {
99 /* Try to load additional data */
100 kernel_segment = &image->segment[kernel_segment_number];
101 ret = load_other_segments(image, kernel_segment->mem,
102 kernel_segment->memsz, initrd,
103 initrd_len, cmdline);
104 if (!ret)
105 break;
106
107 /*
108 * We couldn't find space for the other segments; erase the
109 * kernel segment and try the next available hole.
110 */
111 image->nr_segments -= 1;
112 kbuf.buf_min = kernel_segment->mem + kernel_segment->memsz;
113 kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
114 }
115
116 if (ret) {
117 pr_err("Could not find any suitable kernel location!");
118 return ERR_PTR(ret);
119 }
120
121 kernel_segment = &image->segment[kernel_segment_number];
122 kernel_segment->mem += text_offset;
123 kernel_segment->memsz -= text_offset;
124 image->start = kernel_segment->mem;
125
126 pr_debug("Loaded kernel at 0x%lx bufsz=0x%lx memsz=0x%lx\n",
127 kernel_segment->mem, kbuf.bufsz,
128 kernel_segment->memsz);
129
> 130 return 0;
131 }
132
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 40405 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: arch/arm64/kernel/kexec_image.c:130:16: sparse: sparse: Using plain integer as NULL pointer
Date: Mon, 09 Nov 2020 17:37:40 +0800 [thread overview]
Message-ID: <202011091736.T0zH8kaC-lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 5200 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: f8394f232b1eab649ce2df5c5f15b0e528c92091
commit: 108aa503657ee2fe8aa071dc620d96372c252ecd arm64: kexec_file: try more regions if loading segments fails
date: 4 days ago
config: arm64-randconfig-s032-20201109 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-76-gf680124b-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=108aa503657ee2fe8aa071dc620d96372c252ecd
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 108aa503657ee2fe8aa071dc620d96372c252ecd
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
"sparse warnings: (new ones prefixed by >>)"
>> arch/arm64/kernel/kexec_image.c:130:16: sparse: sparse: Using plain integer as NULL pointer
vim +130 arch/arm64/kernel/kexec_image.c
36
37 static void *image_load(struct kimage *image,
38 char *kernel, unsigned long kernel_len,
39 char *initrd, unsigned long initrd_len,
40 char *cmdline, unsigned long cmdline_len)
41 {
42 struct arm64_image_header *h;
43 u64 flags, value;
44 bool be_image, be_kernel;
45 struct kexec_buf kbuf;
46 unsigned long text_offset, kernel_segment_number;
47 struct kexec_segment *kernel_segment;
48 int ret;
49
50 /*
51 * We require a kernel with an unambiguous Image header. Per
52 * Documentation/arm64/booting.rst, this is the case when image_size
53 * is non-zero (practically speaking, since v3.17).
54 */
55 h = (struct arm64_image_header *)kernel;
56 if (!h->image_size)
57 return ERR_PTR(-EINVAL);
58
59 /* Check cpu features */
60 flags = le64_to_cpu(h->flags);
61 be_image = arm64_image_flag_field(flags, ARM64_IMAGE_FLAG_BE);
62 be_kernel = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN);
63 if ((be_image != be_kernel) && !system_supports_mixed_endian())
64 return ERR_PTR(-EINVAL);
65
66 value = arm64_image_flag_field(flags, ARM64_IMAGE_FLAG_PAGE_SIZE);
67 if (((value == ARM64_IMAGE_FLAG_PAGE_SIZE_4K) &&
68 !system_supports_4kb_granule()) ||
69 ((value == ARM64_IMAGE_FLAG_PAGE_SIZE_64K) &&
70 !system_supports_64kb_granule()) ||
71 ((value == ARM64_IMAGE_FLAG_PAGE_SIZE_16K) &&
72 !system_supports_16kb_granule()))
73 return ERR_PTR(-EINVAL);
74
75 /* Load the kernel */
76 kbuf.image = image;
77 kbuf.buf_min = 0;
78 kbuf.buf_max = ULONG_MAX;
79 kbuf.top_down = false;
80
81 kbuf.buffer = kernel;
82 kbuf.bufsz = kernel_len;
83 kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
84 kbuf.memsz = le64_to_cpu(h->image_size);
85 text_offset = le64_to_cpu(h->text_offset);
86 kbuf.buf_align = MIN_KIMG_ALIGN;
87
88 /* Adjust kernel segment with TEXT_OFFSET */
89 kbuf.memsz += text_offset;
90
91 kernel_segment_number = image->nr_segments;
92
93 /*
94 * The location of the kernel segment may make it impossible to satisfy
95 * the other segment requirements, so we try repeatedly to find a
96 * location that will work.
97 */
98 while ((ret = kexec_add_buffer(&kbuf)) == 0) {
99 /* Try to load additional data */
100 kernel_segment = &image->segment[kernel_segment_number];
101 ret = load_other_segments(image, kernel_segment->mem,
102 kernel_segment->memsz, initrd,
103 initrd_len, cmdline);
104 if (!ret)
105 break;
106
107 /*
108 * We couldn't find space for the other segments; erase the
109 * kernel segment and try the next available hole.
110 */
111 image->nr_segments -= 1;
112 kbuf.buf_min = kernel_segment->mem + kernel_segment->memsz;
113 kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
114 }
115
116 if (ret) {
117 pr_err("Could not find any suitable kernel location!");
118 return ERR_PTR(ret);
119 }
120
121 kernel_segment = &image->segment[kernel_segment_number];
122 kernel_segment->mem += text_offset;
123 kernel_segment->memsz -= text_offset;
124 image->start = kernel_segment->mem;
125
126 pr_debug("Loaded kernel at 0x%lx bufsz=0x%lx memsz=0x%lx\n",
127 kernel_segment->mem, kbuf.bufsz,
128 kernel_segment->memsz);
129
> 130 return 0;
131 }
132
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 40405 bytes --]
next reply other threads:[~2020-11-09 9:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-09 9:37 kernel test robot [this message]
2020-11-09 9:37 ` arch/arm64/kernel/kexec_image.c:130:16: sparse: sparse: Using plain integer as NULL pointer kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202011091736.T0zH8kaC-lkp@intel.com \
--to=lkp@intel.com \
--cc=bgwin@google.com \
--cc=kbuild-all@lists.01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.