hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/drivers/xen/pvcalls-front.c
....@@ -1,15 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * (c) 2017 Stefano Stabellini <stefano@aporeto.com>
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License as published by
6
- * the Free Software Foundation; either version 2 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
134 */
145
156 #include <linux/module.h>
....@@ -346,8 +337,8 @@
346337 if (!map->active.ring)
347338 return;
348339
349
- free_pages((unsigned long)map->active.data.in,
350
- map->active.ring->ring_order);
340
+ free_pages_exact(map->active.data.in,
341
+ PAGE_SIZE << map->active.ring->ring_order);
351342 free_page((unsigned long)map->active.ring);
352343 }
353344
....@@ -361,8 +352,8 @@
361352 goto out;
362353
363354 map->active.ring->ring_order = PVCALLS_RING_ORDER;
364
- bytes = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
365
- PVCALLS_RING_ORDER);
355
+ bytes = alloc_pages_exact(PAGE_SIZE << PVCALLS_RING_ORDER,
356
+ GFP_KERNEL | __GFP_ZERO);
366357 if (!bytes)
367358 goto out;
368359
....@@ -377,12 +368,12 @@
377368 return -ENOMEM;
378369 }
379370
380
-static int create_active(struct sock_mapping *map, int *evtchn)
371
+static int create_active(struct sock_mapping *map, evtchn_port_t *evtchn)
381372 {
382373 void *bytes;
383
- int ret = -ENOMEM, irq = -1, i;
374
+ int ret, irq = -1, i;
384375
385
- *evtchn = -1;
376
+ *evtchn = 0;
386377 init_waitqueue_head(&map->active.inflight_conn_req);
387378
388379 bytes = map->active.data.in;
....@@ -413,7 +404,7 @@
413404 return 0;
414405
415406 out_error:
416
- if (*evtchn >= 0)
407
+ if (*evtchn > 0)
417408 xenbus_free_evtchn(pvcalls_front_dev, *evtchn);
418409 return ret;
419410 }
....@@ -424,7 +415,8 @@
424415 struct pvcalls_bedata *bedata;
425416 struct sock_mapping *map = NULL;
426417 struct xen_pvcalls_request *req;
427
- int notify, req_id, ret, evtchn;
418
+ int notify, req_id, ret;
419
+ evtchn_port_t evtchn;
428420
429421 if (addr->sa_family != AF_INET || sock->type != SOCK_STREAM)
430422 return -EOPNOTSUPP;
....@@ -774,7 +766,8 @@
774766 struct sock_mapping *map;
775767 struct sock_mapping *map2 = NULL;
776768 struct xen_pvcalls_request *req;
777
- int notify, req_id, ret, evtchn, nonblock;
769
+ int notify, req_id, ret, nonblock;
770
+ evtchn_port_t evtchn;
778771
779772 map = pvcalls_enter_sock(sock);
780773 if (IS_ERR(map))
....@@ -1134,7 +1127,8 @@
11341127 static int pvcalls_front_probe(struct xenbus_device *dev,
11351128 const struct xenbus_device_id *id)
11361129 {
1137
- int ret = -ENOMEM, evtchn, i;
1130
+ int ret = -ENOMEM, i;
1131
+ evtchn_port_t evtchn;
11381132 unsigned int max_page_order, function_calls, len;
11391133 char *versions;
11401134 grant_ref_t gref_head = 0;
....@@ -1269,7 +1263,7 @@
12691263 if (dev->state == XenbusStateClosed)
12701264 break;
12711265 /* Missed the backend's CLOSING state */
1272
- /* fall through */
1266
+ fallthrough;
12731267 case XenbusStateClosing:
12741268 xenbus_frontend_closed(dev);
12751269 break;