Print this page
MFV: illumos-gate@9f16e2df28efab26216cf68e3841c0a460c5bb73
9790 buffer freed to wrong cache in virtio_register_intx
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Reviewed by: Andy Fiddaman <omnios@citrus-it.net>
Approved by: Garrett D'Amore <garrett@damore.org>
Author: Hans Rosenfeld <hans.rosenfeld@joyent.com>
re #13879 make libsqlite a real shared lib (tweaks)
  Fix rebuild after pull (remove files left in the way)
  Make sqlite.h SQLITE_VERSION more predictable.
OS-5 Integrate virtio drivers
    integration cleanup (copyrights, cddl 1.0)
port of illumos-3644
    3644 Add virtio-net support into the Illumos
    Reviewed by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
    Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
    Reviewed by: David Hoppner <0xffea@gmail.com>
port of illumos-1562
    1562 Integrate the virtio core module
    Reviewed by: Dmitry Yusupov <Dmitry.Yusupov@nexenta.com>
    Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
    Approved by: Garrett D'Amore <garrett@damore.org>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/virtio/virtio.c
          +++ new/usr/src/uts/common/io/virtio/virtio.c
   1    1  /*
   2      - * CDDL HEADER START
        2 + * This file and its contents are supplied under the terms of the
        3 + * Common Development and Distribution License ("CDDL"), version 1.0.
        4 + * You may only use this file in accordance with the terms of version
        5 + * 1.0 of the CDDL.
   3    6   *
   4      - * The contents of this file are subject to the terms of the
   5      - * Common Development and Distribution License (the "License").
   6      - * You may not use this file except in compliance with the License.
   7      - *
   8      - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9      - * or http://www.opensolaris.org/os/licensing.
  10      - * See the License for the specific language governing permissions
  11      - * and limitations under the License.
  12      - *
  13      - * When distributing Covered Code, include this CDDL HEADER in each
  14      - * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15      - * If applicable, add the following below this CDDL HEADER, with the
  16      - * fields enclosed by brackets "[]" replaced with your own identifying
  17      - * information: Portions Copyright [yyyy] [name of copyright owner]
  18      - *
  19      - * CDDL HEADER END
        7 + * A full copy of the text of the CDDL should have accompanied this
        8 + * source.  A copy of the CDDL is also available via the Internet at
        9 + * http://www.illumos.org/license/CDDL.
  20   10   */
  21   11  
  22   12  /*
  23   13   * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  24   14   * Copyright 2012 Alexey Zaytsev <alexey.zaytsev@gmail.com>
  25   15   * Copyright (c) 2016 by Delphix. All rights reserved.
       16 + * Copyright 2017 Joyent, Inc.
  26   17   */
  27   18  
  28   19  /* Based on the NetBSD virtio driver by Minoura Makoto. */
  29   20  /*
  30   21   * Copyright (c) 2010 Minoura Makoto.
  31   22   * All rights reserved.
  32   23   *
  33   24   * Redistribution and use in source and binary forms, with or without
  34   25   * modification, are permitted provided that the following conditions
  35   26   * are met:
↓ open down ↓ 941 lines elided ↑ open up ↑
 977  968  /*
 978  969   * config_handler and vq_handlers may be allocated on stack.
 979  970   * Take precautions not to loose them.
 980  971   */
 981  972  static int
 982  973  virtio_register_intx(struct virtio_softc *sc,
 983  974      struct virtio_int_handler *config_handler,
 984  975      struct virtio_int_handler vq_handlers[])
 985  976  {
 986  977          int vq_handler_count;
 987      -        int config_handler_count = 0;
 988  978          int actual;
 989  979          struct virtio_handler_container *vhc;
      980 +        size_t vhc_sz;
 990  981          int ret = DDI_FAILURE;
 991  982  
 992  983          /* Walk the handler table to get the number of handlers. */
 993  984          for (vq_handler_count = 0;
 994  985              vq_handlers && vq_handlers[vq_handler_count].vh_func;
 995  986              vq_handler_count++)
 996  987                  ;
 997  988  
 998      -        if (config_handler != NULL)
 999      -                config_handler_count = 1;
      989 +        vhc_sz = sizeof (struct virtio_handler_container) +
      990 +            sizeof (struct virtio_int_handler) * vq_handler_count;
      991 +        vhc = kmem_zalloc(vhc_sz, KM_SLEEP);
1000  992  
1001      -        vhc = kmem_zalloc(sizeof (struct virtio_handler_container) +
1002      -            sizeof (struct virtio_int_handler) * vq_handler_count, KM_SLEEP);
1003      -
1004  993          vhc->nhandlers = vq_handler_count;
1005  994          (void) memcpy(vhc->vq_handlers, vq_handlers,
1006  995              sizeof (struct virtio_int_handler) * vq_handler_count);
1007  996  
1008  997          if (config_handler != NULL) {
1009  998                  (void) memcpy(&vhc->config_handler, config_handler,
1010  999                      sizeof (struct virtio_int_handler));
1011 1000          }
1012 1001  
1013 1002          /* Just a single entry for a single interrupt. */
↓ open down ↓ 25 lines elided ↑ open up ↑
1039 1028  
1040 1029          sc->sc_int_type = DDI_INTR_TYPE_FIXED;
1041 1030  
1042 1031          return (DDI_SUCCESS);
1043 1032  
1044 1033  out_add_handlers:
1045 1034  out_prio:
1046 1035          (void) ddi_intr_free(sc->sc_intr_htable[0]);
1047 1036  out_int_alloc:
1048 1037          kmem_free(sc->sc_intr_htable, sizeof (ddi_intr_handle_t));
1049      -        kmem_free(vhc, sizeof (struct virtio_int_handler) *
1050      -            (vq_handler_count + config_handler_count));
     1038 +        kmem_free(vhc, vhc_sz);
1051 1039          return (ret);
1052 1040  }
1053 1041  
1054 1042  /*
1055 1043   * We find out if we support MSI during this, and the register layout
1056 1044   * depends on the MSI (doh). Don't acces the device specific bits in
1057 1045   * BAR 0 before calling it!
1058 1046   */
1059 1047  int
1060 1048  virtio_register_ints(struct virtio_softc *sc,
↓ open down ↓ 306 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX