Project

General

Profile

Bug #696

Incorrect check dma_attr_sgllen <= 0 in rootnex_valid_alloc_parms

Added by Yuri Pankov almost 9 years ago. Updated over 8 years ago.

Status:
Resolved
Priority:
Normal
Category:
kernel
Start date:
2011-02-05
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

The check in question:

/*
 * rootnex_valid_alloc_parms()
 *    Called in ddi_dma_alloc_handle path to validate its parameters.
 */
static int
rootnex_valid_alloc_parms(ddi_dma_attr_t *attr, uint_t maxsegmentsize)
...
        if ((attr->dma_attr_seg & MMU_PAGEOFFSET) != MMU_PAGEOFFSET ||
            MMU_PAGESIZE & (attr->dma_attr_granular - 1) ||
==>         attr->dma_attr_sgllen <= 0) {          <===
                return (DDI_DMA_BADATTR);
        }
...

dmi_dma_attr(9S) does specify values < 0 as correct, so the check looks incorrect, breaking vmxnet3 driver when DEBUG is defined, at least.

The fix is to to remove the check or make it == 0 (0 is reserved, per manpage).

History

#1

Updated by Yuri Pankov almost 9 years ago

That should read ddi_dma_attr(9S), of course.

#2

Updated by Garrett D'Amore almost 9 years ago

  • Category set to kernel
  • Assignee set to Garrett D'Amore

The check should just include == 0... clearly negative values are legal.

#3

Updated by Rich Lowe almost 9 years ago

The check's been there for a long, long time. I must be missing how vmxnet3 worked previously, if this has thought its attributes invalid for so long?

Also, a quick glance over the code doesn't find other drivers using negative values and also doesn't really find evidence of negative values behaving as documented.
Am I missing where the magic happens?

#4

Updated by Garrett D'Amore almost 9 years ago

It only gets used in debug kernels.

Strangely, I don't see any drivers in ON that have -1 set. I thought for sure that there were others.... I do see some that have "big" values ... dnet for example has it set to 0x7fff in one instance. tavor has it set to 0x7FFFFFFF in another.

#5

Updated by Rich Lowe almost 9 years ago

WDD just documents it as the maximum scatter/gather length, no mention of negative values.

#6

Updated by Garrett D'Amore over 8 years ago

  • Status changed from New to Resolved
  • Difficulty set to Medium
  • Tags set to needs-triage

Also available in: Atom PDF