From: kernel test robot <lkp@intel.com>
To: Breno Leitao <leitao@debian.org>
Cc: oe-kbuild-all@lists.linux.dev,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
Ben Widawsky <ben.widawsky@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
linux-cxl@vger.kernel.org
Subject: [cxl:fixes 4/5] drivers/cxl/acpi.c:299:30: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'resource_size_t' {aka 'unsigned int'}
Date: Sat, 15 Jul 2023 10:02:25 +0800 [thread overview]
Message-ID: <202307151059.2vvBt55H-lkp@intel.com> (raw)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git fixes
head: 0e99e96b85fc2c608a65d05063f40c671214b2da
commit: 3840e10e8dcafc89a2d96ab7dbb640434c8da8cf [4/5] cxl/acpi: Fix a use-after-free in cxl_parse_cfmws()
config: i386-randconfig-i005-20230714 (https://download.01.org/0day-ci/archive/20230715/202307151059.2vvBt55H-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230715/202307151059.2vvBt55H-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202307151059.2vvBt55H-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from include/linux/device.h:15,
from include/linux/platform_device.h:13,
from drivers/cxl/acpi.c:3:
drivers/cxl/acpi.c: In function 'cxl_parse_cfmws':
>> drivers/cxl/acpi.c:299:30: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'resource_size_t' {aka 'unsigned int'} [-Wformat=]
299 | dev_err(dev, "Failed to add decode range [%#llx - %#llx]\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
110 | _p_func(dev, fmt, ##__VA_ARGS__); \
| ^~~
include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
drivers/cxl/acpi.c:299:17: note: in expansion of macro 'dev_err'
299 | dev_err(dev, "Failed to add decode range [%#llx - %#llx]\n",
| ^~~~~~~
drivers/cxl/acpi.c:299:63: note: format string is defined here
299 | dev_err(dev, "Failed to add decode range [%#llx - %#llx]\n",
| ~~~~^
| |
| long long unsigned int
| %#x
drivers/cxl/acpi.c:299:30: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 4 has type 'resource_size_t' {aka 'unsigned int'} [-Wformat=]
299 | dev_err(dev, "Failed to add decode range [%#llx - %#llx]\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
110 | _p_func(dev, fmt, ##__VA_ARGS__); \
| ^~~
include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
drivers/cxl/acpi.c:299:17: note: in expansion of macro 'dev_err'
299 | dev_err(dev, "Failed to add decode range [%#llx - %#llx]\n",
| ^~~~~~~
drivers/cxl/acpi.c:299:71: note: format string is defined here
299 | dev_err(dev, "Failed to add decode range [%#llx - %#llx]\n",
| ~~~~^
| |
| long long unsigned int
| %#x
vim +299 drivers/cxl/acpi.c
f4ce1f766f1ebf Dan Williams 2021-10-29 196
f4ce1f766f1ebf Dan Williams 2021-10-29 197 static int cxl_parse_cfmws(union acpi_subtable_headers *header, void *arg,
f4ce1f766f1ebf Dan Williams 2021-10-29 198 const unsigned long end)
3e23d17ce1980c Alison Schofield 2021-06-17 199 {
a5c25802168993 Dan Williams 2021-09-08 200 int target_map[CXL_DECODER_MAX_INTERLEAVE];
f4ce1f766f1ebf Dan Williams 2021-10-29 201 struct cxl_cfmws_context *ctx = arg;
f4ce1f766f1ebf Dan Williams 2021-10-29 202 struct cxl_port *root_port = ctx->root_port;
974854ab072853 Dan Williams 2022-07-12 203 struct resource *cxl_res = ctx->cxl_res;
f9db85bfec0dcc Alison Schofield 2022-11-30 204 struct cxl_cxims_context cxims_ctx;
0f157c7fa1a0e1 Dan Williams 2022-07-12 205 struct cxl_root_decoder *cxlrd;
f4ce1f766f1ebf Dan Williams 2021-10-29 206 struct device *dev = ctx->dev;
3e23d17ce1980c Alison Schofield 2021-06-17 207 struct acpi_cedt_cfmws *cfmws;
f9db85bfec0dcc Alison Schofield 2022-11-30 208 cxl_calc_hb_fn cxl_calc_hb;
3e23d17ce1980c Alison Schofield 2021-06-17 209 struct cxl_decoder *cxld;
419af595b11891 Dan Williams 2022-05-22 210 unsigned int ways, i, ig;
974854ab072853 Dan Williams 2022-07-12 211 struct resource *res;
419af595b11891 Dan Williams 2022-05-22 212 int rc;
3e23d17ce1980c Alison Schofield 2021-06-17 213
f4ce1f766f1ebf Dan Williams 2021-10-29 214 cfmws = (struct acpi_cedt_cfmws *) header;
3e23d17ce1980c Alison Schofield 2021-06-17 215
3e23d17ce1980c Alison Schofield 2021-06-17 216 rc = cxl_acpi_cfmws_verify(dev, cfmws);
3e23d17ce1980c Alison Schofield 2021-06-17 217 if (rc) {
3e23d17ce1980c Alison Schofield 2021-06-17 218 dev_err(dev, "CFMWS range %#llx-%#llx not registered\n",
f4ce1f766f1ebf Dan Williams 2021-10-29 219 cfmws->base_hpa,
f4ce1f766f1ebf Dan Williams 2021-10-29 220 cfmws->base_hpa + cfmws->window_size - 1);
f4ce1f766f1ebf Dan Williams 2021-10-29 221 return 0;
3e23d17ce1980c Alison Schofield 2021-06-17 222 }
3e23d17ce1980c Alison Schofield 2021-06-17 223
c99b2e8cf79616 Dave Jiang 2022-12-05 224 rc = eiw_to_ways(cfmws->interleave_ways, &ways);
419af595b11891 Dan Williams 2022-05-22 225 if (rc)
419af595b11891 Dan Williams 2022-05-22 226 return rc;
83351ddb786b30 Dave Jiang 2022-12-05 227 rc = eig_to_granularity(cfmws->granularity, &ig);
419af595b11891 Dan Williams 2022-05-22 228 if (rc)
419af595b11891 Dan Williams 2022-05-22 229 return rc;
419af595b11891 Dan Williams 2022-05-22 230 for (i = 0; i < ways; i++)
a5c25802168993 Dan Williams 2021-09-08 231 target_map[i] = cfmws->interleave_targets[i];
a5c25802168993 Dan Williams 2021-09-08 232
974854ab072853 Dan Williams 2022-07-12 233 res = kzalloc(sizeof(*res), GFP_KERNEL);
974854ab072853 Dan Williams 2022-07-12 234 if (!res)
974854ab072853 Dan Williams 2022-07-12 235 return -ENOMEM;
974854ab072853 Dan Williams 2022-07-12 236
974854ab072853 Dan Williams 2022-07-12 237 res->name = kasprintf(GFP_KERNEL, "CXL Window %d", ctx->id++);
974854ab072853 Dan Williams 2022-07-12 238 if (!res->name)
974854ab072853 Dan Williams 2022-07-12 239 goto err_name;
974854ab072853 Dan Williams 2022-07-12 240
974854ab072853 Dan Williams 2022-07-12 241 res->start = cfmws->base_hpa;
974854ab072853 Dan Williams 2022-07-12 242 res->end = cfmws->base_hpa + cfmws->window_size - 1;
974854ab072853 Dan Williams 2022-07-12 243 res->flags = IORESOURCE_MEM;
974854ab072853 Dan Williams 2022-07-12 244
974854ab072853 Dan Williams 2022-07-12 245 /* add to the local resource tracking to establish a sort order */
974854ab072853 Dan Williams 2022-07-12 246 rc = insert_resource(cxl_res, res);
974854ab072853 Dan Williams 2022-07-12 247 if (rc)
974854ab072853 Dan Williams 2022-07-12 248 goto err_insert;
974854ab072853 Dan Williams 2022-07-12 249
f9db85bfec0dcc Alison Schofield 2022-11-30 250 if (cfmws->interleave_arithmetic == ACPI_CEDT_CFMWS_ARITHMETIC_MODULO)
f9db85bfec0dcc Alison Schofield 2022-11-30 251 cxl_calc_hb = cxl_hb_modulo;
f9db85bfec0dcc Alison Schofield 2022-11-30 252 else
f9db85bfec0dcc Alison Schofield 2022-11-30 253 cxl_calc_hb = cxl_hb_xor;
f9db85bfec0dcc Alison Schofield 2022-11-30 254
f9db85bfec0dcc Alison Schofield 2022-11-30 255 cxlrd = cxl_root_decoder_alloc(root_port, ways, cxl_calc_hb);
0f157c7fa1a0e1 Dan Williams 2022-07-12 256 if (IS_ERR(cxlrd))
f4ce1f766f1ebf Dan Williams 2021-10-29 257 return 0;
3e23d17ce1980c Alison Schofield 2021-06-17 258
0f157c7fa1a0e1 Dan Williams 2022-07-12 259 cxld = &cxlrd->cxlsd.cxld;
48667f676189ec Dan Williams 2021-09-21 260 cxld->flags = cfmws_to_decoder_flags(cfmws->restrictions);
5aa39a9165cfc8 Dan Williams 2023-06-14 261 cxld->target_type = CXL_DECODER_HOSTONLYMEM;
e50fe01e1f2a4a Dan Williams 2022-05-18 262 cxld->hpa_range = (struct range) {
974854ab072853 Dan Williams 2022-07-12 263 .start = res->start,
974854ab072853 Dan Williams 2022-07-12 264 .end = res->end,
e50fe01e1f2a4a Dan Williams 2022-05-18 265 };
419af595b11891 Dan Williams 2022-05-22 266 cxld->interleave_ways = ways;
e77483055c325f Dan Williams 2022-07-22 267 /*
e77483055c325f Dan Williams 2022-07-22 268 * Minimize the x1 granularity to advertise support for any
e77483055c325f Dan Williams 2022-07-22 269 * valid region granularity
e77483055c325f Dan Williams 2022-07-22 270 */
e77483055c325f Dan Williams 2022-07-22 271 if (ways == 1)
e77483055c325f Dan Williams 2022-07-22 272 ig = CXL_DECODER_MIN_GRANULARITY;
419af595b11891 Dan Williams 2022-05-22 273 cxld->interleave_granularity = ig;
48667f676189ec Dan Williams 2021-09-21 274
f9db85bfec0dcc Alison Schofield 2022-11-30 275 if (cfmws->interleave_arithmetic == ACPI_CEDT_CFMWS_ARITHMETIC_XOR) {
f9db85bfec0dcc Alison Schofield 2022-11-30 276 if (ways != 1 && ways != 3) {
f9db85bfec0dcc Alison Schofield 2022-11-30 277 cxims_ctx = (struct cxl_cxims_context) {
f9db85bfec0dcc Alison Schofield 2022-11-30 278 .dev = dev,
f9db85bfec0dcc Alison Schofield 2022-11-30 279 .cxlrd = cxlrd,
f9db85bfec0dcc Alison Schofield 2022-11-30 280 };
f9db85bfec0dcc Alison Schofield 2022-11-30 281 rc = acpi_table_parse_cedt(ACPI_CEDT_TYPE_CXIMS,
f9db85bfec0dcc Alison Schofield 2022-11-30 282 cxl_parse_cxims, &cxims_ctx);
f9db85bfec0dcc Alison Schofield 2022-11-30 283 if (rc < 0)
f9db85bfec0dcc Alison Schofield 2022-11-30 284 goto err_xormap;
14628aec8415e4 Alison Schofield 2022-12-04 285 if (!cxlrd->platform_data) {
14628aec8415e4 Alison Schofield 2022-12-04 286 dev_err(dev, "No CXIMS for HBIG %u\n", ig);
14628aec8415e4 Alison Schofield 2022-12-04 287 rc = -EINVAL;
14628aec8415e4 Alison Schofield 2022-12-04 288 goto err_xormap;
14628aec8415e4 Alison Schofield 2022-12-04 289 }
f9db85bfec0dcc Alison Schofield 2022-11-30 290 }
f9db85bfec0dcc Alison Schofield 2022-11-30 291 }
48667f676189ec Dan Williams 2021-09-21 292 rc = cxl_decoder_add(cxld, target_map);
f9db85bfec0dcc Alison Schofield 2022-11-30 293 err_xormap:
48667f676189ec Dan Williams 2021-09-21 294 if (rc)
48667f676189ec Dan Williams 2021-09-21 295 put_device(&cxld->dev);
48667f676189ec Dan Williams 2021-09-21 296 else
48667f676189ec Dan Williams 2021-09-21 297 rc = cxl_decoder_autoremove(dev, cxld);
48667f676189ec Dan Williams 2021-09-21 298 if (rc) {
e50fe01e1f2a4a Dan Williams 2022-05-18 @299 dev_err(dev, "Failed to add decode range [%#llx - %#llx]\n",
3840e10e8dcafc Breno Leitao 2023-07-14 300 res->start, res->end);
f4ce1f766f1ebf Dan Williams 2021-10-29 301 return 0;
da6aafec3dca61 Alison Schofield 2021-06-17 302 }
e50fe01e1f2a4a Dan Williams 2022-05-18 303 dev_dbg(dev, "add: %s node: %d range [%#llx - %#llx]\n",
e50fe01e1f2a4a Dan Williams 2022-05-18 304 dev_name(&cxld->dev),
e50fe01e1f2a4a Dan Williams 2022-05-18 305 phys_to_target_node(cxld->hpa_range.start),
e50fe01e1f2a4a Dan Williams 2022-05-18 306 cxld->hpa_range.start, cxld->hpa_range.end);
da6aafec3dca61 Alison Schofield 2021-06-17 307
f4ce1f766f1ebf Dan Williams 2021-10-29 308 return 0;
974854ab072853 Dan Williams 2022-07-12 309
974854ab072853 Dan Williams 2022-07-12 310 err_insert:
974854ab072853 Dan Williams 2022-07-12 311 kfree(res->name);
974854ab072853 Dan Williams 2022-07-12 312 err_name:
974854ab072853 Dan Williams 2022-07-12 313 kfree(res);
974854ab072853 Dan Williams 2022-07-12 314 return -ENOMEM;
da6aafec3dca61 Alison Schofield 2021-06-17 315 }
da6aafec3dca61 Alison Schofield 2021-06-17 316
:::::: The code at line 299 was first introduced by commit
:::::: e50fe01e1f2a4aba2275edee7d5c77ac87674ddb cxl/core: Drop ->platform_res attribute for root decoders
:::::: TO: Dan Williams <dan.j.williams@intel.com>
:::::: CC: Dan Williams <dan.j.williams@intel.com>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2023-07-15 2:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=202307151059.2vvBt55H-lkp@intel.com \
--to=lkp@intel.com \
--cc=alison.schofield@intel.com \
--cc=ben.widawsky@intel.com \
--cc=dan.j.williams@intel.com \
--cc=ira.weiny@intel.com \
--cc=leitao@debian.org \
--cc=linux-cxl@vger.kernel.org \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=vishal.l.verma@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox