* [PATCH V2] Xen: ARM: Zero reserved fields of xatp before making hypervisor call
@ 2016-12-28 0:47 Jiandi An
2017-01-02 6:13 ` Juergen Gross
0 siblings, 1 reply; 4+ messages in thread
From: Jiandi An @ 2016-12-28 0:47 UTC (permalink / raw)
To: boris.ostrovsky, jgross, xen-devel, linux-kernel, sstabellini,
julien.grall
Cc: Jiandi An
Ensure all reserved fields of xatp are zero before making
hypervisor call to XEN in xen_map_device_mmio().
xenmem_add_to_physmap_one() in XEN fails the mapping request if
extra.res reserved field in xatp is not zero for XENMAPSPACE_dev_mmio
request.
Signed-off-by: Jiandi An <anjiandi@codeaurora.org>
---
Changed zeroing xatp to a static initialization
of .domid and .space for xatp.
drivers/xen/arm-device.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/xen/arm-device.c b/drivers/xen/arm-device.c
index 778acf8..85dd20e 100644
--- a/drivers/xen/arm-device.c
+++ b/drivers/xen/arm-device.c
@@ -58,9 +58,13 @@ static int xen_map_device_mmio(const struct resource *resources,
xen_pfn_t *gpfns;
xen_ulong_t *idxs;
int *errs;
- struct xen_add_to_physmap_range xatp;
for (i = 0; i < count; i++) {
+ struct xen_add_to_physmap_range xatp = {
+ .domid = DOMID_SELF,
+ .space = XENMAPSPACE_dev_mmio
+ };
+
r = &resources[i];
nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE);
if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0))
@@ -87,9 +91,7 @@ static int xen_map_device_mmio(const struct resource *resources,
idxs[j] = XEN_PFN_DOWN(r->start) + j;
}
- xatp.domid = DOMID_SELF;
xatp.size = nr;
- xatp.space = XENMAPSPACE_dev_mmio;
set_xen_guest_handle(xatp.gpfns, gpfns);
set_xen_guest_handle(xatp.idxs, idxs);
--
Jiandi An
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH V2] Xen: ARM: Zero reserved fields of xatp before making hypervisor call
2016-12-28 0:47 [PATCH V2] Xen: ARM: Zero reserved fields of xatp before making hypervisor call Jiandi An
@ 2017-01-02 6:13 ` Juergen Gross
2017-01-03 18:03 ` Stefano Stabellini
0 siblings, 1 reply; 4+ messages in thread
From: Juergen Gross @ 2017-01-02 6:13 UTC (permalink / raw)
To: Jiandi An, boris.ostrovsky, xen-devel, linux-kernel, sstabellini,
julien.grall
On 28/12/16 01:47, Jiandi An wrote:
> Ensure all reserved fields of xatp are zero before making
> hypervisor call to XEN in xen_map_device_mmio().
> xenmem_add_to_physmap_one() in XEN fails the mapping request if
> extra.res reserved field in xatp is not zero for XENMAPSPACE_dev_mmio
> request.
>
> Signed-off-by: Jiandi An <anjiandi@codeaurora.org>
> ---
> Changed zeroing xatp to a static initialization
> of .domid and .space for xatp.
>
> drivers/xen/arm-device.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/xen/arm-device.c b/drivers/xen/arm-device.c
> index 778acf8..85dd20e 100644
> --- a/drivers/xen/arm-device.c
> +++ b/drivers/xen/arm-device.c
> @@ -58,9 +58,13 @@ static int xen_map_device_mmio(const struct resource *resources,
> xen_pfn_t *gpfns;
> xen_ulong_t *idxs;
> int *errs;
> - struct xen_add_to_physmap_range xatp;
>
> for (i = 0; i < count; i++) {
> + struct xen_add_to_physmap_range xatp = {
> + .domid = DOMID_SELF,
> + .space = XENMAPSPACE_dev_mmio
> + };
> +
I still don't see the need to re-initialize the input parts of xatp
on each loop iteration unless you can show the need for it (e.g. a
buggy hypervisor version not conforming to the interface specification).
OTOH I don't feel really strong about it and let Stefano being the
maintainer for the ARM parts decide.
Juergen
> r = &resources[i];
> nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE);
> if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0))
> @@ -87,9 +91,7 @@ static int xen_map_device_mmio(const struct resource *resources,
> idxs[j] = XEN_PFN_DOWN(r->start) + j;
> }
>
> - xatp.domid = DOMID_SELF;
> xatp.size = nr;
> - xatp.space = XENMAPSPACE_dev_mmio;
>
> set_xen_guest_handle(xatp.gpfns, gpfns);
> set_xen_guest_handle(xatp.idxs, idxs);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] Xen: ARM: Zero reserved fields of xatp before making hypervisor call
2017-01-02 6:13 ` Juergen Gross
@ 2017-01-03 18:03 ` Stefano Stabellini
2017-01-16 15:03 ` Julien Grall
0 siblings, 1 reply; 4+ messages in thread
From: Stefano Stabellini @ 2017-01-03 18:03 UTC (permalink / raw)
To: Juergen Gross
Cc: Jiandi An, boris.ostrovsky, xen-devel, linux-kernel, sstabellini,
julien.grall
On Mon, 2 Jan 2017, Juergen Gross wrote:
> On 28/12/16 01:47, Jiandi An wrote:
> > Ensure all reserved fields of xatp are zero before making
> > hypervisor call to XEN in xen_map_device_mmio().
> > xenmem_add_to_physmap_one() in XEN fails the mapping request if
> > extra.res reserved field in xatp is not zero for XENMAPSPACE_dev_mmio
> > request.
> >
> > Signed-off-by: Jiandi An <anjiandi@codeaurora.org>
> > ---
> > Changed zeroing xatp to a static initialization
> > of .domid and .space for xatp.
> >
> > drivers/xen/arm-device.c | 8 +++++---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/xen/arm-device.c b/drivers/xen/arm-device.c
> > index 778acf8..85dd20e 100644
> > --- a/drivers/xen/arm-device.c
> > +++ b/drivers/xen/arm-device.c
> > @@ -58,9 +58,13 @@ static int xen_map_device_mmio(const struct resource *resources,
> > xen_pfn_t *gpfns;
> > xen_ulong_t *idxs;
> > int *errs;
> > - struct xen_add_to_physmap_range xatp;
> >
> > for (i = 0; i < count; i++) {
> > + struct xen_add_to_physmap_range xatp = {
> > + .domid = DOMID_SELF,
> > + .space = XENMAPSPACE_dev_mmio
> > + };
> > +
>
> I still don't see the need to re-initialize the input parts of xatp
> on each loop iteration unless you can show the need for it (e.g. a
> buggy hypervisor version not conforming to the interface specification).
>
> OTOH I don't feel really strong about it and let Stefano being the
> maintainer for the ARM parts decide.
I don't feel strongly about this either - I think this patch is good
enough. I'll apply to xentip.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] Xen: ARM: Zero reserved fields of xatp before making hypervisor call
2017-01-03 18:03 ` Stefano Stabellini
@ 2017-01-16 15:03 ` Julien Grall
0 siblings, 0 replies; 4+ messages in thread
From: Julien Grall @ 2017-01-16 15:03 UTC (permalink / raw)
To: Stefano Stabellini, Juergen Gross
Cc: Jiandi An, boris.ostrovsky, xen-devel, linux-kernel
Hi Stefano,
On 03/01/17 18:03, Stefano Stabellini wrote:
> On Mon, 2 Jan 2017, Juergen Gross wrote:
>> On 28/12/16 01:47, Jiandi An wrote:
>>> Ensure all reserved fields of xatp are zero before making
>>> hypervisor call to XEN in xen_map_device_mmio().
>>> xenmem_add_to_physmap_one() in XEN fails the mapping request if
>>> extra.res reserved field in xatp is not zero for XENMAPSPACE_dev_mmio
>>> request.
>>>
>>> Signed-off-by: Jiandi An <anjiandi@codeaurora.org>
>>> ---
>>> Changed zeroing xatp to a static initialization
>>> of .domid and .space for xatp.
>>>
>>> drivers/xen/arm-device.c | 8 +++++---
>>> 1 file changed, 5 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/xen/arm-device.c b/drivers/xen/arm-device.c
>>> index 778acf8..85dd20e 100644
>>> --- a/drivers/xen/arm-device.c
>>> +++ b/drivers/xen/arm-device.c
>>> @@ -58,9 +58,13 @@ static int xen_map_device_mmio(const struct resource *resources,
>>> xen_pfn_t *gpfns;
>>> xen_ulong_t *idxs;
>>> int *errs;
>>> - struct xen_add_to_physmap_range xatp;
>>>
>>> for (i = 0; i < count; i++) {
>>> + struct xen_add_to_physmap_range xatp = {
>>> + .domid = DOMID_SELF,
>>> + .space = XENMAPSPACE_dev_mmio
>>> + };
>>> +
>>
>> I still don't see the need to re-initialize the input parts of xatp
>> on each loop iteration unless you can show the need for it (e.g. a
>> buggy hypervisor version not conforming to the interface specification).
>>
>> OTOH I don't feel really strong about it and let Stefano being the
>> maintainer for the ARM parts decide.
>
> I don't feel strongly about this either - I think this patch is good
> enough. I'll apply to xentip.
I think this patch should be backported to stable trees because the
issue could appear depending on the compiler.
Cheers,
--
Julien Grall
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-01-16 15:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-28 0:47 [PATCH V2] Xen: ARM: Zero reserved fields of xatp before making hypervisor call Jiandi An
2017-01-02 6:13 ` Juergen Gross
2017-01-03 18:03 ` Stefano Stabellini
2017-01-16 15:03 ` Julien Grall
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).