Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 May 2017 07:58:29 -0700
From:      Conrad Meyer <cem@freebsd.org>
To:        Anish Gupta <anish@freebsd.org>
Cc:        src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r317600 - in head/sys: amd64/vmm/amd modules/vmm
Message-ID:  <CAG6CVpVa9z2T=D8oOqL%2B4U0PPmW-sJLg2Bs9FnA%2B%2BUrSrDzkKA@mail.gmail.com>
In-Reply-To: <201704300208.v3U28lZo093446@repo.freebsd.org>
References:  <201704300208.v3U28lZo093446@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Anish,


On Sat, Apr 29, 2017 at 7:08 PM, Anish Gupta <anish@freebsd.org> wrote:
> Author: anish
> Date: Sun Apr 30 02:08:46 2017
> New Revision: 317600
> URL: https://svnweb.freebsd.org/changeset/base/317600
>
> Log:
>   Add AMD IOMMU/AMD-Vi support in bhyve for passthrough/direct assignment to VMs. To enable AMD-Vi, set hw.vmm.amdvi.enable=1.
>
>   Reviewed by:bcr
>   Approved by:grehan
>   Tested by:rgrimes
>   Differential Revision:https://reviews.freebsd.org/D10049
> ...
>
> Added: head/sys/amd64/vmm/amd/amdvi_hw.c
> ...
> +/* See section 2.5.4 of AMD IOMMU spec ver 2.62.*/
> +static inline void
> +amdvi_decode_evt_flag_type(uint8_t type)
> +{
> +
> +       switch (AMDVI_EVENT_FLAG_TYPE(type)) {
> +       case 0:
> +               printf("RSVD\n");
> +               break;
> +       case 1:
> +               printf("Master Abort\n");
> +               break;
> +       case 2:
> +               printf("Target Abort\n");
> +               break;
> +       case 3:
> +               printf("Data Err\n");
> +               break;
> +       default:
> +               break;
> +       }
> +}

Coverity warns that the result of AMDVI_EVENT_FLAG_TYPE() in this
function will always be zero.  This makes sense, as the macro is
defined as:

#define AMDVI_EVENT_FLAG_TYPE(x)        (((x) >> 9) & 0x3)

And "type" is a uint8_t.  Right-shifting it by 9 will always zero it.
Perhaps the function's parameter should be a wider type?

FYI, this is Coverity CID 1374742.

Best,
Conrad



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpVa9z2T=D8oOqL%2B4U0PPmW-sJLg2Bs9FnA%2B%2BUrSrDzkKA>