mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-18 21:27:56 +00:00
parent
c943e26913
commit
bba4790002
@ -16,7 +16,6 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/thread.h>
|
||||
#include <base/lock.h>
|
||||
#include <base/log.h>
|
||||
|
||||
/* NOVA includes */
|
||||
@ -34,10 +33,10 @@ namespace Vmm {
|
||||
{
|
||||
struct Utcb_backup { char buf[Nova::Utcb::size()]; };
|
||||
|
||||
static Lock lock;
|
||||
static Mutex mutex;
|
||||
static Utcb_backup utcb_backup;
|
||||
|
||||
Lock::Guard guard(lock);
|
||||
Mutex::Guard guard(mutex);
|
||||
|
||||
utcb_backup = *(Utcb_backup *)Thread::myself()->utcb();
|
||||
|
||||
@ -51,10 +50,10 @@ namespace Vmm {
|
||||
{
|
||||
struct Utcb_backup { char buf[Nova::Utcb::size()]; };
|
||||
|
||||
static Lock lock;
|
||||
static Mutex mutex;
|
||||
static Utcb_backup utcb_backup;
|
||||
|
||||
Lock::Guard guard(lock);
|
||||
Mutex::Guard guard(mutex);
|
||||
|
||||
utcb_backup = *(Utcb_backup *)Thread::myself()->utcb();
|
||||
|
||||
@ -68,10 +67,10 @@ namespace Vmm {
|
||||
{
|
||||
struct Utcb_backup { char buf[Nova::Utcb::size()]; };
|
||||
|
||||
static Lock lock;
|
||||
static Mutex mutex;
|
||||
static Utcb_backup utcb_backup;
|
||||
|
||||
Lock::Guard guard(lock);
|
||||
Mutex::Guard guard(mutex);
|
||||
|
||||
utcb_backup = *(Utcb_backup *)Thread::myself()->utcb();
|
||||
|
||||
|
@ -219,11 +219,11 @@ struct Timer_queue : public Qemu::Timer_queue
|
||||
|
||||
Qemu::int64_t get_ns() { return TMTimerGetNano(tm_timer); }
|
||||
|
||||
Genode::Lock _timer_lock;
|
||||
Genode::Mutex _timer_mutex { };
|
||||
|
||||
void register_timer(void *qtimer, void (*cb)(void*), void *data) override
|
||||
{
|
||||
Genode::Lock::Guard lock_guard(_timer_lock);
|
||||
Genode::Mutex::Guard guard(_timer_mutex);
|
||||
if (verbose_timer)
|
||||
Genode::log("qtimer: ", qtimer, " cb: ", cb, " data: ", data);
|
||||
|
||||
@ -238,7 +238,7 @@ struct Timer_queue : public Qemu::Timer_queue
|
||||
|
||||
void delete_timer(void *qtimer) override
|
||||
{
|
||||
Genode::Lock::Guard lock_guard(_timer_lock);
|
||||
Genode::Mutex::Guard guard(_timer_mutex);
|
||||
if (verbose_timer)
|
||||
Genode::log("qtimer: ", qtimer);
|
||||
|
||||
@ -256,7 +256,7 @@ struct Timer_queue : public Qemu::Timer_queue
|
||||
|
||||
void activate_timer(void *qtimer, long long int expire_abs) override
|
||||
{
|
||||
Genode::Lock::Guard lock_guard(_timer_lock);
|
||||
Genode::Mutex::Guard guard(_timer_mutex);
|
||||
if (verbose_timer)
|
||||
Genode::log("qtimer: ", qtimer, " expire: ", expire_abs);
|
||||
|
||||
@ -274,7 +274,7 @@ struct Timer_queue : public Qemu::Timer_queue
|
||||
|
||||
void deactivate_timer(void *qtimer) override
|
||||
{
|
||||
Genode::Lock::Guard lock_guard(_timer_lock);
|
||||
Genode::Mutex::Guard guard(_timer_mutex);
|
||||
if (verbose_timer)
|
||||
Genode::log("qtimer: ", qtimer);
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
#include <base/log.h>
|
||||
#include <base/sleep.h>
|
||||
|
||||
#include <string.h> /* libc memcpy */
|
||||
|
||||
@ -163,8 +164,7 @@ char *pdmR3FileR3(const char * file, bool)
|
||||
void RTAssertMsg2Add(const char *pszFormat, ...)
|
||||
{
|
||||
Genode::error(__func__, "not implemented");
|
||||
Genode::Lock lock(Genode::Lock::LOCKED);
|
||||
lock.lock();
|
||||
Genode::sleep_forever();
|
||||
}
|
||||
|
||||
const char * RTBldCfgRevisionStr(void)
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <base/heap.h>
|
||||
#include <base/log.h>
|
||||
#include <base/semaphore.h>
|
||||
#include <base/sleep.h>
|
||||
#include <util/flex_iterator.h>
|
||||
#include <rom_session/connection.h>
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
@ -728,8 +729,7 @@ uint64_t genode_cpu_hz()
|
||||
|
||||
if (cpu_freq == 0) {
|
||||
Genode::error("could not read out CPU frequency");
|
||||
Genode::Lock lock;
|
||||
lock.lock();
|
||||
Genode::sleep_forever();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,14 +48,14 @@ static struct {
|
||||
static Libc::Mem_alloc * heap_by_mmtag(MMTAG enmTag)
|
||||
{
|
||||
enum { REGION_SIZE = 4096 * 4096 };
|
||||
static Genode::Lock memory_init_lock;
|
||||
static Genode::Mutex memory_init_mutex { };
|
||||
|
||||
Assert(enmTag < sizeof(memory_regions) / sizeof(memory_regions[0]));
|
||||
|
||||
if (memory_regions[enmTag].conn)
|
||||
return memory_regions[enmTag].heap;
|
||||
|
||||
Genode::Lock::Guard guard(memory_init_lock);
|
||||
Genode::Mutex::Guard guard(memory_init_mutex);
|
||||
|
||||
if (memory_regions[enmTag].conn)
|
||||
return memory_regions[enmTag].heap;
|
||||
|
@ -81,10 +81,10 @@ typedef struct DRVNIC
|
||||
* Return lock to synchronize the destruction of the
|
||||
* PDRVNIC, i.e., the Nic_client.
|
||||
*/
|
||||
static Genode::Lock *destruct_lock()
|
||||
static Genode::Blockade &destruct_blockade()
|
||||
{
|
||||
static Genode::Lock lock(Genode::Lock::LOCKED);
|
||||
return &lock;
|
||||
static Genode::Blockade blockade { };
|
||||
return blockade;
|
||||
}
|
||||
|
||||
|
||||
@ -153,7 +153,7 @@ class Nic_client
|
||||
_nic.rx_channel()->sigh_packet_avail(Genode::Signal_context_capability());
|
||||
_nic.rx_channel()->sigh_ready_to_ack(Genode::Signal_context_capability());
|
||||
|
||||
destruct_lock()->unlock();
|
||||
destruct_blockade().wakeup();
|
||||
}
|
||||
|
||||
void _tx_ack(bool block = false)
|
||||
@ -451,7 +451,7 @@ static DECLCALLBACK(void) drvNicDestruct(PPDMDRVINS pDrvIns)
|
||||
Genode::Signal_transmitter(nic_client->dispatcher()).submit();
|
||||
|
||||
/* wait until the recv thread exits */
|
||||
destruct_lock()->lock();
|
||||
destruct_blockade().block();
|
||||
|
||||
if (nic_client)
|
||||
destroy(vmm_heap(), nic_client);
|
||||
|
@ -189,7 +189,12 @@ class Avl_ds : public Genode::Avl_node<Avl_ds>
|
||||
|
||||
Genode::Avl_tree<Avl_ds> Avl_ds::_runtime_ds;
|
||||
Genode::Avl_tree<Avl_ds> Avl_ds::_unused_ds;
|
||||
static Genode::Lock lock_ds;
|
||||
|
||||
static Genode::Mutex & mutex_ds()
|
||||
{
|
||||
static Genode::Mutex mutex { };
|
||||
return mutex;
|
||||
}
|
||||
|
||||
Genode::addr_t Avl_ds::hit = 0;
|
||||
Genode::addr_t Avl_ds::hit_coarse = 0;
|
||||
@ -209,7 +214,7 @@ static void *alloc_mem(size_t cb, const char *pszTag, bool executable = false)
|
||||
if (cb % 0x1000)
|
||||
cb = (cb & ~0xFFFUL) + 0x1000UL;
|
||||
|
||||
Lock::Guard guard(lock_ds);
|
||||
Mutex::Guard guard(mutex_ds());
|
||||
|
||||
if (Avl_ds * ds_free = Avl_ds::find_match(cb)) {
|
||||
ds_free->used(cb);
|
||||
@ -281,7 +286,7 @@ void *RTMemPageAllocTag(size_t cb, const char *pszTag)
|
||||
|
||||
void RTMemPageFree(void *pv, size_t cb)
|
||||
{
|
||||
Genode::Lock::Guard guard(lock_ds);
|
||||
Genode::Mutex::Guard guard(mutex_ds());
|
||||
|
||||
Avl_ds::free_memory(pv, cb);
|
||||
}
|
||||
@ -323,7 +328,7 @@ void * RTMemTCGAlloc(size_t cb)
|
||||
return alloc_mem(cb, __func__);
|
||||
|
||||
{
|
||||
Genode::Lock::Guard guard(lock_ds);
|
||||
Genode::Mutex::Guard guard(mutex_ds());
|
||||
|
||||
for (Tcg_slab * tcg = list.first(); tcg; tcg = tcg->next()) {
|
||||
if (tcg->_full)
|
||||
@ -341,7 +346,7 @@ void * RTMemTCGAlloc(size_t cb)
|
||||
Tcg_slab * tcg = new (vmm_heap()) Tcg_slab(alloc_mem(TCG_CACHE, __func__));
|
||||
if (tcg && tcg->_base) {
|
||||
{
|
||||
Genode::Lock::Guard guard(lock_ds);
|
||||
Genode::Mutex::Guard guard(mutex_ds());
|
||||
list.insert(tcg);
|
||||
}
|
||||
return RTMemTCGAlloc(cb);
|
||||
@ -367,7 +372,7 @@ void * RTMemTCGAllocZ(size_t cb)
|
||||
|
||||
void RTMemTCGFree(void *pv)
|
||||
{
|
||||
Genode::Lock::Guard guard(lock_ds);
|
||||
Genode::Mutex::Guard guard(mutex_ds());
|
||||
|
||||
Genode::addr_t const ptr = reinterpret_cast<Genode::addr_t>(pv);
|
||||
for (Tcg_slab * tcg = list.first(); tcg; tcg = tcg->next()) {
|
||||
@ -393,7 +398,7 @@ void * RTMemTCGRealloc(void *ptr, size_t size)
|
||||
|
||||
Genode::addr_t max_size = 0;
|
||||
{
|
||||
Genode::Lock::Guard guard(lock_ds);
|
||||
Genode::Mutex::Guard guard(mutex_ds());
|
||||
|
||||
max_size = Avl_ds::max_size_at(ptr);
|
||||
if (!max_size) {
|
||||
|
@ -700,8 +700,7 @@ uint64_t genode_cpu_hz()
|
||||
|
||||
if (cpu_freq == 0) {
|
||||
Genode::error("could not read out CPU frequency");
|
||||
Genode::Lock lock;
|
||||
lock.lock();
|
||||
Genode::sleep_forever();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/log.h>
|
||||
#include <base/sleep.h>
|
||||
#include <cpu/consts.h>
|
||||
#include <util/flex_iterator.h>
|
||||
#include <util/touch.h>
|
||||
@ -858,8 +859,7 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher<Genode::Thread>,
|
||||
|
||||
if (ec_ctrl(EC_RECALL, _ec_sel) != NOVA_OK) {
|
||||
Genode::error("recall failed");
|
||||
Genode::Lock lock(Genode::Lock::LOCKED);
|
||||
lock.lock();
|
||||
Genode::sleep_forever();
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -14,6 +14,7 @@
|
||||
/* Genode */
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <base/log.h>
|
||||
#include <base/sleep.h>
|
||||
#include <base/thread.h>
|
||||
#include <cpu_session/connection.h>
|
||||
|
||||
@ -60,11 +61,11 @@ static Genode::Cpu_connection * cpu_connection(RTTHREADTYPE type)
|
||||
using namespace Genode;
|
||||
|
||||
static Cpu_connection * con[RTTHREADTYPE_END - 1];
|
||||
static Lock lock;
|
||||
static Mutex mutex { };
|
||||
|
||||
Assert(type && type < RTTHREADTYPE_END);
|
||||
|
||||
Lock::Guard guard(lock);
|
||||
Mutex::Guard guard(mutex);
|
||||
|
||||
if (con[type - 1])
|
||||
return con[type - 1];
|
||||
@ -168,8 +169,7 @@ extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
}
|
||||
|
||||
Genode::error("could not create vbox pthread - halt");
|
||||
Genode::Lock lock(Genode::Lock::LOCKED);
|
||||
lock.lock();
|
||||
Genode::sleep_forever();
|
||||
return EAGAIN;
|
||||
}
|
||||
|
||||
|
@ -66,12 +66,12 @@ class Vcpu_handler : public Genode::List<Vcpu_handler>::Element
|
||||
protected:
|
||||
|
||||
Genode::Entrypoint _ep;
|
||||
Genode::Lock _lock_emt;
|
||||
Genode::Blockade _blockade_emt { };
|
||||
Genode::Semaphore _sem_handler;
|
||||
Genode::Vm_state *_state { nullptr };
|
||||
|
||||
/* halt / wakeup handling with timeout support */
|
||||
Genode::Lock _r0_block_guard;
|
||||
Genode::Mutex _r0_mutex;
|
||||
Genode::Semaphore _r0_block;
|
||||
Genode::uint64_t _r0_wakeup_abs { 0 };
|
||||
|
||||
@ -152,7 +152,7 @@ class Vcpu_handler : public Genode::List<Vcpu_handler>::Element
|
||||
_sem_handler.up();
|
||||
|
||||
/* wait for next exit */
|
||||
_lock_emt.lock();
|
||||
_blockade_emt.block();
|
||||
|
||||
/* next time run - recall() may change this */
|
||||
_next_state = RUN;
|
||||
@ -173,7 +173,7 @@ class Vcpu_handler : public Genode::List<Vcpu_handler>::Element
|
||||
if (npt_ept_unmap) {
|
||||
Genode::error("NPT/EPT unmap not supported - stop");
|
||||
while (true) {
|
||||
_lock_emt.lock();
|
||||
_blockade_emt.block();
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ class Vcpu_handler : public Genode::List<Vcpu_handler>::Element
|
||||
|
||||
_vm_state = PAUSED;
|
||||
|
||||
_lock_emt.unlock();
|
||||
_blockade_emt.wakeup();
|
||||
}
|
||||
|
||||
bool _recall_handler()
|
||||
@ -479,7 +479,7 @@ class Vcpu_handler : public Genode::List<Vcpu_handler>::Element
|
||||
_vm_exits ++;
|
||||
|
||||
_vm_state = IRQ_WIN;
|
||||
_lock_emt.unlock();
|
||||
_blockade_emt.wakeup();
|
||||
}
|
||||
|
||||
void _npt_ept()
|
||||
@ -491,7 +491,7 @@ class Vcpu_handler : public Genode::List<Vcpu_handler>::Element
|
||||
_vm_exits ++;
|
||||
|
||||
_vm_state = NPT_EPT;
|
||||
_lock_emt.unlock();
|
||||
_blockade_emt.wakeup();
|
||||
}
|
||||
|
||||
void _irq_window_pthread()
|
||||
@ -725,7 +725,7 @@ class Vcpu_handler : public Genode::List<Vcpu_handler>::Element
|
||||
void check_time()
|
||||
{
|
||||
{
|
||||
Genode::Lock_guard<Genode::Lock> lock(_r0_block_guard);
|
||||
Genode::Mutex::Guard guard(_r0_mutex);
|
||||
|
||||
const uint64_t u64NowGip = RTTimeNanoTS();
|
||||
if (!_r0_wakeup_abs || _r0_wakeup_abs >= u64NowGip)
|
||||
@ -738,7 +738,7 @@ class Vcpu_handler : public Genode::List<Vcpu_handler>::Element
|
||||
void halt(Genode::uint64_t rttime_abs)
|
||||
{
|
||||
{
|
||||
Genode::Lock_guard<Genode::Lock> lock(_r0_block_guard);
|
||||
Genode::Mutex::Guard guard(_r0_mutex);
|
||||
_r0_wakeup_abs = rttime_abs;
|
||||
}
|
||||
|
||||
@ -748,7 +748,7 @@ class Vcpu_handler : public Genode::List<Vcpu_handler>::Element
|
||||
void wake_up()
|
||||
{
|
||||
{
|
||||
Genode::Lock_guard<Genode::Lock> lock(_r0_block_guard);
|
||||
Genode::Mutex::Guard guard(_r0_mutex);
|
||||
_r0_wakeup_abs = 0;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ class Vcpu_handler_svm : public Vcpu_handler
|
||||
break;
|
||||
case VCPU_STARTUP:
|
||||
_svm_startup();
|
||||
_lock_emt.unlock();
|
||||
_blockade_emt.wakeup();
|
||||
/* pause - no resume */
|
||||
break;
|
||||
default:
|
||||
@ -170,13 +170,10 @@ class Vcpu_handler_svm : public Vcpu_handler
|
||||
{
|
||||
_state = _state_ds.local_addr<Genode::Vm_state>();
|
||||
|
||||
/* sync with initial startup exception */
|
||||
_lock_emt.lock();
|
||||
|
||||
_vm_session.run(_vcpu);
|
||||
|
||||
/* sync with initial startup exception */
|
||||
_lock_emt.lock();
|
||||
_blockade_emt.block();
|
||||
}
|
||||
|
||||
bool hw_save_state(Genode::Vm_state *state, VM * pVM, PVMCPU pVCpu) {
|
||||
|
@ -156,7 +156,7 @@ class Vcpu_handler_vmx : public Vcpu_handler
|
||||
break;
|
||||
case VCPU_STARTUP:
|
||||
_vmx_startup();
|
||||
_lock_emt.unlock();
|
||||
_blockade_emt.wakeup();
|
||||
/* pause - no resume */
|
||||
break;
|
||||
default:
|
||||
@ -245,13 +245,10 @@ class Vcpu_handler_vmx : public Vcpu_handler
|
||||
{
|
||||
_state = _state_ds.local_addr<Genode::Vm_state>();
|
||||
|
||||
/* sync with initial startup exception */
|
||||
_lock_emt.lock();
|
||||
|
||||
_vm_session.run(_vcpu);
|
||||
|
||||
/* sync with initial startup exception */
|
||||
_lock_emt.lock();
|
||||
_blockade_emt.block();
|
||||
}
|
||||
|
||||
bool hw_save_state(Genode::Vm_state *state, VM * pVM, PVMCPU pVCpu) {
|
||||
|
Loading…
Reference in New Issue
Block a user