netif & grant tables
A message that is not in the archive (sent off-list or not yet received): [email protected]
Mark Williamson <[email protected]> wrote on 07/03/2005 09:26:18 PM:
Quoted 4 lines
[off list]
Quoted 2 lines
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()
Quoted 1 line
Quoted 1 line
test be removed from the call path which basically would allow all
user
Quoted 3 lines
Quoted 1 line
domains to do mapping by default?
I'm not clear what you mean here - AFAIK grant tables don't require
IS_PRIV()
Quoted 1 line
in order to work. Or am I misunderstanding?
You are right, it's not the grant tables per se that need the privileged bit to be set, but other functions need it and keep backends from working.
Here are two code paths from the network backend:
from netback/interface.c calls
linux-2.6.11-xen-sparse/arch/xen/i386/mm/ioremap.c:direct_remap_area_pages() calls
HYPERVISOR_mmu_update calls
xen/arch/x86/mm.c:do_mmu_update calls
set_foreigndom() which has an IS_PRIV() in the path
-> The direct_remap_area_pages call fails if a domain does not have the privilege bit set.
netback/netback.c: alloc_mfn() calls
HYPERVISOR_dom_mem_op(MEMOP_increase_reservation, mfn_list,MAX_MFN_ALLOC, 0);
xen/common/dom_mem_ops.c:do_dom_mem_op() is called which has aIS_PRIV() in the path
Stefan
Quoted 2 lines
What I meant was that since grant tables are an explicit capability (you
can
Quoted 1 line
only map a page of another dom if it gave you an explicit grant) there's
no
Quoted 1 line
need for mappings in the IO path to require special privileges at all.
If
Quoted 1 line
someone gave you a grant, they must trust you enough to access that
page.
Quoted 11 lines
Cheers,
MarkQuoted 7 lines
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
Quoted 4 lines
Quoted 4 lines
doing
Quoted 1 line
Quoted 1 line
other things - like the backend problem I see. I agree, though,
that
Quoted 15 lines
Quoted 15 lines
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
Quoted 8 lines · Stefan Berger
linux-2.6.11-xen-sparse/arch/xen/i386/mm/ioremap.c:direct_remap_area_pages() calls
HYPERVISOR_mmu_updatecalls
xen/arch/x86/mm.c:do_mmu_update calls
set_foreigndom()which has anIS_PRIV()in the path-> The
direct_remap_area_pagescall fails if a domain does not have the privilege bit set.
The backend driver parts that use this function need cleaning up to use a grant reference instead.
Quoted 5 lines
netback/netback.c:alloc_mfn()calls
HYPERVISOR_dom_mem_op(MEMOP_increase_reservation,mfn_list,MAX_MFN_ALLOC, 0);
xen/common/dom_mem_ops.c:do_dom_mem_op() is called which has aIS_PRIV()in the path
It only disallows you from adjusting others' reservations. You can still adjust your own.
-- Keir
Quoted 4 lines
You are right, it's not the grant tables per se that need the privileged bit to be set, but other functions need it and keep backends from working.
Here are two code paths from the network backend:
I suspected it might be something like this. There's no reason for those to require privilege either: they can fairly trivially be converted to use grant tables too. Once it's fully grant-table-ified it shouldn't be necessary to make such domains be privileged.
Full grant tables support also a pre-req for the point to point "snappable frontend" connections directly between domains with high bandwidth requirements.
Cheers,
Mark
Quoted 71 lines
from
netback/interface.ccallslinux-2.6.11-xen-sparse/arch/xen/i386/mm/ioremap.c:direct_remap_area_pages( ) calls
HYPERVISOR_mmu_updatecalls
xen/arch/x86/mm.c:do_mmu_update calls
set_foreigndom()which has anIS_PRIV()in the path-> The
direct_remap_area_pagescall fails if a domain does not have the privilege bit set.
netback/netback.c:alloc_mfn()calls
HYPERVISOR_dom_mem_op(MEMOP_increase_reservation,mfn_list,MAX_MFN_ALLOC, 0);
xen/common/dom_mem_ops.c:do_dom_mem_op() is called which has aIS_PRIV()in the pathStefan
Quoted 1 line
What I meant was that since grant tables are an explicit capability (you
can
Quoted 1 line
only map a page of another dom if it gave you an explicit grant) there's
no
Quoted 1 line
need for mappings in the IO path to require special privileges at all.
If
Quoted 1 line
someone gave you a grant, they must trust you enough to access that
page.
Quoted 10 lines
Cheers,
MarkQuoted 7 lines
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 domainsof
Quoted 3 lines
Quoted 3 lines
doing
Quoted 1 line
Quoted 1 line
other things - like the backend problem I see. I agree, though,
that
Quoted 14 lines
Quoted 14 lines
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
PATCH 1/1 block FE/BE grant table support for initial shared memory page
Hello!
Attached is a patch that fully 'grant-table-ifies' the block front and
backends. It is necessary to do a make clean in the tools directory and then rebuild the tree.
[email protected] wrote on 07/04/2005 03:11:40 PM:
Quoted 1 line
Quoted 1 line
You are right, it's not the grant tables per se that need the
privileged
Quoted 1 line
Quoted 1 line
bit to be set, but other functions need it and keep backends from
working.
Quoted 4 lines
Quoted 2 lines
Here are two code paths from the network backend:
I suspected it might be something like this. There's no reason for
those to
Quoted 1 line
require privilege either: they can fairly trivially be converted to use
grant
Quoted 1 line
tables too. Once it's fully grant-table-ified it shouldn't be necessary
to
Quoted 3 lines
make such domains be privileged.
Full grant tables support also a pre-req for the point to point
"snappable
Quoted 9 lines
frontend" connections directly between domains with high bandwidth requirements.
Cheers,
MarkQuoted 3 lines
from
netback/interface.ccalls
linux-2.6.11-xen-sparse/arch/xen/i386/mm/ioremap.c:direct_remap_area_pages(
Quoted 6 lines
Quoted 6 lines
) calls
HYPERVISOR_mmu_updatecalls
xen/arch/x86/mm.c:do_mmu_update calls
set_foreigndom()which has anIS_PRIV()in the path-> The
direct_remap_area_pagescall fails if a domain does not have
the
Quoted 11 lines
Quoted 11 lines
privilege bit set.
netback/netback.c:alloc_mfn()calls
HYPERVISOR_dom_mem_op(MEMOP_increase_reservation,mfn_list,MAX_MFN_ALLOC, 0);
xen/common/dom_mem_ops.c:do_dom_mem_op() is called which has aIS_PRIV()in the path
Quoted 3 lines
Quoted 3 lines
Stefan
Quoted 1 line
What I meant was that since grant tables are an explicit capability
(you
Quoted 4 lines
Quoted 4 lines
can
Quoted 1 line
only map a page of another dom if it gave you an explicit grant)
there's
Quoted 4 lines
Quoted 4 lines
no
Quoted 1 line
need for mappings in the IO path to require special privileges at
all.
Quoted 10 lines
Quoted 10 lines
If
Quoted 1 line
someone gave you a grant, they must trust you enough to access that
page.
Quoted 3 lines
Cheers,
Mark
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
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
Quoted 6 lines
Quoted 6 lines
of
Quoted 3 lines
Quoted 3 lines
doing
Quoted 1 line
Quoted 1 line
other things - like the backend problem I see. I agree,
though,
Quoted 18 lines
Quoted 17 lines
that
Quoted 14 lines
Quoted 14 lines
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
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
linux-2.6.11-xen-sparse/drivers/xen/blkback/common.h +5 -0
@@ -65,6 +65,11 @@ typedef struct blkif_st {atomic_t refcnt;struct work_struct work; +#ifdef CONFIG_XEN_BLKDEV_GRANT +u16 shmem_handle; +memory_t shmem_vaddr; +grant_ref_t shmem_ref; +#endif } blkif_t;void blkif_create (blkif_be_create_t *create);
linux-2.6.11-xen-sparse/drivers/xen/blkback/interface.c +52 -0
78 lines not on this page · raw message
linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c +10 -3
@@ -1136,6 +1136,12 @@ static void blkif_send_interface_connect msg->handle =0 ; msg->shmem_frame = (virt_to_machine (blk_ring.sring) >>PAGE_SHIFT ); +#ifdef CONFIG_XEN_BLKDEV_GRANT + msg->shmem_ref =gnttab_claim_grant_reference ( &gref_head, gref_terminal ); +ASSERT ( msg->shmem_ref != -ENOSPC ); +gnttab_grant_foreign_access_ref ( msg->shmem_ref , rdomid, msg->shmem_frame,0 ); +#endif +ctrl_if_send_message_block (&cmsg,NULL ,0 ,TASK_UNINTERRUPTIBLE ); }
@@ -1261,9 +1266,6 @@ static void blkif_connect(blkif_fe_inter blkif_evtchn = status->evtchn; blkif_irq =bind_evtchn_to_irq (blkif_evtchn); -#ifdef CONFIG_XEN_BLKDEV_GRANT - rdomid = status->domid; -#endif err =request_irq (blkif_irq, blkif_int,SA_SAMPLE_RANDOM ,"blkif" ,NULL );if ( err )
@@ -1300,6 +1302,10 @@ static void unexpected(blkif_fe_interfacstatic void blkif_status (blkif_fe_interface_status_t *status) { +#ifdef CONFIG_XEN_BLKDEV_GRANT + rdomid = status->domid;/* need to set rdomid early */ +#endif +if ( status->handle != blkif_handle ) {WPRINTK (" Invalid blkif: handle=%u\n" , status->handle);
tools/python/xen/lowlevel/xu/xu.c +3 -0
@@ -594,6 +594,7 @@ static PyObject *xu_message_get_payload(case TYPE (CMSG_BLKIF_FE ,CMSG_BLKIF_FE_INTERFACE_CONNECT ):C2P (blkif_fe_interface_connect_t, handle, Int, Long);C2P (blkif_fe_interface_connect_t, shmem_frame, Int, Long); +C2P (blkif_fe_interface_connect_t, shmem_ref , Int, Long);return dict;case TYPE (CMSG_BLKIF_FE ,CMSG_BLKIF_FE_INTERFACE_DISCONNECT ):C2P (blkif_fe_interface_disconnect_t, handle, Int, Long);
@@ -612,6 +613,7 @@ static PyObject *xu_message_get_payload(C2P (blkif_be_connect_t, domid, Int, Long);C2P (blkif_be_connect_t, blkif_handle, Int, Long);C2P (blkif_be_connect_t, shmem_frame, Int, Long); +C2P (blkif_be_connect_t, shmem_ref, Int, Long);C2P (blkif_be_connect_t, evtchn, Int, Long);C2P (blkif_be_connect_t, status, Int, Long);return dict;
@@ -842,6 +844,7 @@ static PyObject *xu_message_new(PyObjectP2C (blkif_be_connect_t, domid, u32);P2C (blkif_be_connect_t, blkif_handle, u32);P2C (blkif_be_connect_t, shmem_frame, memory_t); +P2C (blkif_be_connect_t, shmem_ref, u32);P2C (blkif_be_connect_t, evtchn, u16);break ;case TYPE (CMSG_BLKIF_BE ,CMSG_BLKIF_BE_DISCONNECT ):
tools/python/xen/xend/server/blkif.py +2 -1
@@ -126,7 +126,8 @@ class BlkifBackend: { 'domid' : self.frontendDomain, 'blkif_handle' : self.id, 'evtchn' : self.getEventChannelBackend(), - 'shmem_frame' : val['shmem_frame'] }) + 'shmem_frame' : val['shmem_frame'], + 'shmem_ref' : val['shmem_ref'] }) msg = self.backendChannel.requestResponse(msg) #todo: check return status val = unpackMsg('blkif_be_connect_t', msg)
xen/include/public/io/domain_controller.h +2 -0
@@ -140,6 +140,7 @@ typedef struct blkif_fe_driver_status {typedef struct blkif_fe_interface_connect {u32 handle;memory_t shmem_frame; +int shmem_ref; }blkif_fe_interface_connect_t ;/*
@@ -249,6 +250,7 @@ typedef struct blkif_be_connect {domid_t domid;/* Domain attached to new interface. */ u32 blkif_handle;/* Domain-specific interface handle. */ memory_t shmem_frame;/* Page cont. shared comms window. */ +int shmem_ref;/* Grant table reference. */ u32 evtchn;/* Event channel for notifications. */ /* OUT */ u32 status;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel