Commit Graph

33 Commits

Author SHA1 Message Date
Avi Kivity
38443e2c4c posix: change file_desc mmap API to return an mmap_area
An mmap_area munmap()s itself when destroyed, reclaiming memory.
2014-12-11 12:25:31 +02:00
Asias He
20acb6db9c xen: Fix mismatched signature
Found with clang:

[46/68] CXX build/release/core/xen/evtchn.o
FAILED: clang -MMD -MT build/release/core/xen/evtchn.o -MF
build/release/core/xen/evtchn.o.d -std=gnu++1y   -Wall -Werror
-fvisibility=hidden -pthread -I.  -Wno-mismatched-tags -DHAVE_XEN
-DHAVE_HWLOC -DHAVE_NUMA -O2 -I build/release/gen -c -o
build/release/core/xen/evtchn.o core/xen/evtchn.cc
core/xen/evtchn.cc:83:18: error: 'xen::userspace_evtchn::umask' hides
overloaded virtual function [-Werror,-Woverloaded-virtual]
    virtual void umask(int *port, unsigned count);
                 ^
core/xen/evtchn.hh:38:18: note: hidden overloaded virtual function
'xen::evtchn::umask' declared here: type mismatch at 2nd parameter
('int' vs 'unsigned int')
    virtual void umask(int *port, int count) {};
                 ^
1 error generated.
2014-12-09 09:59:46 +02:00
Glauber Costa
2cf187590f xen: fix userspace interrupts
The local variable used to read the ports won't be valid after we return from
the function. Moving it to be an instance member is not ideal, but it work if
we don't unmask the ports until we're ready signaling them all.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-28 14:23:14 +01:00
Glauber Costa
a4667c48e6 xen: fix gntalloc for userspace
It broke when we changed things to accomodate OSv's functions. The following
code works.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-27 18:00:35 +01:00
Glauber Costa
f06233695c xenstore: bail on error
If there is some error opening the xenstore - for instance, if we run
without privileges, we should bail out or we will segfault later.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-27 18:00:35 +01:00
Glauber Costa
bd8a18c178 xen: umask event channels when setup is ready
This is not required for OSv, but is required for userspace operation.
It won't work without it.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-27 18:00:35 +01:00
Glauber Costa
bc617f8340 make xen work again.
After the latest reactor rework from Nadav, it is no longer allowed to use eventfds
in the reactor for OSv. Change the code to use the reactor notifier instead.

We could just use that instead of semaphores altogether. But because the semaphore is
per listener, we need a translation anyway. So let's keep this one doing the interrupt
processing, and the semaphores doing the rest of the work.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
2014-11-20 14:59:25 +02:00
Avi Kivity
ce03a3a9c0 xen: add evtchn port default constructor and move assignment operator 2014-11-20 12:17:29 +02:00
Avi Kivity
c588eb66d4 xen: fix evtchn port destructor and move constructor w/ uninitialized port 2014-11-20 12:16:40 +02:00
Avi Kivity
5bb13601fe xen: wrap in "xen" namespace
Names like "port" are too generic for the global namespace.
2014-11-09 14:41:01 +02:00
Avi Kivity
fede31896c xen: mark port's constructor as explicit
Prevent accidental construction.
2014-11-09 14:36:06 +02:00
Avi Kivity
14968812fe xen: remove port::operator int()
It's dangerous as it can be invoked in unexpected places.
2014-11-09 14:34:25 +02:00
Avi Kivity
16b0013c6b xen: add port destructor
De-register from the port list.

Add a FIXME for unbinding the port from Xen.
2014-11-09 13:34:30 +02:00
Avi Kivity
46aac42704 xen: make 'port' a value object
Makes it easier of users to manage its lifetime.
2014-11-09 13:30:52 +02:00
Avi Kivity
f5a2dcd9ec xen: simplify evtchn port management
By switching from a map of a list of semaphores to a multimap of ports,
we have less indirection and things become more straightforward.
2014-11-09 13:14:23 +02:00
Avi Kivity
b2af728f0e xen: provide xenstore::read_or_default()
This is useful for features that are provided incrementally, so may not
be present on all hypervisors.  If the value is not present, return a
user-provided default, which also has a system-provided default (0).
2014-11-09 12:07:31 +02:00
Glauber Costa
9a8cde5170 xen: have a list of semaphores per event channel
We current have one port per event channel. We need to have a list of
semaphores that will all be made ready when an interrupt kicks in. This is
useful in the case where both tx and rx are bound to the same event channel.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-09 11:54:10 +02:00
Glauber Costa
7ae3ab57d4 xen: change process_interrupts to take a port, rather than a semaphore
If we do that, plus make it an instance method, we should be able to use
make_ready_port. This is consistent with the userspace implementation and
from that point any changes there will be propagated to both.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-09 11:54:10 +02:00
Glauber Costa
ab3d02e347 xen: use a port class instead of an integer to represent an event channel
The representation of an event channel as an integer poses a problem, in which
waiting on an integer port doesn't work well when the same event channel is
assigned for both tx and rx. The future will be ready for one of the sides, but
we won't process the other.

One alternative is to have conditions in the future processing, and in case the
event channels are bound to the same port, process both events. But a better
solution is to use a class to represent the bound ports, and instances of those
classes will have their own pending methods.

Infrastructure will be written in a following patch to make sure that all
listeners to the same port will be made ready when an interrupt kicks in

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-09 11:54:08 +02:00
Glauber Costa
4dcc48c306 evtchn: allow to retrieve instance without parameters
gntalloc already has a method like this, code it for evtchn as well.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-09 11:54:07 +02:00
Glauber Costa
3d0f2de8bb xen: method to end a grant operation
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-06 11:21:30 +01:00
Glauber Costa
0a1f5f9e73 xen: defer grant table operations
Instead of returning a reference to a grant that is already present in an
array, defer the initialization. This is how the OSv driver handles it, and I
honestly am not sure if this is really needed: it seems to me we should be able
to just reuse the old grants. I need to check in the backend code if we can be
any smarter than this.

However, right now we need to do something to recycle the buffers, and just
re-doing the refs would lead to inconsistencies. So the best by now is to close
and reopen the grants, and then later on rework this in a way that works for
both the initial setup and the recycle.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-06 11:21:30 +01:00
Glauber Costa
ee172e36c1 xen: enhance gntref
Enhance gntref with some useful operations. Also provide a default object that
represents an invalid grant.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-06 11:21:29 +01:00
Glauber Costa
63c8db870f xen: remove debug printfs
As packet flow is working reasonably now, most of the prints can go.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-05 22:30:25 +01:00
Avi Kivity
2d14053e6e xen: make gntref more readable
Convert it from std::pair with meaningless .first and .second fields to
a proper struct.
2014-11-05 15:09:04 +02:00
Avi Kivity
a9a87c8dbd xen: fix low-level interrupt handling with osv
The Xen code registers a function that calls semaphore::signal as
an interrupt handler, however that function is not smp safe and may crash,
and in events it generates are likely to be ignored, since they are just
appended to the reactor queue without any real wakeup to the reactor thread.

Switch to using an eventfd.  That's still unsafe, but a little better, since
its signalling is smp safe, and will cause the reactor thread to wake up
in case it was asleep.

With this, we are able to receive multiple packets.
2014-11-05 15:09:03 +02:00
Avi Kivity
a769737faa xen: fix another bad grant operation
We used gnttab_grant_foreign_access() instead of
gnttab_grant_foreign_access_ref().  While the two functions have similar
enough signatures, they do very different things.

With the change, we are able to receive packets from Xen, though we crash
immediately.
2014-11-05 15:09:03 +02:00
Avi Kivity
afbe788235 xen: fix bad grant operation
We used gnttab_grant_foreign_access() instead of
gnttab_grant_foreign_access_ref().  While the two functions have similar
enough signatures, they do very different things.

With the change, we are able to transmit packets through Xen.
2014-11-05 15:09:03 +02:00
Avi Kivity
6269fe2bdf xen: fix virt_to_mfn()
Need to shift by 12 to get to a frame number.  With this the host accepts
the guest interface.
2014-11-05 15:09:03 +02:00
Glauber Costa
9fa8124ade xen: evtchn support
This patch enables xen event channels. It creates the placeholder for the
kernel evtchns when we move to OSv as well.

The main problem with this patch, is that evtchn::pending can return more than
one evtchn, so this that I am doing here is technically wrong. We should probably
call keep_doing() in pending() itself, and have that to store the references to
futures equivalent to the possible event channels, that would then be made ready.

I am, however, having a bit of a hard time coding this, since it's still
unclear how, once the future is consumed, we would generate the next.

Please note: All of this is moot if we disable "split event channels", which
can be done by masking that feature in case it is even available. In that case,
only one event channel will be notified, and when ready, we process both tx and
rx. This is yet another reason why I haven't insisted so much in fixing this properly

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-05 15:09:03 +02:00
Glauber Costa
891b40a2af xen: gntalloc device
This patch creates a seastar enabled version of the xen gntalloc device.

TODO: grow the table dynamically, and fix the index selection algorithm. Shouldn't
just always bump 1.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-05 15:09:03 +02:00
Glauber Costa
7963eb026c header functions for osv + xen
Should come from OSv, we should fix this soon.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-05 15:09:03 +02:00
Glauber Costa
9a86af9543 xen: xenstore communication
This patch enables to interact with xenstore. Since now OSv now fakes the
presence of libxenstore, the code is the same for userspace and kernel.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
2014-11-02 16:41:19 +02:00