Pull xen fixes from Juergen Gross: - a minor fix for the Xen grant driver - a small series fixing a recently introduced problem in the Xen blkfront/blkback drivers with negotiation of feature usage * tag 'for-linus-6.0-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen/grants: prevent integer overflow in gnttab_dma_alloc_pages() xen-blkfront: Cache feature_persistent value before advertisement xen-blkfront: Advertise feature-persistent as user requested xen-blkback: Advertise feature-persistent as user requested
Unified · Split
| @@ -226,6 +226,9 @@ struct xen_vbd { · 225 unmodified lines | ||
| 226 | 226 | sector_t size; |
| 227 | 227 | unsigned int flush_support:1; |
| 228 | 228 | unsigned int discard_secure:1; |
| 229 | + /* Connect-time cached feature_persistent parameter value */ | |
| 230 | + unsigned int feature_gnt_persistent_parm:1; | |
| 231 | + /* Persistent grants feature negotiation result */ | |
| 229 | 232 | unsigned int feature_gnt_persistent:1; |
| 230 | 233 | unsigned int overflow_max_grants:1; |
| 231 | 234 | }; |
| @@ -907,7 +907,7 @@ again: · 906 unmodified lines | ||
| 907 | 907 | xen_blkbk_barrier(xbt, be, be->blkif->vbd.flush_support); |
| 908 | 908 | |
| 909 | 909 | err = xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u", |
| 910 | − be->blkif->vbd.feature_gnt_persistent); | |
| 910 | + be->blkif->vbd.feature_gnt_persistent_parm); | |
| 911 | 911 | if (err) { |
| 912 | 912 | xenbus_dev_fatal(dev, err, "writing %s/feature-persistent", |
| 913 | 913 | dev->nodename); |
| @@ -1085,7 +1085,9 @@ static int connect_ring(struct backend_info *be) · 171 unmodified lines | ||
| 1085 | 1085 | return -ENOSYS; |
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | − blkif->vbd.feature_gnt_persistent = feature_persistent && | |
| 1088 | + blkif->vbd.feature_gnt_persistent_parm = feature_persistent; | |
| 1089 | + blkif->vbd.feature_gnt_persistent = | |
| 1090 | + blkif->vbd.feature_gnt_persistent_parm && | |
| 1089 | 1091 | xenbus_read_unsigned(dev->otherend, "feature-persistent", 0); |
| 1090 | 1092 | |
| 1091 | 1093 | blkif->vbd.overflow_max_grants = 0; |
| @@ -213,6 +213,9 @@ struct blkfront_info · 212 unmodified lines | ||
| 213 | 213 | unsigned int feature_fua:1; |
| 214 | 214 | unsigned int feature_discard:1; |
| 215 | 215 | unsigned int feature_secdiscard:1; |
| 216 | + /* Connect-time cached feature_persistent parameter */ | |
| 217 | + unsigned int feature_persistent_parm:1; | |
| 218 | + /* Persistent grants feature negotiation result */ | |
| 216 | 219 | unsigned int feature_persistent:1; |
| 217 | 220 | unsigned int bounce:1; |
| 218 | 221 | unsigned int discard_granularity; |
| @@ -1756,6 +1759,12 @@ abort_transaction: · 1537 unmodified lines | ||
| 1756 | 1759 | return err; |
| 1757 | 1760 | } |
| 1758 | 1761 | |
| 1762 | +/* Enable the persistent grants feature. */ | |
| 1763 | +static bool feature_persistent = true; | |
| 1764 | +module_param(feature_persistent, bool, 0644); | |
| 1765 | +MODULE_PARM_DESC(feature_persistent, | |
| 1766 | + "Enables the persistent grants feature"); | |
| 1767 | + | |
| 1759 | 1768 | /* Common code used when first setting up, and when resuming. */ |
| 1760 | 1769 | static int talk_to_blkback(struct xenbus_device *dev, |
| 1761 | 1770 | struct blkfront_info *info) |
| @@ -1847,8 +1856,9 @@ again: · 85 unmodified lines | ||
| 1847 | 1856 | message = "writing protocol"; |
| 1848 | 1857 | goto abort_transaction; |
| 1849 | 1858 | } |
| 1859 | + info->feature_persistent_parm = feature_persistent; | |
| 1850 | 1860 | err = xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u", |
| 1851 | − info->feature_persistent); | |
| 1861 | + info->feature_persistent_parm); | |
| 1852 | 1862 | if (err) |
| 1853 | 1863 | dev_warn(&dev->dev, |
| 1854 | 1864 | "writing persistent grants feature to xenbus"); |
| @@ -1916,12 +1926,6 @@ static int negotiate_mq(struct blkfront_info *info) · 61 unmodified lines | ||
| 1916 | 1926 | return 0; |
| 1917 | 1927 | } |
| 1918 | 1928 | |
| 1919 | −/* Enable the persistent grants feature. */ | |
| 1920 | −static bool feature_persistent = true; | |
| 1921 | −module_param(feature_persistent, bool, 0644); | |
| 1922 | −MODULE_PARM_DESC(feature_persistent, | |
| 1923 | − "Enables the persistent grants feature"); | |
| 1924 | − | |
| 1925 | 1929 | /* |
| 1926 | 1930 | * Entry point to this code when a new device is created. Allocate the basic |
| 1927 | 1931 | * structures and the ring buffer for communication with the backend, and |
| @@ -2281,7 +2285,7 @@ static void blkfront_gather_backend_features(struct blkfront_info *info) · 353 unmodified lines | ||
| 2281 | 2285 | if (xenbus_read_unsigned(info->xbdev->otherend, "feature-discard", 0)) |
| 2282 | 2286 | blkfront_setup_discard(info); |
| 2283 | 2287 | |
| 2284 | − if (feature_persistent) | |
| 2288 | + if (info->feature_persistent_parm) | |
| 2285 | 2289 | info->feature_persistent = |
| 2286 | 2290 | !!xenbus_read_unsigned(info->xbdev->otherend, |
| 2287 | 2291 | "feature-persistent", 0); |
| @@ -1047,6 +1047,9 @@ int gnttab_dma_alloc_pages(struct gnttab_dma_alloc_args *args) · 1046 unmodified lines | ||
| 1047 | 1047 | size_t size; |
| 1048 | 1048 | int i, ret; |
| 1049 | 1049 | |
| 1050 | + if (args->nr_pages < 0 || args->nr_pages > (INT_MAX >> PAGE_SHIFT)) | |
| 1051 | + return -ENOMEM; | |
| 1052 | + | |
| 1050 | 1053 | size = args->nr_pages << PAGE_SHIFT; |
| 1051 | 1054 | if (args->coherent) |
| 1052 | 1055 | args->vaddr = dma_alloc_coherent(args->dev, size, |