qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Yuke Peng <pykfirst@gmail.com>
To: cmd <clement.mathieudrif.etu@gmail.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Peter Xu <peterx@redhat.com>,  Jason Wang <jasowang@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	 Richard Henderson <richard.henderson@linaro.org>,
	Eduardo Habkost <eduardo@habkost.net>,
	 Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Subject: Re: [PATCH] hw/i386/intel_iommu: Block CFI when necessary
Date: Thu, 27 Jun 2024 13:08:21 +0800	[thread overview]
Message-ID: <CAHJVP30fNZvuc7MVwAvNZM6fY+zUCOJcsUsXo2i4pG844RgvDA@mail.gmail.com> (raw)
In-Reply-To: <0baa7fcd-0b86-4ce0-88c9-4954363c2616@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2429 bytes --]

On Wed, Jun 26, 2024 at 2:15 PM cmd <clement.mathieudrif.etu@gmail.com>
wrote:

> Hi,
>
> On 25/06/2024 13:28, Yuke Peng wrote:
> > According to Intel VT-d specification 5.1.4, CFI must be blocked when
> > Extended Interrupt Mode is enabled or Compatibility format interrupts
> > are disabled.
> >
> > Signed-off-by: Yuke Peng <pykfirst@gmail.com>
> > ---
> >   hw/i386/intel_iommu.c         | 28 ++++++++++++++++++++++++++++
> >   hw/i386/trace-events          |  1 +
> >   include/hw/i386/intel_iommu.h |  1 +
> >   3 files changed, 30 insertions(+)
> >
> > diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
> > index 5085a6fee3..dfa2f979e7 100644
> > --- a/hw/i386/intel_iommu.c
> > +++ b/hw/i386/intel_iommu.c
> > @@ -2410,6 +2410,22 @@ static void vtd_handle_gcmd_ire(IntelIOMMUState
> *s, bool en)
> >       }
> >   }
> >
> > +/* Handle Compatibility Format Interrupts Enable/Disable */
> > +static void vtd_handle_gcmd_cfi(IntelIOMMUState *s, bool en)
> > +{
> > +    trace_vtd_cfi_enable(en);
> > +
> > +    if (en) {
> > +        s->cfi_enabled = true;
> > +        /* Ok - report back to driver */
> > +        vtd_set_clear_mask_long(s, DMAR_GSTS_REG, 0, VTD_GSTS_CFIS);
> > +    } else {
> > +        s->cfi_enabled = false;
> > +        /* Ok - report back to driver */
> > +        vtd_set_clear_mask_long(s, DMAR_GSTS_REG, VTD_GSTS_CFIS, 0);
> > +    }
> You have the same comment in both branches of the if statement, couldn't
> we put it between 'trace' and 'if'?
>

The reason I put the comment within the branches is that the function
'vtd_handle_gcmd_cfi'  is similar to the function 'vtd_handle_gcmd_ire'
and  'vtd_handle_gcmd_te'. So for consistency, I also put comments
within the branches instead of in front of 'if'. Besides, I think the
comments
only explain the statement 'vtd_set_clear_mask_long'.

The 'vtd_handle_gcmd_ire' function:

> /* Handle Interrupt Remap Enable/Disable */
> static void vtd_handle_gcmd_ire(IntelIOMMUState *s, bool en)
> {
>     trace_vtd_ir_enable(en);
>
>     if (en) {
>         s->intr_enabled = true;
>         /* Ok - report back to driver */
>         vtd_set_clear_mask_long(s, DMAR_GSTS_REG, 0, VTD_GSTS_IRES);
>     } else {
>         s->intr_enabled = false;
>         /* Ok - report back to driver */
>         vtd_set_clear_mask_long(s, DMAR_GSTS_REG, VTD_GSTS_IRES, 0);
>     }
> }

[-- Attachment #2: Type: text/html, Size: 3319 bytes --]

  reply	other threads:[~2024-06-27  5:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-25 11:28 [PATCH] hw/i386/intel_iommu: Block CFI when necessary Yuke Peng
2024-06-26  6:16 ` cmd
2024-06-27  5:08   ` Yuke Peng [this message]
2024-06-27  5:15     ` cmd
2024-07-01 20:51 ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHJVP30fNZvuc7MVwAvNZM6fY+zUCOJcsUsXo2i4pG844RgvDA@mail.gmail.com \
    --to=pykfirst@gmail.com \
    --cc=clement.mathieudrif.etu@gmail.com \
    --cc=eduardo@habkost.net \
    --cc=jasowang@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).