* [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness()
@ 2015-08-26 10:04 Jason Wang
2015-08-26 10:04 ` [Qemu-devel] [PATCH 2/2] pci: test-dev: try to test fast mmio bus for wildcard mmio event Jason Wang
2015-08-26 14:21 ` [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness() Peter Maydell
0 siblings, 2 replies; 18+ messages in thread
From: Jason Wang @ 2015-08-26 10:04 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, Jason Wang, Greg Kurz, mst
Wildcard mmio eventfd use zero size, but it will lead abort() since it
was illegal in adjust_endianness(). Fix this by allowing zero size.
Cc: Greg Kurz <gkurz@linux.vnet.ibm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
memory.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/memory.c b/memory.c
index 4eb138a..134aa57 100644
--- a/memory.c
+++ b/memory.c
@@ -353,6 +353,7 @@ static void adjust_endianness(MemoryRegion *mr, uint64_t *data, unsigned size)
{
if (memory_region_wrong_endianness(mr)) {
switch (size) {
+ case 0:
case 1:
break;
case 2:
--
2.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [Qemu-devel] [PATCH 2/2] pci: test-dev: try to test fast mmio bus for wildcard mmio event
2015-08-26 10:04 [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness() Jason Wang
@ 2015-08-26 10:04 ` Jason Wang
2015-08-27 10:28 ` Michael S. Tsirkin
2015-08-26 14:21 ` [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness() Peter Maydell
1 sibling, 1 reply; 18+ messages in thread
From: Jason Wang @ 2015-08-26 10:04 UTC (permalink / raw)
To: qemu-devel; +Cc: Jason Wang, mst
Test fast mmio by using zero size eventfd.
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/misc/pci-testdev.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/hw/misc/pci-testdev.c b/hw/misc/pci-testdev.c
index 26b9b86..7bf67ed 100644
--- a/hw/misc/pci-testdev.c
+++ b/hw/misc/pci-testdev.c
@@ -261,8 +261,12 @@ static void pci_testdev_realize(PCIDevice *pci_dev, Error **errp)
memcpy(test->hdr->name, name, strlen(name) + 1);
g_free(name);
test->hdr->offset = cpu_to_le32(IOTEST_SIZE(i) + i * IOTEST_ACCESS_WIDTH);
- test->size = IOTEST_ACCESS_WIDTH;
test->match_data = strcmp(IOTEST_TEST(i), "wildcard-eventfd");
+ if (!test->match_data && !strcmp(IOTEST_TYPE(i), "mmio")) {
+ test->size = 0;
+ } else {
+ test->size = IOTEST_ACCESS_WIDTH;
+ }
test->hdr->test = i;
test->hdr->data = test->match_data ? IOTEST_DATAMATCH : IOTEST_NOMATCH;
test->hdr->width = IOTEST_ACCESS_WIDTH;
--
2.1.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness()
2015-08-26 10:04 [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness() Jason Wang
2015-08-26 10:04 ` [Qemu-devel] [PATCH 2/2] pci: test-dev: try to test fast mmio bus for wildcard mmio event Jason Wang
@ 2015-08-26 14:21 ` Peter Maydell
2015-08-26 14:51 ` Greg Kurz
1 sibling, 1 reply; 18+ messages in thread
From: Peter Maydell @ 2015-08-26 14:21 UTC (permalink / raw)
To: Jason Wang; +Cc: Paolo Bonzini, Michael S. Tsirkin, QEMU Developers, Greg Kurz
On 26 August 2015 at 11:04, Jason Wang <jasowang@redhat.com> wrote:
> Wildcard mmio eventfd use zero size, but it will lead abort() since it
> was illegal in adjust_endianness(). Fix this by allowing zero size.
>
> Cc: Greg Kurz <gkurz@linux.vnet.ibm.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
This seems to me like a bug in the caller. Why would anything
try to call into the memory subsystem to do a zero-size
transaction?
thanks
-- PMM
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness()
2015-08-26 14:21 ` [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness() Peter Maydell
@ 2015-08-26 14:51 ` Greg Kurz
2015-08-27 4:50 ` Jason Wang
0 siblings, 1 reply; 18+ messages in thread
From: Greg Kurz @ 2015-08-26 14:51 UTC (permalink / raw)
To: Peter Maydell
Cc: Paolo Bonzini, Jason Wang, QEMU Developers, Michael S. Tsirkin
On Wed, 26 Aug 2015 15:21:59 +0100
Peter Maydell <peter.maydell@linaro.org> wrote:
> On 26 August 2015 at 11:04, Jason Wang <jasowang@redhat.com> wrote:
> > Wildcard mmio eventfd use zero size, but it will lead abort() since it
> > was illegal in adjust_endianness(). Fix this by allowing zero size.
> >
> > Cc: Greg Kurz <gkurz@linux.vnet.ibm.com>
> > Cc: Paolo Bonzini <pbonzini@redhat.com>
> > Signed-off-by: Jason Wang <jasowang@redhat.com>
>
> This seems to me like a bug in the caller. Why would anything
> try to call into the memory subsystem to do a zero-size
> transaction?
>
> thanks
> -- PMM
>
Here's the patch which needs zero-size eventfd:
http://patchwork.ozlabs.org/patch/509428/
Cheers.
--
Greg
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness()
2015-08-26 14:51 ` Greg Kurz
@ 2015-08-27 4:50 ` Jason Wang
2015-08-27 10:49 ` Peter Maydell
0 siblings, 1 reply; 18+ messages in thread
From: Jason Wang @ 2015-08-27 4:50 UTC (permalink / raw)
To: Greg Kurz, Peter Maydell
Cc: Paolo Bonzini, QEMU Developers, Michael S. Tsirkin
On 08/26/2015 10:51 PM, Greg Kurz wrote:
> On Wed, 26 Aug 2015 15:21:59 +0100
> Peter Maydell <peter.maydell@linaro.org> wrote:
>
>> On 26 August 2015 at 11:04, Jason Wang <jasowang@redhat.com> wrote:
>>> Wildcard mmio eventfd use zero size, but it will lead abort() since it
>>> was illegal in adjust_endianness(). Fix this by allowing zero size.
>>>
>>> Cc: Greg Kurz <gkurz@linux.vnet.ibm.com>
>>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>> This seems to me like a bug in the caller. Why would anything
>> try to call into the memory subsystem to do a zero-size
>> transaction?
>>
>> thanks
>> -- PMM
>>
> Here's the patch which needs zero-size eventfd:
>
> http://patchwork.ozlabs.org/patch/509428/
>
> Cheers.
>
> --
> Greg
>
Yes, this is because we want to use wildcard mmio eventfd (which
requires size to be zero) to speed up virtio 1.0 mmio.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] pci: test-dev: try to test fast mmio bus for wildcard mmio event
2015-08-26 10:04 ` [Qemu-devel] [PATCH 2/2] pci: test-dev: try to test fast mmio bus for wildcard mmio event Jason Wang
@ 2015-08-27 10:28 ` Michael S. Tsirkin
0 siblings, 0 replies; 18+ messages in thread
From: Michael S. Tsirkin @ 2015-08-27 10:28 UTC (permalink / raw)
To: Jason Wang; +Cc: qemu-devel
On Wed, Aug 26, 2015 at 06:04:08PM +0800, Jason Wang wrote:
> Test fast mmio by using zero size eventfd.
>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
wildcard is not the same as ignoring length.
I think I have a nicer patch, will post now.
> ---
> hw/misc/pci-testdev.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/hw/misc/pci-testdev.c b/hw/misc/pci-testdev.c
> index 26b9b86..7bf67ed 100644
> --- a/hw/misc/pci-testdev.c
> +++ b/hw/misc/pci-testdev.c
> @@ -261,8 +261,12 @@ static void pci_testdev_realize(PCIDevice *pci_dev, Error **errp)
> memcpy(test->hdr->name, name, strlen(name) + 1);
> g_free(name);
> test->hdr->offset = cpu_to_le32(IOTEST_SIZE(i) + i * IOTEST_ACCESS_WIDTH);
> - test->size = IOTEST_ACCESS_WIDTH;
> test->match_data = strcmp(IOTEST_TEST(i), "wildcard-eventfd");
> + if (!test->match_data && !strcmp(IOTEST_TYPE(i), "mmio")) {
> + test->size = 0;
> + } else {
> + test->size = IOTEST_ACCESS_WIDTH;
> + }
> test->hdr->test = i;
> test->hdr->data = test->match_data ? IOTEST_DATAMATCH : IOTEST_NOMATCH;
> test->hdr->width = IOTEST_ACCESS_WIDTH;
> --
> 2.1.4
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness()
2015-08-27 4:50 ` Jason Wang
@ 2015-08-27 10:49 ` Peter Maydell
2015-08-27 10:53 ` Michael S. Tsirkin
0 siblings, 1 reply; 18+ messages in thread
From: Peter Maydell @ 2015-08-27 10:49 UTC (permalink / raw)
To: Jason Wang; +Cc: Paolo Bonzini, Michael S. Tsirkin, QEMU Developers, Greg Kurz
On 27 August 2015 at 05:50, Jason Wang <jasowang@redhat.com> wrote:
> On 08/26/2015 10:51 PM, Greg Kurz wrote:
>> On Wed, 26 Aug 2015 15:21:59 +0100
>> Peter Maydell <peter.maydell@linaro.org> wrote:
>>> This seems to me like a bug in the caller. Why would anything
>>> try to call into the memory subsystem to do a zero-size
>>> transaction?
>> Here's the patch which needs zero-size eventfd:
>>
>> http://patchwork.ozlabs.org/patch/509428/
> Yes, this is because we want to use wildcard mmio eventfd (which
> requires size to be zero) to speed up virtio 1.0 mmio.
But *why* does it require the size to be zero? I still think
the caller should just avoid trying to do zero-size memory
operations: they don't make sense. What is a zero size
operation supposed to mean?
-- PMM
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness()
2015-08-27 10:49 ` Peter Maydell
@ 2015-08-27 10:53 ` Michael S. Tsirkin
2015-08-27 11:04 ` Peter Maydell
0 siblings, 1 reply; 18+ messages in thread
From: Michael S. Tsirkin @ 2015-08-27 10:53 UTC (permalink / raw)
To: Peter Maydell; +Cc: Paolo Bonzini, Jason Wang, QEMU Developers, Greg Kurz
On Thu, Aug 27, 2015 at 11:49:32AM +0100, Peter Maydell wrote:
> On 27 August 2015 at 05:50, Jason Wang <jasowang@redhat.com> wrote:
> > On 08/26/2015 10:51 PM, Greg Kurz wrote:
> >> On Wed, 26 Aug 2015 15:21:59 +0100
> >> Peter Maydell <peter.maydell@linaro.org> wrote:
> >>> This seems to me like a bug in the caller. Why would anything
> >>> try to call into the memory subsystem to do a zero-size
> >>> transaction?
>
> >> Here's the patch which needs zero-size eventfd:
> >>
> >> http://patchwork.ozlabs.org/patch/509428/
>
> > Yes, this is because we want to use wildcard mmio eventfd (which
> > requires size to be zero) to speed up virtio 1.0 mmio.
>
> But *why* does it require the size to be zero? I still think
> the caller should just avoid trying to do zero-size memory
> operations: they don't make sense. What is a zero size
> operation supposed to mean?
>
> -- PMM
This just mirrors an API we have in kvm: if you pass 0
size when registering an ioeventfd, it will match on access
of any size.
--
MST
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness()
2015-08-27 10:53 ` Michael S. Tsirkin
@ 2015-08-27 11:04 ` Peter Maydell
2015-08-27 11:08 ` Michael S. Tsirkin
0 siblings, 1 reply; 18+ messages in thread
From: Peter Maydell @ 2015-08-27 11:04 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Paolo Bonzini, Jason Wang, QEMU Developers, Greg Kurz
On 27 August 2015 at 11:53, Michael S. Tsirkin <mst@redhat.com> wrote:
> On Thu, Aug 27, 2015 at 11:49:32AM +0100, Peter Maydell wrote:
>> But *why* does it require the size to be zero? I still think
>> the caller should just avoid trying to do zero-size memory
>> operations: they don't make sense. What is a zero size
>> operation supposed to mean?
> This just mirrors an API we have in kvm: if you pass 0
> size when registering an ioeventfd, it will match on access
> of any size.
Hrm. It feels to me like the memory APIs ought to filter
out bad access sizes at an earlier stage, rather than
trying to make them work all the way through.
-- PMM
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness()
2015-08-27 11:04 ` Peter Maydell
@ 2015-08-27 11:08 ` Michael S. Tsirkin
2015-08-27 12:12 ` Peter Maydell
0 siblings, 1 reply; 18+ messages in thread
From: Michael S. Tsirkin @ 2015-08-27 11:08 UTC (permalink / raw)
To: Peter Maydell; +Cc: Paolo Bonzini, Jason Wang, QEMU Developers, Greg Kurz
On Thu, Aug 27, 2015 at 12:04:49PM +0100, Peter Maydell wrote:
> On 27 August 2015 at 11:53, Michael S. Tsirkin <mst@redhat.com> wrote:
> > On Thu, Aug 27, 2015 at 11:49:32AM +0100, Peter Maydell wrote:
> >> But *why* does it require the size to be zero? I still think
> >> the caller should just avoid trying to do zero-size memory
> >> operations: they don't make sense. What is a zero size
> >> operation supposed to mean?
>
> > This just mirrors an API we have in kvm: if you pass 0
> > size when registering an ioeventfd, it will match on access
> > of any size.
>
> Hrm. It feels to me like the memory APIs ought to filter
> out bad access sizes at an earlier stage, rather than
> trying to make them work all the way through.
>
> -- PMM
Why do you mention APIs? It's all internal to memory.c, isn't it?
--
MST
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness()
2015-08-27 11:08 ` Michael S. Tsirkin
@ 2015-08-27 12:12 ` Peter Maydell
2015-08-27 12:17 ` Michael S. Tsirkin
0 siblings, 1 reply; 18+ messages in thread
From: Peter Maydell @ 2015-08-27 12:12 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Paolo Bonzini, Jason Wang, QEMU Developers, Greg Kurz
On 27 August 2015 at 12:08, Michael S. Tsirkin <mst@redhat.com> wrote:
> On Thu, Aug 27, 2015 at 12:04:49PM +0100, Peter Maydell wrote:
>> On 27 August 2015 at 11:53, Michael S. Tsirkin <mst@redhat.com> wrote:
>> > On Thu, Aug 27, 2015 at 11:49:32AM +0100, Peter Maydell wrote:
>> >> But *why* does it require the size to be zero? I still think
>> >> the caller should just avoid trying to do zero-size memory
>> >> operations: they don't make sense. What is a zero size
>> >> operation supposed to mean?
>>
>> > This just mirrors an API we have in kvm: if you pass 0
>> > size when registering an ioeventfd, it will match on access
>> > of any size.
>>
>> Hrm. It feels to me like the memory APIs ought to filter
>> out bad access sizes at an earlier stage, rather than
>> trying to make them work all the way through.
> Why do you mention APIs? It's all internal to memory.c, isn't it?
adjust_endianness() is internal to memory.c. The APIs
memory.c exposes to the rest of the world are the ones
declared in memory.h. I'm suggesting that it would be
better to filter out rubbish like zero sizes at the
point where the rest of the world calls the memory
subsystem rather than ensuring that every part of the
memory subsystem code can handle what is basically
a completely meaningless request.
-- PMM
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness()
2015-08-27 12:12 ` Peter Maydell
@ 2015-08-27 12:17 ` Michael S. Tsirkin
2015-08-27 12:20 ` Peter Maydell
0 siblings, 1 reply; 18+ messages in thread
From: Michael S. Tsirkin @ 2015-08-27 12:17 UTC (permalink / raw)
To: Peter Maydell; +Cc: Paolo Bonzini, Jason Wang, QEMU Developers, Greg Kurz
On Thu, Aug 27, 2015 at 01:12:32PM +0100, Peter Maydell wrote:
> On 27 August 2015 at 12:08, Michael S. Tsirkin <mst@redhat.com> wrote:
> > On Thu, Aug 27, 2015 at 12:04:49PM +0100, Peter Maydell wrote:
> >> On 27 August 2015 at 11:53, Michael S. Tsirkin <mst@redhat.com> wrote:
> >> > On Thu, Aug 27, 2015 at 11:49:32AM +0100, Peter Maydell wrote:
> >> >> But *why* does it require the size to be zero? I still think
> >> >> the caller should just avoid trying to do zero-size memory
> >> >> operations: they don't make sense. What is a zero size
> >> >> operation supposed to mean?
> >>
> >> > This just mirrors an API we have in kvm: if you pass 0
> >> > size when registering an ioeventfd, it will match on access
> >> > of any size.
> >>
> >> Hrm. It feels to me like the memory APIs ought to filter
> >> out bad access sizes at an earlier stage, rather than
> >> trying to make them work all the way through.
>
> > Why do you mention APIs? It's all internal to memory.c, isn't it?
>
> adjust_endianness() is internal to memory.c. The APIs
> memory.c exposes to the rest of the world are the ones
> declared in memory.h. I'm suggesting that it would be
> better to filter out rubbish like zero sizes at the
> point where the rest of the world calls the memory
> subsystem rather than ensuring that every part of the
> memory subsystem code can handle what is basically
> a completely meaningless request.
>
> -- PMM
Basically the point is that ABI is extended to make
ioeventfd with len = 0 mean "any length".
0 is thus not meaningless anymore.
--
MST
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness()
2015-08-27 12:17 ` Michael S. Tsirkin
@ 2015-08-27 12:20 ` Peter Maydell
2015-08-27 12:25 ` Michael S. Tsirkin
0 siblings, 1 reply; 18+ messages in thread
From: Peter Maydell @ 2015-08-27 12:20 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Paolo Bonzini, Jason Wang, QEMU Developers, Greg Kurz
On 27 August 2015 at 13:17, Michael S. Tsirkin <mst@redhat.com> wrote:
> Basically the point is that ABI is extended to make
> ioeventfd with len = 0 mean "any length".
> 0 is thus not meaningless anymore.
But how can you do adjustment for incorrect endianness
if you don't know the size of the data that you're
trying to work with? That's why this switch insists
that the size is 1, 2, 4 or 8.
-- PMM
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness()
2015-08-27 12:20 ` Peter Maydell
@ 2015-08-27 12:25 ` Michael S. Tsirkin
2015-08-27 12:27 ` Peter Maydell
0 siblings, 1 reply; 18+ messages in thread
From: Michael S. Tsirkin @ 2015-08-27 12:25 UTC (permalink / raw)
To: Peter Maydell; +Cc: Paolo Bonzini, Jason Wang, QEMU Developers, Greg Kurz
On Thu, Aug 27, 2015 at 01:20:52PM +0100, Peter Maydell wrote:
> On 27 August 2015 at 13:17, Michael S. Tsirkin <mst@redhat.com> wrote:
> > Basically the point is that ABI is extended to make
> > ioeventfd with len = 0 mean "any length".
> > 0 is thus not meaningless anymore.
>
> But how can you do adjustment for incorrect endianness
> if you don't know the size of the data that you're
> trying to work with? That's why this switch insists
> that the size is 1, 2, 4 or 8.
>
> -- PMM
For kvm at least, "any length" implies "any data".
So data is eventually discarded, we don't really need
to adjust it for endian-ness.
--
MST
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness()
2015-08-27 12:25 ` Michael S. Tsirkin
@ 2015-08-27 12:27 ` Peter Maydell
2015-08-27 12:30 ` Michael S. Tsirkin
0 siblings, 1 reply; 18+ messages in thread
From: Peter Maydell @ 2015-08-27 12:27 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Paolo Bonzini, Jason Wang, QEMU Developers, Greg Kurz
On 27 August 2015 at 13:25, Michael S. Tsirkin <mst@redhat.com> wrote:
> On Thu, Aug 27, 2015 at 01:20:52PM +0100, Peter Maydell wrote:
>> On 27 August 2015 at 13:17, Michael S. Tsirkin <mst@redhat.com> wrote:
>> > Basically the point is that ABI is extended to make
>> > ioeventfd with len = 0 mean "any length".
>> > 0 is thus not meaningless anymore.
>>
>> But how can you do adjustment for incorrect endianness
>> if you don't know the size of the data that you're
>> trying to work with? That's why this switch insists
>> that the size is 1, 2, 4 or 8.
> For kvm at least, "any length" implies "any data".
> So data is eventually discarded, we don't really need
> to adjust it for endian-ness.
I'm still confused. If you have data it needs to be
adjusted. If we're not actually doing anything with
the data why are we calling this function in the first
place?
-- PMM
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness()
2015-08-27 12:27 ` Peter Maydell
@ 2015-08-27 12:30 ` Michael S. Tsirkin
2015-08-27 13:10 ` Greg Kurz
0 siblings, 1 reply; 18+ messages in thread
From: Michael S. Tsirkin @ 2015-08-27 12:30 UTC (permalink / raw)
To: Peter Maydell; +Cc: Paolo Bonzini, Jason Wang, QEMU Developers, Greg Kurz
On Thu, Aug 27, 2015 at 01:27:54PM +0100, Peter Maydell wrote:
> On 27 August 2015 at 13:25, Michael S. Tsirkin <mst@redhat.com> wrote:
> > On Thu, Aug 27, 2015 at 01:20:52PM +0100, Peter Maydell wrote:
> >> On 27 August 2015 at 13:17, Michael S. Tsirkin <mst@redhat.com> wrote:
> >> > Basically the point is that ABI is extended to make
> >> > ioeventfd with len = 0 mean "any length".
> >> > 0 is thus not meaningless anymore.
> >>
> >> But how can you do adjustment for incorrect endianness
> >> if you don't know the size of the data that you're
> >> trying to work with? That's why this switch insists
> >> that the size is 1, 2, 4 or 8.
>
> > For kvm at least, "any length" implies "any data".
> > So data is eventually discarded, we don't really need
> > to adjust it for endian-ness.
>
> I'm still confused. If you have data it needs to be
> adjusted. If we're not actually doing anything with
> the data why are we calling this function in the first
> place?
>
> -- PMM
I guess you could skip calls to adjust_endianness when len == 0,
that should work just as well.
--
MST
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness()
2015-08-27 12:30 ` Michael S. Tsirkin
@ 2015-08-27 13:10 ` Greg Kurz
2015-08-28 2:23 ` Jason Wang
0 siblings, 1 reply; 18+ messages in thread
From: Greg Kurz @ 2015-08-27 13:10 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Peter Maydell, Jason Wang, QEMU Developers, Paolo Bonzini
On Thu, 27 Aug 2015 15:30:55 +0300
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> On Thu, Aug 27, 2015 at 01:27:54PM +0100, Peter Maydell wrote:
> > On 27 August 2015 at 13:25, Michael S. Tsirkin <mst@redhat.com> wrote:
> > > On Thu, Aug 27, 2015 at 01:20:52PM +0100, Peter Maydell wrote:
> > >> On 27 August 2015 at 13:17, Michael S. Tsirkin <mst@redhat.com> wrote:
> > >> > Basically the point is that ABI is extended to make
> > >> > ioeventfd with len = 0 mean "any length".
> > >> > 0 is thus not meaningless anymore.
> > >>
> > >> But how can you do adjustment for incorrect endianness
> > >> if you don't know the size of the data that you're
> > >> trying to work with? That's why this switch insists
> > >> that the size is 1, 2, 4 or 8.
> >
> > > For kvm at least, "any length" implies "any data".
> > > So data is eventually discarded, we don't really need
> > > to adjust it for endian-ness.
> >
> > I'm still confused. If you have data it needs to be
> > adjusted. If we're not actually doing anything with
> > the data why are we calling this function in the first
> > place?
> >
> > -- PMM
>
> I guess you could skip calls to adjust_endianness when len == 0,
> that should work just as well.
>
adjust_endianness() is called from 4 different locations:
- memory_region_dispatch_read()
- memory_region_dispatch_write()
- memory_region_add_eventfd()
- memory_region_del_eventfd()
Since the issue was raised for the eventfd ones, it makes more sense to check
in the caller indeed... and to preserve other paths.
Cheers.
--
Greg
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness()
2015-08-27 13:10 ` Greg Kurz
@ 2015-08-28 2:23 ` Jason Wang
0 siblings, 0 replies; 18+ messages in thread
From: Jason Wang @ 2015-08-28 2:23 UTC (permalink / raw)
To: Greg Kurz, Michael S. Tsirkin
Cc: Peter Maydell, QEMU Developers, Paolo Bonzini
On 08/27/2015 09:10 PM, Greg Kurz wrote:
> On Thu, 27 Aug 2015 15:30:55 +0300
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
>
>> On Thu, Aug 27, 2015 at 01:27:54PM +0100, Peter Maydell wrote:
>>> On 27 August 2015 at 13:25, Michael S. Tsirkin <mst@redhat.com> wrote:
>>>> On Thu, Aug 27, 2015 at 01:20:52PM +0100, Peter Maydell wrote:
>>>>> On 27 August 2015 at 13:17, Michael S. Tsirkin <mst@redhat.com> wrote:
>>>>>> Basically the point is that ABI is extended to make
>>>>>> ioeventfd with len = 0 mean "any length".
>>>>>> 0 is thus not meaningless anymore.
>>>>> But how can you do adjustment for incorrect endianness
>>>>> if you don't know the size of the data that you're
>>>>> trying to work with? That's why this switch insists
>>>>> that the size is 1, 2, 4 or 8.
>>>> For kvm at least, "any length" implies "any data".
>>>> So data is eventually discarded, we don't really need
>>>> to adjust it for endian-ness.
>>> I'm still confused. If you have data it needs to be
>>> adjusted. If we're not actually doing anything with
>>> the data why are we calling this function in the first
>>> place?
>>>
>>> -- PMM
>> I guess you could skip calls to adjust_endianness when len == 0,
>> that should work just as well.
>>
> adjust_endianness() is called from 4 different locations:
> - memory_region_dispatch_read()
> - memory_region_dispatch_write()
> - memory_region_add_eventfd()
> - memory_region_del_eventfd()
>
> Since the issue was raised for the eventfd ones, it makes more sense to check
> in the caller indeed... and to preserve other paths.
>
> Cheers.
>
> --
> Greg
>
Yes, this seems fine.
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2015-08-28 2:23 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-26 10:04 [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness() Jason Wang
2015-08-26 10:04 ` [Qemu-devel] [PATCH 2/2] pci: test-dev: try to test fast mmio bus for wildcard mmio event Jason Wang
2015-08-27 10:28 ` Michael S. Tsirkin
2015-08-26 14:21 ` [Qemu-devel] [PATCH 1/2] memory: allow zero size for adjust_endianness() Peter Maydell
2015-08-26 14:51 ` Greg Kurz
2015-08-27 4:50 ` Jason Wang
2015-08-27 10:49 ` Peter Maydell
2015-08-27 10:53 ` Michael S. Tsirkin
2015-08-27 11:04 ` Peter Maydell
2015-08-27 11:08 ` Michael S. Tsirkin
2015-08-27 12:12 ` Peter Maydell
2015-08-27 12:17 ` Michael S. Tsirkin
2015-08-27 12:20 ` Peter Maydell
2015-08-27 12:25 ` Michael S. Tsirkin
2015-08-27 12:27 ` Peter Maydell
2015-08-27 12:30 ` Michael S. Tsirkin
2015-08-27 13:10 ` Greg Kurz
2015-08-28 2:23 ` Jason Wang
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).