[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH V2 11/25] x86/hvm: Introduce a emulated VTD for HVM



On Thu, Aug 24, 2017 at 04:54:25PM +0800, Lan Tianyu wrote:
> On 2017年08月24日 16:49, Roger Pau Monné wrote:
> > On Thu, Aug 24, 2017 at 10:16:32AM +0800, Lan Tianyu wrote:
> >> On 2017年08月23日 15:58, Roger Pau Monné wrote:
> >>> On Wed, Aug 09, 2017 at 04:34:12PM -0400, Lan Tianyu wrote:
> >>>> From: Chao Gao <chao.gao@xxxxxxxxx>
> >>>> +}
> >>>> +
> >>>> +#define vvtd_get_reg_quad(vvtd, reg, val) do {  \
> >>>> +    (val) = vvtd_get_reg(vvtd, (reg) + 4 );     \
> >>>> +    (val) = (val) << 32;                        \
> >>>> +    (val) += vvtd_get_reg(vvtd, reg);           \
> >>>> +} while(0)
> >>>> +#define vvtd_set_reg_quad(vvtd, reg, val) do {  \
> >>>> +    vvtd_set_reg(vvtd, reg, (val));             \
> >>>> +    vvtd_set_reg(vvtd, (reg) + 4, (val) >> 32); \
> >>>> +} while(0)
> >>>
> >>> You seem to need to access hvm_hw_vvtd_regs using different sizes, why
> >>> not do:
> >>>
> >>> union hvm_hw_vvtd_regs {
> >>>     uint8_t  data8[1024];
> >>>     uint16_t data16[512];
> >>>     uint32_t data32[256];
> >>>     uint64_t data64[128];
> >>> };
> >>>
> >>> Then the access is much more straightforward and you don't need the
> >>> complicated helpers that you have above.
> >>
> >> Yes, that will be simpler.
> > 
> > Keep in mind (as said in another patch) that this approach will only
> > work correctly as long as you force accesses to be size aligned, which
> > you where not doing now.
> > 
> > I've looked at the VT-d spec, but I cannot find any section that
> > explains the restrictions on access sizes and alignments.
> > 
> 
> 10.2 Software Access to Registers?

Oh, thanks. I was grepping for "access sizes".

So yes only size aligned accesses are allowed. You should fix the
patch where you check the access size/alignment so it checks for (addr
& (len - 1)) (IIRC you where checking addr & 3).

Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.