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.

Merge tag 'for-linus-5.15-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip

Pull xen updates from Juergen Gross:

- some small cleanups

- a fix for a bug when running as Xen PV guest which could result in
not all memory being transferred in case of a migration of the guest

- a small series for getting rid of code for supporting very old Xen
hypervisor versions nobody should be using since many years now

- a series for hardening the Xen block frontend driver

- a fix for Xen PV boot code issuing warning messages due to a stray
preempt_disable() on the non-boot processors

* tag 'for-linus-5.15-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
xen: remove stray preempt_disable() from PV AP startup code
xen/pcifront: Removed unnecessary __ref annotation
x86: xen: platform-pci-unplug: use pr_err() and pr_warn() instead of raw printk()
drivers/xen/xenbus/xenbus_client.c: fix bugon.cocci warnings
xen/blkfront: don't trust the backend response data blindly
xen/blkfront: don't take local copy of a request from the ring page
xen/blkfront: read response from backend only once
xen: assume XENFEAT_gnttab_map_avail_bits being set for pv guests
xen: assume XENFEAT_mmu_pt_update_preserve_ad being set for pv guests
xen: check required Xen features
xen: fix setting of max_pfn in shared_info

+141 -115
+2 -10
arch/x86/xen/enlighten_pv.c
··· 116 116 HYPERVISOR_xen_version(XENVER_extraversion, &extra); 117 117 118 118 pr_info("Booting paravirtualized kernel on %s\n", pv_info.name); 119 - printk(KERN_INFO "Xen version: %d.%d%s%s\n", 120 - version >> 16, version & 0xffff, extra.extraversion, 121 - xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" : ""); 119 + pr_info("Xen version: %d.%d%s (preserve-AD)\n", 120 + version >> 16, version & 0xffff, extra.extraversion); 122 121 } 123 122 124 123 static void __init xen_pv_init_platform(void) ··· 1300 1301 */ 1301 1302 xen_init_apic(); 1302 1303 #endif 1303 - 1304 - if (xen_feature(XENFEAT_mmu_pt_update_preserve_ad)) { 1305 - pv_ops.mmu.ptep_modify_prot_start = 1306 - xen_ptep_modify_prot_start; 1307 - pv_ops.mmu.ptep_modify_prot_commit = 1308 - xen_ptep_modify_prot_commit; 1309 - } 1310 1304 1311 1305 machine_ops = xen_machine_ops; 1312 1306
+2 -2
arch/x86/xen/mmu_pv.c
··· 2099 2099 .set_pte = xen_set_pte_init, 2100 2100 .set_pmd = xen_set_pmd_hyper, 2101 2101 2102 - .ptep_modify_prot_start = __ptep_modify_prot_start, 2103 - .ptep_modify_prot_commit = __ptep_modify_prot_commit, 2102 + .ptep_modify_prot_start = xen_ptep_modify_prot_start, 2103 + .ptep_modify_prot_commit = xen_ptep_modify_prot_commit, 2104 2104 2105 2105 .pte_val = PV_CALLEE_SAVE(xen_pte_val), 2106 2106 .pgd_val = PV_CALLEE_SAVE(xen_pgd_val),
+2 -2
arch/x86/xen/p2m.c
··· 618 618 } 619 619 620 620 /* Expanded the p2m? */ 621 - if (pfn > xen_p2m_last_pfn) { 622 - xen_p2m_last_pfn = pfn; 621 + if (pfn >= xen_p2m_last_pfn) { 622 + xen_p2m_last_pfn = ALIGN(pfn + 1, P2M_PER_PAGE); 623 623 HYPERVISOR_shared_info->arch.max_pfn = xen_p2m_last_pfn; 624 624 } 625 625
+9 -7
arch/x86/xen/platform-pci-unplug.c
··· 7 7 * Copyright (c) 2010, Citrix 8 8 */ 9 9 10 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 11 + 10 12 #include <linux/init.h> 11 13 #include <linux/io.h> 12 14 #include <linux/export.h> ··· 32 30 33 31 magic = inw(XEN_IOPORT_MAGIC); 34 32 if (magic != XEN_IOPORT_MAGIC_VAL) { 35 - printk(KERN_ERR "Xen Platform PCI: unrecognised magic value\n"); 33 + pr_err("Xen Platform PCI: unrecognised magic value\n"); 36 34 return XEN_PLATFORM_ERR_MAGIC; 37 35 } 38 36 39 37 protocol = inb(XEN_IOPORT_PROTOVER); 40 38 41 - printk(KERN_DEBUG "Xen Platform PCI: I/O protocol version %d\n", 39 + pr_debug("Xen Platform PCI: I/O protocol version %d\n", 42 40 protocol); 43 41 44 42 switch (protocol) { ··· 46 44 outw(XEN_IOPORT_LINUX_PRODNUM, XEN_IOPORT_PRODNUM); 47 45 outl(XEN_IOPORT_LINUX_DRVVER, XEN_IOPORT_DRVVER); 48 46 if (inw(XEN_IOPORT_MAGIC) != XEN_IOPORT_MAGIC_VAL) { 49 - printk(KERN_ERR "Xen Platform: blacklisted by host\n"); 47 + pr_err("Xen Platform: blacklisted by host\n"); 50 48 return XEN_PLATFORM_ERR_BLACKLIST; 51 49 } 52 50 break; 53 51 default: 54 - printk(KERN_WARNING "Xen Platform PCI: unknown I/O protocol version\n"); 52 + pr_warn("Xen Platform PCI: unknown I/O protocol version\n"); 55 53 return XEN_PLATFORM_ERR_PROTOCOL; 56 54 } 57 55 ··· 157 155 * been compiled for this kernel (modules or built-in are both OK). */ 158 156 if (!xen_emul_unplug) { 159 157 if (xen_must_unplug_nics()) { 160 - printk(KERN_INFO "Netfront and the Xen platform PCI driver have " 158 + pr_info("Netfront and the Xen platform PCI driver have " 161 159 "been compiled for this kernel: unplug emulated NICs.\n"); 162 160 xen_emul_unplug |= XEN_UNPLUG_ALL_NICS; 163 161 } 164 162 if (xen_must_unplug_disks()) { 165 - printk(KERN_INFO "Blkfront and the Xen platform PCI driver have " 163 + pr_info("Blkfront and the Xen platform PCI driver have " 166 164 "been compiled for this kernel: unplug emulated disks.\n" 167 165 "You might have to change the root device\n" 168 166 "from /dev/hd[a-d] to /dev/xvd[a-d]\n" ··· 202 200 else if (!strncmp(p, "never", l)) 203 201 xen_emul_unplug |= XEN_UNPLUG_NEVER; 204 202 else 205 - printk(KERN_WARNING "unrecognised option '%s' " 203 + pr_warn("unrecognised option '%s' " 206 204 "in parameter 'xen_emul_unplug'\n", p); 207 205 } 208 206 return 0;
-1
arch/x86/xen/smp_pv.c
··· 64 64 cr4_init(); 65 65 cpu_init(); 66 66 touch_softlockup_watchdog(); 67 - preempt_disable(); 68 67 69 68 /* PVH runs in ring 0 and allows us to do native syscalls. Yay! */ 70 69 if (!xen_feature(XENFEAT_supervisor_mode_kernel)) {
+84 -42
drivers/block/xen-blkfront.c
··· 80 80 BLKIF_STATE_DISCONNECTED, 81 81 BLKIF_STATE_CONNECTED, 82 82 BLKIF_STATE_SUSPENDED, 83 + BLKIF_STATE_ERROR, 83 84 }; 84 85 85 86 struct grant { ··· 90 89 }; 91 90 92 91 enum blk_req_status { 92 + REQ_PROCESSING, 93 93 REQ_WAITING, 94 94 REQ_DONE, 95 95 REQ_ERROR, ··· 532 530 533 531 id = get_id_from_freelist(rinfo); 534 532 rinfo->shadow[id].request = req; 535 - rinfo->shadow[id].status = REQ_WAITING; 533 + rinfo->shadow[id].status = REQ_PROCESSING; 536 534 rinfo->shadow[id].associated_id = NO_ASSOCIATED_ID; 537 535 538 - (*ring_req)->u.rw.id = id; 536 + rinfo->shadow[id].req.u.rw.id = id; 539 537 540 538 return id; 541 539 } ··· 543 541 static int blkif_queue_discard_req(struct request *req, struct blkfront_ring_info *rinfo) 544 542 { 545 543 struct blkfront_info *info = rinfo->dev_info; 546 - struct blkif_request *ring_req; 544 + struct blkif_request *ring_req, *final_ring_req; 547 545 unsigned long id; 548 546 549 547 /* Fill out a communications ring structure. */ 550 - id = blkif_ring_get_request(rinfo, req, &ring_req); 548 + id = blkif_ring_get_request(rinfo, req, &final_ring_req); 549 + ring_req = &rinfo->shadow[id].req; 551 550 552 551 ring_req->operation = BLKIF_OP_DISCARD; 553 552 ring_req->u.discard.nr_sectors = blk_rq_sectors(req); ··· 559 556 else 560 557 ring_req->u.discard.flag = 0; 561 558 562 - /* Keep a private copy so we can reissue requests when recovering. */ 563 - rinfo->shadow[id].req = *ring_req; 559 + /* Copy the request to the ring page. */ 560 + *final_ring_req = *ring_req; 561 + rinfo->shadow[id].status = REQ_WAITING; 564 562 565 563 return 0; 566 564 } ··· 694 690 { 695 691 struct blkfront_info *info = rinfo->dev_info; 696 692 struct blkif_request *ring_req, *extra_ring_req = NULL; 693 + struct blkif_request *final_ring_req, *final_extra_ring_req = NULL; 697 694 unsigned long id, extra_id = NO_ASSOCIATED_ID; 698 695 bool require_extra_req = false; 699 696 int i; ··· 739 734 } 740 735 741 736 /* Fill out a communications ring structure. */ 742 - id = blkif_ring_get_request(rinfo, req, &ring_req); 737 + id = blkif_ring_get_request(rinfo, req, &final_ring_req); 738 + ring_req = &rinfo->shadow[id].req; 743 739 744 740 num_sg = blk_rq_map_sg(req->q, req, rinfo->shadow[id].sg); 745 741 num_grant = 0; ··· 791 785 ring_req->u.rw.nr_segments = num_grant; 792 786 if (unlikely(require_extra_req)) { 793 787 extra_id = blkif_ring_get_request(rinfo, req, 794 - &extra_ring_req); 788 + &final_extra_ring_req); 789 + extra_ring_req = &rinfo->shadow[extra_id].req; 790 + 795 791 /* 796 792 * Only the first request contains the scatter-gather 797 793 * list. ··· 835 827 if (setup.segments) 836 828 kunmap_atomic(setup.segments); 837 829 838 - /* Keep a private copy so we can reissue requests when recovering. */ 839 - rinfo->shadow[id].req = *ring_req; 840 - if (unlikely(require_extra_req)) 841 - rinfo->shadow[extra_id].req = *extra_ring_req; 830 + /* Copy request(s) to the ring page. */ 831 + *final_ring_req = *ring_req; 832 + rinfo->shadow[id].status = REQ_WAITING; 833 + if (unlikely(require_extra_req)) { 834 + *final_extra_ring_req = *extra_ring_req; 835 + rinfo->shadow[extra_id].status = REQ_WAITING; 836 + } 842 837 843 838 if (new_persistent_gnts) 844 839 gnttab_free_grant_references(setup.gref_head); ··· 1364 1353 static int blkif_get_final_status(enum blk_req_status s1, 1365 1354 enum blk_req_status s2) 1366 1355 { 1367 - BUG_ON(s1 == REQ_WAITING); 1368 - BUG_ON(s2 == REQ_WAITING); 1356 + BUG_ON(s1 < REQ_DONE); 1357 + BUG_ON(s2 < REQ_DONE); 1369 1358 1370 1359 if (s1 == REQ_ERROR || s2 == REQ_ERROR) 1371 1360 return BLKIF_RSP_ERROR; ··· 1398 1387 s->status = blkif_rsp_to_req_status(bret->status); 1399 1388 1400 1389 /* Wait the second response if not yet here. */ 1401 - if (s2->status == REQ_WAITING) 1390 + if (s2->status < REQ_DONE) 1402 1391 return false; 1403 1392 1404 1393 bret->status = blkif_get_final_status(s->status, ··· 1506 1495 static irqreturn_t blkif_interrupt(int irq, void *dev_id) 1507 1496 { 1508 1497 struct request *req; 1509 - struct blkif_response *bret; 1498 + struct blkif_response bret; 1510 1499 RING_IDX i, rp; 1511 1500 unsigned long flags; 1512 1501 struct blkfront_ring_info *rinfo = (struct blkfront_ring_info *)dev_id; ··· 1517 1506 1518 1507 spin_lock_irqsave(&rinfo->ring_lock, flags); 1519 1508 again: 1520 - rp = rinfo->ring.sring->rsp_prod; 1521 - rmb(); /* Ensure we see queued responses up to 'rp'. */ 1509 + rp = READ_ONCE(rinfo->ring.sring->rsp_prod); 1510 + virt_rmb(); /* Ensure we see queued responses up to 'rp'. */ 1511 + if (RING_RESPONSE_PROD_OVERFLOW(&rinfo->ring, rp)) { 1512 + pr_alert("%s: illegal number of responses %u\n", 1513 + info->gd->disk_name, rp - rinfo->ring.rsp_cons); 1514 + goto err; 1515 + } 1522 1516 1523 1517 for (i = rinfo->ring.rsp_cons; i != rp; i++) { 1524 1518 unsigned long id; 1519 + unsigned int op; 1525 1520 1526 - bret = RING_GET_RESPONSE(&rinfo->ring, i); 1527 - id = bret->id; 1521 + RING_COPY_RESPONSE(&rinfo->ring, i, &bret); 1522 + id = bret.id; 1523 + 1528 1524 /* 1529 1525 * The backend has messed up and given us an id that we would 1530 1526 * never have given to it (we stamp it up to BLK_RING_SIZE - 1531 1527 * look in get_id_from_freelist. 1532 1528 */ 1533 1529 if (id >= BLK_RING_SIZE(info)) { 1534 - WARN(1, "%s: response to %s has incorrect id (%ld)\n", 1535 - info->gd->disk_name, op_name(bret->operation), id); 1536 - /* We can't safely get the 'struct request' as 1537 - * the id is busted. */ 1538 - continue; 1530 + pr_alert("%s: response has incorrect id (%ld)\n", 1531 + info->gd->disk_name, id); 1532 + goto err; 1539 1533 } 1534 + if (rinfo->shadow[id].status != REQ_WAITING) { 1535 + pr_alert("%s: response references no pending request\n", 1536 + info->gd->disk_name); 1537 + goto err; 1538 + } 1539 + 1540 + rinfo->shadow[id].status = REQ_PROCESSING; 1540 1541 req = rinfo->shadow[id].request; 1541 1542 1542 - if (bret->operation != BLKIF_OP_DISCARD) { 1543 + op = rinfo->shadow[id].req.operation; 1544 + if (op == BLKIF_OP_INDIRECT) 1545 + op = rinfo->shadow[id].req.u.indirect.indirect_op; 1546 + if (bret.operation != op) { 1547 + pr_alert("%s: response has wrong operation (%u instead of %u)\n", 1548 + info->gd->disk_name, bret.operation, op); 1549 + goto err; 1550 + } 1551 + 1552 + if (bret.operation != BLKIF_OP_DISCARD) { 1543 1553 /* 1544 1554 * We may need to wait for an extra response if the 1545 1555 * I/O request is split in 2 1546 1556 */ 1547 - if (!blkif_completion(&id, rinfo, bret)) 1557 + if (!blkif_completion(&id, rinfo, &bret)) 1548 1558 continue; 1549 1559 } 1550 1560 1551 1561 if (add_id_to_freelist(rinfo, id)) { 1552 1562 WARN(1, "%s: response to %s (id %ld) couldn't be recycled!\n", 1553 - info->gd->disk_name, op_name(bret->operation), id); 1563 + info->gd->disk_name, op_name(bret.operation), id); 1554 1564 continue; 1555 1565 } 1556 1566 1557 - if (bret->status == BLKIF_RSP_OKAY) 1567 + if (bret.status == BLKIF_RSP_OKAY) 1558 1568 blkif_req(req)->error = BLK_STS_OK; 1559 1569 else 1560 1570 blkif_req(req)->error = BLK_STS_IOERR; 1561 1571 1562 - switch (bret->operation) { 1572 + switch (bret.operation) { 1563 1573 case BLKIF_OP_DISCARD: 1564 - if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) { 1574 + if (unlikely(bret.status == BLKIF_RSP_EOPNOTSUPP)) { 1565 1575 struct request_queue *rq = info->rq; 1566 - printk(KERN_WARNING "blkfront: %s: %s op failed\n", 1567 - info->gd->disk_name, op_name(bret->operation)); 1576 + 1577 + pr_warn_ratelimited("blkfront: %s: %s op failed\n", 1578 + info->gd->disk_name, op_name(bret.operation)); 1568 1579 blkif_req(req)->error = BLK_STS_NOTSUPP; 1569 1580 info->feature_discard = 0; 1570 1581 info->feature_secdiscard = 0; ··· 1596 1563 break; 1597 1564 case BLKIF_OP_FLUSH_DISKCACHE: 1598 1565 case BLKIF_OP_WRITE_BARRIER: 1599 - if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) { 1600 - printk(KERN_WARNING "blkfront: %s: %s op failed\n", 1601 - info->gd->disk_name, op_name(bret->operation)); 1566 + if (unlikely(bret.status == BLKIF_RSP_EOPNOTSUPP)) { 1567 + pr_warn_ratelimited("blkfront: %s: %s op failed\n", 1568 + info->gd->disk_name, op_name(bret.operation)); 1602 1569 blkif_req(req)->error = BLK_STS_NOTSUPP; 1603 1570 } 1604 - if (unlikely(bret->status == BLKIF_RSP_ERROR && 1571 + if (unlikely(bret.status == BLKIF_RSP_ERROR && 1605 1572 rinfo->shadow[id].req.u.rw.nr_segments == 0)) { 1606 - printk(KERN_WARNING "blkfront: %s: empty %s op failed\n", 1607 - info->gd->disk_name, op_name(bret->operation)); 1573 + pr_warn_ratelimited("blkfront: %s: empty %s op failed\n", 1574 + info->gd->disk_name, op_name(bret.operation)); 1608 1575 blkif_req(req)->error = BLK_STS_NOTSUPP; 1609 1576 } 1610 1577 if (unlikely(blkif_req(req)->error)) { ··· 1617 1584 fallthrough; 1618 1585 case BLKIF_OP_READ: 1619 1586 case BLKIF_OP_WRITE: 1620 - if (unlikely(bret->status != BLKIF_RSP_OKAY)) 1621 - dev_dbg(&info->xbdev->dev, "Bad return from blkdev data " 1622 - "request: %x\n", bret->status); 1587 + if (unlikely(bret.status != BLKIF_RSP_OKAY)) 1588 + dev_dbg_ratelimited(&info->xbdev->dev, 1589 + "Bad return from blkdev data request: %#x\n", 1590 + bret.status); 1623 1591 1624 1592 break; 1625 1593 default: ··· 1645 1611 1646 1612 spin_unlock_irqrestore(&rinfo->ring_lock, flags); 1647 1613 1614 + return IRQ_HANDLED; 1615 + 1616 + err: 1617 + info->connected = BLKIF_STATE_ERROR; 1618 + 1619 + spin_unlock_irqrestore(&rinfo->ring_lock, flags); 1620 + 1621 + pr_alert("%s disabled for further use\n", info->gd->disk_name); 1648 1622 return IRQ_HANDLED; 1649 1623 } 1650 1624
+19 -11
drivers/pci/xen-pcifront.c
··· 115 115 struct xen_pci_op *active_op = &pdev->sh_info->op; 116 116 unsigned long irq_flags; 117 117 evtchn_port_t port = pdev->evtchn; 118 - unsigned irq = pdev->irq; 118 + unsigned int irq = pdev->irq; 119 119 s64 ns, ns_timeout; 120 120 121 121 spin_lock_irqsave(&pdev->sh_info_lock, irq_flags); ··· 153 153 } 154 154 155 155 /* 156 - * We might lose backend service request since we 157 - * reuse same evtchn with pci_conf backend response. So re-schedule 158 - * aer pcifront service. 159 - */ 156 + * We might lose backend service request since we 157 + * reuse same evtchn with pci_conf backend response. So re-schedule 158 + * aer pcifront service. 159 + */ 160 160 if (test_bit(_XEN_PCIB_active, 161 161 (unsigned long *)&pdev->sh_info->flags)) { 162 162 dev_err(&pdev->xdev->dev, ··· 414 414 struct pci_dev *d; 415 415 unsigned int devfn; 416 416 417 - /* Scan the bus for functions and add. 417 + /* 418 + * Scan the bus for functions and add. 418 419 * We omit handling of PCI bridge attachment because pciback prevents 419 420 * bridges from being exported. 420 421 */ ··· 493 492 494 493 list_add(&bus_entry->list, &pdev->root_buses); 495 494 496 - /* pci_scan_root_bus skips devices which do not have a 497 - * devfn==0. The pcifront_scan_bus enumerates all devfn. */ 495 + /* 496 + * pci_scan_root_bus skips devices which do not have a 497 + * devfn==0. The pcifront_scan_bus enumerates all devfn. 498 + */ 498 499 err = pcifront_scan_bus(pdev, domain, bus, b); 499 500 500 501 /* Claim resources before going "live" with our devices */ ··· 654 651 pci_channel_state_t state = 655 652 (pci_channel_state_t)pdev->sh_info->aer_op.err; 656 653 657 - /*If a pci_conf op is in progress, 658 - we have to wait until it is done before service aer op*/ 654 + /* 655 + * If a pci_conf op is in progress, we have to wait until it is done 656 + * before service aer op 657 + */ 659 658 dev_dbg(&pdev->xdev->dev, 660 659 "pcifront service aer bus %x devfn %x\n", 661 660 pdev->sh_info->aer_op.bus, pdev->sh_info->aer_op.devfn); ··· 681 676 static irqreturn_t pcifront_handler_aer(int irq, void *dev) 682 677 { 683 678 struct pcifront_device *pdev = dev; 679 + 684 680 schedule_pcifront_aer_op(pdev); 685 681 return IRQ_HANDLED; 686 682 } ··· 1033 1027 /* Find devices being detached and remove them. */ 1034 1028 for (i = 0; i < num_devs; i++) { 1035 1029 int l, state; 1030 + 1036 1031 l = snprintf(str, sizeof(str), "state-%d", i); 1037 1032 if (unlikely(l >= (sizeof(str) - 1))) { 1038 1033 err = -ENOMEM; ··· 1085 1078 return err; 1086 1079 } 1087 1080 1088 - static void __ref pcifront_backend_changed(struct xenbus_device *xdev, 1081 + static void pcifront_backend_changed(struct xenbus_device *xdev, 1089 1082 enum xenbus_state be_state) 1090 1083 { 1091 1084 struct pcifront_device *pdev = dev_get_drvdata(&xdev->dev); ··· 1144 1137 static int pcifront_xenbus_remove(struct xenbus_device *xdev) 1145 1138 { 1146 1139 struct pcifront_device *pdev = dev_get_drvdata(&xdev->dev); 1140 + 1147 1141 if (pdev) 1148 1142 free_pdev(pdev); 1149 1143
+18
drivers/xen/features.c
··· 9 9 #include <linux/types.h> 10 10 #include <linux/cache.h> 11 11 #include <linux/export.h> 12 + #include <linux/printk.h> 12 13 13 14 #include <asm/xen/hypercall.h> 14 15 16 + #include <xen/xen.h> 15 17 #include <xen/interface/xen.h> 16 18 #include <xen/interface/version.h> 17 19 #include <xen/features.h> 20 + 21 + /* 22 + * Linux kernel expects at least Xen 4.0. 23 + * 24 + * Assume some features to be available for that reason (depending on guest 25 + * mode, of course). 26 + */ 27 + #define chk_required_feature(f) { \ 28 + if (!xen_feature(f)) \ 29 + panic("Xen: feature %s not available!\n", #f); \ 30 + } 18 31 19 32 u8 xen_features[XENFEAT_NR_SUBMAPS * 32] __read_mostly; 20 33 EXPORT_SYMBOL_GPL(xen_features); ··· 43 30 break; 44 31 for (j = 0; j < 32; j++) 45 32 xen_features[i * 32 + j] = !!(fi.submap & 1<<j); 33 + } 34 + 35 + if (xen_pv_domain()) { 36 + chk_required_feature(XENFEAT_mmu_pt_update_preserve_ad); 37 + chk_required_feature(XENFEAT_gnttab_map_avail_bits); 46 38 } 47 39 }
+2 -34
drivers/xen/gntdev.c
··· 266 266 { 267 267 struct gntdev_grant_map *map = data; 268 268 unsigned int pgnr = (addr - map->vma->vm_start) >> PAGE_SHIFT; 269 - int flags = map->flags | GNTMAP_application_map | GNTMAP_contains_pte; 269 + int flags = map->flags | GNTMAP_application_map | GNTMAP_contains_pte | 270 + (1 << _GNTMAP_guest_avail0); 270 271 u64 pte_maddr; 271 272 272 273 BUG_ON(pgnr >= map->count); 273 274 pte_maddr = arbitrary_virt_to_machine(pte).maddr; 274 - 275 - /* 276 - * Set the PTE as special to force get_user_pages_fast() fall 277 - * back to the slow path. If this is not supported as part of 278 - * the grant map, it will be done afterwards. 279 - */ 280 - if (xen_feature(XENFEAT_gnttab_map_avail_bits)) 281 - flags |= (1 << _GNTMAP_guest_avail0); 282 275 283 276 gnttab_set_map_op(&map->map_ops[pgnr], pte_maddr, flags, 284 277 map->grants[pgnr].ref, ··· 280 287 INVALID_GRANT_HANDLE); 281 288 return 0; 282 289 } 283 - 284 - #ifdef CONFIG_X86 285 - static int set_grant_ptes_as_special(pte_t *pte, unsigned long addr, void *data) 286 - { 287 - set_pte_at(current->mm, addr, pte, pte_mkspecial(*pte)); 288 - return 0; 289 - } 290 - #endif 291 290 292 291 int gntdev_map_grant_pages(struct gntdev_grant_map *map) 293 292 { ··· 1040 1055 err = vm_map_pages_zero(vma, map->pages, map->count); 1041 1056 if (err) 1042 1057 goto out_put_map; 1043 - } else { 1044 - #ifdef CONFIG_X86 1045 - /* 1046 - * If the PTEs were not made special by the grant map 1047 - * hypercall, do so here. 1048 - * 1049 - * This is racy since the mapping is already visible 1050 - * to userspace but userspace should be well-behaved 1051 - * enough to not touch it until the mmap() call 1052 - * returns. 1053 - */ 1054 - if (!xen_feature(XENFEAT_gnttab_map_avail_bits)) { 1055 - apply_to_page_range(vma->vm_mm, vma->vm_start, 1056 - vma->vm_end - vma->vm_start, 1057 - set_grant_ptes_as_special, NULL); 1058 - } 1059 - #endif 1060 1058 } 1061 1059 1062 1060 return 0;
+3 -6
drivers/xen/xenbus/xenbus_client.c
··· 542 542 } 543 543 } 544 544 545 - if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, info->unmap, j)) 546 - BUG(); 545 + BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, info->unmap, j)); 547 546 548 547 *leaked = false; 549 548 for (i = 0; i < j; i++) { ··· 580 581 gnttab_set_unmap_op(&unmap[i], vaddrs[i], 581 582 GNTMAP_host_map, handles[i]); 582 583 583 - if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap, i)) 584 - BUG(); 584 + BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap, i)); 585 585 586 586 err = GNTST_okay; 587 587 for (i = 0; i < nr_handles; i++) { ··· 776 778 unmap[i].handle = node->handles[i]; 777 779 } 778 780 779 - if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap, i)) 780 - BUG(); 781 + BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap, i)); 781 782 782 783 err = GNTST_okay; 783 784 leaked = false;