Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xen/xenbus: let xenbus_map_ring_valloc() return errno values only

Today xenbus_map_ring_valloc() can return either a negative errno
value (-ENOMEM or -EINVAL) or a grant status value. This is a mess as
e.g -ENOMEM and GNTST_eagain have the same numeric value.

Fix that by turning all grant mapping errors into -ENOENT. This is
no problem as all callers of xenbus_map_ring_valloc() only use the
return value to print an error message, and in case of mapping errors
the grant status value has already been printed by __xenbus_map_ring()
before.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Link: https://lore.kernel.org/r/20200701121638.19840-3-jgross@suse.com
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

authored by

Juergen Gross and committed by
Boris Ostrovsky
578c1bb9 3848e4e0

+6 -16
+6 -16
drivers/xen/xenbus/xenbus_client.c
··· 456 456 * Map @nr_grefs pages of memory into this domain from another 457 457 * domain's grant table. xenbus_map_ring_valloc allocates @nr_grefs 458 458 * pages of virtual address space, maps the pages to that address, and 459 - * sets *vaddr to that address. Returns 0 on success, and GNTST_* 460 - * (see xen/include/interface/grant_table.h) or -ENOMEM / -EINVAL on 459 + * sets *vaddr to that address. Returns 0 on success, and -errno on 461 460 * error. If an error is returned, device will switch to 462 461 * XenbusStateClosing and the error message will be saved in XenStore. 463 462 */ ··· 476 477 return -ENOMEM; 477 478 478 479 info->node = kzalloc(sizeof(*info->node), GFP_KERNEL); 479 - if (!info->node) { 480 + if (!info->node) 480 481 err = -ENOMEM; 481 - goto out; 482 - } 482 + else 483 + err = ring_ops->map(dev, info, gnt_refs, nr_grefs, vaddr); 483 484 484 - err = ring_ops->map(dev, info, gnt_refs, nr_grefs, vaddr); 485 - 486 - /* Some hypervisors are buggy and can return 1. */ 487 - if (err > 0) 488 - err = GNTST_general_error; 489 - 490 - out: 491 485 kfree(info->node); 492 486 kfree(info); 493 487 return err; ··· 499 507 bool *leaked) 500 508 { 501 509 int i, j; 502 - int err = GNTST_okay; 503 510 504 511 if (nr_grefs > XENBUS_MAX_RING_GRANTS) 505 512 return -EINVAL; ··· 513 522 514 523 for (i = 0; i < nr_grefs; i++) { 515 524 if (info->map[i].status != GNTST_okay) { 516 - err = info->map[i].status; 517 525 xenbus_dev_fatal(dev, info->map[i].status, 518 526 "mapping in shared page %d from domain %d", 519 527 gnt_refs[i], dev->otherend_id); ··· 521 531 handles[i] = info->map[i].handle; 522 532 } 523 533 524 - return GNTST_okay; 534 + return 0; 525 535 526 536 fail: 527 537 for (i = j = 0; i < nr_grefs; i++) { ··· 544 554 } 545 555 } 546 556 547 - return err; 557 + return -ENOENT; 548 558 } 549 559 550 560 /**