hw/arm: xenpvh: Enable PCI for ARM PVH
cover hw/arm: xenpvh: Enable PCI for ARM PVH
From: "Edgar E. Iglesias" <[email protected]>
Enable PCI on the ARM PVH machine. First we add a way to control the use of buffered IOREQ's since those are not supported on Xen/ARM. Finally we enable the PCI support.
I've published some instructions on how to try this including the work in progress Xen side of the PVH PCI support:
https://github.com/edgarigl/docs/blob/master/xen/pvh/virtio-pci-dom0less.md
Cheers,
Edgar
Edgar E. Iglesias (4):
xen: Expose handle_bufioreq in xen_register_ioreq hw/xen: xenpvh: Disable buffered IOREQs for ARM hw/xen: xenpvh: Add pci-intx-irq-base property hw/arm: xenpvh: Enable PCI for ARM PVH
hw/arm/xen-pvh.c | 17 ++++++ hw/i386/xen/xen-hvm.c | 4 +- hw/i386/xen/xen-pvh.c | 3 + hw/xen/xen-hvm-common.c | 100 +++++++++++++++++++------------- hw/xen/xen-pvh-common.c | 40 ++++++++++++- include/hw/xen/xen-hvm-common.h | 3 + include/hw/xen/xen-pvh-common.h | 3 + include/hw/xen/xen_native.h | 3 +- 8 files changed, 129 insertions(+), 44 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/4 xen: Expose handle_bufioreq in xen_register_ioreq
From: "Edgar E. Iglesias" <[email protected]>
Expose handle_bufioreq in xen_register_ioreq().
This is to allow machines to enable or disable buffered ioreqs.
No functional change since all callers still set it to HVM_IOREQSRV_BUFIOREQ_ATOMIC.
--- hw/i386/xen/xen-hvm.c | 4 +- hw/xen/xen-hvm-common.c | 100 +++++++++++++++++++------------- hw/xen/xen-pvh-common.c | 4 +- include/hw/xen/xen-hvm-common.h | 3 + include/hw/xen/xen_native.h | 3 +- 5 files changed, 70 insertions(+), 44 deletions(-)
hw/i386/xen/xen-hvm.c +3 -1
@@ -614,7 +614,9 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) state =g_new0 (XenIOState,1 ); -xen_register_ioreq (state, max_cpus, &xen_memory_listener); +xen_register_ioreq (state, max_cpus, +HVM_IOREQSRV_BUFIOREQ_ATOMIC , + &xen_memory_listener); xen_is_stubdomain =xen_check_stubdomain (state->xenstore);
hw/xen/xen-hvm-common.c +59 -41
151 lines not on this page · raw message
hw/xen/xen-pvh-common.c +3 -1
@@ -194,7 +194,9 @@ static void xen_pvh_init(MachineState *ms) }xen_pvh_init_ram (s, sysmem); -xen_register_ioreq (&s->ioreq, ms->smp.max_cpus, &xen_memory_listener); +xen_register_ioreq (&s->ioreq, ms->smp.max_cpus, +HVM_IOREQSRV_BUFIOREQ_ATOMIC , + &xen_memory_listener);if (s->cfg.virtio_mmio_num) {xen_create_virtio_mmio_devices (s);
include/hw/xen/xen-hvm-common.h +3 -0
@@ -81,6 +81,8 @@ typedef struct XenIOState { QLIST_HEAD(, XenPciDevice) dev_list;DeviceListener device_listener; +bool has_bufioreq; +Notifier exit; } XenIOState;
@@ -95,6 +97,7 @@ void xen_device_unrealize(DeviceListener *listener, DeviceState *dev);void xen_hvm_change_state_handler (void *opaque,bool running,RunState rstate);void xen_register_ioreq (XenIOState *state,unsigned int max_cpus, +int handle_bufioreq,const MemoryListener *xen_memory_listener);void cpu_ioreq_pio (ioreq_t *req);
include/hw/xen/xen_native.h +2 -1
@@ -464,10 +464,11 @@ static inline void xen_unmap_pcidev(domid_t dom, }static inline int xen_create_ioreq_server (domid_t dom, +int handle_bufioreq,ioservid_t *ioservid) {int rc =xendevicemodel_create_ioreq_server (xen_dmod, dom, -HVM_IOREQSRV_BUFIOREQ_ATOMIC , + handle_bufioreq, ioservid);if (rc ==0 ) {
Signature · 1 line
2.43.0
Re: [PATCH v1 1/4] xen: Expose handle_bufioreq in xen_register_ioreq
Quoted 110 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Expose
handle_bufioreqinxen_register_ioreq().
This is to allow machines to enable or disable buffered ioreqs.No functional change since all callers still set it to
HVM_IOREQSRV_BUFIOREQ_ATOMIC.Signed-off-by Edgar E. Iglesias <[email protected]>--- hw/i386/xen/xen-hvm.c | 4 +- hw/xen/xen-hvm-common.c | 100 +++++++++++++++++++------------- hw/xen/xen-pvh-common.c | 4 +- include/hw/xen/xen-hvm-common.h | 3 + include/hw/xen/xen_native.h | 3 +- 5 files changed, 70 insertions(+), 44 deletions(-)hw/i386/xen/xen-hvm.c +3
-1@@ -614,7 +614,9 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) state =g_new0 (XenIOState,1 ); -xen_register_ioreq (state, max_cpus, &xen_memory_listener); +xen_register_ioreq (state, max_cpus, +HVM_IOREQSRV_BUFIOREQ_ATOMIC , + &xen_memory_listener); xen_is_stubdomain =xen_check_stubdomain (state->xenstore);hw/xen/xen-hvm-common.c +27
-22@@ -667,6 +667,8 @@ static int xen_map_ioreq_server(XenIOState *state)xen_pfn_t ioreq_pfn;xen_pfn_t bufioreq_pfn;evtchn_port_t bufioreq_evtchn; +unsigned long num_frames =1 ; +unsigned long frame =1 ;int rc;/* @@ -675,59 +677,72 @@ static int xen_map_ioreq_server(XenIOState *state)*/ QEMU_BUILD_BUG_ON (XENMEM_resource_ioreq_server_frame_bufioreq !=0 );QEMU_BUILD_BUG_ON (XENMEM_resource_ioreq_server_frame_ioreq (0 ) !=1 ); + +if (state->has_bufioreq) { + frame =0 ; + num_frames =2 ; + } state->fres =xenforeignmemory_map_resource (xen_fmem, xen_domid, XENMEM_resource_ioreq_server, - state->ioservid,0 ,2 , + state->ioservid, + frame, num_frames, &addr,PROT_READ |PROT_WRITE ,0 );if (state->fres !=NULL ) {trace_xen_map_resource_ioreq (state->ioservid, addr); - state->buffered_io_page = addr; - state->shared_page = addr +XC_PAGE_SIZE ; + state->shared_page = addr; +if (state->has_bufioreq) { + state->buffered_io_page = addr; + state->shared_page = addr +XC_PAGE_SIZE ; + } }else if (errno !=EOPNOTSUPP ) {error_report ("failed to map ioreq server resources: error %d handle=%p" , errno, xen_xc);return -1 ; } - rc =xen_get_ioreq_server_info (xen_domid, state->ioservid, - (state->shared_page ==NULL ) ? - &ioreq_pfn :NULL , - (state->buffered_io_page ==NULL ) ? - &bufioreq_pfn :NULL , - &bufioreq_evtchn); -if (rc <0 ) { -error_report ("failed to get ioreq server info: error %d handle=%p" , - errno, xen_xc); -return rc; - } - -if (state->shared_page ==NULL ) { -trace_xen_map_ioreq_server_shared_page (ioreq_pfn); +if (state->has_bufioreq) { + rc =xen_get_ioreq_server_info (xen_domid, state->ioservid, + (state->shared_page ==NULL ) ? + &ioreq_pfn :NULL , + (state->buffered_io_page ==NULL ) ? + &bufioreq_pfn :NULL , + &bufioreq_evtchn); +if (rc <0 ) { +error_report ("failed to get ioreq server info: error %d handle=%p" , + errno, xen_xc); +return rc; + } - state->shared_page =xenforeignmemory_map (xen_fmem, xen_domid, -PROT_READ |PROT_WRITE , -1 , &ioreq_pfn,NULL );if (state->shared_page ==NULL ) { -error_report ("map shared IO page returned error %d handle=%p" , - errno, xen_xc); +trace_xen_map_ioreq_server_shared_page (ioreq_pfn);
hw/xen/xen-hvm-common.c static int xen_map_ioreq_server(XenIOState *state) · line 715
Quoted 10 lines
hw/xen/xen-hvm-common.c +8
-1+ + state->shared_page =xenforeignmemory_map (xen_fmem, xen_domid, +PROT_READ |PROT_WRITE , +1 , &ioreq_pfn,NULL ); +if (state->shared_page ==NULL ) { +error_report ("map shared IO page returned error %d handle=%p" , + errno, xen_xc); + } } - }
If I am reading the code right the calls to xen_get_ioreq_server_info and xenforeignmemory_map were not done to setup bufioreq. They were done for legacy compatibility to support systems where xenforeignmemory_map_resource returns EOPNOTSUPP.
I think we should either get rid of this legacy path completely, or keep it for both bufioreq and non-bufioreq.
Quoted 127 lines
hw/xen/xen-hvm-common.c +24
-18-if (state->buffered_io_page ==NULL ) { -trace_xen_map_ioreq_server_buffered_io_page (bufioreq_pfn); - - state->buffered_io_page =xenforeignmemory_map (xen_fmem, xen_domid, -PROT_READ |PROT_WRITE , -1 , &bufioreq_pfn, -NULL );if (state->buffered_io_page ==NULL ) { -error_report ("map buffered IO page returned error %d" , errno); -return -1 ; +trace_xen_map_ioreq_server_buffered_io_page (bufioreq_pfn); + + state->buffered_io_page =xenforeignmemory_map (xen_fmem, xen_domid, +PROT_READ |PROT_WRITE , +1 , &bufioreq_pfn, +NULL ); +if (state->buffered_io_page ==NULL ) { +error_report ("map buffered IO page returned error %d" , errno); +return -1 ; + } } } -if (state->shared_page ==NULL || state->buffered_io_page ==NULL ) { + +if (state->shared_page ==NULL || + (state->has_bufioreq && state->buffered_io_page ==NULL )) {return -1 ; }@@ -830,14 +845,15 @@ static void xen_do_ioreq_register(XenIOState *state, state->ioreq_local_port[i] = rc; } - rc =qemu_xen_evtchn_bind_interdomain (state->xce_handle, xen_domid, - state->bufioreq_remote_port); -if (rc ==-1 ) { -error_report ("buffered evtchn bind error %d" , errno); - goto err; +if (state->has_bufioreq) { + rc =qemu_xen_evtchn_bind_interdomain (state->xce_handle, xen_domid, + state->bufioreq_remote_port); +if (rc ==-1 ) { +error_report ("buffered evtchn bind error %d" , errno); + goto err; + } + state->bufioreq_local_port = rc; } - state->bufioreq_local_port = rc; -/* Init RAM management */ #ifdef XEN_COMPAT_PHYSMAP xen_map_cache_init (xen_phys_offset_to_gaddr, state);@@ -865,6 +881,7 @@ err: }void xen_register_ioreq (XenIOState *state,unsigned int max_cpus, +int handle_bufioreq,const MemoryListener *xen_memory_listener) {int rc;@@ -883,7 +900,8 @@ void xen_register_ioreq(XenIOState *state, unsigned int max_cpus, goto err; } - rc =xen_create_ioreq_server (xen_domid, &state->ioservid); + state->has_bufioreq = handle_bufioreq !=HVM_IOREQSRV_BUFIOREQ_OFF ; + rc =xen_create_ioreq_server (xen_domid, handle_bufioreq, &state->ioservid);if (!rc) {xen_do_ioreq_register (state, max_cpus, xen_memory_listener); }else {hw/xen/xen-pvh-common.c +3
-1@@ -194,7 +194,9 @@ static void xen_pvh_init(MachineState *ms) }xen_pvh_init_ram (s, sysmem); -xen_register_ioreq (&s->ioreq, ms->smp.max_cpus, &xen_memory_listener); +xen_register_ioreq (&s->ioreq, ms->smp.max_cpus, +HVM_IOREQSRV_BUFIOREQ_ATOMIC , + &xen_memory_listener);if (s->cfg.virtio_mmio_num) {xen_create_virtio_mmio_devices (s);include/hw/xen/xen-hvm-common.h +3
-0@@ -81,6 +81,8 @@ typedef struct XenIOState { QLIST_HEAD(, XenPciDevice) dev_list;DeviceListener device_listener; +bool has_bufioreq; +Notifier exit; } XenIOState;@@ -95,6 +97,7 @@ void xen_device_unrealize(DeviceListener *listener, DeviceState *dev);void xen_hvm_change_state_handler (void *opaque,bool running,RunState rstate);void xen_register_ioreq (XenIOState *state,unsigned int max_cpus, +int handle_bufioreq,const MemoryListener *xen_memory_listener);void cpu_ioreq_pio (ioreq_t *req);include/hw/xen/xen_native.h +2
-1@@ -464,10 +464,11 @@ static inline void xen_unmap_pcidev(domid_t dom, }static inline int xen_create_ioreq_server (domid_t dom, +int handle_bufioreq,ioservid_t *ioservid) {int rc =xendevicemodel_create_ioreq_server (xen_dmod, dom, -HVM_IOREQSRV_BUFIOREQ_ATOMIC , + handle_bufioreq, ioservid);if (rc ==0 ) {Signature · 1 line
2.43.0
Re: [PATCH v1 1/4] xen: Expose handle_bufioreq in xen_register_ioreq
Quoted 128 lines · Stefano Stabellini
Quoted 110 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Expose
handle_bufioreqinxen_register_ioreq().
This is to allow machines to enable or disable buffered ioreqs.No functional change since all callers still set it to
HVM_IOREQSRV_BUFIOREQ_ATOMIC.Signed-off-by Edgar E. Iglesias <[email protected]>--- hw/i386/xen/xen-hvm.c | 4 +- hw/xen/xen-hvm-common.c | 100 +++++++++++++++++++------------- hw/xen/xen-pvh-common.c | 4 +- include/hw/xen/xen-hvm-common.h | 3 + include/hw/xen/xen_native.h | 3 +- 5 files changed, 70 insertions(+), 44 deletions(-)hw/i386/xen/xen-hvm.c +3
-1@@ -614,7 +614,9 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) state =g_new0 (XenIOState,1 ); -xen_register_ioreq (state, max_cpus, &xen_memory_listener); +xen_register_ioreq (state, max_cpus, +HVM_IOREQSRV_BUFIOREQ_ATOMIC , + &xen_memory_listener); xen_is_stubdomain =xen_check_stubdomain (state->xenstore);hw/xen/xen-hvm-common.c +27
-22@@ -667,6 +667,8 @@ static int xen_map_ioreq_server(XenIOState *state)xen_pfn_t ioreq_pfn;xen_pfn_t bufioreq_pfn;evtchn_port_t bufioreq_evtchn; +unsigned long num_frames =1 ; +unsigned long frame =1 ;int rc;/* @@ -675,59 +677,72 @@ static int xen_map_ioreq_server(XenIOState *state)*/ QEMU_BUILD_BUG_ON (XENMEM_resource_ioreq_server_frame_bufioreq !=0 );QEMU_BUILD_BUG_ON (XENMEM_resource_ioreq_server_frame_ioreq (0 ) !=1 ); + +if (state->has_bufioreq) { + frame =0 ; + num_frames =2 ; + } state->fres =xenforeignmemory_map_resource (xen_fmem, xen_domid, XENMEM_resource_ioreq_server, - state->ioservid,0 ,2 , + state->ioservid, + frame, num_frames, &addr,PROT_READ |PROT_WRITE ,0 );if (state->fres !=NULL ) {trace_xen_map_resource_ioreq (state->ioservid, addr); - state->buffered_io_page = addr; - state->shared_page = addr +XC_PAGE_SIZE ; + state->shared_page = addr; +if (state->has_bufioreq) { + state->buffered_io_page = addr; + state->shared_page = addr +XC_PAGE_SIZE ; + } }else if (errno !=EOPNOTSUPP ) {error_report ("failed to map ioreq server resources: error %d handle=%p" , errno, xen_xc);return -1 ; } - rc =xen_get_ioreq_server_info (xen_domid, state->ioservid, - (state->shared_page ==NULL ) ? - &ioreq_pfn :NULL , - (state->buffered_io_page ==NULL ) ? - &bufioreq_pfn :NULL , - &bufioreq_evtchn); -if (rc <0 ) { -error_report ("failed to get ioreq server info: error %d handle=%p" , - errno, xen_xc); -return rc; - } - -if (state->shared_page ==NULL ) { -trace_xen_map_ioreq_server_shared_page (ioreq_pfn); +if (state->has_bufioreq) { + rc =xen_get_ioreq_server_info (xen_domid, state->ioservid, + (state->shared_page ==NULL ) ? + &ioreq_pfn :NULL , + (state->buffered_io_page ==NULL ) ? + &bufioreq_pfn :NULL , + &bufioreq_evtchn); +if (rc <0 ) { +error_report ("failed to get ioreq server info: error %d handle=%p" , + errno, xen_xc); +return rc; + } - state->shared_page =xenforeignmemory_map (xen_fmem, xen_domid, -PROT_READ |PROT_WRITE , -1 , &ioreq_pfn,NULL );if (state->shared_page ==NULL ) { -error_report ("map shared IO page returned error %d handle=%p" , - errno, xen_xc); +trace_xen_map_ioreq_server_shared_page (ioreq_pfn);hw/xen/xen-hvm-common.c static int xen_map_ioreq_server(XenIOState *state) · line 715
Quoted 10 lines
hw/xen/xen-hvm-common.c +8
-1+ + state->shared_page =xenforeignmemory_map (xen_fmem, xen_domid, +PROT_READ |PROT_WRITE , +1 , &ioreq_pfn,NULL ); +if (state->shared_page ==NULL ) { +error_report ("map shared IO page returned error %d handle=%p" , + errno, xen_xc); + } } - }If I am reading the code right the calls to
xen_get_ioreq_server_infoandxenforeignmemory_mapwere not done to setup bufioreq. They were done for legacy compatibility to support systems wherexenforeignmemory_map_resourcereturns EOPNOTSUPP.
Quoted 2 lines
I think we should either get rid of this legacy path completely, or keep it for both bufioreq and non-bufioreq.
Yes, I'll fix the conditions and keep the legacy code for now!
Cheers,
Edgar
Quoted 130 lines
Quoted 130 lines
hw/xen/xen-hvm-common.c +24
-18-if (state->buffered_io_page ==NULL ) { -trace_xen_map_ioreq_server_buffered_io_page (bufioreq_pfn); - - state->buffered_io_page =xenforeignmemory_map (xen_fmem, xen_domid, -PROT_READ |PROT_WRITE , -1 , &bufioreq_pfn, -NULL );if (state->buffered_io_page ==NULL ) { -error_report ("map buffered IO page returned error %d" , errno); -return -1 ; +trace_xen_map_ioreq_server_buffered_io_page (bufioreq_pfn); + + state->buffered_io_page =xenforeignmemory_map (xen_fmem, xen_domid, +PROT_READ |PROT_WRITE , +1 , &bufioreq_pfn, +NULL ); +if (state->buffered_io_page ==NULL ) { +error_report ("map buffered IO page returned error %d" , errno); +return -1 ; + } } } -if (state->shared_page ==NULL || state->buffered_io_page ==NULL ) { + +if (state->shared_page ==NULL || + (state->has_bufioreq && state->buffered_io_page ==NULL )) {return -1 ; }@@ -830,14 +845,15 @@ static void xen_do_ioreq_register(XenIOState *state, state->ioreq_local_port[i] = rc; } - rc =qemu_xen_evtchn_bind_interdomain (state->xce_handle, xen_domid, - state->bufioreq_remote_port); -if (rc ==-1 ) { -error_report ("buffered evtchn bind error %d" , errno); - goto err; +if (state->has_bufioreq) { + rc =qemu_xen_evtchn_bind_interdomain (state->xce_handle, xen_domid, + state->bufioreq_remote_port); +if (rc ==-1 ) { +error_report ("buffered evtchn bind error %d" , errno); + goto err; + } + state->bufioreq_local_port = rc; } - state->bufioreq_local_port = rc; -/* Init RAM management */ #ifdef XEN_COMPAT_PHYSMAP xen_map_cache_init (xen_phys_offset_to_gaddr, state);@@ -865,6 +881,7 @@ err: }void xen_register_ioreq (XenIOState *state,unsigned int max_cpus, +int handle_bufioreq,const MemoryListener *xen_memory_listener) {int rc;@@ -883,7 +900,8 @@ void xen_register_ioreq(XenIOState *state, unsigned int max_cpus, goto err; } - rc =xen_create_ioreq_server (xen_domid, &state->ioservid); + state->has_bufioreq = handle_bufioreq !=HVM_IOREQSRV_BUFIOREQ_OFF ; + rc =xen_create_ioreq_server (xen_domid, handle_bufioreq, &state->ioservid);if (!rc) {xen_do_ioreq_register (state, max_cpus, xen_memory_listener); }else {hw/xen/xen-pvh-common.c +3
-1@@ -194,7 +194,9 @@ static void xen_pvh_init(MachineState *ms) }xen_pvh_init_ram (s, sysmem); -xen_register_ioreq (&s->ioreq, ms->smp.max_cpus, &xen_memory_listener); +xen_register_ioreq (&s->ioreq, ms->smp.max_cpus, +HVM_IOREQSRV_BUFIOREQ_ATOMIC , + &xen_memory_listener);if (s->cfg.virtio_mmio_num) {xen_create_virtio_mmio_devices (s);include/hw/xen/xen-hvm-common.h +3
-0@@ -81,6 +81,8 @@ typedef struct XenIOState { QLIST_HEAD(, XenPciDevice) dev_list;DeviceListener device_listener; +bool has_bufioreq; +Notifier exit; } XenIOState;@@ -95,6 +97,7 @@ void xen_device_unrealize(DeviceListener *listener, DeviceState *dev);void xen_hvm_change_state_handler (void *opaque,bool running,RunState rstate);void xen_register_ioreq (XenIOState *state,unsigned int max_cpus, +int handle_bufioreq,const MemoryListener *xen_memory_listener);void cpu_ioreq_pio (ioreq_t *req);include/hw/xen/xen_native.h +2
-1@@ -464,10 +464,11 @@ static inline void xen_unmap_pcidev(domid_t dom, }static inline int xen_create_ioreq_server (domid_t dom, +int handle_bufioreq,ioservid_t *ioservid) {int rc =xendevicemodel_create_ioreq_server (xen_dmod, dom, -HVM_IOREQSRV_BUFIOREQ_ATOMIC , + handle_bufioreq, ioservid);if (rc ==0 ) {Signature · 1 line
2.43.0
PATCH 2/4 hw/xen: xenpvh: Disable buffered IOREQs for ARM
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Add a way to enable/disable buffered IOREQs for PVH machines and disable them for ARM. ARM does not support buffered IOREQ's nor the legacy way to map IOREQ info pages.
See the following for more details:
https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=2fbd7e609e1803ac5e5c26e22aa8e4b5a6cddbb1
https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/arch/arm/ioreq.c;h=2e829d2e7f3760401b96fa7c930e2015fb1cf463;hb=HEAD#l138
--- hw/arm/xen-pvh.c | 3 +++ hw/i386/xen/xen-pvh.c | 3 +++ hw/xen/xen-pvh-common.c | 2 +- include/hw/xen/xen-pvh-common.h | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-)
hw/arm/xen-pvh.c +3 -0
@@ -66,6 +66,9 @@ static void xen_arm_machine_class_init(ObjectClass *oc, void *data)*/ mc->max_cpus =GUEST_MAX_VCPUS ; +/* Xen/ARM does not use buffered IOREQs. */ + xpc->handle_bufioreq =HVM_IOREQSRV_BUFIOREQ_OFF ; +/* List of supported features known to work on PVH ARM. */ xpc->has_tpm = true; xpc->has_virtio_mmio = true;
hw/i386/xen/xen-pvh.c +3 -0
@@ -89,6 +89,9 @@ static void xen_pvh_machine_class_init(ObjectClass *oc, void *data)/* We have an implementation specific init to create CPU objects. */ xpc->init = xen_pvh_init; +/* Enable buffered IOREQs. */ + xpc->handle_bufioreq =HVM_IOREQSRV_BUFIOREQ_ATOMIC ; +/* * PCI INTX routing. *
hw/xen/xen-pvh-common.c +1 -1
@@ -195,7 +195,7 @@ static void xen_pvh_init(MachineState *ms)xen_pvh_init_ram (s, sysmem);xen_register_ioreq (&s->ioreq, ms->smp.max_cpus, -HVM_IOREQSRV_BUFIOREQ_ATOMIC , + xpc->handle_bufioreq, &xen_memory_listener);if (s->cfg.virtio_mmio_num) {
include/hw/xen/xen-pvh-common.h +3 -0
@@ -43,6 +43,9 @@ struct XenPVHMachineClass {*/ int (*set_pci_link_route)(uint8_t line,uint8_t irq); +/* Allow implementations to optionally enable buffered ioreqs. */ +int handle_bufioreq; +/* * Each implementation can optionally enable features that it * supports and are known to work.
Signature · 1 line
2.43.0
Re: [PATCH v1 2/4] hw/xen: xenpvh: Disable buffered IOREQs for ARM
Quoted 64 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Add a way to enable/disable buffered IOREQs for PVH machines and disable them for ARM. ARM does not support buffered IOREQ's nor the legacy way to map IOREQ info pages.
See the following for more details:
https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=2fbd7e609e1803ac5e5c26e22aa8e4b5a6cddbb1
https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/arch/arm/ioreq.c;h=2e829d2e7f3760401b96fa7c930e2015fb1cf463;hb=HEAD#l138Signed-off-by Edgar E. Iglesias <[email protected]>--- hw/arm/xen-pvh.c | 3 +++ hw/i386/xen/xen-pvh.c | 3 +++ hw/xen/xen-pvh-common.c | 2 +- include/hw/xen/xen-pvh-common.h | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-)hw/arm/xen-pvh.c +3
-0@@ -66,6 +66,9 @@ static void xen_arm_machine_class_init(ObjectClass *oc, void *data)*/ mc->max_cpus =GUEST_MAX_VCPUS ; +/* Xen/ARM does not use buffered IOREQs. */ + xpc->handle_bufioreq =HVM_IOREQSRV_BUFIOREQ_OFF ; +/* List of supported features known to work on PVH ARM. */ xpc->has_tpm = true; xpc->has_virtio_mmio = true;hw/i386/xen/xen-pvh.c +3
-0@@ -89,6 +89,9 @@ static void xen_pvh_machine_class_init(ObjectClass *oc, void *data)/* We have an implementation specific init to create CPU objects. */ xpc->init = xen_pvh_init; +/* Enable buffered IOREQs. */ + xpc->handle_bufioreq =HVM_IOREQSRV_BUFIOREQ_ATOMIC ; +/* * PCI INTX routing. * hw/xen/xen-pvh-common.c +1
-1@@ -195,7 +195,7 @@ static void xen_pvh_init(MachineState *ms)xen_pvh_init_ram (s, sysmem);xen_register_ioreq (&s->ioreq, ms->smp.max_cpus, -HVM_IOREQSRV_BUFIOREQ_ATOMIC , + xpc->handle_bufioreq, &xen_memory_listener);if (s->cfg.virtio_mmio_num) {include/hw/xen/xen-pvh-common.h +0
-0
include/hw/xen/xen-pvh-common.h struct XenPVHMachineClass { · line 47
Quoted 5 lines
include/hw/xen/xen-pvh-common.h +2
-0@@ -43,6 +43,9 @@ struct XenPVHMachineClass {*/ int (*set_pci_link_route)(uint8_t line,uint8_t irq); +/* Allow implementations to optionally enable buffered ioreqs. */ +int handle_bufioreq;
Looking at the corresponding Xen interface this field is uint8_t. I think it would be better to use the same type here and also as a parameter to xen_register_ioreq in QEMU
Quoted 6 lines
include/hw/xen/xen-pvh-common.h +0
-0/* * Each implementation can optionally enable features that it * supports and are known to work. Signature · 1 line
2.43.0
Re: [PATCH v1 2/4] hw/xen: xenpvh: Disable buffered IOREQs for ARM
Quoted 68 lines · Stefano Stabellini
Quoted 67 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Add a way to enable/disable buffered IOREQs for PVH machines and disable them for ARM. ARM does not support buffered IOREQ's nor the legacy way to map IOREQ info pages.
See the following for more details:
https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=2fbd7e609e1803ac5e5c26e22aa8e4b5a6cddbb1
https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/arch/arm/ioreq.c;h=2e829d2e7f3760401b96fa7c930e2015fb1cf463;hb=HEAD#l138Signed-off-by Edgar E. Iglesias <[email protected]>--- hw/arm/xen-pvh.c | 3 +++ hw/i386/xen/xen-pvh.c | 3 +++ hw/xen/xen-pvh-common.c | 2 +- include/hw/xen/xen-pvh-common.h | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-)hw/arm/xen-pvh.c +3
-0@@ -66,6 +66,9 @@ static void xen_arm_machine_class_init(ObjectClass *oc, void *data)*/ mc->max_cpus =GUEST_MAX_VCPUS ; +/* Xen/ARM does not use buffered IOREQs. */ + xpc->handle_bufioreq =HVM_IOREQSRV_BUFIOREQ_OFF ; +/* List of supported features known to work on PVH ARM. */ xpc->has_tpm = true; xpc->has_virtio_mmio = true;hw/i386/xen/xen-pvh.c +3
-0@@ -89,6 +89,9 @@ static void xen_pvh_machine_class_init(ObjectClass *oc, void *data)/* We have an implementation specific init to create CPU objects. */ xpc->init = xen_pvh_init; +/* Enable buffered IOREQs. */ + xpc->handle_bufioreq =HVM_IOREQSRV_BUFIOREQ_ATOMIC ; +/* * PCI INTX routing. * hw/xen/xen-pvh-common.c +1
-1@@ -195,7 +195,7 @@ static void xen_pvh_init(MachineState *ms)xen_pvh_init_ram (s, sysmem);xen_register_ioreq (&s->ioreq, ms->smp.max_cpus, -HVM_IOREQSRV_BUFIOREQ_ATOMIC , + xpc->handle_bufioreq, &xen_memory_listener);if (s->cfg.virtio_mmio_num) {include/hw/xen/xen-pvh-common.h +0
-0@@ -43,6 +43,9 @@ struct XenPVHMachineClass {*/ int (*set_pci_link_route)(uint8_t line,uint8_t irq);
Quoted 7 lines
include/hw/xen/xen-pvh-common.h struct XenPVHMachineClass { · line 47
Quoted 2 lines
include/hw/xen/xen-pvh-common.h +2
-0+/* Allow implementations to optionally enable buffered ioreqs. */ +int handle_bufioreq;Looking at the corresponding Xen interface this field is
uint8_t. I think it would be better to use the same type here and also as a parameter toxen_register_ioreqin QEMU
Thanks Stefano,
I chose int because the interface to the Xen libs uses int:
https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/include/xendevicemodel.h;h=797e0c6b2961926a68cd96b8ff5e1627067903ac;hb=HEAD#l40
But yes, the hypercall interface uses uint8_t, I'm happy to change it to uint8_t in the next version!
Cheers,
Edgar
PATCH 3/4 hw/xen: xenpvh: Add pci-intx-irq-base property
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
--- hw/xen/xen-pvh-common.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
hw/xen/xen-pvh-common.c +36 -0
@@ -218,6 +218,11 @@ static void xen_pvh_init(MachineState *ms)error_report ("pci-ecam-size only supports values 0 or 0x10000000" );exit (EXIT_FAILURE ); } +if (!s->cfg.pci_intx_irq_base) { +error_report ("PCI enabled but pci-intx-irq-base not set" ); +exit (EXIT_FAILURE ); + } +xenpvh_gpex_init (s, xpc, sysmem); }
@@ -273,6 +278,30 @@ XEN_PVH_PROP_MEMMAP(pci_ecam)XEN_PVH_PROP_MEMMAP (pci_mmio)XEN_PVH_PROP_MEMMAP (pci_mmio_high) +static void xen_pvh_set_pci_intx_irq_base (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ + XenPVHMachineState *xp = XEN_PVH_MACHINE(obj); +uint32_t value; + + if (!visit_type_uint32(v, name, &value, errp)) { +return ; + } + + xp->cfg.pci_intx_irq_base = value; +} + +static void xen_pvh_get_pci_intx_irq_base (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +XenPVHMachineState *xp =XEN_PVH_MACHINE (obj); +uint32_t value = xp->cfg.pci_intx_irq_base; + +visit_type_uint32 (v, name, &value, errp); +} +void xen_pvh_class_setup_common_props (XenPVHMachineClass *xpc) {ObjectClass *oc =OBJECT_CLASS (xpc);
@@ -318,6 +347,13 @@ do { \OC_MEMMAP_PROP (oc,"pci-ecam" , pci_ecam);OC_MEMMAP_PROP (oc,"pci-mmio" , pci_mmio);OC_MEMMAP_PROP (oc,"pci-mmio-high" , pci_mmio_high); + +object_class_property_add (oc,"pci-intx-irq-base" ,"uint32_t" , + xen_pvh_get_pci_intx_irq_base, + xen_pvh_set_pci_intx_irq_base, +NULL ,NULL ); +object_class_property_set_description (oc,"pci-intx-irq-base" , +"Set PCI INTX interrupt base line." ); }#ifdef CONFIG_TPM
Signature · 1 line
2.43.0
Re: [PATCH v1 3/4] hw/xen: xenpvh: Add pci-intx-irq-base property
Quoted 3 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>
Quoted 68 lines
--- hw/xen/xen-pvh-common.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)hw/xen/xen-pvh-common.c +36
-0@@ -218,6 +218,11 @@ static void xen_pvh_init(MachineState *ms)error_report ("pci-ecam-size only supports values 0 or 0x10000000" );exit (EXIT_FAILURE ); } +if (!s->cfg.pci_intx_irq_base) { +error_report ("PCI enabled but pci-intx-irq-base not set" ); +exit (EXIT_FAILURE ); + } +xenpvh_gpex_init (s, xpc, sysmem); }@@ -273,6 +278,30 @@ XEN_PVH_PROP_MEMMAP(pci_ecam)XEN_PVH_PROP_MEMMAP (pci_mmio)XEN_PVH_PROP_MEMMAP (pci_mmio_high) +static void xen_pvh_set_pci_intx_irq_base (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ + XenPVHMachineState *xp = XEN_PVH_MACHINE(obj); +uint32_t value; + + if (!visit_type_uint32(v, name, &value, errp)) { +return ; + } + + xp->cfg.pci_intx_irq_base = value; +} + +static void xen_pvh_get_pci_intx_irq_base (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +XenPVHMachineState *xp =XEN_PVH_MACHINE (obj); +uint32_t value = xp->cfg.pci_intx_irq_base; + +visit_type_uint32 (v, name, &value, errp); +} +void xen_pvh_class_setup_common_props (XenPVHMachineClass *xpc) {ObjectClass *oc =OBJECT_CLASS (xpc);@@ -318,6 +347,13 @@ do { \OC_MEMMAP_PROP (oc,"pci-ecam" , pci_ecam);OC_MEMMAP_PROP (oc,"pci-mmio" , pci_mmio);OC_MEMMAP_PROP (oc,"pci-mmio-high" , pci_mmio_high); + +object_class_property_add (oc,"pci-intx-irq-base" ,"uint32_t" , + xen_pvh_get_pci_intx_irq_base, + xen_pvh_set_pci_intx_irq_base, +NULL ,NULL ); +object_class_property_set_description (oc,"pci-intx-irq-base" , +"Set PCI INTX interrupt base line." ); }#ifdef CONFIG_TPM Signature · 1 line
2.43.0
PATCH 4/4 hw/arm: xenpvh: Enable PCI for ARM PVH
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Enable PCI support for the ARM Xen PVH machine.
--- hw/arm/xen-pvh.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
hw/arm/xen-pvh.c +14 -0
@@ -39,6 +39,16 @@ static void xen_arm_instance_init(Object *obj) VIRTIO_MMIO_DEV_SIZE }; } +static void xen_pvh_set_pci_intx_irq (void *opaque,int intx_irq,int level) +{ +XenPVHMachineState *s =XEN_PVH_MACHINE (opaque); +int irq = s->cfg.pci_intx_irq_base + intx_irq; + +if (xendevicemodel_set_irq_level (xen_dmod, xen_domid, irq, level)) { +error_report ("xendevicemodel_set_pci_intx_level failed" ); + } +} +static void xen_arm_machine_class_init (ObjectClass *oc,void *data) {XenPVHMachineClass *xpc =XEN_PVH_MACHINE_CLASS (oc);
@@ -69,7 +79,11 @@ static void xen_arm_machine_class_init(ObjectClass *oc, void *data)/* Xen/ARM does not use buffered IOREQs. */ xpc->handle_bufioreq =HVM_IOREQSRV_BUFIOREQ_OFF ; +/* PCI INTX delivery. */ + xpc->set_pci_intx_irq = xen_pvh_set_pci_intx_irq; +/* List of supported features known to work on PVH ARM. */ + xpc->has_pci = true; xpc->has_tpm = true; xpc->has_virtio_mmio = true;
Signature · 1 line
2.43.0
Quoted 5 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Enable PCI support for the ARM Xen PVH machine.
Signed-off-by Edgar E. Iglesias <[email protected]>
Quoted 40 lines
--- hw/arm/xen-pvh.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)hw/arm/xen-pvh.c +14
-0@@ -39,6 +39,16 @@ static void xen_arm_instance_init(Object *obj) VIRTIO_MMIO_DEV_SIZE }; } +static void xen_pvh_set_pci_intx_irq (void *opaque,int intx_irq,int level) +{ +XenPVHMachineState *s =XEN_PVH_MACHINE (opaque); +int irq = s->cfg.pci_intx_irq_base + intx_irq; + +if (xendevicemodel_set_irq_level (xen_dmod, xen_domid, irq, level)) { +error_report ("xendevicemodel_set_pci_intx_level failed" ); + } +} +static void xen_arm_machine_class_init (ObjectClass *oc,void *data) {XenPVHMachineClass *xpc =XEN_PVH_MACHINE_CLASS (oc);@@ -69,7 +79,11 @@ static void xen_arm_machine_class_init(ObjectClass *oc, void *data)/* Xen/ARM does not use buffered IOREQs. */ xpc->handle_bufioreq =HVM_IOREQSRV_BUFIOREQ_OFF ; +/* PCI INTX delivery. */ + xpc->set_pci_intx_irq = xen_pvh_set_pci_intx_irq; +/* List of supported features known to work on PVH ARM. */ + xpc->has_pci = true; xpc->has_tpm = true; xpc->has_virtio_mmio = true;Signature · 1 line
2.43.0