From: Matthew Fioravante Subject: Re: [PATCH xm/xl enhancements for vptm 3/6] add iomem option to xl Date: Wed, 19 Sep 2012 10:04:48 -0400 Message-ID: <5059D100.6030507@jhuapl.edu> References: <5058BA2C.7090804@jhuapl.edu> <1348057981.14977.107.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4804813936959707545==" Return-path: In-Reply-To: <1348057981.14977.107.camel@zakaz.uk.xensource.com> 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 Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a cryptographically signed message in MIME format. --===============4804813936959707545== Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha1; boundary="------------ms090509070905060800030708" This is a cryptographically signed message in MIME format. --------------ms090509070905060800030708 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sorry I forgot about the allow boolean, and yes its compatible with xm in terms of how ioport and irq are implemented. On 09/19/2012 08:33 AM, Ian Campbell wrote: > On Tue, 2012-09-18 at 19:15 +0100, Matthew Fioravante wrote: >> This patch adds a new option for xen config files for directly mapping= >> hardware io memory into a vm. >> >> iomem=3D['pagenum,size',..] >> >> Where pagenum is the page number and size is the number of page. >> example (for a tpm: >> iomem=3D['fed40,5'] > Please can you patch the docs too. > > Your implementation seems to also support a third field "allow"? > > Did xm/xend have similar functionality? Is this compatible with the > syntax? > > Also this patch is whitespace mangled again I'm afraid (I expect they > all are so I'll stop mentioning it) > >> Signed off by Matthew Fioravante matthew.fioravante@jhuapl.edu >> >> diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h >> --- a/tools/libxl/libxl.h >> +++ b/tools/libxl/libxl.h >> @@ -477,7 +477,7 @@ typedef struct { >> libxl_domain_create_info c_info; >> libxl_domain_build_info b_info; >> =20 >> - int num_disks, num_vifs, num_pcidevs, num_vfbs, num_vkbs, num_vtp= ms; >> + int num_disks, num_vifs, num_pcidevs, num_vfbs, num_vkbs, >> num_vtpms, num_iorngs; >> =20 >> libxl_device_disk *disks; >> libxl_device_nic *vifs; >> @@ -485,6 +485,7 @@ typedef struct { >> libxl_device_vfb *vfbs; >> libxl_device_vkb *vkbs; >> libxl_device_vtpm *vtpms; >> + libxl_iomem_range *iorngs; >> =20 >> libxl_action_on_shutdown on_poweroff; >> libxl_action_on_shutdown on_reboot; >> diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c >> --- a/tools/libxl/libxl_create.c >> +++ b/tools/libxl/libxl_create.c >> @@ -58,6 +58,10 @@ void libxl_domain_config_dispose(libxl_domain_confi= g >> *d_config) >> libxl_device_vtpm_dispose(&d_config->vtpms[i]); >> free(d_config->vtpms); >> =20 >> + for (i=3D0; inum_iorngs; i++) >> + libxl_iomem_range_dispose(&d_config->iorngs[i]); >> + free(d_config->iorngs); >> + >> libxl_domain_create_info_dispose(&d_config->c_info); >> libxl_domain_build_info_dispose(&d_config->b_info); >> } >> @@ -718,6 +722,15 @@ static void domcreate_bootloader_done(libxl__egc = *egc, >> =20 >> store_libxl_entry(gc, domid, &d_config->b_info); >> =20 >> + for (i =3D 0; i < d_config->num_iorngs; i++) { >> + ret =3D xc_domain_iomem_permission(ctx->xch, domid, >> d_config->iorngs[i].start, d_config->iorngs[i].length, >> d_config->iorngs[i].allow); >> + if (ret) { >> + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, >> + "cannot add iomem range %d to domain: %d", i, = ret); >> + ret =3D ERROR_FAIL; >> + goto error_out; >> + } >> + } >> for (i =3D 0; i < d_config->num_disks; i++) { >> ret =3D libxl_device_disk_add(ctx, domid, &d_config->disks[i]= ); >> if (ret) { >> diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl= >> --- a/tools/libxl/libxl_types.idl >> +++ b/tools/libxl/libxl_types.idl >> @@ -317,6 +317,12 @@ libxl_domain_build_info =3D Struct("domain_build_= info",[ >> ], dir=3DDIR_IN >> ) >> =20 >> +libxl_iomem_range =3D Struct("iomem_range", [ >> + ("start", uint64), >> + ("length", uint64), >> + ("allow", bool), >> +]); >> + >> libxl_device_vfb =3D Struct("device_vfb", [ >> ("backend_domid", libxl_domid), >> ("devid", libxl_devid), >> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c >> --- a/tools/libxl/xl_cmdimpl.c >> +++ b/tools/libxl/xl_cmdimpl.c >> @@ -560,7 +560,7 @@ static void parse_config_data(const char *config_s= ource, >> const char *buf; >> long l; >> XLU_Config *config; >> - XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpm= s; >> + XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpm= s, >> *iomems; >> int pci_power_mgmt =3D 0; >> int pci_msitranslate =3D 1; >> int pci_permissive =3D 0; >> @@ -1145,6 +1145,42 @@ skip_vfb: >> libxl_defbool_set(&b_info->u.pv.e820_host, true); >> } >> =20 >> + if(!xlu_cfg_get_list(config, "iomem", &iomems, 0, 0)) { >> + int i; >> + for(i =3D0; (buf =3D xlu_cfg_get_listitem(iomems, i)) !=3D NUL= L; ++i) { >> + libxl_iomem_range *iorng; >> + char* buf2 =3D strdup(buf); >> + char *st, *len, *al; >> + >> + d_config->iorngs =3D realloc(d_config->iorngs, >> sizeof(libxl_iomem_range) * (d_config->num_iorngs + 1)); >> + iorng =3D d_config->iorngs + d_config->num_iorngs; >> + >> + libxl_iomem_range_init(iorng); >> + >> + st =3D strtok(buf2, ","); >> + len =3D strtok(NULL, ","); >> + al =3D strtok(NULL, ","); >> + >> + if(st =3D=3D NULL || len =3D=3D NULL || >> + sscanf(st, "%" PRIx64, &iorng->start) !=3D 1 || >> + sscanf(len, "%" PRIu64, &iorng->length) !=3D 1 || >> + (al !=3D NULL && ((al[0] !=3D '1' && al[0] !=3D '0') = || al[1] >> !=3D '\0')) >> + ) { >> + fprintf(stderr, "Malformed iomem specification!\n"); >> + free(buf2); >> + exit(1); >> + } >> + if(al !=3D NULL) { >> + iorng->allow =3D al[0] - '0'; >> + } else { >> + iorng->allow =3D 1; >> + } >> + >> + free(buf2); >> + d_config->num_iorngs++; >> + } >> + } >> + >> switch (xlu_cfg_get_list(config, "cpuid", &cpuids, 0, 1)) { >> case 0: >> { > --------------ms090509070905060800030708 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 AwEBAQIEChIIMDAxMDQyNjEwWAYJYIZIAYb6ax4BBEsMSVRoZ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l7n1vXQwSNbxxA8I8Hkn5SW1vy7JbsYc1LtBoRrRMDjHa+03etZQQNqxJcINnYM tC2Dm2OtUGx3dYYiV2hH/iaedFdXxul8sigiBzLRyS03Tjxbpx7Th6+AGSprCC7WjAAAAAAA AA== --------------ms090509070905060800030708-- --===============4804813936959707545== 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 --===============4804813936959707545==--