All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Rita Sinha <rita.sinha89@gmail.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/2] i386: Prepare for interrupt remapping
Date: Thu, 10 Mar 2016 13:18:08 +0800	[thread overview]
Message-ID: <20160310051808.GA25832@pxdev.xzpeter.org> (raw)
In-Reply-To: <1457465321-15252-1-git-send-email-rita.sinha89@gmail.com>

Hi, Jan/Rita,

Have not gone deeper... Got several comments and questions inline.

On Wed, Mar 09, 2016 at 12:58:41AM +0530, Rita Sinha wrote:

[...]

> +static AddressSpace *get_dma_address_space(void)
> +{
> +    return &PC_MACHINE(qdev_get_machine())->dma_address_space;
> +}
> +
>  /* Given the reg addr of both the message data and address, generate an
>   * interrupt via MSI.
>   */
> @@ -282,7 +288,7 @@ static void vtd_generate_interrupt(IntelIOMMUState *s, hwaddr mesg_addr_reg,
>      data = vtd_get_long_raw(s, mesg_data_reg);
>  
>      VTD_DPRINTF(FLOG, "msi: addr 0x%"PRIx64 " data 0x%"PRIx32, addr, data);
> -    address_space_stl_le(&address_space_memory, addr, data,
> +    address_space_stl_le(get_dma_address_space(), addr, data,
>                           MEMTXATTRS_UNSPECIFIED, NULL);
>  }

Would this work? AFAIU, IOMMU generated fault interrupts does not
need any translation at all.

One more question about the design itself: I see that one new AS is
created for DMA address space named dma_address_space. Could you
help explain why we need this? I am still naive on QEMU memory, what
I feel is that, current memory framework can work nicely without
this extra address space, using existing address translation
mechanisms, like the implementation in the following patch:

https://lists.gnu.org/archive/html/qemu-devel/2016-02/msg04393.html

With the new address space, we will need more loops when doing
memory address translation for IR (in address_space_translate()). 

>  
> @@ -496,7 +502,7 @@ static int vtd_get_root_entry(IntelIOMMUState *s, uint8_t index,
>      dma_addr_t addr;
>  
>      addr = s->root + index * sizeof(*re);
> -    if (dma_memory_read(&address_space_memory, addr, re, sizeof(*re))) {
> +    if (dma_memory_read(get_dma_address_space(), addr, re, sizeof(*re))) {

For memory reads from IOMMU, I suppose we do not need translation as
well? I think this should work though, IMHO is because you did not
implement read() op for int_remap_as.  So, this read will fall
through to system address space finally, just like what happened
before this change.

>          VTD_DPRINTF(GENERAL, "error: fail to access root-entry at 0x%"PRIx64
>                      " + %"PRIu8, s->root, index);
>          re->val = 0;
> @@ -521,7 +527,7 @@ static int vtd_get_context_entry_from_root(VTDRootEntry *root, uint8_t index,
>          return -VTD_FR_ROOT_ENTRY_P;
>      }
>      addr = (root->val & VTD_ROOT_ENTRY_CTP) + index * sizeof(*ce);
> -    if (dma_memory_read(&address_space_memory, addr, ce, sizeof(*ce))) {
> +    if (dma_memory_read(get_dma_address_space(), addr, ce, sizeof(*ce))) {

Same as above. Will skip all similiar ones.

[...]

>  static void kvm_apic_reset(APICCommonState *s)
> @@ -182,8 +186,10 @@ static void kvm_apic_realize(DeviceState *dev, Error **errp)
>  {
>      APICCommonState *s = APIC_COMMON(dev);
>  
> -    memory_region_init_io(&s->io_memory, NULL, &kvm_apic_io_ops, s, "kvm-apic-msi",
> -                          APIC_SPACE_SIZE);
> +    memory_region_init(&s->io_memory, NULL, "kvm-apic", APIC_SPACE_SIZE);
> +
> +    memory_region_init_io(&s->msi_region, NULL, &kvm_msi_region_ops, NULL,
> +                          "kvm-msi", MSI_REGION_SIZE);

I do not quite understand why we need to have two MRs. Could you
help explain too?

Thanks.
Peter

  parent reply	other threads:[~2016-03-10  5:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-08 19:28 [Qemu-devel] [PATCH 1/2] i386: Prepare for interrupt remapping Rita Sinha
2016-03-08 23:07 ` Eric Blake
2016-03-08 23:09   ` Eric Blake
2016-03-10  5:18 ` Peter Xu [this message]
2016-03-11  7:27   ` Jan Kiszka
2016-03-14  3:25     ` Peter Xu

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=20160310051808.GA25832@pxdev.xzpeter.org \
    --to=peterx@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rita.sinha89@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.