real host page API
cover real host page API
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(-)
Signature · 1 line
1.9.1
PATCH 1/2 cpu-all: complete "real" host page size API
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.
--- include/exec/cpu-all.h | 3 +++ translate-all.c | 2 ++ 2 files changed, 5 insertions(+)
include/exec/cpu-all.h +3 -0
@@ -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
translate-all.c +2 -0
@@ -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; }
Signature · 1 line
1.9.1
PATCH 2/2 vfio: cpu: Use "real" page size API
In reply to Peter CrosthwaiteThis 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.
--- hw/vfio/pci.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
hw/vfio/pci.c +4 -3
@@ -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 );
Signature · 1 line
1.9.1
Quoted 10 lines · Peter Crosthwaite
Hi All,
As we discussed earlier, the sole use of
HOST_PAGE_ALIGNin system level code should be targeting the "real" host page alignment and not the target-specificHOST_PAGE_ALIGN.This complete the API for
REAL_HOST_PAGE_ALIGNand friends that can be use the same way asHOST_PAGE_ALIGNin system level code.The one use in vfio/pci is then patches.
Looks good to me.
Quoted 13 lines
Regards,
PeterPeter Crosthwaite (2):
cpu-all: complete "real" host page size API
vfio: cpu: Use "real" page size APIhw/vfio/pci.c | 7 ++++--- include/exec/cpu-all.h | 3 +++ translate-all.c | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-)
Signature · 1 line
Alexey
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
Quoted 27 lines · Peter Crosthwaite
Hi All,
As we discussed earlier, the sole use of
HOST_PAGE_ALIGNin system level code should be targeting the "real" host page alignment and not the target-specificHOST_PAGE_ALIGN.This complete the API for
REAL_HOST_PAGE_ALIGNand friends that can be use the same way asHOST_PAGE_ALIGNin system level code.The one use in vfio/pci is then patches.
Regards,
PeterPeter Crosthwaite (2):
cpu-all: complete "real" host page size API
vfio: cpu: Use "real" page size APIhw/vfio/pci.c | 7 ++++--- include/exec/cpu-all.h | 3 +++ translate-all.c | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-)--
1.9.1
Paolo Bonzini
Acked-byQuoted 37 lines · Peter Crosthwaite
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,
PeterQuoted 27 lines · Peter Crosthwaite
Hi All,
As we discussed earlier, the sole use of
HOST_PAGE_ALIGNin system level code should be targeting the "real" host page alignment and not the target-specificHOST_PAGE_ALIGN.This complete the API for
REAL_HOST_PAGE_ALIGNand friends that can be use the same way asHOST_PAGE_ALIGNin system level code.The one use in vfio/pci is then patches.
Regards,
PeterPeter Crosthwaite (2):
cpu-all: complete "real" host page size API
vfio: cpu: Use "real" page size APIhw/vfio/pci.c | 7 ++++--- include/exec/cpu-all.h | 3 +++ translate-all.c | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-)--
1.9.1
Alex, can you pick it up or shall I?
Paolo
Quoted 35 lines · Paolo Bonzini
Quoted 33 lines · Peter Crosthwaite
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,
PeterQuoted 23 lines · Peter Crosthwaite
Hi All,
As we discussed earlier, the sole use of
HOST_PAGE_ALIGNin system level code should be targeting the "real" host page alignment and not the target-specificHOST_PAGE_ALIGN.This complete the API for
REAL_HOST_PAGE_ALIGNand friends that can be use the same way asHOST_PAGE_ALIGNin system level code.The one use in vfio/pci is then patches.
Regards,
PeterPeter Crosthwaite (2):
cpu-all: complete "real" host page size API
vfio: cpu: Use "real" page size APIhw/vfio/pci.c | 7 ++++--- include/exec/cpu-all.h | 3 +++ translate-all.c | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-)
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
--
1.9.1Acked-by Paolo Bonzini <[email protected]>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