qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] real host page API
@ 2015-06-06  6:17 Peter Crosthwaite
  2015-06-06  6:17 ` [Qemu-devel] [PATCH 1/2] cpu-all: complete "real" host page size API Peter Crosthwaite
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Peter Crosthwaite @ 2015-06-06  6:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: aik, pbonzini, alex.williamson, Peter Crosthwaite, rth

Hi All,

As we discussed earlier, the sole use of HOST_PAGE_ALIGN in system
level code should be targeting the "real" host page alignment and
not the target-specific HOST_PAGE_ALIGN.

This complete the API for REAL_HOST_PAGE_ALIGN and friends that can
be use the same way as HOST_PAGE_ALIGN in system level code.

The one use in vfio/pci is then patches.

Regards,
Peter

Peter Crosthwaite (2):
  cpu-all: complete "real" host page size API
  vfio: cpu: Use "real" page size API

 hw/vfio/pci.c          | 7 ++++---
 include/exec/cpu-all.h | 3 +++
 translate-all.c        | 2 ++
 3 files changed, 9 insertions(+), 3 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH 1/2] cpu-all: complete "real" host page size API
  2015-06-06  6:17 [Qemu-devel] [PATCH 0/2] real host page API Peter Crosthwaite
@ 2015-06-06  6:17 ` Peter Crosthwaite
  2015-06-06  6:17 ` [Qemu-devel] [PATCH 2/2] vfio: cpu: Use "real" " Peter Crosthwaite
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Peter Crosthwaite @ 2015-06-06  6:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: aik, pbonzini, alex.williamson, Peter Crosthwaite, rth

Currently the "host" page size alignment API is really aligning to both
host and target page sizes. There is the qemu_real_page_size which can
be used for the actual host page size but it's missing a mask and ALIGN
macro as provided for qemu_page_size. Complete the API. This allows
system level code that cares about the host page size to use a
consistent alignment interface without having to un-needingly align to
the target page size. This also reduces system level code dependency
on the cpu specific TARGET_PAGE_SIZE.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
 include/exec/cpu-all.h | 3 +++
 translate-all.c        | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index ac06c67..8f89669 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -177,10 +177,13 @@ extern unsigned long reserved_va;
 
 /* ??? These should be the larger of uintptr_t and target_ulong.  */
 extern uintptr_t qemu_real_host_page_size;
+extern uintptr_t qemu_real_host_page_mask;
 extern uintptr_t qemu_host_page_size;
 extern uintptr_t qemu_host_page_mask;
 
 #define HOST_PAGE_ALIGN(addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask)
+#define REAL_HOST_PAGE_ALIGN(addr) (((addr) + qemu_real_host_page_size - 1) & \
+                                    qemu_real_host_page_mask)
 
 /* same as PROT_xxx */
 #define PAGE_READ      0x0001
diff --git a/translate-all.c b/translate-all.c
index 62042af..d5a1977 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -117,6 +117,7 @@ typedef struct PageDesc {
 #define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS)
 
 uintptr_t qemu_real_host_page_size;
+uintptr_t qemu_real_host_page_mask;
 uintptr_t qemu_host_page_size;
 uintptr_t qemu_host_page_mask;
 
@@ -306,6 +307,7 @@ void page_size_init(void)
     /* NOTE: we can always suppose that qemu_host_page_size >=
        TARGET_PAGE_SIZE */
     qemu_real_host_page_size = getpagesize();
+    qemu_real_host_page_mask = ~(qemu_real_host_page_size - 1);
     if (qemu_host_page_size == 0) {
         qemu_host_page_size = qemu_real_host_page_size;
     }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH 2/2] vfio: cpu: Use "real" page size API
  2015-06-06  6:17 [Qemu-devel] [PATCH 0/2] real host page API Peter Crosthwaite
  2015-06-06  6:17 ` [Qemu-devel] [PATCH 1/2] cpu-all: complete "real" host page size API Peter Crosthwaite
@ 2015-06-06  6:17 ` Peter Crosthwaite
  2015-06-16 10:51 ` [Qemu-devel] [PATCH 0/2] real host page API Alexey Kardashevskiy
  2015-06-24  4:29 ` Peter Crosthwaite
  3 siblings, 0 replies; 7+ messages in thread
From: Peter Crosthwaite @ 2015-06-06  6:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: aik, pbonzini, alex.williamson, Peter Crosthwaite, rth

This is system level code, and should only depend on the host page
size, not the target page size.

Note that HOST_PAGE_SIZE is misleadingly lead and is really aligning
to both host and target page size. Hence it's replacement with
REAL_HOST_PAGE_SIZE.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
 hw/vfio/pci.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index e0e339a..cf9791e 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2388,7 +2388,7 @@ static void vfio_map_bar(VFIOPCIDevice *vdev, int nr)
      * potentially insert a direct-mapped subregion before and after it.
      */
     if (vdev->msix && vdev->msix->table_bar == nr) {
-        size = vdev->msix->table_offset & qemu_host_page_mask;
+        size = vdev->msix->table_offset & qemu_real_host_page_mask;
     }
 
     strncat(name, " mmap", sizeof(name) - strlen(name) - 1);
@@ -2401,8 +2401,9 @@ static void vfio_map_bar(VFIOPCIDevice *vdev, int nr)
     if (vdev->msix && vdev->msix->table_bar == nr) {
         uint64_t start;
 
-        start = HOST_PAGE_ALIGN((uint64_t)vdev->msix->table_offset +
-                                (vdev->msix->entries * PCI_MSIX_ENTRY_SIZE));
+        start = REAL_HOST_PAGE_ALIGN((uint64_t)vdev->msix->table_offset +
+                                     (vdev->msix->entries *
+                                      PCI_MSIX_ENTRY_SIZE));
 
         size = start < bar->region.size ? bar->region.size - start : 0;
         strncat(name, " msix-hi", sizeof(name) - strlen(name) - 1);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] real host page API
  2015-06-06  6:17 [Qemu-devel] [PATCH 0/2] real host page API Peter Crosthwaite
  2015-06-06  6:17 ` [Qemu-devel] [PATCH 1/2] cpu-all: complete "real" host page size API Peter Crosthwaite
  2015-06-06  6:17 ` [Qemu-devel] [PATCH 2/2] vfio: cpu: Use "real" " Peter Crosthwaite
@ 2015-06-16 10:51 ` Alexey Kardashevskiy
  2015-06-24  4:29 ` Peter Crosthwaite
  3 siblings, 0 replies; 7+ messages in thread
From: Alexey Kardashevskiy @ 2015-06-16 10:51 UTC (permalink / raw)
  To: Peter Crosthwaite, qemu-devel
  Cc: pbonzini, alex.williamson, Peter Crosthwaite, rth

On 06/06/2015 04:17 PM, Peter Crosthwaite wrote:
> Hi All,
>
> As we discussed earlier, the sole use of HOST_PAGE_ALIGN in system
> level code should be targeting the "real" host page alignment and
> not the target-specific HOST_PAGE_ALIGN.
>
> This complete the API for REAL_HOST_PAGE_ALIGN and friends that can
> be use the same way as HOST_PAGE_ALIGN in system level code.
>
> The one use in vfio/pci is then patches.

Looks good to me.

Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>	


>
> Regards,
> Peter
>
> Peter Crosthwaite (2):
>    cpu-all: complete "real" host page size API
>    vfio: cpu: Use "real" page size API
>
>   hw/vfio/pci.c          | 7 ++++---
>   include/exec/cpu-all.h | 3 +++
>   translate-all.c        | 2 ++
>   3 files changed, 9 insertions(+), 3 deletions(-)
>


-- 
Alexey

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] real host page API
  2015-06-06  6:17 [Qemu-devel] [PATCH 0/2] real host page API Peter Crosthwaite
                   ` (2 preceding siblings ...)
  2015-06-16 10:51 ` [Qemu-devel] [PATCH 0/2] real host page API Alexey Kardashevskiy
@ 2015-06-24  4:29 ` Peter Crosthwaite
  2015-06-24 10:10   ` Paolo Bonzini
  3 siblings, 1 reply; 7+ messages in thread
From: Peter Crosthwaite @ 2015-06-24  4:29 UTC (permalink / raw)
  To: Peter Crosthwaite, Peter Maydell
  Cc: Peter Crosthwaite, Alexey Kardashevskiy,
	qemu-devel@nongnu.org Developers, Alex Williamson, Paolo Bonzini,
	Richard Henderson

Ping!

Can this go via the TCG queue, is there something for VFIO, or can
Peter pick it up as a between-the-maintainerships straggler?

Regards,
Peter

On Fri, Jun 5, 2015 at 11:17 PM, Peter Crosthwaite
<crosthwaitepeter@gmail.com> wrote:
> Hi All,
>
> As we discussed earlier, the sole use of HOST_PAGE_ALIGN in system
> level code should be targeting the "real" host page alignment and
> not the target-specific HOST_PAGE_ALIGN.
>
> This complete the API for REAL_HOST_PAGE_ALIGN and friends that can
> be use the same way as HOST_PAGE_ALIGN in system level code.
>
> The one use in vfio/pci is then patches.
>
> Regards,
> Peter
>
> Peter Crosthwaite (2):
>   cpu-all: complete "real" host page size API
>   vfio: cpu: Use "real" page size API
>
>  hw/vfio/pci.c          | 7 ++++---
>  include/exec/cpu-all.h | 3 +++
>  translate-all.c        | 2 ++
>  3 files changed, 9 insertions(+), 3 deletions(-)
>
> --
> 1.9.1
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] real host page API
  2015-06-24  4:29 ` Peter Crosthwaite
@ 2015-06-24 10:10   ` Paolo Bonzini
  2015-06-25 15:22     ` Alex Williamson
  0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2015-06-24 10:10 UTC (permalink / raw)
  To: Peter Crosthwaite, Peter Crosthwaite, Peter Maydell,
	Alex Williamson
  Cc: Alexey Kardashevskiy, Richard Henderson,
	qemu-devel@nongnu.org Developers, Peter Crosthwaite



On 24/06/2015 06:29, Peter Crosthwaite wrote:
> Ping!
> 
> Can this go via the TCG queue, is there something for VFIO, or can
> Peter pick it up as a between-the-maintainerships straggler?
> 
> Regards,
> Peter
> 
> On Fri, Jun 5, 2015 at 11:17 PM, Peter Crosthwaite
> <crosthwaitepeter@gmail.com> wrote:
>> Hi All,
>>
>> As we discussed earlier, the sole use of HOST_PAGE_ALIGN in system
>> level code should be targeting the "real" host page alignment and
>> not the target-specific HOST_PAGE_ALIGN.
>>
>> This complete the API for REAL_HOST_PAGE_ALIGN and friends that can
>> be use the same way as HOST_PAGE_ALIGN in system level code.
>>
>> The one use in vfio/pci is then patches.
>>
>> Regards,
>> Peter
>>
>> Peter Crosthwaite (2):
>>   cpu-all: complete "real" host page size API
>>   vfio: cpu: Use "real" page size API
>>
>>  hw/vfio/pci.c          | 7 ++++---
>>  include/exec/cpu-all.h | 3 +++
>>  translate-all.c        | 2 ++
>>  3 files changed, 9 insertions(+), 3 deletions(-)
>>
>> --
>> 1.9.1
>>
>>

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

Alex, can you pick it up or shall I?

Paolo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] real host page API
  2015-06-24 10:10   ` Paolo Bonzini
@ 2015-06-25 15:22     ` Alex Williamson
  0 siblings, 0 replies; 7+ messages in thread
From: Alex Williamson @ 2015-06-25 15:22 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Peter Maydell, Peter Crosthwaite, Peter Crosthwaite,
	Alexey Kardashevskiy, qemu-devel@nongnu.org Developers,
	Peter Crosthwaite, Richard Henderson

On Wed, 2015-06-24 at 12:10 +0200, Paolo Bonzini wrote:
> 
> On 24/06/2015 06:29, Peter Crosthwaite wrote:
> > Ping!
> > 
> > Can this go via the TCG queue, is there something for VFIO, or can
> > Peter pick it up as a between-the-maintainerships straggler?
> > 
> > Regards,
> > Peter
> > 
> > On Fri, Jun 5, 2015 at 11:17 PM, Peter Crosthwaite
> > <crosthwaitepeter@gmail.com> wrote:
> >> Hi All,
> >>
> >> As we discussed earlier, the sole use of HOST_PAGE_ALIGN in system
> >> level code should be targeting the "real" host page alignment and
> >> not the target-specific HOST_PAGE_ALIGN.
> >>
> >> This complete the API for REAL_HOST_PAGE_ALIGN and friends that can
> >> be use the same way as HOST_PAGE_ALIGN in system level code.
> >>
> >> The one use in vfio/pci is then patches.
> >>
> >> Regards,
> >> Peter
> >>
> >> Peter Crosthwaite (2):
> >>   cpu-all: complete "real" host page size API
> >>   vfio: cpu: Use "real" page size API
> >>
> >>  hw/vfio/pci.c          | 7 ++++---
> >>  include/exec/cpu-all.h | 3 +++
> >>  translate-all.c        | 2 ++
> >>  3 files changed, 9 insertions(+), 3 deletions(-)
> >>
> >> --
> >> 1.9.1
> >>
> >>
> 
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
> 
> Alex, can you pick it up or shall I?

I'll take it, I need to send a pull request for your coverity fix before
hard freeze anyway.  Thanks,

Alex

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-06-25 15:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-06  6:17 [Qemu-devel] [PATCH 0/2] real host page API Peter Crosthwaite
2015-06-06  6:17 ` [Qemu-devel] [PATCH 1/2] cpu-all: complete "real" host page size API Peter Crosthwaite
2015-06-06  6:17 ` [Qemu-devel] [PATCH 2/2] vfio: cpu: Use "real" " Peter Crosthwaite
2015-06-16 10:51 ` [Qemu-devel] [PATCH 0/2] real host page API Alexey Kardashevskiy
2015-06-24  4:29 ` Peter Crosthwaite
2015-06-24 10:10   ` Paolo Bonzini
2015-06-25 15:22     ` Alex Williamson

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).