From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Fioravante Subject: Re: PATCH [base vtpm and libxl patches 4/6] add iomem support to libxl Date: Wed, 26 Sep 2012 12:05:19 -0400 Message-ID: <506327BF.2080802@jhuapl.edu> References: <505CBA02.5040308@jhuapl.edu> <1348569044.3452.176.camel@zakaz.uk.xensource.com> <5061E293.7000106@jhuapl.edu> <1348649549.19176.15.camel@zakaz.uk.xensource.com> <506310BA.9080202@jhuapl.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1298253401627824443==" Return-path: In-Reply-To: <506310BA.9080202@jhuapl.edu> 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. --===============1298253401627824443== Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha1; boundary="------------ms010709000901080708070108" This is a cryptographically signed message in MIME format. --------------ms010709000901080708070108 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/26/2012 10:27 AM, Matthew Fioravante wrote: > On 09/26/2012 04:52 AM, Ian Campbell wrote: >> On Tue, 2012-09-25 at 17:57 +0100, Matthew Fioravante wrote: >>>>> @@ -1005,6 +1005,30 @@ static void parse_config_data(const char >>>>> *config_source, >>>>> } >>>>> } >>>>> =20 >>>>> + if (!xlu_cfg_get_list(config, "iomem", &iomem, &num_iomem, 0))= { >>>>> + b_info->num_iomem =3D num_iomem; >>>>> + b_info->iomem =3D calloc(num_iomem, sizeof(*b_info->iomem)= ); >>>>> + if (b_info->iomem =3D=3D NULL) { >>>>> + fprintf(stderr, "unable to allocate memory for iomem\n= "); >>>>> + exit(-1); >>>>> + } >>>>> + for (i =3D 0; i < num_iomem; i++) { >>>>> + buf =3D xlu_cfg_get_listitem (iomem, i); >>>>> + if (!buf) { >>>>> + fprintf(stderr, >>>>> + "xl: Unable to get element %d in iomem lis= t\n", i); >>>>> + exit(1); >>>>> + } >>>>> + if(sscanf(buf, "%" SCNx64",%" SCNu64, >>>>> &b_info->iomem[i].start, &b_info->iomem[i].number) !=3D 2) { >>>> This should be relatively simply to parse with strtoul (see the iopo= rts >>>> case) which would allow people to select hex or decimal in their >>>> configuration files. >>> Do we want to support hex or decimal? Pretty much anytime people star= t >>> talking about physical memory addresses or page numbers they use hex.= >>> Also the ioports code actually only supports hexadecimal as it sets t= he >>> base in strtoul to 16. It also explicitly says in the xl.cfg manpage >>> that ioports should be given in hex. >> Good point. You mix decimal (SCNu64) and hex (SCNx64) though, it would= >> be better to be consistent (in hex) I think. >> >> Ian >> > It seemed natural to me that when someone thinks they want N pages they= > would think in decimal. It might be better to be hex though for consist= ency. > New patch Signed off by Matthew Fioravante: matthew.fioravante@jhuapl.edu --- Changes from previous * Rebased onto latest xen-unstable * Rewrote the feature to mimic the style used by iports and irqs in current libxl * Updated xl.cfg manpage * removed the redundant "allow" field, its not used by irq or ioports either. * fixed whitespace errors * s/everytime/every time/ * Make num_pages argument a hex value diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5 --- a/docs/man/xl.cfg.pod.5 +++ b/docs/man/xl.cfg.pod.5 @@ -496,6 +496,17 @@ is given in hexadecimal and may either a span e.g. C<2f8-2ff> It is recommended to use this option only for trusted VMs under administrator control. =20 +=3Ditem B + +Allow guest to access specific hardware I/O memory pages. B= +is a physical page number. B is the number +of pages beginning with B to allow access. Both values +must be given in hexadecimal. + +It is recommended to use this option only for trusted VMs under +administrator control. + + =3Ditem B =20 Allow a guest to access specific physical IRQs. 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 @@ -963,6 +963,24 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, } } =20 + for (i =3D 0; i < d_config->b_info.num_iomem; i++) { + libxl_iomem_range *io =3D &d_config->b_info.iomem[i]; + + LOG(DEBUG, "dom%d iomem %"PRIx64"-%"PRIx64, + domid, io->start, io->start + io->number - 1); + + ret =3D xc_domain_iomem_permission(CTX->xch, domid, + io->start, io->number, 1); + if ( ret<0 ) { + LOGE(ERROR, + "failed give dom%d access to iomem range %"PRIx64"-%"PRIx64, + domid, io->start, io->start + io->number - 1); + ret =3D ERROR_FAIL; + } + } + + + for (i =3D 0; i < d_config->num_nics; i++) { /* We have to init the nic here, because we still haven't * called libxl_device_nic_add at this point, but qemu needs 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 @@ -140,6 +140,11 @@ libxl_ioport_range =3D Struct("ioport_range", [ ("number", uint32), ]) =20 +libxl_iomem_range =3D Struct("iomem_range", [ + ("start", uint64), + ("number", uint64), + ]) + libxl_vga_interface_info =3D Struct("vga_interface_info", [ ("kind", libxl_vga_interface_type), ]) @@ -284,6 +289,7 @@ libxl_domain_build_info =3D Struct("domain_build_info= ",[ =20 ("ioports", Array(libxl_ioport_range, "num_ioports")), ("irqs", Array(uint32, "num_irqs")), + ("iomem", Array(libxl_iomem_range, "num_iomem")), =20 ("u", KeyedUnion(None, libxl_domain_type, "type", [("hvm", Struct(None, [("firmware", string), 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 @@ -574,8 +574,8 @@ static void parse_config_data(const char *config_sour= ce, long l; XLU_Config *config; XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids; - XLU_ConfigList *ioports, *irqs; - int num_ioports, num_irqs; + XLU_ConfigList *ioports, *irqs, *iomem; + int num_ioports, num_irqs, num_iomem; int pci_power_mgmt =3D 0; int pci_msitranslate =3D 0; int pci_permissive =3D 0; @@ -1005,6 +1005,30 @@ static void parse_config_data(const char *config_source, } } =20 + if (!xlu_cfg_get_list(config, "iomem", &iomem, &num_iomem, 0)) { + b_info->num_iomem =3D num_iomem; + b_info->iomem =3D calloc(num_iomem, sizeof(*b_info->iomem)); + if (b_info->iomem =3D=3D NULL) { + fprintf(stderr, "unable to allocate memory for iomem\n"); + exit(-1); + } + for (i =3D 0; i < num_iomem; i++) { + buf =3D xlu_cfg_get_listitem (iomem, i); + if (!buf) { + fprintf(stderr, + "xl: Unable to get element %d in iomem list\n", = i); + exit(1); + } + if(sscanf(buf, "%" SCNx64",%" SCNx64, &b_info->iomem[i].start, &b_info->iomem[i].number) !=3D 2) { + fprintf(stderr, + "xl: Invalid argument parsing iomem: %s\n", buf);= + exit(1); + } + } + } + + + if (!xlu_cfg_get_list (config, "disk", &vbds, 0, 0)) { d_config->num_disks =3D 0; d_config->disks =3D NULL; --------------ms010709000901080708070108 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 bY7iHLJeq0NPr4BqYNqnCFP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RYEFHwDnu5tOI64mey5 vDSKIsQOE03iMGwGCSqGSIb3DQEJDzFfMF0wCwYJYIZIAWUDBAEqMAsGCWCGSAFlAwQBAjAK BggqhkiG9w0DBzAOBggqhkiG9w0DAgICAIAwDQYIKoZIhvcNAwICAUAwBwYFKw4DAgcwDQYI KoZIhvcNAwICASgwDQYJKoZIhvcNAQEBBQAEgYB5CffQxtgzxaZGDQRrk6CwmY2r06m/p7Yt OP6rjtYrz3Wwcb2lNUU9lJMo5kqTKHnuJznLNqcazt9i816Hs2LOYgyJRh96+7tr75Saz9qu 5dq1m5v9t6zWnR2zmEM6V4/pFelRKE7t6NA+GOP4/F70NrYSoIXXmffc3Y9Iw7+I7QAAAAAA AA== --------------ms010709000901080708070108-- --===============1298253401627824443== 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 --===============1298253401627824443==--