From: Matthew Fioravante Subject: [PATCH xm/xl enhancements for vptm 6/6] add iomem feature to xm Date: Tue, 18 Sep 2012 14:22:31 -0400 Message-ID: <5058BBE7.8070607@jhuapl.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2883952936382868964==" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell , "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a cryptographically signed message in MIME format. --===============2883952936382868964== Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha1; boundary="------------ms040300050604030608050805" This is a cryptographically signed message in MIME format. --------------ms040300050604030608050805 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable This adds the iomem feature from patch 3 to xm as well. Signed off by Matthew Fioravante matthew.fioravante@jhuapl.edu diff --git a/tools/python/xen/xend/XendDevices.py b/tools/python/xen/xend/XendDevices.py --- a/tools/python/xen/xend/XendDevices.py +++ b/tools/python/xen/xend/XendDevices.py @@ -19,7 +19,7 @@ # A collection of DevControllers # =20 -from xen.xend.server import blkif, netif, tpmif, pciif, iopif, irqif, vfbif, vscsiif, netif2, vusbif +from xen.xend.server import blkif, netif, tpmif, pciif, iopif, irqif, iomemif, vfbif, vscsiif, netif2, vusbif from xen.xend.server.BlktapController import BlktapController, Blktap2Controller from xen.xend.server.ConsoleController import ConsoleController =20 @@ -42,6 +42,7 @@ class XendDevices: 'pci': pciif.PciController, 'ioports': iopif.IOPortsController, 'irq': irqif.IRQController, + 'iomem': iomemif.IOMEMController, 'tap': BlktapController, 'tap2': Blktap2Controller, 'vfb': vfbif.VfbifController, diff --git a/tools/python/xen/xend/server/iomemif.py b/tools/python/xen/xend/server/iomemif.py --- /dev/null +++ b/tools/python/xen/xend/server/iomemif.py @@ -0,0 +1,103 @@ +#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D +# This library is free software; you can redistribute it and/or +# modify it under the terms of version 2.1 of the GNU Lesser General Pub= lic +# License as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 = USA +#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D +# Copyright (C) 2004, 2005 Mike Wray +# Copyright (C) 2005 XenSource Ltd +# Copyright (C) 2005 Jody Belka +#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D + + +import types + +import xen.lowlevel.xc + +from xen.xend.XendError import VmError + +from xen.xend.server.DevController import DevController + + +xc =3D xen.lowlevel.xc.xc() + + +def parse_iomemaddr(val): + """Parse an iomem address + """ + if isinstance(val, types.StringType): + radix =3D 10 + if val.startswith('0x') or val.startswith('0X'): + radix =3D 16 + v =3D int(val, radix) + else: + v =3D val + return v + + +class IOMEMController(DevController): + + valid_cfg =3D ['mfn', 'nmfns', 'enable'] + + def __init__(self, vm): + DevController.__init__(self, vm) + + def getDeviceConfiguration(self, devid, transaction =3D None): + result =3D DevController.getDeviceConfiguration(self, devid, transaction) + if transaction is None: + devinfo =3D self.readBackend(devid, *self.valid_cfg) + else: + devinfo =3D self.readBackendTxn(transaction, devid, *self.valid_cfg) + config =3D dict(zip(self.valid_cfg, devinfo)) + config =3D dict([(key, val) for key, val in config.items() + if val !=3D None]) + return config + + def getDeviceDetails(self, config): + """@see DevController.getDeviceDetails""" + + def get_param(field): + try: + val =3D config.get(field) + + if not val: + raise VmError('iomem: Missing %s config setting' % field) + + return parse_iomemaddr(val) + except: + raise VmError('iomem: Invalid config setting %s: %s' % + (field, val)) + =20 + mfn =3D get_param('mfn') + nmfns =3D get_param('nmfns') + enable =3D get_param('enable') + + if nmfns <=3D 0: + raise VmError('iomem: invalid number of mfns: %s' % str(nmfns)) + #FIXME: Bounds check for max iomem range?? + + rc =3D xc.domain_iomem_permission(domid =3D self.getDomid= (), + first_pfn =3D mfn, + nr_pfns =3D nmfns, + allow_access =3D enable) + + if rc < 0: + #todo non-fatal + raise VmError( + 'iomem: Failed to configure memory mapped i/o range: %s,%s' % + (str(mfn), str(nmfns))) + + back =3D dict([(k, config[k]) for k in self.valid_cfg if k in config]) + return (self.allocateDeviceID(), back, {}) + + def waitForDevice(self, devid): + # don't wait for hotplug + return diff --git a/tools/python/xen/xm/create.py b/tools/python/xen/xm/create.p= y --- a/tools/python/xen/xm/create.py +++ b/tools/python/xen/xm/create.py @@ -378,6 +378,14 @@ gopts.var('irq', val=3D'IRQ', For example 'irq=3D7'. This option may be repeated to add more than one IRQ.""") =20 +gopts.var('iomem', val=3D'MFN,NMFNS,ENABLE', + fn=3Dappend_value, default=3D[], + use=3D"""Allow access to memory mapped IO pages, using the given params. + For example 'iomem=3De4df0,5,1', to allow access to 5 pages startin= g + at page number 0xe4df0. The first arg is in hex, the second in decimal. + The last argument is a 1 or 0, to either enable or disable the memory region. + This option may be repeated to add more than one memory range""") + gopts.var('vfb', val=3D"vnc=3D1,sdl=3D1,vncunused=3D1,vncdisplay=3DN,vnclisten=3DADDR,disp= lay=3DDISPLAY,xauthority=3DXAUTHORITY,vncpasswd=3DPASSWORD,opengl=3D1,key= map=3DFILE,serial=3DFILE,monitor=3DFILE", fn=3Dappend_value, default=3D[], use=3D"""Make the domain a framebuffer backend. @@ -947,6 +955,13 @@ def configure_irq(config_devs, vals): config_irq =3D ['irq', ['irq', irq]] config_devs.append(['device', config_irq]) =20 +def configure_iomem(config_devs, vals): + """Create the config for iomem. + """ + for (mfn, nmfns, enable) in vals.iomem: + config_iomem =3D ['iomem', ['mfn', mfn], ['nmfns', nmfns], ['enable', enable]] + config_devs.append(['device', config_iomem]) + def configure_vfbs(config_devs, vals): for f in vals.vfb: d =3D comma_sep_kv_to_dict(f) @@ -1191,6 +1206,7 @@ def make_config(vals): configure_vscsis(config_devs, vals) configure_vusbs(config_devs, vals) configure_ioports(config_devs, vals) + configure_iomem(config_devs, vals) configure_irq(config_devs, vals) configure_vifs(config_devs, vals) configure_vtpm(config_devs, vals) @@ -1307,6 +1323,18 @@ def preprocess_irq(vals): irq.append(d) vals.irq =3D irq =20 +def preprocess_iomem(vals): + if not vals.iomem: return + iomem =3D [] + for v in vals.iomem: + d =3D v.split(',') + if len(d) < 1 or len(d) > 3: + err('Invalid iomem range specifier: ' + v) + #Add hex specifier to the page number + d[0] =3D '0x' + d[0] + iomem.append(d) + vals.iomem =3D iomem + def preprocess_vtpm(vals): if not vals.vtpm: return vtpms =3D [] @@ -1398,6 +1426,7 @@ def preprocess(vals): preprocess_pci(vals) preprocess_vscsi(vals) preprocess_ioports(vals) + preprocess_iomem(vals) preprocess_ip(vals) preprocess_irq(vals) preprocess_nfs(vals) --------------ms040300050604030608050805 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIDyjCC A8YwggMvoAMCAQICBD/xyf0wDQYJKoZIhvcNAQEFBQAwLzELMAkGA1UEBhMCVVMxDzANBgNV BAoTBkpIVUFQTDEPMA0GA1UECxMGQklTRENBMB4XDTEwMDYxMTE4MjIwNloXDTEzMDYxMTE4 NTIwNlowZjELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkpIVUFQTDEPMA0GA1UECxMGUGVvcGxl MTUwFgYDVQQLEw9WUE5Hcm91cC1CSVNEQ0EwGwYDVQQDExRNYXR0aGV3IEUgRmlvcmF2YW50 ZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAnpbwVSP6o1Nb5lcW7dd3yTo9iBJdi7qz 4nANOMFPK7JOy5npKN1iiousl28U/scUJES55gPwAWYJK3uVyQAsA4adgDKi5DoD1UHDQEwp bY7iHLJeq0NPr4BqYNqnCFPbE6HC8zSJrr4qKn+gVUQT39SIFqdiIPJwZL8FYTRQ/zsCAwEA AaOCAbYwggGyMAsGA1UdDwQEAwIHgDArBgNVHRAEJDAigA8yMDEwMDYxMTE4MjIwNlqBDzIw MTIwNzE3MjI1MjA2WjAbBg0rBgEEAbMlCwMBAQEBBAoWCGZpb3JhbWUxMBsGDSsGAQQBsyUL AwEBAQIEChIIMDAxMDQyNjEwWAYJYIZIAYb6ax4BBEsMSVRoZSBwcml2YXRlIGtleSBjb3Jy ZXNwb25kaW5nIHRvIHRoaXMgY2VydGlmaWNhdGUgbWF5IGhhdmUgYmVlbiBleHBvcnRlZC4w KAYDVR0RBCEwH4EdTWF0dGhldy5GaW9yYXZhbnRlQGpod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050805-- --===============2883952936382868964== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============2883952936382868964==--