netif & grant tables
Hi,
I'm currently looking at getting domU networking working on IA64, and to do this I need to make netback/netfront use grant tables.
I'm told that there's already a patch floating around, can someone tell me where to find it?
Matt
Quoted 6 lines · Matt Chapman
I'm currently looking at getting domU networking working on IA64, and to do this I need to make netback/netfront use grant tables.
I'm told that there's already a patch floating around, can someone tell me where to find it?
Hi Matt,
Here is the patch for having grant tables with netback and netfront.
linux-2.6.11-xen-sparse/arch/xen/Kconfig +14 -0
@@ -97,6 +97,20 @@ dedicated device-driver domain, or your master control domain (domain 0), then you almost certainly want to say Y here. +config XEN_NETDEV_GRANT_TX + bool "Grant table substrate for net drivers tx path (DANGEROUS)" + default y + help + This introduces the use of grant tables as a data exhange mechanism + between the frontend and backend network drivers. + +config XEN_NETDEV_GRANT_RX + bool "Grant table substrate for net drivers rx path (DANGEROUS)" + default y + help + This introduces the use of grant tables as a data exhange mechanism + between the frontend and backend network drivers. + config XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER bool "Pipelined transmitter (DANGEROUS)" depends on XEN_NETDEV_FRONTEND
linux-2.6.11-xen-sparse/arch/xen/kernel/gnttab.c +7 -1
@@ -165,8 +165,14 @@u16 flags; flags = shared[ref].flags; +#ifdef CONFIG_XEN_NETDEV_GRANT_RX +/* +* But can't flags == (GTF_accept_transfer | GTF_transfer_completed) +* if gnttab_donate executes without interruption??? +*/ +#else ASSERT (flags == (GTF_accept_transfer | GTF_transfer_committed)); - +#endif /* * If a transfer is committed then wait for the frame address to appear. * Otherwise invalidate the grant entry against future use.
linux-2.6.11-xen-sparse/drivers/xen/netback/common.h +3 -0
@@ -50,6 +50,9 @@/* Private indexes into shared ring. */ NETIF_RING_IDX rx_req_cons;NETIF_RING_IDX rx_resp_prod;/* private version of shared variable */ +#ifdef CONFIG_XEN_NETDEV_GRANT_RX +NETIF_RING_IDX rx_resp_prod_copy;/* private version of shared variable */ +#endif NETIF_RING_IDX tx_req_cons;NETIF_RING_IDX tx_resp_prod;/* private version of shared variable */
linux-2.6.11-xen-sparse/drivers/xen/netback/netback.c +177 -9
409 lines not on this page · raw message
linux-2.6.11-xen-sparse/drivers/xen/netfront/netfront.c +148 -7
291 lines not on this page · raw message
xen/common/grant_table.c +151 -0
169 lines not on this page · raw message
xen/include/public/grant_table.h +14 -0
@@ -220,6 +220,19 @@s16 status;/* 2: GNTST_* */ }PACKED gnttab_dump_table_t;/* 4 bytes */ +/* +* GNTTABOP_donate_grant_ref: Donate <frame> to a foreign domain. The +* foreign domain has previously registered the details of the transfer. +* These can be identified from <handle>, a grant reference. +*/ +#define GNTTABOP_donate 4 +typedef struct { +memory_t mfn;/* 0 */ +domid_t domid;/* 4 */ +u16 handle;/* 8 */ +s16 status;/* 10: GNTST_* */ +u32 __pad; +} PACKED gnttab_donate_t; /* 14 bytes *//* * Bitfield values for update_pin_status.flags.
@@ -273,6 +286,7 @@gnttab_unmap_grant_ref_t unmap_grant_ref;gnttab_setup_table_t setup_table;gnttab_dump_table_t dump_table; +gnttab_donate_t donate;u8 __dummy[24 ]; }PACKED u; }PACKED gnttab_op_t;/* 32 bytes */
xen/include/public/io/netif.h +4 -1
@@ -25,10 +25,13 @@typedef struct {u16 id;/* 0: Echoed in response message. */ +#ifdef CONFIG_XEN_NETDEV_GRANT_RX +grant_ref_t gref;/* 2: Reference to incoming granted frame */ +#endif } PACKED netif_rx_request_t; /* 2 bytes */ typedef struct { - memory_t addr; /* 0: Machine address of packet. */ + u32 addr; /* 0: Offset in page of start of received packet */ MEMORY_PADDING; u16 csum_valid:1; /* Protocol checksum is validated? */ u16 id:15; /* 8: */
[email protected] wrote on 06/30/2005 10:28:54 PM:
Quoted 5 lines
Hi,
I'm currently looking at getting domU networking working on IA64, and to do this I need to make netback/netfront use grant tables.
You *probably* won't get this to work right out of the box. On i386 it fails due to dom Us not becoming privileged and so a check like IS_PRIV() fails in xen/common/grant_table.c line 692 and probably somewhere else also. The question is how this should be fixed. Should the HV call to create a domain receive an additional parameter including flags that should be set in a domain, such as for example the _DOMF_privileged? Currently this flag only seems to be set in one place for dom 0.
The quick fix is:
add
set_bit(_DOMF_privileged, &d->domain_flags)
before the 'return d' in do_createdomain() in xen/common/domain.c -> it will make all domains privileged
To compile the backends into a domU I had to activate CONFIG_XEN_PRIVILGED_GUEST and CONFIG_XEN_PHYSDEV_ACCESS in the .config file of the dom U kernel for having alloc_empty_lowmem_region() compiled into th kernel (arch/xen/i386/mm/hypervisor.c). Is this call to alloc_empty_lowmem_region() necessary or would another memory allocation routine work as well. All the backends seem to use it, though.
Stefan
Quoted 10 lines
I'm told that there's already a patch floating around, can someone tell me where to find it?
Matt
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Hi Stefan,
I'm not trying to run the backend or any real drivers in domU, only the frontend.
Matt
Quoted 48 lines · Stefan Berger
[email protected] wrote on 06/30/2005 10:28:54 PM:
Quoted 5 lines
Hi,
I'm currently looking at getting domU networking working on IA64, and to do this I need to make netback/netfront use grant tables.
You *probably* won't get this to work right out of the box. On i386 it fails due to dom Us not becoming privileged and so a check like
IS_PRIV()fails inxen/common/grant_table.cline 692 and probably somewhere else also. The question is how this should be fixed. Should the HV call to create a domain receive an additional parameter including flags that should be set in a domain, such as for example the_DOMF_privileged? Currently this flag only seems to be set in one place for dom 0.The quick fix is:
addset_bit(_DOMF_privileged, &d->domain_flags)before the 'return d' in
do_createdomain()inxen/common/domain.c-> it will make all domains privilegedTo compile the backends into a domU I had to activate
CONFIG_XEN_PRIVILGED_GUESTandCONFIG_XEN_PHYSDEV_ACCESSin the .config file of the dom U kernel for havingalloc_empty_lowmem_region()compiled into th kernel (arch/xen/i386/mm/hypervisor.c). Is this call toalloc_empty_lowmem_region()necessary or would another memory allocation routine work as well. All the backends seem to use it, though.Stefan
Quoted 10 lines
I'm told that there's already a patch floating around, can someone tell me where to find it?
Matt
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
[email protected] wrote on 07/01/2005 03:40:31 PM:
Quoted 4 lines
Hi Stefan,
I'm not trying to run the backend or any real drivers in domU, only the frontend.
Just curious: On IA64 you must have grant tables to get networking working?
If someone has the matching problem for my solution, then let me know. :-) Otherwise I think the problem of making domains privileged should really be solved - probably starting somewhere in XEN-D.
Stefan
Quoted 16 lines
Matt
Quoted 11 lines · Stefan Berger
[email protected] wrote on 06/30/2005 10:28:54 PM:
Quoted 5 lines
Hi,
I'm currently looking at getting domU networking working on IA64, and to do this I need to make netback/netfront use grant tables.
You *probably* won't get this to work right out of the box. On i386 it
fails due to dom Us not becoming privileged and so a check like
IS_PRIV()
Quoted 7 lines
Quoted 7 lines
fails in
xen/common/grant_table.cline 692 and probably somewhere elsealso. The question is how this should be fixed. Should the HV call to create a domain receive an additional parameter including flags that should be set in a domain, such as for example the
_DOMF_privileged? Currently this flag only seems to be set in one place for dom 0.
Quoted 5 lines
Quoted 5 lines
The quick fix is:
addset_bit(_DOMF_privileged, &d->domain_flags)before the 'return d' in
do_createdomain()inxen/common/domain.c->
it
Quoted 4 lines
Quoted 4 lines
will make all domains privileged
To compile the backends into a domU I had to activate
CONFIG_XEN_PRIVILGED_GUESTandCONFIG_XEN_PHYSDEV_ACCESSin the
.config
Quoted 1 line
Quoted 1 line
file of the dom U kernel for having
alloc_empty_lowmem_region()
compiled
Quoted 2 lines
Quoted 2 lines
into th kernel (
arch/xen/i386/mm/hypervisor.c). Is this call toalloc_empty_lowmem_region()necessary or would another memory
allocation
Quoted 21 lines
Quoted 16 lines
routine work as well. All the backends seem to use it, though.
Stefan
Quoted 10 lines
I'm told that there's already a patch floating around, can someone tell me where to find it?
Matt
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-develQuoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 9 lines · Stefan Berger
[email protected] wrote on 07/01/2005 03:40:31 PM:
Quoted 4 lines
Hi Stefan,
I'm not trying to run the backend or any real drivers in domU, only the frontend.
Just curious: On IA64 you must have grant tables to get networking working?
Well, on IA64 domU doesn't know about real machine addresses (ala shadow mode on x86). The grant table mechanism is the easiest way to enable sharing of pages - grant references provide a common namespace for referring to a page.
Matt
Quoted 3 lines
If someone has the matching problem for my solution, then let me know. :-) Otherwise I think the problem of making domains privileged should really be solved - probably starting somewhere in XEN-D.
There should probably be a flag you pass down from the config. The current hack people use is to give the domain access to a PCI device but not compile in the drivers. Driver domains are privileged at the moment, so it works :-S
With full grant tables support, full privilege is not necessary, just a grant from the other party. That's probably the nicest long term solution and can also hook in with a suitable IO-TLB to provide protection against rogue DMAs.
Cheers,
Mark
Mark Williamson <[email protected]> wrote on 07/01/2005 09:56:26 PM:
Quoted 1 line
Quoted 1 line
If someone has the matching problem for my solution, then let me know.
:-)
Quoted 1 line
Quoted 1 line
Otherwise I think the problem of making domains privileged should
really
Quoted 3 lines
Quoted 1 line
be solved - probably starting somewhere in XEN-D.
There should probably be a flag you pass down from the config. The
current
It could be done implicitly, meaning that if you give a domain a backend (netif/blkif), that privilege flag will automatically be set by XEN-D and used when creating the domain, or explicitly where one specifies the flag(s) to set in the VM config file.
Quoted 1 line
hack people use is to give the domain access to a PCI device but not
compile
Quoted 1 line
in the drivers. Driver domains are privileged at the moment, so it
works :-S
Quoted 1 line
From what I can see this does not work anymore - I used to do that also.
Passing a PCI device to a partition results in an error since the xc_physdev_pci_access_modify call ends in an error.
Quoted 2 lines
With full grant tables support, full privilege is not necessary, just a
grant
Quoted 1 line
from the other party. That's probably the nicest long term solution and
can
Quoted 1 line
also hook in with a suitable IO-TLB to provide protection against rogue
DMAs.
I am not sure how 'privilege' is defined. The privilege does so far not only mean to do dom 0 ops, but seems to also limit guest domains of doing other things - like the backend problem I see. I agree, though, that for grant table support a backend should not need privileges.
Quoted 3 lines
Cheers,
Mark
Cheers,
Stefan
Quoted 4 lines
It could be done implicitly, meaning that if you give a domain a backend (netif/blkif), that privilege flag will automatically be set by XEN-D and used when creating the domain, or explicitly where one specifies the flag(s) to set in the VM config file.
Doing it implicitly would probably be sensible.
Quoted 3 lines
From what I can see this does not work anymore - I used to do that also. Passing a PCI device to a partition results in an error since the
xc_physdev_pci_access_modifycall ends in an error.
Assigning PCI devices is broken in unstable at the moment. It'll be coming back at some stage.
Quoted 1 line
I am not sure how 'privilege' is defined.
Very coarsely at present: IIRC right now domain who's got access to a PCI device is as privileged as dom0. This means they're allowed to map memory of other domains, do dom0 ops, etc.
Grant tables will enable us to deprivilege guests somewhat, then we'll split privileges down into more fine-grained capabilities.
Cheers,
Mark
Quoted 10 lines
The privilege does so far not
only mean to do dom 0 ops, but seems to also limit guest domains of doing other things - like the backend problem I see. I agree, though, that for grant table support a backend should not need privileges.Quoted 2 lines
Cheers,
MarkCheers,
Stefan
[email protected] wrote on 07/02/2005 11:34:58 AM:
Quoted 1 line
Quoted 1 line
It could be done implicitly, meaning that if you give a domain a
backend
Quoted 1 line
Quoted 1 line
(netif/blkif), that privilege flag will automatically be set by XEN-D
and
Quoted 6 lines
Quoted 2 lines
used when creating the domain, or explicitly where one specifies the flag(s) to set in the VM config file.
Doing it implicitly would probably be sensible.
Quoted 1 line
From what I can see this does not work anymore - I used to do that
also.
Quoted 4 lines
Quoted 2 lines
Passing a PCI device to a partition results in an error since the
xc_physdev_pci_access_modifycall ends in an error.Assigning PCI devices is broken in unstable at the moment. It'll be
coming
Quoted 5 lines
back at some stage.
Quoted 1 line
I am not sure how 'privilege' is defined.
Very coarsely at present: IIRC right now domain who's got access to a
PCI
Quoted 1 line
device is as privileged as dom0. This means they're allowed to map
memory of
Quoted 3 lines
other domains, do dom0 ops, etc.
Grant tables will enable us to deprivilege guests somewhat, then we'll
split
Quoted 2 lines
privileges down into more fine-grained capabilities.
Setting the privileged bit in a user domain gets grant tables to work:
should this bit be set for those kind of domains or rather the IS_PRIV() test be removed from the call path which basically would allow all user domains to do mapping by default?
Stefan
Quoted 5 lines
Cheers,
MarkQuoted 2 lines
The privilege does so far not
only mean to do dom 0 ops, but seems to also limit guest domains of
doing
Quoted 1 line
Quoted 1 line
other things - like the backend problem I see. I agree, though, that
for
Quoted 12 lines
Quoted 7 lines
grant table support a backend should not need privileges.
Quoted 2 lines
Cheers,
MarkCheers,
Stefan_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel