From: Wei Wang <wei.wang2@amd.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Ian.Jackson@eu.citrix.com, xen-devel@lists.xensource.com,
keir@xen.org, Ian.Campbell@citrix.com
Subject: Re: [PATCH 03 of 14 V3] amd iommu: Add iommu emulation for hvm guest
Date: Mon, 16 Jan 2012 11:29:35 +0100 [thread overview]
Message-ID: <4F13FC0F.1020104@amd.com> (raw)
In-Reply-To: <4F0ED3BC020000780006C120@nat28.tlf.novell.com>
[-- Attachment #1: Type: text/plain, Size: 1450 bytes --]
On 01/12/2012 12:36 PM, Jan Beulich wrote:
>>>> On 10.01.12 at 18:07, Wei Wang<wei.wang2@amd.com> wrote:
>> +static unsigned long get_gfn_from_base_reg(uint64_t base_raw)
>> +{
>> + uint64_t addr_lo, addr_hi, addr64;
>> +
>> + addr_lo = iommu_get_addr_lo_from_reg(base_raw& DMA_32BIT_MASK);
>> + addr_hi = iommu_get_addr_hi_from_reg(base_raw>> 32);
>> + addr64 = (addr_hi<< 32) | (addr_lo<< PAGE_SHIFT);
> I suppose that this isn't really correct - addr_lo shouldn't really
> need any shifting, or else base_raw would be a pretty odd entity.
> I'll convert the function to use reg_to_u64() instead. While I
> won't do this, I then also wonder whether the first two operations
> could be converted to u64_to_reg(), and if so, what the purpose
> of the whole function is (it would then merely shift the input
> value to obtain a frame number)
The names might be confusing but actually iommu mmio regs do not cache
lower 12 bit of the base addresses, so that addr_lo only contains bit 12
- bit 31 of the lower 32 bit part. That is why 12 bit left shift is
needed to form a fully 64 bit address. But anyway this function seems
redundant, I attached a patch to simplify it.
Thanks,
Wei
> Jan
>
>> +
>> + ASSERT ( addr64 != 0 );
>> +
>> + return addr64>> PAGE_SHIFT;
>> +}
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
>
[-- Attachment #2: 1.patch --]
[-- Type: text/x-patch, Size: 1846 bytes --]
# HG changeset patch
# Parent 0d4a60bf37b95b58bbae7019e0c263c556999131
# User Wei Wang <wei.wang2@amd.com>
cleanup get_gfn_from_base_reg() function.
Signed-off-by: Wei Wang <wei.wang2@amd.com>
diff -r 0d4a60bf37b9 -r 87ab207e4833 xen/drivers/passthrough/amd/iommu_guest.c
--- a/xen/drivers/passthrough/amd/iommu_guest.c Mon Jan 16 09:55:05 2012 +0100
+++ b/xen/drivers/passthrough/amd/iommu_guest.c Mon Jan 16 10:15:39 2012 +0100
@@ -121,16 +121,9 @@ static unsigned int host_domid(struct do
static unsigned long get_gfn_from_base_reg(uint64_t base_raw)
{
- struct mmio_reg reg;
- uint64_t addr64;
-
- reg.lo = iommu_get_addr_lo_from_reg(base_raw & DMA_32BIT_MASK);
- reg.hi = iommu_get_addr_hi_from_reg(base_raw >> 32);
- addr64 = reg_to_u64(reg);
-
- ASSERT ( addr64 != 0 );
-
- return addr64 >> PAGE_SHIFT;
+ base_raw &= ~(0xFFFULL << 52);
+ ASSERT ( base_raw != 0 );
+ return base_raw >> PAGE_SHIFT;
}
static void guest_iommu_deliver_msi(struct domain *d)
diff -r 0d4a60bf37b9 -r 87ab207e4833 xen/include/asm-x86/hvm/svm/amd-iommu-proto.h
--- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h Mon Jan 16 09:55:05 2012 +0100
+++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h Mon Jan 16 10:15:39 2012 +0100
@@ -257,16 +257,4 @@ static inline void iommu_set_addr_hi_to_
IOMMU_REG_BASE_ADDR_HIGH_SHIFT, reg);
}
-static inline uint32_t iommu_get_addr_lo_from_reg(uint32_t reg)
-{
- return get_field_from_reg_u32(reg, IOMMU_REG_BASE_ADDR_LOW_MASK,
- IOMMU_REG_BASE_ADDR_LOW_SHIFT);
-}
-
-static inline uint32_t iommu_get_addr_hi_from_reg(uint32_t reg)
-{
- return get_field_from_reg_u32(reg, IOMMU_REG_BASE_ADDR_HIGH_MASK,
- IOMMU_REG_BASE_ADDR_HIGH_SHIFT);
-}
-
#endif /* _ASM_X86_64_AMD_IOMMU_PROTO_H */
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next prev parent reply other threads:[~2012-01-16 10:29 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-10 17:07 [PATCH 00 of 14 V3] amd iommu: support ATS device passthru on IOMMUv2 systems Wei Wang
2012-01-10 17:07 ` [PATCH 01 of 14 V3] amd iommu: Refactoring iommu ring buffer definition Wei Wang
2012-01-10 17:07 ` [PATCH 02 of 14 V3] amd iommu: Introduces new helper functions to simplify bitwise operations Wei Wang
2012-01-10 17:07 ` [PATCH 03 of 14 V3] amd iommu: Add iommu emulation for hvm guest Wei Wang
2012-01-12 11:36 ` Jan Beulich
2012-01-16 10:29 ` Wei Wang [this message]
2012-01-10 17:07 ` [PATCH 04 of 14 V3] amd iommu: Enable ppr log Wei Wang
2012-01-10 17:07 ` [PATCH 05 of 14 V3] amd iommu: Enable guest level translation Wei Wang
2012-01-10 17:07 ` [PATCH 06 of 14 V3] amd iommu: add ppr log processing into iommu interrupt handling Wei Wang
2012-01-10 17:07 ` [PATCH 07 of 14 V3] amd iommu: Add 2 hypercalls for libxc Wei Wang
2012-01-10 17:07 ` [PATCH 08 of 14 V3] amd iommu: Add a new flag to indication iommuv2 feature enabled or not Wei Wang
2012-01-10 17:07 ` [PATCH 09 of 14 V3] amd iommu: Add a hypercall for hvmloader Wei Wang
2012-01-10 17:07 ` [PATCH 10 of 14 V3] amd iommu: Enable FC bit in iommu host level PTE Wei Wang
2012-01-10 17:07 ` [PATCH 11 of 14 V3] hvmloader: Build IVRS table Wei Wang
2012-01-10 17:07 ` [PATCH 12 of 14 V3] libxc: add wrappers for new hypercalls Wei Wang
2012-01-10 17:07 ` [PATCH 13 of 14 V3] libxl: bind virtual bdf to physical bdf after device assignment Wei Wang
2012-01-10 17:13 ` Ian Jackson
2012-01-10 17:35 ` Wei Wang2
2012-01-10 17:07 ` [PATCH 14 of 14 V3] libxl: Introduce a new guest config file parameter Wei Wang
2011-12-23 11:29 ` [PATCH 00 of 16] [V2] amd iommu: support ATS device passthru on IOMMUv2 systems Wei Wang
2011-12-23 11:29 ` [PATCH 01 of 16] amd iommu: Refactoring iommu ring buffer definition Wei Wang
2012-01-02 12:44 ` Jan Beulich
2011-12-23 11:29 ` [PATCH 02 of 16] amd iommu: Introduces new helper functions to simplify iommu bitwise operations Wei Wang
2012-01-02 12:52 ` Jan Beulich
2011-12-23 11:29 ` [PATCH 03 of 16] amd iommu: Add iommu emulation for hvm guest Wei Wang
2011-12-23 11:29 ` [PATCH 04 of 16] amd iommu: Enable ppr log Wei Wang
2012-01-02 13:10 ` Jan Beulich
2011-12-23 11:29 ` [PATCH 05 of 16] amd iommu: Enable guest level translation Wei Wang
2011-12-23 11:29 ` [PATCH 06 of 16] amd iommu: add ppr log processing into iommu interrupt handling Wei Wang
2012-01-02 13:13 ` Jan Beulich
2012-01-03 8:58 ` Wei Wang2
2011-12-23 11:29 ` [PATCH 07 of 16] amd iommu: Add 2 hypercalls for libxc Wei Wang
2012-01-02 12:15 ` Jan Beulich
2011-12-23 11:29 ` [PATCH 08 of 16] amd iommu: Add a hypercall for hvmloader Wei Wang
2012-01-02 11:41 ` Jan Beulich
2011-12-23 11:29 ` [PATCH 09 of 16] amd iommu: add iommu mmio handler Wei Wang
2012-01-02 11:39 ` Jan Beulich
2011-12-23 11:29 ` [PATCH 10 of 16] amd iommu: Enable FC bit in iommu host level PTE Wei Wang
2012-01-02 11:36 ` Jan Beulich
2012-01-03 10:05 ` Wei Wang2
2012-01-03 10:12 ` Jan Beulich
2012-01-03 10:37 ` Wei Wang2
2011-12-23 11:29 ` [PATCH 11 of 16] amd iommu: Add a new flag to indication iommuv2 feature enabled or not Wei Wang
2012-01-02 11:29 ` Jan Beulich
2011-12-23 11:29 ` [PATCH 12 of 16] hvmloader: Build IVRS table Wei Wang
2011-12-23 11:36 ` Ian Campbell
2011-12-23 11:52 ` Wei Wang2
2011-12-23 11:29 ` [PATCH 13 of 16] libxc: add wrappers for new hypercalls Wei Wang
2011-12-23 11:29 ` [PATCH 14 of 16] libxl: bind virtual bdf to physical bdf after device assignment Wei Wang
2011-12-23 11:37 ` Ian Campbell
2011-12-23 11:56 ` Wei Wang2
2012-01-03 16:03 ` Ian Jackson
2011-12-23 11:29 ` [PATCH 15 of 16] libxl: Introduce a new guest config file parameter Wei Wang
2012-01-03 16:02 ` Ian Jackson
2012-01-10 17:12 ` [PATCH 15 of 16] libxl: Introduce a new guest config file parameter [and 1 more messages] Ian Jackson
2012-01-11 10:20 ` Wei Wang2
2012-01-23 13:59 ` Ian Jackson
2011-12-23 11:29 ` [PATCH 16 of 16] libxl: pass iommu parameter to qemu-dm Wei Wang
2012-01-11 8:43 ` [PATCH 14 of 14 V3] libxl: Introduce a new guest config file parameter Ian Campbell
2012-01-11 10:47 ` Wei Wang2
2012-01-11 15:04 ` [PATCH 00 of 14 V3] amd iommu: support ATS device passthru on IOMMUv2 systems Jan Beulich
2012-01-11 17:36 ` Wei Wang
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=4F13FC0F.1020104@amd.com \
--to=wei.wang2@amd.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=keir@xen.org \
--cc=xen-devel@lists.xensource.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 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).