Message ID | 20170814142850.39133-5-roger.pau@citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
>>> On 14.08.17 at 16:28, <roger.pau@citrix.com> wrote: > --- a/xen/arch/x86/physdev.c > +++ b/xen/arch/x86/physdev.c > @@ -559,6 +559,15 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) > > ret = pci_mmcfg_reserved(info.address, info.segment, > info.start_bus, info.end_bus, info.flags); > + if ( ret || !is_hvm_domain(currd) ) > + break; Don't you also want to check has_vpci() here? Jan
On Tue, Sep 05, 2017 at 08:57:54AM -0600, Jan Beulich wrote: > >>> On 14.08.17 at 16:28, <roger.pau@citrix.com> wrote: > > --- a/xen/arch/x86/physdev.c > > +++ b/xen/arch/x86/physdev.c > > @@ -559,6 +559,15 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) > > > > ret = pci_mmcfg_reserved(info.address, info.segment, > > info.start_bus, info.end_bus, info.flags); > > + if ( ret || !is_hvm_domain(currd) ) > > + break; > > Don't you also want to check has_vpci() here? I don't think the also is needed here, just checking for has_vpci should be fine (PV guests will not have the vpci flag set in any case). Thanks, Roger.
>>> On 13.09.17 at 17:55, <roger.pau@citrix.com> wrote: > On Tue, Sep 05, 2017 at 08:57:54AM -0600, Jan Beulich wrote: >> >>> On 14.08.17 at 16:28, <roger.pau@citrix.com> wrote: >> > --- a/xen/arch/x86/physdev.c >> > +++ b/xen/arch/x86/physdev.c >> > @@ -559,6 +559,15 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) >> > >> > ret = pci_mmcfg_reserved(info.address, info.segment, >> > info.start_bus, info.end_bus, info.flags); >> > + if ( ret || !is_hvm_domain(currd) ) >> > + break; >> >> Don't you also want to check has_vpci() here? > > I don't think the also is needed here, just checking for has_vpci > should be fine (PV guests will not have the vpci flag set in any > case). Ah, right, emulation_flags is not in the HVM/PV union, but available for all guests. Jan
diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index e7238ce293..369abfd262 100644 --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen/arch/x86/hvm/hypercall.c @@ -89,6 +89,10 @@ static long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) if ( !has_pirq(curr->domain) ) return -ENOSYS; break; + case PHYSDEVOP_pci_mmcfg_reserved: + if ( !has_vpci(curr->domain) ) + return -ENOSYS; + break; } if ( !curr->hcall_compat ) diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c index 2845dc5b48..93c3b21a47 100644 --- a/xen/arch/x86/hvm/io.c +++ b/xen/arch/x86/hvm/io.c @@ -524,10 +524,9 @@ static const struct hvm_mmio_ops vpci_mmcfg_ops = { .write = vpci_mmcfg_write, }; -int __hwdom_init register_vpci_mmcfg_handler(struct domain *d, paddr_t addr, - unsigned int start_bus, - unsigned int end_bus, - unsigned int seg) +int register_vpci_mmcfg_handler(struct domain *d, paddr_t addr, + unsigned int start_bus, unsigned int end_bus, + unsigned int seg) { struct hvm_mmcfg *mmcfg; diff --git a/xen/arch/x86/physdev.c b/xen/arch/x86/physdev.c index 0eb409758f..10e0a1ad79 100644 --- a/xen/arch/x86/physdev.c +++ b/xen/arch/x86/physdev.c @@ -559,6 +559,15 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) ret = pci_mmcfg_reserved(info.address, info.segment, info.start_bus, info.end_bus, info.flags); + if ( ret || !is_hvm_domain(currd) ) + break; + + /* + * For HVM (PVH) domains try to add the newly found MMCFG to the + * domain. + */ + ret = register_vpci_mmcfg_handler(currd, info.address, info.start_bus, + info.end_bus, info.segment); break; }
So that MMCFG regions not present in the MCFG ACPI table can be added at run time by the hardware domain. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> --- Cc: Jan Beulich <jbeulich@suse.com> Cc: Andrew Cooper <andrew.cooper3@citrix.com> --- Changes since v4: - Change the hardware_domain check in hvm_physdev_op to a vpci check. - Only register the MMCFG area, but don't scan it. Changes since v3: - New in this version. --- xen/arch/x86/hvm/hypercall.c | 4 ++++ xen/arch/x86/hvm/io.c | 7 +++---- xen/arch/x86/physdev.c | 9 +++++++++ 3 files changed, 16 insertions(+), 4 deletions(-)