diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/brd.c | 3 | ||||
-rw-r--r-- | drivers/char/tpm/tpm-chip.c | 20 | ||||
-rw-r--r-- | drivers/char/tpm/tpm2-cmd.c | 15 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_of.c | 3 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_tis.c | 8 | ||||
-rw-r--r-- | drivers/nvme/host/pci.c | 15 |
6 files changed, 42 insertions, 22 deletions
diff --git a/drivers/block/brd.c b/drivers/block/brd.c index c9f9c30d6467..a5880f4ab40e 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c | |||
@@ -337,6 +337,9 @@ static blk_qc_t brd_make_request(struct request_queue *q, struct bio *bio) | |||
337 | goto io_error; | 337 | goto io_error; |
338 | 338 | ||
339 | if (unlikely(bio->bi_rw & REQ_DISCARD)) { | 339 | if (unlikely(bio->bi_rw & REQ_DISCARD)) { |
340 | if (sector & ((PAGE_SIZE >> SECTOR_SHIFT) - 1) || | ||
341 | bio->bi_iter.bi_size & PAGE_MASK) | ||
342 | goto io_error; | ||
340 | discard_from_brd(brd, sector, bio->bi_iter.bi_size); | 343 | discard_from_brd(brd, sector, bio->bi_iter.bi_size); |
341 | goto out; | 344 | goto out; |
342 | } | 345 | } |
diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index f26b0ae23bea..45cc39aabeee 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c | |||
@@ -226,21 +226,23 @@ int tpm_chip_register(struct tpm_chip *chip) | |||
226 | if (rc) | 226 | if (rc) |
227 | goto out_err; | 227 | goto out_err; |
228 | 228 | ||
229 | if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) { | ||
230 | rc = __compat_only_sysfs_link_entry_to_kobj(&chip->pdev->kobj, | ||
231 | &chip->dev.kobj, | ||
232 | "ppi"); | ||
233 | if (rc) | ||
234 | goto out_err; | ||
235 | } | ||
236 | |||
237 | /* Make the chip available. */ | 229 | /* Make the chip available. */ |
238 | spin_lock(&driver_lock); | 230 | spin_lock(&driver_lock); |
239 | list_add_rcu(&chip->list, &tpm_chip_list); | 231 | list_add_tail_rcu(&chip->list, &tpm_chip_list); |
240 | spin_unlock(&driver_lock); | 232 | spin_unlock(&driver_lock); |
241 | 233 | ||
242 | chip->flags |= TPM_CHIP_FLAG_REGISTERED; | 234 | chip->flags |= TPM_CHIP_FLAG_REGISTERED; |
243 | 235 | ||
236 | if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) { | ||
237 | rc = __compat_only_sysfs_link_entry_to_kobj(&chip->pdev->kobj, | ||
238 | &chip->dev.kobj, | ||
239 | "ppi"); | ||
240 | if (rc && rc != -ENOENT) { | ||
241 | tpm_chip_unregister(chip); | ||
242 | return rc; | ||
243 | } | ||
244 | } | ||
245 | |||
244 | return 0; | 246 | return 0; |
245 | out_err: | 247 | out_err: |
246 | tpm1_chip_unregister(chip); | 248 | tpm1_chip_unregister(chip); |
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c index bd7039fafa8a..c12130485fc1 100644 --- a/drivers/char/tpm/tpm2-cmd.c +++ b/drivers/char/tpm/tpm2-cmd.c | |||
@@ -443,12 +443,13 @@ int tpm2_seal_trusted(struct tpm_chip *chip, | |||
443 | TPM_DIGEST_SIZE); | 443 | TPM_DIGEST_SIZE); |
444 | 444 | ||
445 | /* sensitive */ | 445 | /* sensitive */ |
446 | tpm_buf_append_u16(&buf, 4 + TPM_DIGEST_SIZE + payload->key_len); | 446 | tpm_buf_append_u16(&buf, 4 + TPM_DIGEST_SIZE + payload->key_len + 1); |
447 | 447 | ||
448 | tpm_buf_append_u16(&buf, TPM_DIGEST_SIZE); | 448 | tpm_buf_append_u16(&buf, TPM_DIGEST_SIZE); |
449 | tpm_buf_append(&buf, options->blobauth, TPM_DIGEST_SIZE); | 449 | tpm_buf_append(&buf, options->blobauth, TPM_DIGEST_SIZE); |
450 | tpm_buf_append_u16(&buf, payload->key_len); | 450 | tpm_buf_append_u16(&buf, payload->key_len + 1); |
451 | tpm_buf_append(&buf, payload->key, payload->key_len); | 451 | tpm_buf_append(&buf, payload->key, payload->key_len); |
452 | tpm_buf_append_u8(&buf, payload->migratable); | ||
452 | 453 | ||
453 | /* public */ | 454 | /* public */ |
454 | tpm_buf_append_u16(&buf, 14); | 455 | tpm_buf_append_u16(&buf, 14); |
@@ -573,6 +574,8 @@ static int tpm2_unseal(struct tpm_chip *chip, | |||
573 | u32 blob_handle) | 574 | u32 blob_handle) |
574 | { | 575 | { |
575 | struct tpm_buf buf; | 576 | struct tpm_buf buf; |
577 | u16 data_len; | ||
578 | u8 *data; | ||
576 | int rc; | 579 | int rc; |
577 | 580 | ||
578 | rc = tpm_buf_init(&buf, TPM2_ST_SESSIONS, TPM2_CC_UNSEAL); | 581 | rc = tpm_buf_init(&buf, TPM2_ST_SESSIONS, TPM2_CC_UNSEAL); |
@@ -591,11 +594,13 @@ static int tpm2_unseal(struct tpm_chip *chip, | |||
591 | rc = -EPERM; | 594 | rc = -EPERM; |
592 | 595 | ||
593 | if (!rc) { | 596 | if (!rc) { |
594 | payload->key_len = be16_to_cpup( | 597 | data_len = be16_to_cpup( |
595 | (__be16 *) &buf.data[TPM_HEADER_SIZE + 4]); | 598 | (__be16 *) &buf.data[TPM_HEADER_SIZE + 4]); |
599 | data = &buf.data[TPM_HEADER_SIZE + 6]; | ||
596 | 600 | ||
597 | memcpy(payload->key, &buf.data[TPM_HEADER_SIZE + 6], | 601 | memcpy(payload->key, data, data_len - 1); |
598 | payload->key_len); | 602 | payload->key_len = data_len - 1; |
603 | payload->migratable = data[data_len - 1]; | ||
599 | } | 604 | } |
600 | 605 | ||
601 | tpm_buf_destroy(&buf); | 606 | tpm_buf_destroy(&buf); |
diff --git a/drivers/char/tpm/tpm_of.c b/drivers/char/tpm/tpm_of.c index 1141456a4b1f..570f30c5c5f4 100644 --- a/drivers/char/tpm/tpm_of.c +++ b/drivers/char/tpm/tpm_of.c | |||
@@ -53,17 +53,18 @@ int read_log(struct tpm_bios_log *log) | |||
53 | goto cleanup_eio; | 53 | goto cleanup_eio; |
54 | } | 54 | } |
55 | 55 | ||
56 | of_node_put(np); | ||
57 | log->bios_event_log = kmalloc(*sizep, GFP_KERNEL); | 56 | log->bios_event_log = kmalloc(*sizep, GFP_KERNEL); |
58 | if (!log->bios_event_log) { | 57 | if (!log->bios_event_log) { |
59 | pr_err("%s: ERROR - Not enough memory for BIOS measurements\n", | 58 | pr_err("%s: ERROR - Not enough memory for BIOS measurements\n", |
60 | __func__); | 59 | __func__); |
60 | of_node_put(np); | ||
61 | return -ENOMEM; | 61 | return -ENOMEM; |
62 | } | 62 | } |
63 | 63 | ||
64 | log->bios_event_log_end = log->bios_event_log + *sizep; | 64 | log->bios_event_log_end = log->bios_event_log + *sizep; |
65 | 65 | ||
66 | memcpy(log->bios_event_log, __va(*basep), *sizep); | 66 | memcpy(log->bios_event_log, __va(*basep), *sizep); |
67 | of_node_put(np); | ||
67 | 68 | ||
68 | return 0; | 69 | return 0; |
69 | 70 | ||
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index 696ef1d56b4f..65f7eecc45b0 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c | |||
@@ -645,6 +645,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, | |||
645 | { | 645 | { |
646 | u32 vendor, intfcaps, intmask; | 646 | u32 vendor, intfcaps, intmask; |
647 | int rc, i, irq_s, irq_e, probe; | 647 | int rc, i, irq_s, irq_e, probe; |
648 | int irq_r = -1; | ||
648 | struct tpm_chip *chip; | 649 | struct tpm_chip *chip; |
649 | struct priv_data *priv; | 650 | struct priv_data *priv; |
650 | 651 | ||
@@ -751,6 +752,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, | |||
751 | irq_s = | 752 | irq_s = |
752 | ioread8(chip->vendor.iobase + | 753 | ioread8(chip->vendor.iobase + |
753 | TPM_INT_VECTOR(chip->vendor.locality)); | 754 | TPM_INT_VECTOR(chip->vendor.locality)); |
755 | irq_r = irq_s; | ||
754 | if (irq_s) { | 756 | if (irq_s) { |
755 | irq_e = irq_s; | 757 | irq_e = irq_s; |
756 | } else { | 758 | } else { |
@@ -805,6 +807,8 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, | |||
805 | iowrite32(intmask, | 807 | iowrite32(intmask, |
806 | chip->vendor.iobase + | 808 | chip->vendor.iobase + |
807 | TPM_INT_ENABLE(chip->vendor.locality)); | 809 | TPM_INT_ENABLE(chip->vendor.locality)); |
810 | |||
811 | devm_free_irq(dev, i, chip); | ||
808 | } | 812 | } |
809 | } | 813 | } |
810 | if (chip->vendor.irq) { | 814 | if (chip->vendor.irq) { |
@@ -831,7 +835,9 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, | |||
831 | chip->vendor.iobase + | 835 | chip->vendor.iobase + |
832 | TPM_INT_ENABLE(chip->vendor.locality)); | 836 | TPM_INT_ENABLE(chip->vendor.locality)); |
833 | } | 837 | } |
834 | } | 838 | } else if (irq_r != -1) |
839 | iowrite8(irq_r, chip->vendor.iobase + | ||
840 | TPM_INT_VECTOR(chip->vendor.locality)); | ||
835 | 841 | ||
836 | if (chip->flags & TPM_CHIP_FLAG_TPM2) { | 842 | if (chip->flags & TPM_CHIP_FLAG_TPM2) { |
837 | chip->vendor.timeout_a = msecs_to_jiffies(TPM2_TIMEOUT_A); | 843 | chip->vendor.timeout_a = msecs_to_jiffies(TPM2_TIMEOUT_A); |
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 3dfc28875cc3..8187df204695 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c | |||
@@ -1725,7 +1725,7 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev) | |||
1725 | { | 1725 | { |
1726 | int result; | 1726 | int result; |
1727 | u32 aqa; | 1727 | u32 aqa; |
1728 | u64 cap = readq(&dev->bar->cap); | 1728 | u64 cap = lo_hi_readq(&dev->bar->cap); |
1729 | struct nvme_queue *nvmeq; | 1729 | struct nvme_queue *nvmeq; |
1730 | unsigned page_shift = PAGE_SHIFT; | 1730 | unsigned page_shift = PAGE_SHIFT; |
1731 | unsigned dev_page_min = NVME_CAP_MPSMIN(cap) + 12; | 1731 | unsigned dev_page_min = NVME_CAP_MPSMIN(cap) + 12; |
@@ -1774,8 +1774,8 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev) | |||
1774 | dev->ctrl_config |= NVME_CC_IOSQES | NVME_CC_IOCQES; | 1774 | dev->ctrl_config |= NVME_CC_IOSQES | NVME_CC_IOCQES; |
1775 | 1775 | ||
1776 | writel(aqa, &dev->bar->aqa); | 1776 | writel(aqa, &dev->bar->aqa); |
1777 | writeq(nvmeq->sq_dma_addr, &dev->bar->asq); | 1777 | lo_hi_writeq(nvmeq->sq_dma_addr, &dev->bar->asq); |
1778 | writeq(nvmeq->cq_dma_addr, &dev->bar->acq); | 1778 | lo_hi_writeq(nvmeq->cq_dma_addr, &dev->bar->acq); |
1779 | 1779 | ||
1780 | result = nvme_enable_ctrl(dev, cap); | 1780 | result = nvme_enable_ctrl(dev, cap); |
1781 | if (result) | 1781 | if (result) |
@@ -2606,7 +2606,7 @@ static int nvme_dev_add(struct nvme_dev *dev) | |||
2606 | struct pci_dev *pdev = to_pci_dev(dev->dev); | 2606 | struct pci_dev *pdev = to_pci_dev(dev->dev); |
2607 | int res; | 2607 | int res; |
2608 | struct nvme_id_ctrl *ctrl; | 2608 | struct nvme_id_ctrl *ctrl; |
2609 | int shift = NVME_CAP_MPSMIN(readq(&dev->bar->cap)) + 12; | 2609 | int shift = NVME_CAP_MPSMIN(lo_hi_readq(&dev->bar->cap)) + 12; |
2610 | 2610 | ||
2611 | res = nvme_identify_ctrl(dev, &ctrl); | 2611 | res = nvme_identify_ctrl(dev, &ctrl); |
2612 | if (res) { | 2612 | if (res) { |
@@ -2622,6 +2622,8 @@ static int nvme_dev_add(struct nvme_dev *dev) | |||
2622 | memcpy(dev->firmware_rev, ctrl->fr, sizeof(ctrl->fr)); | 2622 | memcpy(dev->firmware_rev, ctrl->fr, sizeof(ctrl->fr)); |
2623 | if (ctrl->mdts) | 2623 | if (ctrl->mdts) |
2624 | dev->max_hw_sectors = 1 << (ctrl->mdts + shift - 9); | 2624 | dev->max_hw_sectors = 1 << (ctrl->mdts + shift - 9); |
2625 | else | ||
2626 | dev->max_hw_sectors = UINT_MAX; | ||
2625 | if ((pdev->vendor == PCI_VENDOR_ID_INTEL) && | 2627 | if ((pdev->vendor == PCI_VENDOR_ID_INTEL) && |
2626 | (pdev->device == 0x0953) && ctrl->vs[3]) { | 2628 | (pdev->device == 0x0953) && ctrl->vs[3]) { |
2627 | unsigned int max_hw_sectors; | 2629 | unsigned int max_hw_sectors; |
@@ -2695,7 +2697,7 @@ static int nvme_dev_map(struct nvme_dev *dev) | |||
2695 | goto unmap; | 2697 | goto unmap; |
2696 | } | 2698 | } |
2697 | 2699 | ||
2698 | cap = readq(&dev->bar->cap); | 2700 | cap = lo_hi_readq(&dev->bar->cap); |
2699 | dev->q_depth = min_t(int, NVME_CAP_MQES(cap) + 1, NVME_Q_DEPTH); | 2701 | dev->q_depth = min_t(int, NVME_CAP_MQES(cap) + 1, NVME_Q_DEPTH); |
2700 | dev->db_stride = 1 << NVME_CAP_STRIDE(cap); | 2702 | dev->db_stride = 1 << NVME_CAP_STRIDE(cap); |
2701 | dev->dbs = ((void __iomem *)dev->bar) + 4096; | 2703 | dev->dbs = ((void __iomem *)dev->bar) + 4096; |
@@ -2758,7 +2760,7 @@ static void nvme_wait_dq(struct nvme_delq_ctx *dq, struct nvme_dev *dev) | |||
2758 | * queues than admin tags. | 2760 | * queues than admin tags. |
2759 | */ | 2761 | */ |
2760 | set_current_state(TASK_RUNNING); | 2762 | set_current_state(TASK_RUNNING); |
2761 | nvme_disable_ctrl(dev, readq(&dev->bar->cap)); | 2763 | nvme_disable_ctrl(dev, lo_hi_readq(&dev->bar->cap)); |
2762 | nvme_clear_queue(dev->queues[0]); | 2764 | nvme_clear_queue(dev->queues[0]); |
2763 | flush_kthread_worker(dq->worker); | 2765 | flush_kthread_worker(dq->worker); |
2764 | nvme_disable_queue(dev, 0); | 2766 | nvme_disable_queue(dev, 0); |
@@ -3401,6 +3403,7 @@ static const struct pci_error_handlers nvme_err_handler = { | |||
3401 | 3403 | ||
3402 | static const struct pci_device_id nvme_id_table[] = { | 3404 | static const struct pci_device_id nvme_id_table[] = { |
3403 | { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, | 3405 | { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, |
3406 | { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2001) }, | ||
3404 | { 0, } | 3407 | { 0, } |
3405 | }; | 3408 | }; |
3406 | MODULE_DEVICE_TABLE(pci, nvme_id_table); | 3409 | MODULE_DEVICE_TABLE(pci, nvme_id_table); |