Wei Wang
2012-Feb-03 15:29 UTC
[PATCH] amd iommu: Fix a return value of guest_iommu_set_base()
# HG changeset patch # User Wei Wang <wei.wang2@amd.com> # Date 1328282938 -3600 # Node ID 58a2281581a4c4171ca52549b3e8062b9733ec2b # Parent 3432abcf9380d3840ca38439a304f74a37d155fc amd iommu: Fix a return value of guest_iommu_set_base() Remove a unnecessary check in guest_iommu_destroy() Signed-off-by: Wei Wang <wei.wang2@amd.com> diff -r 3432abcf9380 -r 58a2281581a4 xen/drivers/passthrough/amd/iommu_guest.c --- a/xen/drivers/passthrough/amd/iommu_guest.c Thu Feb 02 15:47:26 2012 +0000 +++ b/xen/drivers/passthrough/amd/iommu_guest.c Fri Feb 03 16:28:58 2012 +0100 @@ -806,7 +806,7 @@ int guest_iommu_set_base(struct domain * struct guest_iommu *iommu = domain_iommu(d); if ( !is_hvm_domain(d) || !iommu_enabled || !iommuv2_enabled ) - return 0; + return -EACCES; if ( !iommu ) return -EACCES; @@ -896,9 +896,6 @@ void guest_iommu_destroy(struct domain * { struct guest_iommu *iommu; - if ( !is_hvm_domain(d) || !iommu_enabled || !iommuv2_enabled ) - return; - iommu = domain_iommu(d); if ( !iommu ) return;
Jan Beulich
2012-Feb-03 16:35 UTC
Re: [PATCH] amd iommu: Fix a return value of guest_iommu_set_base()
>>> On 03.02.12 at 16:29, Wei Wang <wei.wang2@amd.com> wrote: > # HG changeset patch > # User Wei Wang <wei.wang2@amd.com> > # Date 1328282938 -3600 > # Node ID 58a2281581a4c4171ca52549b3e8062b9733ec2b > # Parent 3432abcf9380d3840ca38439a304f74a37d155fc > amd iommu: Fix a return value of guest_iommu_set_base() > Remove a unnecessary check in guest_iommu_destroy() > > Signed-off-by: Wei Wang <wei.wang2@amd.com> > > diff -r 3432abcf9380 -r 58a2281581a4 xen/drivers/passthrough/amd/iommu_guest.c > --- a/xen/drivers/passthrough/amd/iommu_guest.c Thu Feb 02 15:47:26 2012 +0000 > +++ b/xen/drivers/passthrough/amd/iommu_guest.c Fri Feb 03 16:28:58 2012 > +0100 > @@ -806,7 +806,7 @@ int guest_iommu_set_base(struct domain * > struct guest_iommu *iommu = domain_iommu(d); > > if ( !is_hvm_domain(d) || !iommu_enabled || !iommuv2_enabled ) > - return 0; > + return -EACCES;But as indicated before, all three checks above are redundant with the one check below. Hence I suggested to remove the checks above, and if you wish put an ASSERT() past the !iommu check below. Jan> > if ( !iommu ) > return -EACCES; > @@ -896,9 +896,6 @@ void guest_iommu_destroy(struct domain * > { > struct guest_iommu *iommu; > > - if ( !is_hvm_domain(d) || !iommu_enabled || !iommuv2_enabled ) > - return; > - > iommu = domain_iommu(d); > if ( !iommu ) > return;
Wei Wang
2012-Feb-06 12:29 UTC
Re: [PATCH] amd iommu: Fix a return value of guest_iommu_set_base()
On 02/03/2012 05:35 PM, Jan Beulich wrote:>>>> On 03.02.12 at 16:29, Wei Wang<wei.wang2@amd.com> wrote: >> # HG changeset patch >> # User Wei Wang<wei.wang2@amd.com> >> # Date 1328282938 -3600 >> # Node ID 58a2281581a4c4171ca52549b3e8062b9733ec2b >> # Parent 3432abcf9380d3840ca38439a304f74a37d155fc >> amd iommu: Fix a return value of guest_iommu_set_base() >> Remove a unnecessary check in guest_iommu_destroy() >> >> Signed-off-by: Wei Wang<wei.wang2@amd.com> >> >> diff -r 3432abcf9380 -r 58a2281581a4 xen/drivers/passthrough/amd/iommu_guest.c >> --- a/xen/drivers/passthrough/amd/iommu_guest.c Thu Feb 02 15:47:26 2012 +0000 >> +++ b/xen/drivers/passthrough/amd/iommu_guest.c Fri Feb 03 16:28:58 2012 >> +0100 >> @@ -806,7 +806,7 @@ int guest_iommu_set_base(struct domain * >> struct guest_iommu *iommu = domain_iommu(d); >> >> if ( !is_hvm_domain(d) || !iommu_enabled || !iommuv2_enabled ) >> - return 0; >> + return -EACCES; > > But as indicated before, all three checks above are redundant with > the one check below. Hence I suggested to remove the checks above, > and if you wish put an ASSERT() past the !iommu check below.OK,then I remove them all. I will send a new thread for the patch. Thanks, Wei> Jan > >> >> if ( !iommu ) >> return -EACCES; >> @@ -896,9 +896,6 @@ void guest_iommu_destroy(struct domain * >> { >> struct guest_iommu *iommu; >> >> - if ( !is_hvm_domain(d) || !iommu_enabled || !iommuv2_enabled ) >> - return; >> - >> iommu = domain_iommu(d); >> if ( !iommu ) >> return; > > > >