From: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
To: David Kiarie <davidkiarie4@gmail.com>, qemu-devel@nongnu.org
Cc: jan.kiszka@web.de, mst@redhat.com
Subject: Re: [Qemu-devel] [RFC 2/4] hw/i386: Introduce AMD IOMMU
Date: Sat, 12 Sep 2015 15:55:51 +0500 [thread overview]
Message-ID: <55F404B7.2090408@gmail.com> (raw)
In-Reply-To: <55ED871C.8090704@gmail.com>
Hi David,
On 07.09.2015 17:46, Valentine Sinitsyn wrote:
...snip...
>> +/* TODO : Mark addresses as Accessed and Dirty */
>> +static void amd_iommu_do_translate(AMDIOMMUAddressSpace *as, hwaddr
>> addr, bool is_write, IOMMUTLBEntry *ret)
>> +{
>> + AMDIOMMUState *s = as->iommu_state;
>> +
>> + int present;
>> + dma_addr_t pte_addr;
>> + uint64_t entry[4], pte, pte_perms;
>> + unsigned level;
>> + unsigned perms;
>> +
>> + if(!amd_iommu_get_dte(s, as->devfn, entry)){
>> + goto no_translation;
>> + }
>> +
>> + pte = entry[0];
>> +
>> + /*
>> + * It's okay to check for either read or write permissions
>> + * even for memory maps, since we don't support R/W maps.
>> + */
>> + perms = is_write ? IOMMU_PERM_WRITE : IOMMU_PERM_READ;
>> +
>> + if(!(level = get_pte_translation_mode(pte))){
>> + goto no_translation;
>> + }
>> +
>> + while(level > 0){
>> + /*
>> + * check permissions: the bitwise
>> + * implication perms -> entry_perms must be true. Pages must
>> be present
>> + * and permissions on all levels must be similar
>> + */
>> + pte_perms = amd_iommu_get_perms(pte);
>> + present = pte & 1;
>> + if(!present || perms != (perms & pte_perms)){
>> + amd_iommu_page_fault(s, as->devfn, entry[1] &
>> DEV_DOMID_ID_MASK, addr, present,
>> + !!(perms & IOMMU_PERM_WRITE));
>> + return;
>> + }
>> +
>> + /* go to the next lower level */
>> + pte_addr = pte & DEV_PT_ROOT_MASK;
>> + pte_addr += ((addr >> ( 9 * level)) & 0xff8);
> Does this work for six level page tables? The highest level has
> different bit size there IIRC.
>
>> + pte = ldq_phys(&address_space_memory, pte_addr);
>> + level = (pte >> DEV_MODE_RSHIFT) & DEV_MODE_MASK;
>> + }
>> +
>> + ret->iova = addr & IOMMU_PAGE_MASK_4K;
>> + ret->translated_addr = (pte & DEV_PT_ROOT_MASK) &
>> IOMMU_PAGE_MASK_4K;
>> + ret->addr_mask = ~IOMMU_PAGE_MASK_4K;
>> + ret->perm = IOMMU_RW;
>> + return;
>> +
>> +no_translation:
>> + ret->iova = addr;
>> + ret->translated_addr = addr & IOMMU_PAGE_MASK_4K;
>> + ret->addr_mask = ~IOMMU_PAGE_MASK_4K;
>> + ret->perm = IOMMU_RW;
>> + return;
> Are you sure these transactions needs to be passed through rather than
> target-aborted?
FYI: They are indeed passed-through; see Table 9 in the spec.
Valentine
next prev parent reply other threads:[~2015-09-12 10:56 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-24 23:19 [Qemu-devel] [RFC 0/4] AMD IOMMU David Kiarie
2015-08-24 23:19 ` [Qemu-devel] [RFC 1/4] hw/core: Prepare for introducing " David Kiarie
2015-08-24 23:19 ` [Qemu-devel] [RFC 2/4] hw/i386: Introduce " David Kiarie
2015-08-25 6:39 ` Valentine Sinitsyn
2015-08-25 7:25 ` David kiarie
2015-08-25 7:31 ` Valentine Sinitsyn
2015-08-25 7:41 ` David kiarie
2015-08-25 7:43 ` Valentine Sinitsyn
2015-08-25 7:44 ` David kiarie
2015-09-07 12:46 ` Valentine Sinitsyn
2015-09-09 7:30 ` David kiarie
2015-09-09 7:45 ` Valentine Sinitsyn
2015-09-09 7:59 ` David kiarie
2015-09-09 8:07 ` Valentine Sinitsyn
2015-09-09 8:12 ` David kiarie
2015-09-09 8:14 ` Valentine Sinitsyn
2015-09-09 8:31 ` David kiarie
2015-09-09 7:59 ` Michael S. Tsirkin
2015-09-09 8:04 ` Valentine Sinitsyn
2015-09-12 10:55 ` Valentine Sinitsyn [this message]
2015-08-24 23:19 ` [Qemu-devel] [RFC 3/4] hw/i386: Introduce IVRS for " David Kiarie
2015-08-24 23:19 ` [Qemu-devel] [RFC 4/4] hw/pci-host: Add AMD IOMMU emulation to q35 and PIIX David Kiarie
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=55F404B7.2090408@gmail.com \
--to=valentine.sinitsyn@gmail.com \
--cc=davidkiarie4@gmail.com \
--cc=jan.kiszka@web.de \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.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).