Skip to content
Snippets Groups Projects
  1. Aug 13, 2013
    • Glauber Costa's avatar
      Xen paravirtual event channel · a8560f2d
      Glauber Costa authored
      This file implements the pv and pv-on-hvm event channel mechanism.
      Verbatim copy from BSD.
      a8560f2d
    • Glauber Costa's avatar
      Xen layer for interrupt registering · fbec6608
      Glauber Costa authored
      The BSD pv event channel will expect the underlying OS to be able to register a
      PIC.  For now we will just allow that for xen, and provide the expected
      translation functions to allow xen to work.
      
      The design I have chosen is to let the xen event handler run in interrupt
      context. We can do threaded if it really becomes a problem, but right now it
      should do. The handlers themselves, though, will be threaded. So the
      intr_execute_handlers() function will do nothing more than to wake the
      respective threads.
      
      BSD will provide us functions, not threads. So we have a common thread that
      executes the function that we were given. One exception for this is the xenstore.
      The xenstore is already threaded, and its interrupt handler will also just wake
      up a thread. So for that we could do better in the future.
      fbec6608
    • Glauber Costa's avatar
      porting: bus definitions · d8dd6623
      Glauber Costa authored
      This contains interrupts, devices and bus definitions. Most of them are is bus
      files in BSD anyway.
      d8dd6623
    • Glauber Costa's avatar
      BSDEDIT/gnttab: compile in the grant tables · b16bdd49
      Glauber Costa authored
      With this patch, the grant table code is compiled into osv.
      The edits in the file reflect the fact that we don't need to go through PCI
      memory for the Xen special device even for HVM. We have mappings that are
      way simpler, so we can just use them. All the rest is kept as unchanged as I
      could.
      b16bdd49
    • Glauber Costa's avatar
      bsd: mmu stub functions · 3e5657ed
      Glauber Costa authored
      3e5657ed
    • Glauber Costa's avatar
      xen: provide C accessible of HYPERVISOR_shared_info · 6fc3d663
      Glauber Costa authored
      Xen files in BSD (and Linux for that matter) expect a variable called
      HYPERVISOR_shared_info that points to the hypercall page - that in our case is
      statically defined. So we just need to point it with the correct name to our
      shared info page.
      
      Note the type mismatch: we are defining our own xen_shared_info to be able to
      access some parts of the structure, like the wallclock, more conveniently.
      Because of that, we need a type cast.
      6fc3d663
    • Glauber Costa's avatar
      generalize interrupt handler further · 4fbb1834
      Glauber Costa authored
      Xen does not need to EOI. At least not with the APIC anywyay: it signals
      end of interrupt by flipping vcpu_info->evtchn_upcall_pending to 0, but
      that is already done by the BSD handler, so we might as well do nothing.
      
      Avi generalized the irq handler to have a pre_eoi and a handler, and in
      this patch I am taking the extra step of adding an EOI indirection as well.
      4fbb1834
    • Glauber Costa's avatar
      add uoff_t to netport.h · d4f0a78f
      Glauber Costa authored
      This is for the lack of a better place.
      d4f0a78f
    • Glauber Costa's avatar
      bus_dma verbatim copy · 2a4d0aa4
      Glauber Costa authored
      2a4d0aa4
    • Glauber Costa's avatar
      xen: verbatim copy of BSD's blkif header · d22e88c8
      Glauber Costa authored
      d22e88c8
    • Avi Kivity's avatar
      build: drop extraneous libstdc++ linking · ecbaccf3
      Avi Kivity authored
      Already specified elsewhere.  Noted by Nadav.
      ecbaccf3
    • Avi Kivity's avatar
      rcu: fix debug build re rcu_read_lock · 14865fa2
      Avi Kivity authored
      The release build optimizes away references to this object, but the debug
      build does not.  Define it.
      14865fa2
    • Avi Kivity's avatar
      dhcp: fix random dhcp failures · 26a04985
      Avi Kivity authored
      We don't initialize the dhcp packets, so some of them get the relay agent IP
      set, and the DHCP DISCOVER packets get sent to a random address on the
      Internet.  Usually it doesn't have a DHCP server installed, so the guest
      does not get configured.
      
      Fix by zero-initializing the packet.
      26a04985
    • Pekka Enberg's avatar
      cli: Catch errors for 'perf callstack' · fba58999
      Pekka Enberg authored
      Currently, looking up a non-existing tracepoint kills the guest:
      
      sun.org.mozilla.javascript.WrappedException: Wrapped java.lang.RuntimeException: Cannot find tracepoint (/console/perf.js#91)
      	at sun.org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1786)
      	at sun.org.mozilla.javascript.MemberBox.newInstance(MemberBox.java:202)
      	at sun.org.mozilla.javascript.NativeJavaClass.constructSpecific(NativeJavaClass.java:284)
      	at sun.org.mozilla.javascript.NativeJavaClass.construct(NativeJavaClass.java:202)
      	at sun.org.mozilla.javascript.ScriptRuntime.newObject(ScriptRuntime.java:2440)
      	at sun.org.mozilla.javascript.gen._console_perf_js_17._c_anonymous_7(/console/perf.js:91)
      	at sun.org.mozilla.javascript.gen._console_perf_js_17.call(/console/perf.js)
      	at sun.org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
      	at sun.org.mozilla.javascript.gen._console_perf_js_17._c_anonymous_10(/console/perf.js:114)
      	at sun.org.mozilla.javascript.gen._console_perf_js_17.call(/console/perf.js)
      	at sun.org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
      	at sun.org.mozilla.javascript.gen._console_perf_js_17._c_anonymous_1(/console/perf.js:8)
      	at sun.org.mozilla.javascript.gen._console_perf_js_17.call(/console/perf.js)
      	at sun.org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
      	at sun.org.mozilla.javascript.gen.cli_js_21._c_run_sync_15(cli.js:202)
      	at sun.org.mozilla.javascript.gen.cli_js_21.call(cli.js)
      	at sun.org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
      	at sun.org.mozilla.javascript.gen.cli_js_21._c_invoke_18(cli.js:223)
      	at sun.org.mozilla.javascript.gen.cli_js_21.call(cli.js)
      	at sun.org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
      	at sun.org.mozilla.javascript.gen.cli_js_21._c_command_19(cli.js:237)
      	at sun.org.mozilla.javascript.gen.cli_js_21.call(cli.js)
      	at sun.org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
      	at sun.org.mozilla.javascript.gen.cli_js_21._c_main_loop_21(cli.js:290)
      	at sun.org.mozilla.javascript.gen.cli_js_21.call(cli.js)
      	at sun.org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
      	at sun.org.mozilla.javascript.gen.cli_js_21._c_script_0(cli.js:323)
      	at sun.org.mozilla.javascript.gen.cli_js_21.call(cli.js)
      	at sun.org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)
      	at sun.org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3178)
      	at sun.org.mozilla.javascript.gen.cli_js_21.call(cli.js)
      	at sun.org.mozilla.javascript.gen.cli_js_21.exec(cli.js)
      	at sun.org.mozilla.javascript.Context.evaluateReader(Context.java:1142)
      	at com.cloudius.cli.main.RhinoCLI.run(Unknown Source)
      	at com.cloudius.cli.util.TelnetCLI.handleConnection(Unknown Source)
      	at com.cloudius.cli.util.TelnetD$1.run(Unknown Source)
      Caused by: java.lang.RuntimeException: Cannot find tracepoint
      	at com.cloudius.trace.Tracepoint.findByName(Native Method)
      	at com.cloudius.trace.Tracepoint.<init>(Unknown Source)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
      	at sun.org.mozilla.javascript.MemberBox.newInstance(MemberBox.java:194)
      	... 34 more
      
      Fix that by catching errors like "perf stat" does.
      fba58999
  2. Aug 12, 2013
    • Avi Kivity's avatar
      build: link libstdc++, libgcc_s only once · c9e61d4a
      Avi Kivity authored
      Currently we statically link to libstdc++ and libgcc_s, and also dynamically
      link to the same libraries (since the payload requires them).  This causes
      some symbols to be available from both the static and dynamic version.
      
      With the resolution order change introduced by 82513d41, we can
      resolve the same symbol to different addresses at different times.  This
      violates the One Definition Rule, and in fact breaks std::string's
      destructor.
      
      Fix by only linking in the libraries statically.  We use ld's --whole-archive
      flag to bring in all symbols, including those that may be used by the payload
      but not by the kernel.
      
      Some symbols now become duplicates; we drop our version.
      c9e61d4a
    • Avi Kivity's avatar
      runtime: add get_nprocs() · 286dd7a0
      Avi Kivity authored
      Needed to link the entirety of libstdc++.a.
      286dd7a0
    • Avi Kivity's avatar
      libc: add sigdelset() · 96f8d595
      Avi Kivity authored
      Needed for statically linking the entirety of libgcc_eh.a.
      96f8d595
    • Avi Kivity's avatar
      tst-lfring: reduce memory overhead · 20e7eb13
      Avi Kivity authored
      Reduce memory consumption so we can test in a 1GB guest.
      20e7eb13
    • Avi Kivity's avatar
      bsd: fix msleep() with mtx == NULL · 61c54fb2
      Avi Kivity authored
      msleep() will fault if mtx is NULL.
      61c54fb2
    • Avi Kivity's avatar
      tst-rwlock: fix rwlock test · 40d1a8fe
      Avi Kivity authored
      The test tries to acquire the write lock while the read lock is taken in the
      same thread, which deadlocks.
      
      Remove the deadlocking construct.
      40d1a8fe
    • Avi Kivity's avatar
      tst-bsd-taskqueue: fix taskqueue creation · 5ecaf3df
      Avi Kivity authored
      taskqueue_thread_enqueue expects a pointer to a pointer to the taskqueue as
      context, give it that.
      5ecaf3df
    • Avi Kivity's avatar
      tst-bsd-evh: reduce excessive printouts · 45cf1b95
      Avi Kivity authored
      45cf1b95
    • Avi Kivity's avatar
      vfs: relax dependency of close() performance on rcu grace periods · 43df74e7
      Avi Kivity authored
      Currently, we perform the final fdrop() in an rcu callback, which means it
      can have considerable latency.  This in turn places restrictions on
      further optimizations we can do to rcu, as we need prompt close() execution.
      
      Relax this by performing the fdrop() immediately, and only deferring the
      final free().  To do this, we harden fget() so it now expects files with
      positive refcounts, and make sure that after the final fdrop() refcounts
      are either zero or negative.
      
      This also makes close() take effect immediately, which fixes tst-pipe.so.
      43df74e7
    • Glauber Costa's avatar
      trivial: name the event channel fields in the vcpu · 0873adf5
      Glauber Costa authored
      There are two spaces for event channel fields in the xen vcpu data.  They were
      so far just a pad because we were not using event channels.  Name them, so we
      can use it. I am also taking the opportunity to fix the tabs/spaces in the
      structure.
      0873adf5
    • Avi Kivity's avatar
      bench: add TCP Echo client and server · 656ea3fa
      Avi Kivity authored
      656ea3fa
    • Avi Kivity's avatar
      virtio-net: advertise TSO on hwassist flags · caf0ca5c
      Avi Kivity authored
      Without this, the networking stack will ignore TSO.
      
      Improves Java Echo test from ~2Gbps to ~5Gbps.
      
      With Dor Laor.
      caf0ca5c
  3. Aug 11, 2013
  4. Aug 08, 2013
    • Nadav Har'El's avatar
      Dynamic linker - fix crash on SMP · d703ec00
      Nadav Har'El authored
      This patch fixes the following bug, of CLI & memcached on two vcpus
      crashing on startup. The cause of the crash is this: Java is running
      two threads. One loads a new shared library (in this example, libnio.so),
      and the second thread just running normally and runs some function it hasn't
      run before (pthread_cond_destroy()). When our on-demand resolver code tries
      to resolve this function name, it iterates over the module list, and sees
      libnio.so, but this object hasn't been completely set up yet (we put it in
      the list first - see program::add_object()), so looking up a symbol in it
      crashes.
      
      Why hasn't this problem been noticed before the recent link-order change?
      Because before that change, the half-loaded library was always last in the
      list (OSV itself was the first), so existing symbols were always found before
      reaching the partially-set-up object. Now OSV, with many symbols, is last, and
      the half-set-up object is in the middle, so the problem is common. But it
      also could happen previously, if we had unresolved symbols (e.g., weak symbols),
      but these were probably rare enough for the bug not to happen in practice.
      
      The fix in this patch is "hacky", because I wanted to avoid restructuring
      the whole code. The problem is that the functions called in add_object()
      (including relocate_rela(), nested add_object(), etc.) all assume that
      they can look up symbols in the being-set-up object, while we don't want
      these objects to be visible for other threads. So we do exactly this -
      each object gets a "visiblity" field. If "visibility" is 0, all threads
      can use this object, but if visibility is a thread pointer, only this
      thread searches in this object. So add_object() starts the object
      with visibility set to its thread, and only when add_object() is done,
      it sets the visibility to 0 so all threads can see it.
      
      While this solves the common bug, not that this patch still leaves
      a small room for SMP bugs, because it doesn't add locking to _modules,
      so a lookup during an add_object() can see a broken vector for a short
      duration. We should fix this remaining problem later, using RCU.
      d703ec00
    • Nadav Har'El's avatar
      dl_iterate_phdr: Don't pass pointers on the stack to callback · a26fe58c
      Nadav Har'El authored
      This patch fixes the exception handling bug seen in tst-except.so.
      
      The callback given dl_iterate_phdr (such as _Unwind_IteratePhdrCallback
      in libgcc_eh.a used to implement exceptions) may decide to cache previous
      information we gave it, as long as the "adds" and "subs" fields are
      unchanged.
      
      The bug was that we passed to the callback a on-stack *copy* of the
      obj->_phdrs vector, and if the callback saved pointers to that in its
      cache, they became invalid on the next call. We need the pointers to
      remain valid as long as adds/subs do not change. So we need to pass
      the actual obj->_phdrs (which doesn't change after the object's load),
      NOT a copy.
      
      Note there's a locking issue remaining here - if someone dlclose()s
      an object while the callback is running (and already checked adds/subs)
      it can use a stale pointer. This should be fixed separately, probably
      by using reference counting on objects.
      a26fe58c
    • Nadav Har'El's avatar
      dl_iterate_phdr: fill missing adds and subs field · 4d8353ac
      Nadav Har'El authored
      The callback function passed to dl_iterate_phdr, such as
      _UnWind_IteratePhdrCallback (used in libgcc_eh.a to implement exceptions),
      may want to cache previous lookups, and wants to know when the list of
      iterated modules hasn't changed since the last call to dl_iterate_phdr.
      For this, dl_iterate_phdr() is supposed to fill two fields, dlpi_adds
      and dlpi_subs, counting the number of times objects were loaded or
      unloaded from the program. If both dlpi_subs and dlpi_adds are unchanged,
      the callback is guaranteed the list of objects is unchanged.
      
      In the existing code, we forgot to set these two fields, so they got
      random values which caused the exception unwinding code to sometimes
      cache, and sometime not cache, depending on the phase of the moon.
      
      This patch adds the counting of the correct "subs" and "adds" counters,
      and after it exception unwinding will always use its cache (as long
      as the list of objects doesn't change).
      
      Note that this does NOT fix the crash in tst-except.so. That is a bug
      which appears when caching is enabled (which before this patch happend
      randomly), and will be fixed by the next patch.
      4d8353ac
    • Christoph Hellwig's avatar
      zfs: enable log replay · 6883527e
      Christoph Hellwig authored
      6883527e
    • Christoph Hellwig's avatar
    • Christoph Hellwig's avatar
      88ef6ce9
    • Glauber Costa's avatar
      console: automatically insert CR · f6a464df
      Glauber Costa authored
      Our console works well with KVM, that redirects the serial to stdio. In Xen,
      this seems not to work very well (some documentation sources - not all - lists
      'serial="stdio"' as a valid option, but it doesn't really work). In that case,
      LFs are not automatically translated into CRLF and the terminal output is totally
      borked.
      
      This is obviously not exclusive to Xen: by changing our qemu command line to run
      a pts instead of stdio, and then connecting to that pts, the same thing happens.
      
      This patch modifies our console's write() function to respect the termios ONLCR
      flag, which is now set by default. When write() sees a newline character and
      this flag is set we output a CF before any LF.
      
      The termios structure is left outside the specific console, and we pass a
      pointer down to it. Our pre-console implementation of simple_write outputs CRs
      unconditionally.
      
      The normal stdio serial still works. Telnet still works.
      f6a464df
    • Glauber Costa's avatar
      cli: insert missing carriage return · 35df99c4
      Glauber Costa authored
      When we call render, we are still in raw mode. So we need to insert the carriage
      return ourselves.
      35df99c4
Loading