diff --git a/repos/base-fiasco/lib/mk/kernel-fiasco.inc b/repos/base-fiasco/lib/mk/kernel-fiasco.inc index 7a01b47126..19e12408fb 100644 --- a/repos/base-fiasco/lib/mk/kernel-fiasco.inc +++ b/repos/base-fiasco/lib/mk/kernel-fiasco.inc @@ -6,6 +6,9 @@ FIASCO_SRC = $(L4_SRC_DIR)/kernel/fiasco KERNEL_BUILD_OUTPUT_FILTER = 2>&1 | sed "s/^/ [fiasco] /" +KERNEL_CXXFLAGS = -std=gnu++98 -fno-delete-null-pointer-checks $(CXXWARN) \ + -Wno-address-of-packed-member + $(FIASCO_BUILD_DIR): $(VERBOSE_MK) set -o pipefail; \ MAKEFLAGS= $(MAKE) SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" \ @@ -21,7 +24,7 @@ $(FIASCO_BUILD_DIR): $(FIASCO): $(FIASCO_BUILD_DIR) $(VERBOSE_MK) set -o pipefail; \ MAKEFLAGS= CFLAGS="-std=gnu89 $(CWARN)" \ - CXXFLAGS="-std=gnu++98 -fno-delete-null-pointer-checks $(CXXWARN)" \ + CXXFLAGS="$(KERNEL_CXXFLAGS)" \ $(MAKE) SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" \ $(VERBOSE_DIR) -C $(FIASCO_BUILD_DIR) \ $(KERNEL_BUILD_OUTPUT_FILTER) diff --git a/repos/base-fiasco/src/core/include/platform_pd.h b/repos/base-fiasco/src/core/include/platform_pd.h index 1b139f7000..d1ee34b88d 100644 --- a/repos/base-fiasco/src/core/include/platform_pd.h +++ b/repos/base-fiasco/src/core/include/platform_pd.h @@ -46,6 +46,7 @@ class Genode::Platform_pd : public Address_space enum { VERSION_BITS = 10, + VERSION_MASK = (1 << VERSION_BITS) - 1, PD_FIRST = 0x10, PD_MAX = (1 << 11) - 1, /* leave 0x7ff free for L4_INVALID_ID */ PD_VERSION_MAX = (1 << 10) - 1, @@ -101,7 +102,7 @@ class Genode::Platform_pd : public Address_space unsigned version : VERSION_BITS; Pd_alloc(bool r, bool f, unsigned v) - : reserved(r), free(f), version(v) { } + : reserved(r), free(f), version(v & VERSION_MASK) { } Pd_alloc() : reserved(0), free(0), version(0) { } }; diff --git a/repos/base-fiasco/src/core/platform_pd.cc b/repos/base-fiasco/src/core/platform_pd.cc index b8d1b9b017..c3196ba628 100644 --- a/repos/base-fiasco/src/core/platform_pd.cc +++ b/repos/base-fiasco/src/core/platform_pd.cc @@ -58,10 +58,13 @@ void Platform_pd::init() void Platform_pd::_create_pd(bool syscall) { + enum { TASK_ID_MASK = (1 << 11) - 1, + VERSION_LOW_MASK = (1 << 10) - 1 }; + l4_threadid_t l4t = l4_myself(); - l4t.id.task = _pd_id; + l4t.id.task = _pd_id & TASK_ID_MASK; l4t.id.lthread = 0; - l4t.id.version_low = _version; + l4t.id.version_low = _version & VERSION_LOW_MASK; l4_taskid_t nt; if (syscall) @@ -203,8 +206,10 @@ bool Platform_pd::bind_thread(Platform_thread &thread) } thread_id = t; + enum { LTHREAD_MASK = (1 << 7) - 1 }; + l4_thread_id = _l4_task_id; - l4_thread_id.id.lthread = thread_id; + l4_thread_id.id.lthread = thread_id & LTHREAD_MASK; /* finally inform thread about binding */ thread.bind(thread_id, l4_thread_id, *this); diff --git a/repos/base-fiasco/src/include/fiasco/syscall.h b/repos/base-fiasco/src/include/fiasco/syscall.h index b1f3cc8701..dfc172ca18 100644 --- a/repos/base-fiasco/src/include/fiasco/syscall.h +++ b/repos/base-fiasco/src/include/fiasco/syscall.h @@ -15,6 +15,10 @@ #define _INCLUDE__FIASCO__SYSCALL_H_ namespace Fiasco { + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" + #include #include #include @@ -24,6 +28,8 @@ namespace Fiasco { #include #include #include + +#pragma GCC diagnostic pop /* restore -Wconversion warnings */ } #endif /* _INCLUDE__FIASCO__SYSCALL_H_ */ diff --git a/repos/base-fiasco/src/lib/base/ipc.cc b/repos/base-fiasco/src/lib/base/ipc.cc index d20aa41f41..1fd36c4caf 100644 --- a/repos/base-fiasco/src/lib/base/ipc.cc +++ b/repos/base-fiasco/src/lib/base/ipc.cc @@ -32,9 +32,9 @@ class Msg_header private: /* kernel-defined message header */ - l4_fpage_t rcv_fpage; /* unused */ - l4_msgdope_t size_dope; - l4_msgdope_t send_dope; + l4_fpage_t _rcv_fpage; /* unused */ + l4_msgdope_t _size_dope; + l4_msgdope_t _send_dope; public: @@ -52,6 +52,8 @@ class Msg_header enum { MAX_CAPS_PER_MSG = Msgbuf_base::MAX_CAPS_PER_MSG }; + enum { SIZE_DOPE_MASK = 0x3ffff }; + l4_threadid_t _cap_tid [MAX_CAPS_PER_MSG]; unsigned long _cap_local_name [MAX_CAPS_PER_MSG]; @@ -68,7 +70,7 @@ class Msg_header public: - void *msg_start() { return &rcv_fpage; } + void *msg_start() { return &_rcv_fpage; } /** * Load header fields according to send-message buffer @@ -79,7 +81,8 @@ class Msg_header num_caps = min((unsigned)MAX_CAPS_PER_MSG, snd_msg.used_caps()); size_t const snd_words = snd_msg.data_size()/sizeof(l4_umword_t); - send_dope = L4_IPC_DOPE(_num_msg_words(snd_words), 0); + + _send_dope = L4_IPC_DOPE(_num_msg_words(snd_words) & SIZE_DOPE_MASK, 0); /* reset _cap_tid and _cap_local_name */ for (unsigned i = 0; i < MAX_CAPS_PER_MSG; i++) { @@ -107,7 +110,7 @@ class Msg_header { size_t const rcv_max_words = rcv_msg.capacity()/sizeof(l4_umword_t); - size_dope = L4_IPC_DOPE(_num_msg_words(rcv_max_words), 0); + _size_dope = L4_IPC_DOPE(_num_msg_words(rcv_max_words) & SIZE_DOPE_MASK, 0); } /** diff --git a/repos/base-foc/include/foc/syscall.h b/repos/base-foc/include/foc/syscall.h index 2c13712dac..17726968e0 100644 --- a/repos/base-foc/include/foc/syscall.h +++ b/repos/base-foc/include/foc/syscall.h @@ -14,6 +14,9 @@ #ifndef _INCLUDE__FOC__SYSCALL_H_ #define _INCLUDE__FOC__SYSCALL_H_ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" + namespace Foc { #include #include @@ -33,4 +36,6 @@ namespace Foc { #include } +#pragma GCC diagnostic pop /* restore -Wconversion warnings */ + #endif /* _INCLUDE__FOC__SYSCALL_H_ */ diff --git a/repos/base-foc/include/foc/thread_state.h b/repos/base-foc/include/foc/thread_state.h index 9936c58278..fa53bd7155 100644 --- a/repos/base-foc/include/foc/thread_state.h +++ b/repos/base-foc/include/foc/thread_state.h @@ -26,7 +26,7 @@ namespace Genode { struct Foc_thread_state; } struct Genode::Foc_thread_state : Thread_state { Foc::l4_cap_idx_t kcap; /* thread's gate cap in its PD */ - int id; /* ID of gate capability */ + uint16_t id; /* ID of gate capability */ addr_t utcb; /* thread's UTCB in its PD */ /** diff --git a/repos/base-foc/src/core/include/cap_id_alloc.h b/repos/base-foc/src/core/include/cap_id_alloc.h index e368fb3cec..dc3c84a10a 100644 --- a/repos/base-foc/src/core/include/cap_id_alloc.h +++ b/repos/base-foc/src/core/include/cap_id_alloc.h @@ -25,6 +25,12 @@ namespace Genode { class Cap_id_allocator; } class Genode::Cap_id_allocator { + public: + + using id_t = uint16_t; + + enum { ID_MASK = 0xffff }; + private: enum { @@ -44,8 +50,8 @@ class Genode::Cap_id_allocator Cap_id_allocator(Allocator &); - unsigned long alloc(); - void free(unsigned long id); + id_t alloc(); + void free(id_t id); }; #endif /* _CORE__INCLUDE__CAP_ID_ALLOC_H_ */ diff --git a/repos/base-foc/src/core/include/irq_object.h b/repos/base-foc/src/core/include/irq_object.h index 7ea4e040df..ef1604e2cc 100644 --- a/repos/base-foc/src/core/include/irq_object.h +++ b/repos/base-foc/src/core/include/irq_object.h @@ -38,7 +38,7 @@ class Genode::Irq_object Irq_session::Polarity _polarity; /* interrupt polarity */ unsigned _irq; - addr_t _msi_addr; + uint64_t _msi_addr; addr_t _msi_data; Signal_context_capability _sig_cap { }; @@ -53,8 +53,8 @@ class Genode::Irq_object Irq_session::Trigger trigger() const { return _trigger; } Irq_session::Polarity polarity() const { return _polarity; } - Genode::addr_t msi_address() const { return _msi_addr; } - Genode::addr_t msi_value() const { return _msi_data; } + uint64_t msi_address() const { return _msi_addr; } + addr_t msi_value() const { return _msi_data; } void sigh(Genode::Signal_context_capability cap) { _sig_cap = cap; } void notify() { Genode::Signal_transmitter(_sig_cap).submit(1); } diff --git a/repos/base-foc/src/core/include/map_local.h b/repos/base-foc/src/core/include/map_local.h index 0448980675..4bfbacfe0b 100644 --- a/repos/base-foc/src/core/include/map_local.h +++ b/repos/base-foc/src/core/include/map_local.h @@ -45,7 +45,7 @@ namespace Genode { using namespace Foc; l4_fpage_t snd_fpage = l4_fpage(from_addr + offset, - page_size_log2, L4_FPAGE_RW); + (unsigned)page_size_log2, L4_FPAGE_RW); if (l4_msgtag_has_error(l4_task_map(L4_BASE_TASK_CAP, L4_BASE_TASK_CAP, @@ -95,13 +95,13 @@ namespace Genode { if (can_use_super_page(from_addr + offset, size)) page_size_log2 = get_super_page_size_log2(); l4_utcb_mr()->mr[1] = l4_fpage(from_addr + offset, - page_size_log2, L4_FPAGE_RWX).raw; + (unsigned)page_size_log2, L4_FPAGE_RWX).raw; /* open receive window for mapping */ l4_utcb_br()->bdr = 0; l4_utcb_br()->br[0] = L4_ITEM_MAP; l4_utcb_br()->br[1] = l4_fpage((addr_t)to_addr + offset, - page_size_log2, L4_FPAGE_RWX).raw; + (unsigned)page_size_log2, L4_FPAGE_RWX).raw; l4_msgtag_t tag = l4_msgtag(L4_PROTO_SIGMA0, 2, 0, 0); tag = l4_ipc_call(L4_BASE_PAGER_CAP, l4_utcb(), tag, L4_IPC_NEVER); diff --git a/repos/base-foc/src/core/io_mem_session_support.cc b/repos/base-foc/src/core/io_mem_session_support.cc index a434511564..891a300dbb 100644 --- a/repos/base-foc/src/core/io_mem_session_support.cc +++ b/repos/base-foc/src/core/io_mem_session_support.cc @@ -34,7 +34,7 @@ addr_t Io_mem_session_component::_map_local(addr_t base, size_t size) : get_page_size_log2(); /* find appropriate region for mapping */ - return platform().region_alloc().alloc_aligned(size, alignment).convert( + return platform().region_alloc().alloc_aligned(size, (unsigned)alignment).convert( [&] (void *local_base) { if (!map_local_io(base, (addr_t)local_base, size >> get_page_size_log2())) { diff --git a/repos/base-foc/src/core/ipc_pager.cc b/repos/base-foc/src/core/ipc_pager.cc index 98c3b08839..0be90ad79b 100644 --- a/repos/base-foc/src/core/ipc_pager.cc +++ b/repos/base-foc/src/core/ipc_pager.cc @@ -86,7 +86,7 @@ void Ipc_pager::wait_for_fault() do { _tag = l4_ipc_wait(l4_utcb(), &label, L4_IPC_NEVER); - int err = l4_ipc_error(_tag, l4_utcb()); + l4_umword_t err = l4_ipc_error(_tag, l4_utcb()); if (!err) { _parse(label); return; @@ -121,7 +121,7 @@ void Ipc_pager::reply_and_wait_for_fault() }; l4_fpage_t const fpage = l4_fpage(_reply_mapping.src_addr, - _reply_mapping.size_log2, + (unsigned)_reply_mapping.size_log2, rights(_reply_mapping.writeable, _reply_mapping.executable)); @@ -129,7 +129,7 @@ void Ipc_pager::reply_and_wait_for_fault() _tag = l4_ipc_send_and_wait(_last.kcap, l4_utcb(), snd_tag, &label, L4_IPC_SEND_TIMEOUT_0); - int const err = l4_ipc_error(_tag, l4_utcb()); + l4_umword_t const err = l4_ipc_error(_tag, l4_utcb()); if (err) { error("Ipc error ", err, " in pagefault from ", Hex(label & ~0x3)); wait_for_fault(); diff --git a/repos/base-foc/src/core/irq_session_component.cc b/repos/base-foc/src/core/irq_session_component.cc index fe7db49c5e..302cd42b0d 100644 --- a/repos/base-foc/src/core/irq_session_component.cc +++ b/repos/base-foc/src/core/irq_session_component.cc @@ -139,7 +139,7 @@ void Irq_object::ack_irq() { using namespace Foc; - int err; + l4_umword_t err; l4_msgtag_t tag = l4_irq_unmask(_capability()); if ((err = l4_ipc_error(tag, l4_utcb()))) error("IRQ unmask: ", err); @@ -148,7 +148,7 @@ void Irq_object::ack_irq() Irq_object::Irq_object() : - _cap(cap_map().insert(platform_specific().cap_id_alloc().alloc())), + _cap(cap_map().insert((Cap_index::id_t)platform_specific().cap_id_alloc().alloc())), _trigger(Irq_session::TRIGGER_UNCHANGED), _polarity(Irq_session::POLARITY_UNCHANGED), _irq(~0U), _msi_addr(0), _msi_data(0) @@ -170,7 +170,7 @@ Irq_object::~Irq_object() if (l4_error(l4_irq_detach(_capability()))) error("cannot detach IRQ"); - if (l4_error(l4_icu_unbind(L4_BASE_ICU_CAP, irq, _capability()))) + if (l4_error(l4_icu_unbind(L4_BASE_ICU_CAP, (unsigned)irq, _capability()))) error("cannot unbind IRQ"); cap_map().remove(_cap); @@ -184,7 +184,7 @@ Irq_object::~Irq_object() Irq_session_component::Irq_session_component(Range_allocator &irq_alloc, const char *args) : - _irq_number(Arg_string::find_arg(args, "irq_number").long_value(-1)), + _irq_number((unsigned)Arg_string::find_arg(args, "irq_number").long_value(-1)), _irq_alloc(irq_alloc), _irq_object() { long const msi = Arg_string::find_arg(args, "device_config_phys").long_value(0); @@ -252,7 +252,7 @@ Irq_session::Info Irq_session_component::info() return { .type = Genode::Irq_session::Info::Type::MSI, - .address = _irq_object.msi_address(), + .address = (addr_t)_irq_object.msi_address(), .value = _irq_object.msi_value() }; } @@ -269,7 +269,7 @@ void Interrupt_handler::entry() { using namespace Foc; - int err; + l4_umword_t err; l4_msgtag_t tag; l4_umword_t label; diff --git a/repos/base-foc/src/core/platform.cc b/repos/base-foc/src/core/platform.cc index 1a191d954a..0c99efffb0 100644 --- a/repos/base-foc/src/core/platform.cc +++ b/repos/base-foc/src/core/platform.cc @@ -293,14 +293,14 @@ void Platform::_setup_mem_alloc() for ( ; beg < end; beg += L4_PAGESIZE) (void)(*beg); /* request pages of known page size starting with largest */ - size_t const log2_sizes[] = { L4_LOG2_SUPERPAGESIZE, L4_LOG2_PAGESIZE }; + unsigned const log2_sizes[] = { L4_LOG2_SUPERPAGESIZE, L4_LOG2_PAGESIZE }; for (unsigned i = 0; i < sizeof(log2_sizes)/sizeof(*log2_sizes); ++i) { - size_t const log2_size = log2_sizes[i]; - size_t const size = 1UL << log2_size; + unsigned const log2_size = log2_sizes[i]; + size_t const size = 1UL << log2_size; - int err = 0; - addr_t addr = 0; + Foc::l4_umword_t err = 0; + addr_t addr = 0; Region region; /* request any page of current size from sigma0 */ diff --git a/repos/base-foc/src/core/platform_pd.cc b/repos/base-foc/src/core/platform_pd.cc index 163698a815..17e7ae4c12 100644 --- a/repos/base-foc/src/core/platform_pd.cc +++ b/repos/base-foc/src/core/platform_pd.cc @@ -122,12 +122,13 @@ void Platform_pd::flush(addr_t, size_t size, Core_local_addr core_local) static Native_capability debug_cap() { - unsigned long const id = platform_specific().cap_id_alloc().alloc(); + Cap_index::id_t const id = platform_specific().cap_id_alloc().alloc(); static Cap_index * idx = cap_map().insert(id, DEBUG_CAP); static Native_capability debug_cap(reinterpret_cast(idx)); return debug_cap; } + Platform_pd::Platform_pd(Core_cap_index &ci) : _task(Native_capability(&ci), TASK_CAP) diff --git a/repos/base-foc/src/core/platform_thread.cc b/repos/base-foc/src/core/platform_thread.cc index f6eef12cfb..05567cf851 100644 --- a/repos/base-foc/src/core/platform_thread.cc +++ b/repos/base-foc/src/core/platform_thread.cc @@ -211,7 +211,7 @@ Foc_thread_state Platform_thread::state() s = _pager_obj->state.state; s.kcap = _gate.remote; - s.id = _gate.local.local_name(); + s.id = (uint16_t)_gate.local.local_name(); s.utcb = _utcb; return s; diff --git a/repos/base-foc/src/core/rpc_cap_factory.cc b/repos/base-foc/src/core/rpc_cap_factory.cc index ad219556c2..1474fe9407 100644 --- a/repos/base-foc/src/core/rpc_cap_factory.cc +++ b/repos/base-foc/src/core/rpc_cap_factory.cc @@ -49,7 +49,7 @@ Cap_index_allocator &Genode::cap_idx_alloc() Core_cap_index *Cap_mapping::_get_cap() { - int const id = platform_specific().cap_id_alloc().alloc(); + Cap_index::id_t const id = platform_specific().cap_id_alloc().alloc(); return static_cast(cap_map().insert(id)); } @@ -104,7 +104,7 @@ Native_capability Rpc_cap_factory::alloc(Native_capability ep) /* * Allocate new id, and ipc-gate and set id as gate-label */ - unsigned long const id = platform_specific().cap_id_alloc().alloc(); + Cap_index::id_t const id = platform_specific().cap_id_alloc().alloc(); Core_cap_index *idx = static_cast(cap_map().insert(id)); if (!idx) { @@ -194,17 +194,21 @@ Cap_id_allocator::Cap_id_allocator(Allocator &alloc) } -unsigned long Cap_id_allocator::alloc() +Cap_id_allocator::id_t Cap_id_allocator::alloc() { Mutex::Guard lock_guard(_mutex); - return _id_alloc.try_alloc(CAP_ID_OFFSET).convert( - [&] (void *id) { return (unsigned long)id; }, - [&] (Range_allocator::Alloc_error) -> unsigned long { throw Out_of_ids(); }); + return _id_alloc.try_alloc(CAP_ID_OFFSET).convert( + + [&] (void *id) -> id_t { + return (addr_t)id & ID_MASK; }, + + [&] (Range_allocator::Alloc_error) -> id_t { + throw Out_of_ids(); }); } -void Cap_id_allocator::free(unsigned long id) +void Cap_id_allocator::free(id_t id) { Mutex::Guard lock_guard(_mutex); diff --git a/repos/base-foc/src/core/signal_source_component.cc b/repos/base-foc/src/core/signal_source_component.cc index 5fb7b82c3e..b25a9019a0 100644 --- a/repos/base-foc/src/core/signal_source_component.cc +++ b/repos/base-foc/src/core/signal_source_component.cc @@ -41,7 +41,7 @@ void Signal_source_component::submit(Signal_context_component &context, unsigned long cnt) { /* enqueue signal to context */ - context.increment_signal_cnt(cnt); + context.increment_signal_cnt((int)cnt); if (!context.enqueued()) { _signal_queue.enqueue(context); diff --git a/repos/base-foc/src/core/vm_session_component.cc b/repos/base-foc/src/core/vm_session_component.cc index 73df144d85..a8f88bb112 100644 --- a/repos/base-foc/src/core/vm_session_component.cc +++ b/repos/base-foc/src/core/vm_session_component.cc @@ -49,7 +49,7 @@ Vcpu::Vcpu(Rpc_entrypoint &ep, } try { - unsigned const vcpu_id = _vcpu_ids.alloc(); + unsigned const vcpu_id = (unsigned)_vcpu_ids.alloc(); _task_index_client = thread.setup_vcpu(vcpu_id, task_cap, recall_cap(), _foc_vcpu_state); if (_task_index_client == Foc::L4_INVALID_CAP) { @@ -76,7 +76,7 @@ Vcpu::~Vcpu() } if (_foc_vcpu_state) { - unsigned const vcpu_id = ((addr_t)_foc_vcpu_state - + addr_t const vcpu_id = ((addr_t)_foc_vcpu_state - Platform::VCPU_VIRT_EXT_START) / L4_PAGESIZE; _vcpu_ids.free(vcpu_id); } @@ -187,7 +187,7 @@ void Vm_session_component::_attach_vm_memory(Dataspace_component &dsc, Flexpage page = flex.page(); while (page.valid()) { - l4_fpage_t fp = l4_fpage(page.addr, page.log2_order, flags); + l4_fpage_t fp = l4_fpage(page.addr, (unsigned)page.log2_order, flags); l4_msgtag_t msg = l4_task_map(_task_vcpu.local.data()->kcap(), L4_BASE_TASK_CAP, fp, l4_map_obj_control(page.hotspot, @@ -210,7 +210,7 @@ void Vm_session_component::_detach_vm_memory(addr_t guest_phys, size_t size) using namespace Foc; l4_task_unmap(_task_vcpu.local.data()->kcap(), - l4_fpage(page.addr, page.log2_order, L4_FPAGE_RWX), + l4_fpage(page.addr, (unsigned)page.log2_order, L4_FPAGE_RWX), L4_FP_ALL_SPACES); page = flex.page(); diff --git a/repos/base-foc/src/include/base/internal/cap_map.h b/repos/base-foc/src/include/base/internal/cap_map.h index 28f7a5d3ff..4653717f14 100644 --- a/repos/base-foc/src/include/base/internal/cap_map.h +++ b/repos/base-foc/src/include/base/internal/cap_map.h @@ -190,7 +190,7 @@ class Genode::Capability_map : private Noncopyable * \param id the global capability id * \return pointer of Cap_index when found, otherwise zero */ - Cap_index* find(int id); + Cap_index* find(Cap_index::id_t id); /** * Create and insert a new Cap_index with a specific capability id @@ -203,7 +203,7 @@ class Genode::Capability_map : private Noncopyable * \return pointer to the new Cap_index object, or zero * when allocation failed */ - Cap_index* insert(int id); + Cap_index* insert(Cap_index::id_t id); /** @@ -217,7 +217,7 @@ class Genode::Capability_map : private Noncopyable * \return pointer to the new Cap_index object, or zero * when allocation failed */ - Cap_index* insert(int id, addr_t kcap); + Cap_index* insert(Cap_index::id_t id, addr_t kcap); /** * Create and insert a new Cap_index with a specific capability id @@ -236,7 +236,7 @@ class Genode::Capability_map : private Noncopyable * with the same id exists and it's kernel-object * differs to the one given by kcap */ - Cap_index *insert_map(int id, addr_t kcap); + Cap_index *insert_map(Cap_index::id_t id, addr_t kcap); /** * Remove (resp. invalidate) a Cap_index object diff --git a/repos/base-foc/src/include/base/internal/capability_data.h b/repos/base-foc/src/include/base/internal/capability_data.h index fcea106e2e..2f083cf190 100644 --- a/repos/base-foc/src/include/base/internal/capability_data.h +++ b/repos/base-foc/src/include/base/internal/capability_data.h @@ -28,13 +28,17 @@ */ class Genode::Native_capability::Data : public Avl_node { + public: + + using id_t = uint16_t; + private: constexpr static uint16_t INVALID_ID = ~0; constexpr static uint16_t UNUSED = 0; - uint8_t _ref_cnt; /* reference counter */ - uint16_t _id; /* global capability id */ + uint8_t _ref_cnt; /* reference counter */ + id_t _id; /* global capability id */ public: @@ -56,7 +60,7 @@ class Genode::Native_capability::Data : public Avl_node ************************/ bool higher(Data *n); - Data *find_by_id(uint16_t id); + Data *find_by_id(id_t id); }; #endif /* _INCLUDE__BASE__INTERNAL__CAPABILITY_DATA_H_ */ diff --git a/repos/base-foc/src/include/base/internal/parent_cap.h b/repos/base-foc/src/include/base/internal/parent_cap.h index 409a072a0b..2f5a5f2487 100644 --- a/repos/base-foc/src/include/base/internal/parent_cap.h +++ b/repos/base-foc/src/include/base/internal/parent_cap.h @@ -30,7 +30,7 @@ namespace Genode { static inline Parent_capability parent_cap() { - unsigned long const local_name = _parent_cap; + Cap_index::id_t const local_name = (Cap_index::id_t)_parent_cap; static Cap_index *i = cap_map().insert(local_name, Foc::PARENT_CAP); /* diff --git a/repos/base-foc/src/lib/base/cap_map.cc b/repos/base-foc/src/lib/base/cap_map.cc index 296202077b..9f79ed3534 100644 --- a/repos/base-foc/src/lib/base/cap_map.cc +++ b/repos/base-foc/src/lib/base/cap_map.cc @@ -104,7 +104,7 @@ uint8_t Cap_index::dec() ** Capability_map class ** ****************************/ -Cap_index* Capability_map::find(int id) +Cap_index* Capability_map::find(Cap_index::id_t id) { Lock_guard guard(_lock); @@ -112,7 +112,7 @@ Cap_index* Capability_map::find(int id) } -Cap_index* Capability_map::insert(int id) +Cap_index* Capability_map::insert(Cap_index::id_t id) { Lock_guard guard(_lock); @@ -128,7 +128,7 @@ Cap_index* Capability_map::insert(int id) } -Cap_index* Capability_map::insert(int id, addr_t kcap) +Cap_index* Capability_map::insert(Cap_index::id_t id, addr_t kcap) { Lock_guard guard(_lock); @@ -146,7 +146,7 @@ Cap_index* Capability_map::insert(int id, addr_t kcap) } -Cap_index* Capability_map::insert_map(int id, addr_t kcap) +Cap_index* Capability_map::insert_map(Cap_index::id_t id, addr_t kcap) { using namespace Foc; diff --git a/repos/base-foc/src/lib/base/ipc.cc b/repos/base-foc/src/lib/base/ipc.cc index ce8c1bcc4f..c674f4535f 100644 --- a/repos/base-foc/src/lib/base/ipc.cc +++ b/repos/base-foc/src/lib/base/ipc.cc @@ -49,13 +49,13 @@ enum Debug { DEBUG_MSG = 1 }; static inline bool ipc_error(l4_msgtag_t tag, bool print) { - int const ipc_error = l4_ipc_error(tag, l4_utcb()); + Foc::l4_umword_t const ipc_error = l4_ipc_error(tag, l4_utcb()); if (ipc_error && print) raw("Ipc error: ", ipc_error, " occurred!"); return ipc_error; } -static constexpr unsigned long INVALID_BADGE = ~0UL; +static constexpr Cap_index::id_t INVALID_BADGE = 0xffff; /** @@ -63,9 +63,9 @@ static constexpr unsigned long INVALID_BADGE = ~0UL; */ struct Cap_info { - bool valid = false; - unsigned long sel = 0; - unsigned long badge = 0; + bool valid = false; + unsigned long sel = 0; + Cap_index::id_t badge = 0; }; @@ -74,9 +74,9 @@ struct Cap_info * * \return protocol word (local name or exception code) */ -static unsigned long extract_msg_from_utcb(l4_msgtag_t tag, - Receive_window &rcv_window, - Msgbuf_base &rcv_msg) +static int extract_msg_from_utcb(l4_msgtag_t tag, + Receive_window &rcv_window, + Msgbuf_base &rcv_msg) { unsigned num_msg_words = l4_msgtag_words(tag); @@ -90,7 +90,7 @@ static unsigned long extract_msg_from_utcb(l4_msgtag_t tag, unsigned long const protocol_word = *msg_words++; /* read number of capability arguments from second message word */ - size_t const num_caps = min(*msg_words, Msgbuf_base::MAX_CAPS_PER_MSG); + unsigned const num_caps = (unsigned)min(*msg_words, Msgbuf_base::MAX_CAPS_PER_MSG); msg_words++; num_msg_words -= 2; @@ -114,7 +114,7 @@ static unsigned long extract_msg_from_utcb(l4_msgtag_t tag, for (unsigned i = 0, sel_idx = 0; i < num_caps; i++) { - unsigned long const badge = *msg_words++; + Cap_index::id_t const badge = (Cap_index::id_t)(*msg_words++); if (badge == INVALID_BADGE) continue; @@ -135,7 +135,7 @@ static unsigned long extract_msg_from_utcb(l4_msgtag_t tag, if ((num_msg_words)*sizeof(l4_mword_t) > rcv_msg.capacity()) { if (DEBUG_MSG) raw("receive message buffer too small"); - num_msg_words = rcv_msg.capacity()/sizeof(l4_mword_t); + num_msg_words = (unsigned)(rcv_msg.capacity()/sizeof(l4_mword_t)); } /* read message payload beginning from the second UTCB message register */ @@ -160,7 +160,7 @@ static unsigned long extract_msg_from_utcb(l4_msgtag_t tag, } } - return protocol_word; + return (int)protocol_word; } @@ -175,8 +175,8 @@ static l4_msgtag_t copy_msgbuf_to_utcb(Msgbuf_base &snd_msg, unsigned long protocol_word) { - unsigned const num_data_words = snd_msg.data_size() / sizeof(l4_mword_t); - unsigned const num_caps = snd_msg.used_caps(); + unsigned const num_data_words = (unsigned)(snd_msg.data_size() / sizeof(l4_mword_t)); + unsigned const num_caps = (unsigned)snd_msg.used_caps(); /* validate capabilities present in the message buffer */ for (unsigned i = 0; i < num_caps; i++) { @@ -201,7 +201,7 @@ static l4_msgtag_t copy_msgbuf_to_utcb(Msgbuf_base &snd_msg, Native_capability const &cap = snd_msg.cap(i); if (cap.valid()) { caps[i].valid = true; - caps[i].badge = cap.local_name(); + caps[i].badge = (Cap_index::id_t)cap.local_name(); caps[i].sel = cap.data()->kcap(); } } diff --git a/repos/base-foc/src/lib/base/x86/vm.cc b/repos/base-foc/src/lib/base/x86/vm.cc index 22a40a4859..a2d97dcb78 100644 --- a/repos/base-foc/src/lib/base/x86/vm.cc +++ b/repos/base-foc/src/lib/base/x86/vm.cc @@ -29,9 +29,12 @@ #include namespace Foc { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" #include #include #include +#pragma GCC diagnostic pop /* restore -Wconversion warnings */ } using namespace Genode; @@ -218,9 +221,9 @@ struct Foc_vcpu : Thread, Noncopyable CR0_PG = 0 /* 1U << 31 - not needed in case of UG */ }; - addr_t const _cr0_mask { CR0_NM | CR0_CD }; - addr_t const vmcb_ctrl0 { CTRL0_IO | CTRL0_MSR }; - addr_t const vmcb_ctrl1 { 0 }; + addr_t const _cr0_mask { CR0_NM | CR0_CD }; + uint32_t const vmcb_ctrl0 { CTRL0_IO | CTRL0_MSR }; + uint32_t const vmcb_ctrl1 { 0 }; addr_t vmcb_cr0_shadow { 0 }; addr_t vmcb_cr4_shadow { 0 }; @@ -481,7 +484,7 @@ struct Foc_vcpu : Thread, Noncopyable * Convert to AMD (and Genode) format comprising 16 bits. */ uint16_t _convert_ar_16(addr_t value) { - return ((value & 0x1f000) >> 4) | (value & 0xff); } + return (uint16_t)(((value & 0x1f000) >> 4) | (value & 0xff)); } void _read_intel_state(Vcpu_state &state, void *vmcs, Foc::l4_vcpu_state_t *vcpu) @@ -495,18 +498,15 @@ struct Foc_vcpu : Thread, Noncopyable state.di.charge(vcpu->r.di); state.si.charge(vcpu->r.si); - state.flags.charge(Foc::l4_vm_vmx_read(vmcs, Vmcs::FLAGS)); - - state.sp.charge(Foc::l4_vm_vmx_read(vmcs, Vmcs::SP)); - - state.ip.charge(Foc::l4_vm_vmx_read(vmcs, Vmcs::IP)); - state.ip_len.charge(Foc::l4_vm_vmx_read(vmcs, Vmcs::INST_LEN)); - - state.dr7.charge(Foc::l4_vm_vmx_read(vmcs, Vmcs::DR7)); + state.flags .charge((addr_t)Foc::l4_vm_vmx_read(vmcs, Vmcs::FLAGS)); + state.sp .charge((addr_t)Foc::l4_vm_vmx_read(vmcs, Vmcs::SP)); + state.ip .charge((addr_t)Foc::l4_vm_vmx_read(vmcs, Vmcs::IP)); + state.ip_len.charge((addr_t)Foc::l4_vm_vmx_read(vmcs, Vmcs::INST_LEN)); + state.dr7 .charge((addr_t)Foc::l4_vm_vmx_read(vmcs, Vmcs::DR7)); #ifdef __x86_64__ - state.r8.charge(vcpu->r.r8); - state.r9.charge(vcpu->r.r9); + state.r8 .charge(vcpu->r.r8); + state.r9 .charge(vcpu->r.r9); state.r10.charge(vcpu->r.r10); state.r11.charge(vcpu->r.r11); state.r12.charge(vcpu->r.r12); @@ -516,21 +516,25 @@ struct Foc_vcpu : Thread, Noncopyable #endif { - addr_t const cr0 = Foc::l4_vm_vmx_read(vmcs, Vmcs::CR0); - addr_t const cr0_shadow = Foc::l4_vm_vmx_read(vmcs, Vmcs::CR0_SHADOW); + addr_t const cr0 = (addr_t)Foc::l4_vm_vmx_read(vmcs, Vmcs::CR0); + addr_t const cr0_shadow = (addr_t)Foc::l4_vm_vmx_read(vmcs, Vmcs::CR0_SHADOW); + state.cr0.charge((cr0 & ~vmcs_cr0_mask) | (cr0_shadow & vmcs_cr0_mask)); + if (state.cr0.value() != cr0_shadow) Foc::l4_vm_vmx_write(vmcs, Vmcs::CR0_SHADOW, state.cr0.value()); } unsigned const cr2 = Foc::l4_vm_vmx_get_cr2_index(vmcs); - state.cr2.charge(Foc::l4_vm_vmx_read(vmcs, cr2)); - state.cr3.charge(Foc::l4_vm_vmx_read(vmcs, Vmcs::CR3)); + state.cr2.charge((addr_t)Foc::l4_vm_vmx_read(vmcs, cr2)); + state.cr3.charge((addr_t)Foc::l4_vm_vmx_read(vmcs, Vmcs::CR3)); { - addr_t const cr4 = Foc::l4_vm_vmx_read(vmcs, Vmcs::CR4); - addr_t const cr4_shadow = Foc::l4_vm_vmx_read(vmcs, Vmcs::CR4_SHADOW); + addr_t const cr4 = (addr_t)Foc::l4_vm_vmx_read(vmcs, Vmcs::CR4); + addr_t const cr4_shadow = (addr_t)Foc::l4_vm_vmx_read(vmcs, Vmcs::CR4_SHADOW); + state.cr4.charge((cr4 & ~vmcs_cr4_mask) | (cr4_shadow & vmcs_cr4_mask)); + if (state.cr4.value() != cr4_shadow) Foc::l4_vm_vmx_write(vmcs, Vmcs::CR4_SHADOW, state.cr4.value()); @@ -545,7 +549,7 @@ struct Foc_vcpu : Thread, Noncopyable { Segment cs { l4_vm_vmx_read_16(vmcs, Vmcs::CS_SEL), - _convert_ar_16(l4_vm_vmx_read(vmcs, Vmcs::CS_AR)), + _convert_ar_16((addr_t)l4_vm_vmx_read(vmcs, Vmcs::CS_AR)), l4_vm_vmx_read_32(vmcs, Vmcs::CS_LIMIT), l4_vm_vmx_read_nat(vmcs, Vmcs::CS_BASE) }; @@ -554,7 +558,7 @@ struct Foc_vcpu : Thread, Noncopyable { Segment ss { l4_vm_vmx_read_16(vmcs, Vmcs::SS_SEL), - _convert_ar_16(l4_vm_vmx_read(vmcs, Vmcs::SS_AR)), + _convert_ar_16((addr_t)l4_vm_vmx_read(vmcs, Vmcs::SS_AR)), l4_vm_vmx_read_32(vmcs, Vmcs::SS_LIMIT), l4_vm_vmx_read_nat(vmcs, Vmcs::SS_BASE) }; @@ -563,7 +567,7 @@ struct Foc_vcpu : Thread, Noncopyable { Segment es { l4_vm_vmx_read_16(vmcs, Vmcs::ES_SEL), - _convert_ar_16(l4_vm_vmx_read(vmcs, Vmcs::ES_AR)), + _convert_ar_16((addr_t)l4_vm_vmx_read(vmcs, Vmcs::ES_AR)), l4_vm_vmx_read_32(vmcs, Vmcs::ES_LIMIT), l4_vm_vmx_read_nat(vmcs, Vmcs::ES_BASE) }; @@ -572,7 +576,7 @@ struct Foc_vcpu : Thread, Noncopyable { Segment ds { l4_vm_vmx_read_16(vmcs, Vmcs::DS_SEL), - _convert_ar_16(l4_vm_vmx_read(vmcs, Vmcs::DS_AR)), + _convert_ar_16((addr_t)l4_vm_vmx_read(vmcs, Vmcs::DS_AR)), l4_vm_vmx_read_32(vmcs, Vmcs::DS_LIMIT), l4_vm_vmx_read_nat(vmcs, Vmcs::DS_BASE) }; @@ -581,7 +585,7 @@ struct Foc_vcpu : Thread, Noncopyable { Segment fs { l4_vm_vmx_read_16(vmcs, Vmcs::FS_SEL), - _convert_ar_16(l4_vm_vmx_read(vmcs, Vmcs::FS_AR)), + _convert_ar_16((addr_t)l4_vm_vmx_read(vmcs, Vmcs::FS_AR)), l4_vm_vmx_read_32(vmcs, Vmcs::FS_LIMIT), l4_vm_vmx_read_nat(vmcs, Vmcs::FS_BASE) }; @@ -590,7 +594,7 @@ struct Foc_vcpu : Thread, Noncopyable { Segment gs { l4_vm_vmx_read_16(vmcs, Vmcs::GS_SEL), - _convert_ar_16(l4_vm_vmx_read(vmcs, Vmcs::GS_AR)), + _convert_ar_16((addr_t)l4_vm_vmx_read(vmcs, Vmcs::GS_AR)), l4_vm_vmx_read_32(vmcs, Vmcs::GS_LIMIT), l4_vm_vmx_read_nat(vmcs, Vmcs::GS_BASE) }; @@ -599,7 +603,7 @@ struct Foc_vcpu : Thread, Noncopyable { Segment tr { l4_vm_vmx_read_16(vmcs, Vmcs::TR_SEL), - _convert_ar_16(l4_vm_vmx_read(vmcs, Vmcs::TR_AR)), + _convert_ar_16((addr_t)l4_vm_vmx_read(vmcs, Vmcs::TR_AR)), l4_vm_vmx_read_32(vmcs, Vmcs::TR_LIMIT), l4_vm_vmx_read_nat(vmcs, Vmcs::TR_BASE) }; @@ -608,7 +612,7 @@ struct Foc_vcpu : Thread, Noncopyable { Segment ldtr { l4_vm_vmx_read_16(vmcs, Vmcs::LDTR_SEL), - _convert_ar_16(l4_vm_vmx_read(vmcs, Vmcs::LDTR_AR)), + _convert_ar_16((addr_t)l4_vm_vmx_read(vmcs, Vmcs::LDTR_AR)), l4_vm_vmx_read_32(vmcs, Vmcs::LDTR_LIMIT), l4_vm_vmx_read_nat(vmcs, Vmcs::LDTR_BASE) }; @@ -621,35 +625,35 @@ struct Foc_vcpu : Thread, Noncopyable state.idtr.charge(Range{.limit = l4_vm_vmx_read_32(vmcs, Vmcs::IDTR_LIMIT), .base = l4_vm_vmx_read_nat(vmcs, Vmcs::IDTR_BASE)}); - state.sysenter_cs.charge(l4_vm_vmx_read(vmcs, Vmcs::SYSENTER_CS)); - state.sysenter_sp.charge(l4_vm_vmx_read(vmcs, Vmcs::SYSENTER_SP)); - state.sysenter_ip.charge(l4_vm_vmx_read(vmcs, Vmcs::SYSENTER_IP)); + state.sysenter_cs.charge((addr_t)l4_vm_vmx_read(vmcs, Vmcs::SYSENTER_CS)); + state.sysenter_sp.charge((addr_t)l4_vm_vmx_read(vmcs, Vmcs::SYSENTER_SP)); + state.sysenter_ip.charge((addr_t)l4_vm_vmx_read(vmcs, Vmcs::SYSENTER_IP)); - state.qual_primary.charge(l4_vm_vmx_read(vmcs, Vmcs::EXIT_QUAL)); + state.qual_primary .charge(l4_vm_vmx_read(vmcs, Vmcs::EXIT_QUAL)); state.qual_secondary.charge(l4_vm_vmx_read(vmcs, Vmcs::GUEST_PHYS)); - state.ctrl_primary.charge(l4_vm_vmx_read(vmcs, Vmcs::CTRL_0)); - state.ctrl_secondary.charge(l4_vm_vmx_read(vmcs, Vmcs::CTRL_1)); + state.ctrl_primary .charge((uint32_t)l4_vm_vmx_read(vmcs, Vmcs::CTRL_0)); + state.ctrl_secondary.charge((uint32_t)l4_vm_vmx_read(vmcs, Vmcs::CTRL_1)); if (state.exit_reason == INTEL_EXIT_INVALID || state.exit_reason == VMEXIT_PAUSED) { - state.inj_info.charge(l4_vm_vmx_read(vmcs, Vmcs::INTR_INFO)); - state.inj_error.charge(l4_vm_vmx_read(vmcs, Vmcs::INTR_ERROR)); + state.inj_info .charge((uint32_t)l4_vm_vmx_read(vmcs, Vmcs::INTR_INFO)); + state.inj_error.charge((uint32_t)l4_vm_vmx_read(vmcs, Vmcs::INTR_ERROR)); } else { - state.inj_info.charge(l4_vm_vmx_read(vmcs, Vmcs::IDT_INFO)); - state.inj_error.charge(l4_vm_vmx_read(vmcs, Vmcs::IDT_ERROR)); + state.inj_info .charge((uint32_t)l4_vm_vmx_read(vmcs, Vmcs::IDT_INFO)); + state.inj_error.charge((uint32_t)l4_vm_vmx_read(vmcs, Vmcs::IDT_ERROR)); } - state.intr_state.charge(l4_vm_vmx_read(vmcs, Vmcs::STATE_INTR)); - state.actv_state.charge(l4_vm_vmx_read(vmcs, Vmcs::STATE_ACTV)); + state.intr_state.charge((uint32_t)l4_vm_vmx_read(vmcs, Vmcs::STATE_INTR)); + state.actv_state.charge((uint32_t)l4_vm_vmx_read(vmcs, Vmcs::STATE_ACTV)); state.tsc.charge(Trace::timestamp()); state.tsc_offset.charge(_tsc_offset); - state.efer.charge(l4_vm_vmx_read(vmcs, Vmcs::EFER)); + state.efer.charge((addr_t)l4_vm_vmx_read(vmcs, Vmcs::EFER)); - state.star.charge(l4_vm_vmx_read(vmcs, Vmcs::MSR_STAR)); + state.star .charge(l4_vm_vmx_read(vmcs, Vmcs::MSR_STAR)); state.lstar.charge(l4_vm_vmx_read(vmcs, Vmcs::MSR_LSTAR)); state.cstar.charge(l4_vm_vmx_read(vmcs, Vmcs::MSR_CSTAR)); state.fmask.charge(l4_vm_vmx_read(vmcs, Vmcs::MSR_FMASK)); @@ -665,7 +669,7 @@ struct Foc_vcpu : Thread, Noncopyable void _read_amd_state(Vcpu_state &state, Foc::l4_vm_svm_vmcb_t *vmcb, Foc::l4_vcpu_state_t * const vcpu) { - state.ax.charge(vmcb->state_save_area.rax); + state.ax.charge((addr_t)vmcb->state_save_area.rax); state.cx.charge(vcpu->r.cx); state.dx.charge(vcpu->r.dx); state.bx.charge(vcpu->r.bx); @@ -674,18 +678,18 @@ struct Foc_vcpu : Thread, Noncopyable state.si.charge(vcpu->r.si); state.bp.charge(vcpu->r.bp); - state.flags.charge(vmcb->state_save_area.rflags); + state.flags.charge((addr_t)vmcb->state_save_area.rflags); - state.sp.charge(vmcb->state_save_area.rsp); + state.sp.charge((addr_t)vmcb->state_save_area.rsp); - state.ip.charge(vmcb->state_save_area.rip); + state.ip.charge((addr_t)vmcb->state_save_area.rip); state.ip_len.charge(0); /* unsupported on AMD */ - state.dr7.charge(vmcb->state_save_area.dr7); + state.dr7.charge((addr_t)vmcb->state_save_area.dr7); #ifdef __x86_64__ - state.r8.charge(vcpu->r.r8); - state.r9.charge(vcpu->r.r9); + state.r8 .charge(vcpu->r.r8); + state.r9 .charge(vcpu->r.r9); state.r10.charge(vcpu->r.r10); state.r11.charge(vcpu->r.r11); state.r12.charge(vcpu->r.r12); @@ -695,15 +699,15 @@ struct Foc_vcpu : Thread, Noncopyable #endif { - addr_t const cr0 = vmcb->state_save_area.cr0; + addr_t const cr0 = (addr_t)vmcb->state_save_area.cr0; state.cr0.charge((cr0 & ~vmcb_cr0_mask) | (vmcb_cr0_shadow & vmcb_cr0_mask)); if (state.cr0.value() != vmcb_cr0_shadow) vmcb_cr0_shadow = state.cr0.value(); } - state.cr2.charge(vmcb->state_save_area.cr2); - state.cr3.charge(vmcb->state_save_area.cr3); + state.cr2.charge((addr_t)vmcb->state_save_area.cr2); + state.cr3.charge((addr_t)vmcb->state_save_area.cr3); { - addr_t const cr4 = vmcb->state_save_area.cr4; + addr_t const cr4 = (addr_t)vmcb->state_save_area.cr4; state.cr4.charge((cr4 & ~vmcb_cr4_mask) | (vmcb_cr4_shadow & vmcb_cr4_mask)); if (state.cr4.value() != vmcb_cr4_shadow) vmcb_cr4_shadow = state.cr4.value(); @@ -712,44 +716,44 @@ struct Foc_vcpu : Thread, Noncopyable typedef Vcpu_state::Segment Segment; state.cs.charge(Segment{vmcb->state_save_area.cs.selector, - vmcb->state_save_area.cs.attrib, - vmcb->state_save_area.cs.limit, - (addr_t)vmcb->state_save_area.cs.base}); + vmcb->state_save_area.cs.attrib, + vmcb->state_save_area.cs.limit, + (addr_t)vmcb->state_save_area.cs.base}); state.ss.charge(Segment{vmcb->state_save_area.ss.selector, - vmcb->state_save_area.ss.attrib, - vmcb->state_save_area.ss.limit, - (addr_t)vmcb->state_save_area.ss.base}); + vmcb->state_save_area.ss.attrib, + vmcb->state_save_area.ss.limit, + (addr_t)vmcb->state_save_area.ss.base}); state.es.charge(Segment{vmcb->state_save_area.es.selector, - vmcb->state_save_area.es.attrib, - vmcb->state_save_area.es.limit, - (addr_t)vmcb->state_save_area.es.base}); + vmcb->state_save_area.es.attrib, + vmcb->state_save_area.es.limit, + (addr_t)vmcb->state_save_area.es.base}); state.ds.charge(Segment{vmcb->state_save_area.ds.selector, - vmcb->state_save_area.ds.attrib, - vmcb->state_save_area.ds.limit, - (addr_t)vmcb->state_save_area.ds.base}); + vmcb->state_save_area.ds.attrib, + vmcb->state_save_area.ds.limit, + (addr_t)vmcb->state_save_area.ds.base}); state.fs.charge(Segment{vmcb->state_save_area.fs.selector, - vmcb->state_save_area.fs.attrib, - vmcb->state_save_area.fs.limit, - (addr_t)vmcb->state_save_area.fs.base}); + vmcb->state_save_area.fs.attrib, + vmcb->state_save_area.fs.limit, + (addr_t)vmcb->state_save_area.fs.base}); state.gs.charge(Segment{vmcb->state_save_area.gs.selector, - vmcb->state_save_area.gs.attrib, - vmcb->state_save_area.gs.limit, - (addr_t)vmcb->state_save_area.gs.base}); + vmcb->state_save_area.gs.attrib, + vmcb->state_save_area.gs.limit, + (addr_t)vmcb->state_save_area.gs.base}); state.tr.charge(Segment{vmcb->state_save_area.tr.selector, - vmcb->state_save_area.tr.attrib, - vmcb->state_save_area.tr.limit, - (addr_t)vmcb->state_save_area.tr.base}); + vmcb->state_save_area.tr.attrib, + vmcb->state_save_area.tr.limit, + (addr_t)vmcb->state_save_area.tr.base}); state.ldtr.charge(Segment{vmcb->state_save_area.ldtr.selector, - vmcb->state_save_area.ldtr.attrib, - vmcb->state_save_area.ldtr.limit, - (addr_t)vmcb->state_save_area.ldtr.base}); + vmcb->state_save_area.ldtr.attrib, + vmcb->state_save_area.ldtr.limit, + (addr_t)vmcb->state_save_area.ldtr.base}); typedef Vcpu_state::Range Range; @@ -759,11 +763,11 @@ struct Foc_vcpu : Thread, Noncopyable state.idtr.charge(Range{.limit = vmcb->state_save_area.idtr.limit, .base = (addr_t)vmcb->state_save_area.idtr.base }); - state.sysenter_cs.charge(vmcb->state_save_area.sysenter_cs); - state.sysenter_sp.charge(vmcb->state_save_area.sysenter_esp); - state.sysenter_ip.charge(vmcb->state_save_area.sysenter_eip); + state.sysenter_cs.charge((addr_t)vmcb->state_save_area.sysenter_cs); + state.sysenter_sp.charge((addr_t)vmcb->state_save_area.sysenter_esp); + state.sysenter_ip.charge((addr_t)vmcb->state_save_area.sysenter_eip); - state.qual_primary.charge(vmcb->control_area.exitinfo1); + state.qual_primary .charge(vmcb->control_area.exitinfo1); state.qual_secondary.charge(vmcb->control_area.exitinfo2); uint32_t inj_info = 0; @@ -771,22 +775,22 @@ struct Foc_vcpu : Thread, Noncopyable if (state.exit_reason == AMD_EXIT_INVALID || state.exit_reason == VMEXIT_PAUSED) { - inj_info = vmcb->control_area.eventinj; - inj_error = vmcb->control_area.eventinj >> 32; + inj_info = (uint32_t)vmcb->control_area.eventinj; + inj_error = (uint32_t)(vmcb->control_area.eventinj >> 32); } else { - inj_info = vmcb->control_area.exitintinfo; - inj_error = vmcb->control_area.exitintinfo >> 32; + inj_info = (uint32_t)vmcb->control_area.exitintinfo; + inj_error = (uint32_t)(vmcb->control_area.exitintinfo >> 32); } - state.inj_info.charge(inj_info); + state.inj_info .charge(inj_info); state.inj_error.charge(inj_error); - state.intr_state.charge(vmcb->control_area.interrupt_shadow); + state.intr_state.charge((uint32_t)vmcb->control_area.interrupt_shadow); state.actv_state.charge(0); state.tsc.charge(Trace::timestamp()); state.tsc_offset.charge(_tsc_offset); - state.efer.charge(vmcb->state_save_area.efer); + state.efer.charge((addr_t)vmcb->state_save_area.efer); if (state.pdpte_0.charged() || state.pdpte_1.charged() || state.pdpte_2.charged() || state.pdpte_3.charged()) { @@ -894,9 +898,9 @@ struct Foc_vcpu : Thread, Noncopyable } if (state.inj_info.charged() || state.inj_error.charged()) { - addr_t ctrl_0 = state.ctrl_primary.charged() ? - state.ctrl_primary.value() : - Foc::l4_vm_vmx_read(vmcs, Vmcs::CTRL_0); + uint32_t ctrl_0 = state.ctrl_primary.charged() + ? (uint32_t)state.ctrl_primary.value() + : (uint32_t)Foc::l4_vm_vmx_read(vmcs, Vmcs::CTRL_0); if (state.inj_info.value() & 0x2000) warning("unimplemented ", state.inj_info.value() & 0x1000, " ", diff --git a/repos/base-foc/src/test/cap_integrity/main.cc b/repos/base-foc/src/test/cap_integrity/main.cc index d14ddcf849..3f98a8736f 100644 --- a/repos/base-foc/src/test/cap_integrity/main.cc +++ b/repos/base-foc/src/test/cap_integrity/main.cc @@ -38,7 +38,8 @@ Main::Main(Env &env) Foc::l4_cap_idx_t tid = Capability_space::kcap(env.pd_session_cap()); /* try the first 1000 local name IDs */ - for (int local_name = 0; local_name < COUNT; local_name++, idx++) { + using id_t = Native_capability::Data::id_t; + for (id_t local_name = 0; local_name < COUNT; local_name++, idx++) { idx->id(local_name); l4_task_map(L4_BASE_TASK_CAP, L4_BASE_TASK_CAP, l4_obj_fpage(tid, 0, L4_FPAGE_RWX), diff --git a/repos/base-hw/include/kernel/interface.h b/repos/base-hw/include/kernel/interface.h index 56723cbedd..7eaff7a6f3 100644 --- a/repos/base-hw/include/kernel/interface.h +++ b/repos/base-hw/include/kernel/interface.h @@ -97,7 +97,7 @@ namespace Kernel { */ inline int timeout(timeout_t const duration_us, capid_t const sigid) { - return call(call_id_timeout(), duration_us, sigid); + return (int)call(call_id_timeout(), duration_us, sigid); } @@ -230,7 +230,7 @@ namespace Kernel { */ inline int send_request_msg(capid_t const thread_id, unsigned rcv_caps) { - return call(call_id_send_request_msg(), thread_id, rcv_caps); + return (int)call(call_id_send_request_msg(), thread_id, rcv_caps); } @@ -248,7 +248,7 @@ namespace Kernel { */ inline int await_request_msg(unsigned rcv_caps) { - return call(call_id_await_request_msg(), rcv_caps); + return (int)call(call_id_await_request_msg(), rcv_caps); } @@ -266,7 +266,7 @@ namespace Kernel { */ inline int send_reply_msg(unsigned rcv_caps, bool const await_request_msg) { - return call(call_id_send_reply_msg(), rcv_caps, await_request_msg); + return (int)call(call_id_send_reply_msg(), rcv_caps, await_request_msg); } @@ -302,7 +302,7 @@ namespace Kernel { */ inline int await_signal(capid_t const receiver_id) { - return call(call_id_await_signal(), receiver_id); + return (int)call(call_id_await_signal(), receiver_id); } @@ -320,7 +320,7 @@ namespace Kernel { */ inline int pending_signal(capid_t const receiver_id) { - return call(call_id_pending_signal(), receiver_id); + return (int)call(call_id_pending_signal(), receiver_id); } @@ -352,7 +352,7 @@ namespace Kernel { */ inline int submit_signal(capid_t const context, unsigned const num) { - return call(call_id_submit_signal(), context, num); + return (int)call(call_id_submit_signal(), context, num); } @@ -377,7 +377,7 @@ namespace Kernel { */ inline int kill_signal_context(capid_t const context) { - return call(call_id_kill_signal_context(), context); + return (int)call(call_id_kill_signal_context(), context); } /** diff --git a/repos/base-hw/lib/mk/bootstrap-hw.inc b/repos/base-hw/lib/mk/bootstrap-hw.inc index 91a1689419..bdd5310976 100644 --- a/repos/base-hw/lib/mk/bootstrap-hw.inc +++ b/repos/base-hw/lib/mk/bootstrap-hw.inc @@ -38,3 +38,5 @@ vpath hw/% $(BASE_HW_DIR)/src/lib vpath lib/base/% $(BASE_HW_DIR)/src vpath lib/base/% $(BASE_DIR)/src vpath lib/startup/% $(BASE_DIR)/src + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/base-hw/lib/mk/spec/arm_v6/core-hw-rpi.mk b/repos/base-hw/lib/mk/spec/arm_v6/core-hw-rpi.mk index d626bc7482..f0fb4f6e9b 100644 --- a/repos/base-hw/lib/mk/spec/arm_v6/core-hw-rpi.mk +++ b/repos/base-hw/lib/mk/spec/arm_v6/core-hw-rpi.mk @@ -14,3 +14,5 @@ SRC_CC += spec/arm/bcm2835_system_timer.cc # include less specific configuration include $(call select_from_repositories,lib/mk/spec/arm_v6/core-hw.inc) + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/base-hw/lib/mk/spec/arm_v7/core-hw-imx53_qsb.inc b/repos/base-hw/lib/mk/spec/arm_v7/core-hw-imx53_qsb.inc index 97d57d2adc..0f421f9bee 100644 --- a/repos/base-hw/lib/mk/spec/arm_v7/core-hw-imx53_qsb.inc +++ b/repos/base-hw/lib/mk/spec/arm_v7/core-hw-imx53_qsb.inc @@ -1,16 +1,8 @@ -# -# \brief Build config for Genodes core process -# \author Stefan Kalkowski -# \author Martin Stein -# \date 2012-10-24 -# - -# add include paths REP_INC_DIR += src/core/board/imx53_qsb SRC_CC += spec/arm/imx_epit.cc SRC_CC += spec/arm/imx_tzic.cc -# include less specific configuration include $(call select_from_repositories,lib/mk/spec/cortex_a8/core-hw.inc) +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/base-hw/lib/mk/spec/arm_v7/core-hw-imx53_qsb_tz.mk b/repos/base-hw/lib/mk/spec/arm_v7/core-hw-imx53_qsb_tz.mk index 495968081b..3ff2b01ac5 100644 --- a/repos/base-hw/lib/mk/spec/arm_v7/core-hw-imx53_qsb_tz.mk +++ b/repos/base-hw/lib/mk/spec/arm_v7/core-hw-imx53_qsb_tz.mk @@ -11,4 +11,3 @@ SRC_S += spec/arm_v7/trustzone/exception_vector.s # include less specific configuration include $(call select_from_repositories,lib/mk/spec/arm_v7/core-hw-imx53_qsb.inc) - diff --git a/repos/base-hw/lib/mk/spec/cortex_a15/core-hw.inc b/repos/base-hw/lib/mk/spec/cortex_a15/core-hw.inc index 0970d6bc43..97daafd4de 100644 --- a/repos/base-hw/lib/mk/spec/cortex_a15/core-hw.inc +++ b/repos/base-hw/lib/mk/spec/cortex_a15/core-hw.inc @@ -11,3 +11,5 @@ SRC_CC += spec/arm/kernel/lock.cc # include less specific configuration include $(call select_from_repositories,lib/mk/spec/arm_v7/core-hw.inc) + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/base-hw/lib/mk/spec/cortex_a9/core-hw.inc b/repos/base-hw/lib/mk/spec/cortex_a9/core-hw.inc index 6939462bd2..f37baa43cf 100644 --- a/repos/base-hw/lib/mk/spec/cortex_a9/core-hw.inc +++ b/repos/base-hw/lib/mk/spec/cortex_a9/core-hw.inc @@ -15,3 +15,5 @@ SRC_CC += kernel/cpu_mp.cc # include less specific configuration include $(call select_from_repositories,lib/mk/spec/arm_v7/core-hw.inc) + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/base-hw/src/bootstrap/platform.cc b/repos/base-hw/src/bootstrap/platform.cc index 78604d2ff7..8f56824ac3 100644 --- a/repos/base-hw/src/bootstrap/platform.cc +++ b/repos/base-hw/src/bootstrap/platform.cc @@ -31,8 +31,9 @@ void * Platform::Ram_allocator::alloc_aligned(size_t size, unsigned align) { using namespace Genode; - return Base::alloc_aligned(Hw::round_page(size), - max(align, get_page_size_log2())).convert( + align = max(align, (unsigned)get_page_size_log2()); + + return Base::alloc_aligned(Hw::round_page(size), align).convert( [&] (void *ptr) { return ptr; }, [&] (Ram_allocator::Alloc_error e) -> void * diff --git a/repos/base-hw/src/bootstrap/spec/x86_64/platform.cc b/repos/base-hw/src/bootstrap/spec/x86_64/platform.cc index 4b631ad67c..3dace7cf8b 100644 --- a/repos/base-hw/src/bootstrap/spec/x86_64/platform.cc +++ b/repos/base-hw/src/bootstrap/spec/x86_64/platform.cc @@ -307,7 +307,7 @@ unsigned Bootstrap::Platform::enable_mmu() /* skip the SMP when ACPI parsing did not reveal the number of CPUs */ if (board.cpus <= 1) - return cpu_id; + return (unsigned)cpu_id; Lapic lapic(board.core_mmio.virt_addr(Hw::Cpu_memory_map::lapic_phys_base())); @@ -317,7 +317,7 @@ unsigned Bootstrap::Platform::enable_mmu() if (!Cpu::IA32_apic_base::Bsp::get(lapic_msr)) /* AP - done */ - return cpu_id; + return (unsigned)cpu_id; /* BSP - we're primary CPU - wake now all other CPUs */ @@ -329,7 +329,7 @@ unsigned Bootstrap::Platform::enable_mmu() /* debates ongoing whether the second SIPI is still required */ ipi_to_all(lapic, AP_BOOT_CODE_PAGE >> 12, Lapic::Icr_low::Delivery_mode::SIPI); - return cpu_id; + return (unsigned)cpu_id; } diff --git a/repos/base-hw/src/core/core_region_map.cc b/repos/base-hw/src/core/core_region_map.cc index ca1e20a489..f5cc4f9ed3 100644 --- a/repos/base-hw/src/core/core_region_map.cc +++ b/repos/base-hw/src/core/core_region_map.cc @@ -66,7 +66,7 @@ Core_region_map::attach(Dataspace_capability ds_cap, size_t size, using namespace Hw; /* map the dataspace's physical pages to corresponding virtual addresses */ - unsigned num_pages = page_rounded_size >> get_page_size_log2(); + unsigned num_pages = (unsigned)(page_rounded_size >> get_page_size_log2()); Page_flags const flags { (writeable && ds.writable()) ? RW : RO, NO_EXEC, KERN, GLOBAL, ds.io_mem() ? DEVICE : RAM, diff --git a/repos/base-hw/src/core/irq_session_component.cc b/repos/base-hw/src/core/irq_session_component.cc index 038b267a77..33d54b2f59 100644 --- a/repos/base-hw/src/core/irq_session_component.cc +++ b/repos/base-hw/src/core/irq_session_component.cc @@ -28,7 +28,7 @@ using namespace Genode; unsigned Irq_session_component::_find_irq_number(const char * const args) { - return Arg_string::find_arg(args, "irq_number").long_value(-1); + return (unsigned)Arg_string::find_arg(args, "irq_number").long_value(-1); } @@ -64,7 +64,8 @@ Irq_session_component::~Irq_session_component() Irq_session_component::Irq_session_component(Range_allocator &irq_alloc, const char * const args) : - _irq_args(args), _irq_number(Platform::irq(_irq_args.irq_number())), + _irq_args(args), + _irq_number((unsigned)Platform::irq(_irq_args.irq_number())), _irq_alloc(irq_alloc), _kobj(), _is_msi(false), _address(0), _value(0) { long const mmconf = diff --git a/repos/base-hw/src/core/kernel/core_interface.h b/repos/base-hw/src/core/kernel/core_interface.h index 80ee2e24cf..3f59178871 100644 --- a/repos/base-hw/src/core/kernel/core_interface.h +++ b/repos/base-hw/src/core/kernel/core_interface.h @@ -132,8 +132,8 @@ namespace Kernel { inline int start_thread(Thread & thread, unsigned const cpu_id, Pd & pd, Native_utcb & utcb) { - return call(call_id_start_thread(), (Call_arg)&thread, cpu_id, - (Call_arg)&pd, (Call_arg)&utcb); + return (int)call(call_id_start_thread(), (Call_arg)&thread, cpu_id, + (Call_arg)&pd, (Call_arg)&utcb); } diff --git a/repos/base-hw/src/core/kernel/cpu.h b/repos/base-hw/src/core/kernel/cpu.h index e9c412b916..30c2c1635e 100644 --- a/repos/base-hw/src/core/kernel/cpu.h +++ b/repos/base-hw/src/core/kernel/cpu.h @@ -121,8 +121,8 @@ class Kernel::Cpu : public Genode::Cpu, private Irq::Pool, private Timeout Inter_processor_work_list _local_work_list {}; void _arch_init(); - unsigned _quota() const { return _timer.us_to_ticks(cpu_quota_us); } - unsigned _fill() const { return _timer.us_to_ticks(cpu_fill_us); } + unsigned _quota() const { return (unsigned)_timer.us_to_ticks(cpu_quota_us); } + unsigned _fill() const { return (unsigned)_timer.us_to_ticks(cpu_fill_us); } public: diff --git a/repos/base-hw/src/core/kernel/irq.h b/repos/base-hw/src/core/kernel/irq.h index b7096e31e7..4472cb8cb8 100644 --- a/repos/base-hw/src/core/kernel/irq.h +++ b/repos/base-hw/src/core/kernel/irq.h @@ -188,8 +188,8 @@ class Kernel::User_irq : public Kernel::Irq Genode::Irq_session::Polarity polarity, capid_t sig) { - return call(call_id_new_irq(), (Call_arg)&irq, nr, - (trigger << 2) | polarity, sig); + return (capid_t)call(call_id_new_irq(), (Call_arg)&irq, nr, + (trigger << 2) | polarity, sig); } /** diff --git a/repos/base-hw/src/core/kernel/object.cc b/repos/base-hw/src/core/kernel/object.cc index b1e278260f..1cb3f71131 100644 --- a/repos/base-hw/src/core/kernel/object.cc +++ b/repos/base-hw/src/core/kernel/object.cc @@ -195,7 +195,7 @@ void Object_identity_reference::invalidate() Object_identity_reference::Object_identity_reference(Object_identity *oi, Pd &pd) : - _capid(pd.capid_alloc().alloc()), _identity(oi), _pd(pd), _in_utcbs(0) + _capid((capid_t)pd.capid_alloc().alloc()), _identity(oi), _pd(pd), _in_utcbs(0) { if (_identity) _identity->insert(this); diff --git a/repos/base-hw/src/core/kernel/object.h b/repos/base-hw/src/core/kernel/object.h index e6407e63df..d54ece909d 100644 --- a/repos/base-hw/src/core/kernel/object.h +++ b/repos/base-hw/src/core/kernel/object.h @@ -250,7 +250,7 @@ class Kernel::Core_object_identity : public Object_identity, static capid_t syscall_create(Genode::Constructible> & t, capid_t const cap) { - return call(call_id_new_obj(), (Call_arg)&t, (Call_arg)cap); } + return (capid_t)call(call_id_new_obj(), (Call_arg)&t, (Call_arg)cap); } static void syscall_destroy(Genode::Constructible> & t) { call(call_id_delete_obj(), (Call_arg)&t); } diff --git a/repos/base-hw/src/core/kernel/pd.h b/repos/base-hw/src/core/kernel/pd.h index 4192830b91..4a82c0b71f 100644 --- a/repos/base-hw/src/core/kernel/pd.h +++ b/repos/base-hw/src/core/kernel/pd.h @@ -72,7 +72,7 @@ class Kernel::Pd _platform_pd(platform_pd), mmu_regs((addr_t)&table, addr_space_id_alloc) { - capid_t invalid = _capid_alloc.alloc(); + capid_t invalid = (capid_t)_capid_alloc.alloc(); assert(invalid == cap_id_invalid()); } @@ -86,8 +86,8 @@ class Kernel::Pd Hw::Page_table &tt, Genode::Platform_pd &pd) { - return call(call_id_new_pd(), (Call_arg)&p, - (Call_arg)&tt, (Call_arg)&pd); + return (capid_t)call(call_id_new_pd(), (Call_arg)&p, + (Call_arg)&tt, (Call_arg)&pd); } static void syscall_destroy(Genode::Kernel_object & p) { diff --git a/repos/base-hw/src/core/kernel/signal_receiver.h b/repos/base-hw/src/core/kernel/signal_receiver.h index 39f47a8d3a..2aabe24ef5 100644 --- a/repos/base-hw/src/core/kernel/signal_receiver.h +++ b/repos/base-hw/src/core/kernel/signal_receiver.h @@ -203,8 +203,8 @@ class Kernel::Signal_context Signal_receiver & receiver, addr_t const imprint) { - return call(call_id_new_signal_context(), (Call_arg)&c, - (Call_arg)&receiver, (Call_arg)imprint); + return (capid_t)call(call_id_new_signal_context(), (Call_arg)&c, + (Call_arg)&receiver, (Call_arg)imprint); } /** @@ -283,7 +283,7 @@ class Kernel::Signal_receiver * \retval capability id of the new kernel object */ static capid_t syscall_create(Genode::Kernel_object &r) { - return call(call_id_new_signal_receiver(), (Call_arg)&r); } + return (capid_t)call(call_id_new_signal_receiver(), (Call_arg)&r); } /** * Syscall to destruct a signal receiver diff --git a/repos/base-hw/src/core/kernel/thread.cc b/repos/base-hw/src/core/kernel/thread.cc index 5e17dffe93..0d2e9227e7 100644 --- a/repos/base-hw/src/core/kernel/thread.cc +++ b/repos/base-hw/src/core/kernel/thread.cc @@ -90,7 +90,7 @@ void Thread::_ipc_free_recv_caps() void Thread::_ipc_init(Genode::Native_utcb &utcb, Thread &starter) { _utcb = &utcb; - _ipc_alloc_recv_caps(starter._utcb->cap_cnt()); + _ipc_alloc_recv_caps((unsigned)(starter._utcb->cap_cnt())); ipc_copy_msg(starter); } @@ -311,14 +311,14 @@ size_t Thread::_core_to_kernel_quota(size_t const quota) const void Thread::_call_thread_quota() { Thread * const thread = (Thread *)user_arg_1(); - thread->Cpu_job::quota(_core_to_kernel_quota(user_arg_2())); + thread->Cpu_job::quota((unsigned)(_core_to_kernel_quota(user_arg_2()))); } void Thread::_call_start_thread() { /* lookup CPU */ - Cpu & cpu = _cpu_pool.cpu(user_arg_2()); + Cpu & cpu = _cpu_pool.cpu((unsigned)user_arg_2()); user_arg_0(0); Thread &thread = *(Thread*)user_arg_1(); @@ -362,7 +362,7 @@ void Thread::_call_stop_thread() void Thread::_call_restart_thread() { - Thread *thread_ptr = pd().cap_tree().find(user_arg_1()); + Thread *thread_ptr = pd().cap_tree().find((capid_t)user_arg_1()); if (!thread_ptr) return; @@ -450,7 +450,7 @@ void Thread::_call_delete_thread() void Thread::_call_await_request_msg() { if (_ipc_node.can_await_request()) { - _ipc_alloc_recv_caps(user_arg_1()); + _ipc_alloc_recv_caps((unsigned)user_arg_1()); _ipc_node.await_request(); if (_ipc_node.awaits_request()) { _become_inactive(AWAITS_IPC); @@ -467,7 +467,7 @@ void Thread::_call_await_request_msg() void Thread::_call_timeout() { Timer & t = _cpu->timer(); - _timeout_sigid = user_arg_2(); + _timeout_sigid = (Kernel::capid_t)user_arg_2(); t.set_timeout(this, t.us_to_ticks(user_arg_1())); } @@ -499,7 +499,7 @@ void Thread::timeout_triggered() void Thread::_call_send_request_msg() { - Object_identity_reference * oir = pd().cap_tree().find(user_arg_1()); + Object_identity_reference * oir = pd().cap_tree().find((capid_t)user_arg_1()); Thread * const dst = (oir) ? oir->object() : nullptr; if (!dst) { Genode::raw(*this, ": cannot send to unknown recipient ", @@ -513,7 +513,7 @@ void Thread::_call_send_request_msg() if (!_ipc_node.can_send_request()) { Genode::raw("IPC send request: bad state"); } else { - _ipc_alloc_recv_caps(user_arg_2()); + _ipc_alloc_recv_caps((unsigned)user_arg_2()); _ipc_capid = oir ? oir->capid() : cap_id_invalid(); _ipc_node.send_request(dst->_ipc_node, help); } @@ -536,7 +536,7 @@ void Thread::_call_pager() { /* override event route */ Thread &thread = *(Thread *)user_arg_1(); - thread._pager = pd().cap_tree().find(user_arg_2()); + thread._pager = pd().cap_tree().find((Kernel::capid_t)user_arg_2()); } @@ -552,7 +552,7 @@ void Thread::_call_await_signal() return; } /* lookup receiver */ - Signal_receiver * const r = pd().cap_tree().find(user_arg_1()); + Signal_receiver * const r = pd().cap_tree().find((Kernel::capid_t)user_arg_1()); if (!r) { Genode::raw(*this, ": cannot await, unknown signal receiver ", (unsigned)user_arg_1()); @@ -573,7 +573,7 @@ void Thread::_call_await_signal() void Thread::_call_pending_signal() { /* lookup receiver */ - Signal_receiver * const r = pd().cap_tree().find(user_arg_1()); + Signal_receiver * const r = pd().cap_tree().find((Kernel::capid_t)user_arg_1()); if (!r) { Genode::raw(*this, ": cannot await, unknown signal receiver ", (unsigned)user_arg_1()); @@ -601,7 +601,7 @@ void Thread::_call_pending_signal() void Thread::_call_cancel_next_await_signal() { /* kill the caller if the capability of the target thread is invalid */ - Thread * const thread = pd().cap_tree().find(user_arg_1()); + Thread * const thread = pd().cap_tree().find((Kernel::capid_t)user_arg_1()); if (!thread || (&pd() != &thread->pd())) { raw(*this, ": failed to lookup thread ", (unsigned)user_arg_1()); _die(); @@ -620,7 +620,7 @@ void Thread::_call_cancel_next_await_signal() void Thread::_call_submit_signal() { /* lookup signal context */ - Signal_context * const c = pd().cap_tree().find(user_arg_1()); + Signal_context * const c = pd().cap_tree().find((Kernel::capid_t)user_arg_1()); if(!c) { /* cannot submit unknown signal context */ user_arg_0(-1); @@ -628,12 +628,12 @@ void Thread::_call_submit_signal() } /* trigger signal context */ - if (!c->can_submit(user_arg_2())) { + if (!c->can_submit((unsigned)user_arg_2())) { Genode::raw("failed to submit signal context"); user_arg_0(-1); return; } - c->submit(user_arg_2()); + c->submit((unsigned)user_arg_2()); user_arg_0(0); } @@ -641,7 +641,7 @@ void Thread::_call_submit_signal() void Thread::_call_ack_signal() { /* lookup signal context */ - Signal_context * const c = pd().cap_tree().find(user_arg_1()); + Signal_context * const c = pd().cap_tree().find((Kernel::capid_t)user_arg_1()); if (!c) { Genode::raw(*this, ": cannot ack unknown signal context"); return; @@ -655,7 +655,7 @@ void Thread::_call_ack_signal() void Thread::_call_kill_signal_context() { /* lookup signal context */ - Signal_context * const c = pd().cap_tree().find(user_arg_1()); + Signal_context * const c = pd().cap_tree().find((Kernel::capid_t)user_arg_1()); if (!c) { Genode::raw(*this, ": cannot kill unknown signal context"); user_arg_0(-1); @@ -674,7 +674,7 @@ void Thread::_call_kill_signal_context() void Thread::_call_new_irq() { - Signal_context * const c = pd().cap_tree().find(user_arg_4()); + Signal_context * const c = pd().cap_tree().find((Kernel::capid_t)user_arg_4()); if (!c) { Genode::raw(*this, ": invalid signal context for interrupt"); user_arg_0(-1); @@ -699,7 +699,7 @@ void Thread::_call_ack_irq() { void Thread::_call_new_obj() { /* lookup thread */ - Object_identity_reference * ref = pd().cap_tree().find(user_arg_2()); + Object_identity_reference * ref = pd().cap_tree().find((Kernel::capid_t)user_arg_2()); Thread * thread = ref ? ref->object() : nullptr; if (!thread || (static_cast*>(thread)->capid() != ref->capid())) { @@ -726,14 +726,14 @@ void Thread::_call_delete_obj() void Thread::_call_ack_cap() { - Object_identity_reference * oir = pd().cap_tree().find(user_arg_1()); + Object_identity_reference * oir = pd().cap_tree().find((Kernel::capid_t)user_arg_1()); if (oir) oir->remove_from_utcb(); } void Thread::_call_delete_cap() { - Object_identity_reference * oir = pd().cap_tree().find(user_arg_1()); + Object_identity_reference * oir = pd().cap_tree().find((Kernel::capid_t)user_arg_1()); if (!oir) return; if (oir->in_utcb()) return; @@ -766,7 +766,7 @@ void Thread::_call() try { /* switch over unrestricted kernel calls */ - unsigned const call_id = user_arg_0(); + unsigned const call_id = (unsigned)user_arg_0(); switch (call_id) { case call_id_cache_coherent_region(): _call_cache_coherent_region(); return; case call_id_cache_clean_inv_region(): _call_cache_clean_invalidate_data_region(); return; diff --git a/repos/base-hw/src/core/kernel/thread.h b/repos/base-hw/src/core/kernel/thread.h index a9db6f2228..f7516a6ba9 100644 --- a/repos/base-hw/src/core/kernel/thread.h +++ b/repos/base-hw/src/core/kernel/thread.h @@ -356,8 +356,9 @@ class Kernel::Thread : private Kernel::Object, public Cpu_job, private Timeout size_t const quota, char const * const label) { - return call(call_id_new_thread(), (Call_arg)&t, (Call_arg)priority, - (Call_arg)quota, (Call_arg)label); + return (capid_t)call(call_id_new_thread(), (Call_arg)&t, + (Call_arg)priority, (Call_arg)quota, + (Call_arg)label); } /** @@ -371,8 +372,8 @@ class Kernel::Thread : private Kernel::Object, public Cpu_job, private Timeout static capid_t syscall_create(Genode::Kernel_object & t, char const * const label) { - return call(call_id_new_core_thread(), (Call_arg)&t, - (Call_arg)label); + return (capid_t)call(call_id_new_core_thread(), (Call_arg)&t, + (Call_arg)label); } /** diff --git a/repos/base-hw/src/core/kernel/vm.h b/repos/base-hw/src/core/kernel/vm.h index ca202e0511..bc7301e577 100644 --- a/repos/base-hw/src/core/kernel/vm.h +++ b/repos/base-hw/src/core/kernel/vm.h @@ -101,8 +101,8 @@ class Kernel::Vm : private Kernel::Object, public Cpu_job capid_t const signal_context_id, Identity & id) { - return call(call_id_new_vm(), (Call_arg)&vm, (Call_arg)cpu, - (Call_arg)state, (Call_arg)&id, signal_context_id); + return (capid_t)call(call_id_new_vm(), (Call_arg)&vm, (Call_arg)cpu, + (Call_arg)state, (Call_arg)&id, signal_context_id); } /** diff --git a/repos/base-hw/src/core/kernel/vm_thread_on.cc b/repos/base-hw/src/core/kernel/vm_thread_on.cc index cdbb202939..4bfa7703f9 100644 --- a/repos/base-hw/src/core/kernel/vm_thread_on.cc +++ b/repos/base-hw/src/core/kernel/vm_thread_on.cc @@ -19,7 +19,7 @@ void Kernel::Thread::_call_new_vm() { Signal_context * context = - pd().cap_tree().find(user_arg_5()); + pd().cap_tree().find((capid_t)user_arg_5()); if (!context) { user_arg_0(cap_id_invalid()); return; @@ -36,7 +36,7 @@ void Kernel::Thread::_call_delete_vm() { _call_delete(); } void Kernel::Thread::_call_run_vm() { - Object_identity_reference * ref = pd().cap_tree().find(user_arg_1()); + Object_identity_reference * ref = pd().cap_tree().find((capid_t)user_arg_1()); Vm * vm = ref ? ref->object() : nullptr; if (!vm) { @@ -52,7 +52,7 @@ void Kernel::Thread::_call_run_vm() void Kernel::Thread::_call_pause_vm() { - Object_identity_reference * ref = pd().cap_tree().find(user_arg_1()); + Object_identity_reference * ref = pd().cap_tree().find((capid_t)user_arg_1()); Vm * vm = ref ? ref->object() : nullptr; if (!vm) { diff --git a/repos/base-hw/src/core/platform.cc b/repos/base-hw/src/core/platform.cc index b12714ae67..66d1146a89 100644 --- a/repos/base-hw/src/core/platform.cc +++ b/repos/base-hw/src/core/platform.cc @@ -300,11 +300,9 @@ Platform::Platform() ** Support for core memory management ** ****************************************/ -bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr, - unsigned size) { - return ::map_local(phys_addr, virt_addr, size / get_page_size()); } +bool Mapped_mem_allocator::_map_local(addr_t virt, addr_t phys, size_t size) { + return ::map_local(phys, virt, size / get_page_size()); } -bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, addr_t, - unsigned size) { - return ::unmap_local(virt_addr, size / get_page_size()); } +bool Mapped_mem_allocator::_unmap_local(addr_t virt, addr_t, size_t size) { + return ::unmap_local(virt, size / get_page_size()); } diff --git a/repos/base-hw/src/core/platform_thread.cc b/repos/base-hw/src/core/platform_thread.cc index cd5c39fa7a..8235f64152 100644 --- a/repos/base-hw/src/core/platform_thread.cc +++ b/repos/base-hw/src/core/platform_thread.cc @@ -54,7 +54,7 @@ Platform_thread::~Platform_thread() void Platform_thread::quota(size_t const quota) { - _quota = quota; + _quota = (unsigned)quota; Kernel::thread_quota(*_kobj, quota); } @@ -97,7 +97,7 @@ Platform_thread::Platform_thread(size_t const quota, _pager(nullptr), _utcb_pd_addr((Native_utcb *)utcb), _priority(_scale_priority(virt_prio)), - _quota(quota), + _quota((unsigned)quota), _main_thread(false), _location(location), _kobj(_kobj.CALLED_FROM_CORE, _priority, _quota, _label.string()) diff --git a/repos/base-hw/src/core/spec/arm/cpu_support.h b/repos/base-hw/src/core/spec/arm/cpu_support.h index 0b3cb3fb38..3fa86f1a07 100644 --- a/repos/base-hw/src/core/spec/arm/cpu_support.h +++ b/repos/base-hw/src/core/spec/arm/cpu_support.h @@ -71,7 +71,7 @@ struct Genode::Arm_cpu : public Hw::Arm_cpu ~Mmu_context(); - uint8_t id() { return cidr; } + uint8_t id() { return (uint8_t)cidr; } }; /** diff --git a/repos/base-hw/src/core/spec/arm/generic_timer.cc b/repos/base-hw/src/core/spec/arm/generic_timer.cc index 46dca2e7dd..5bf6195059 100644 --- a/repos/base-hw/src/core/spec/arm/generic_timer.cc +++ b/repos/base-hw/src/core/spec/arm/generic_timer.cc @@ -24,7 +24,7 @@ unsigned Timer::interrupt_id() const { return Board::TIMER_IRQ; } unsigned long Board::Timer::_freq() { return Genode::Cpu::Cntfrq::read(); } -Board::Timer::Timer(unsigned) : ticks_per_ms(_freq() / 1000) +Board::Timer::Timer(unsigned) : ticks_per_ms((unsigned)(_freq() / 1000)) { Cpu::Cntp_ctl::access_t ctl = 0; Cpu::Cntp_ctl::Enable::set(ctl, 1); @@ -35,7 +35,7 @@ Board::Timer::Timer(unsigned) : ticks_per_ms(_freq() / 1000) void Timer::_start_one_shot(time_t const ticks) { _device.last_time = Cpu::Cntpct::read(); - Cpu::Cntp_tval::write(ticks); + Cpu::Cntp_tval::write((Cpu::Cntp_tval::access_t)ticks); Cpu::Cntp_ctl::access_t ctl = Cpu::Cntp_ctl::read(); Cpu::Cntp_ctl::Istatus::set(ctl, 0); Cpu::Cntp_ctl::write(ctl); diff --git a/repos/base-hw/src/core/spec/arm/virtualization/vm_session_component.cc b/repos/base-hw/src/core/spec/arm/virtualization/vm_session_component.cc index 3320e51411..8edbc971f3 100644 --- a/repos/base-hw/src/core/spec/arm/virtualization/vm_session_component.cc +++ b/repos/base-hw/src/core/spec/arm/virtualization/vm_session_component.cc @@ -96,7 +96,7 @@ static Vmid_allocator &alloc() allocator = unmanaged_singleton(); /* reserve VM ID 0 for the hypervisor */ - unsigned id = allocator->alloc(); + addr_t id = allocator->alloc(); assert (id == 0); } return *allocator; diff --git a/repos/base-hw/src/core/spec/arm_v8/cpu.h b/repos/base-hw/src/core/spec/arm_v8/cpu.h index d6874d755d..502d9ca62a 100644 --- a/repos/base-hw/src/core/spec/arm_v8/cpu.h +++ b/repos/base-hw/src/core/spec/arm_v8/cpu.h @@ -96,7 +96,7 @@ struct Genode::Cpu : Hw::Arm_64_cpu ~Mmu_context(); Genode::uint16_t id() { - return Ttbr::Asid::get(ttbr); } + return Ttbr::Asid::get(ttbr) & 0xffff; } }; void switch_to(Context&, Mmu_context &); diff --git a/repos/base-hw/src/core/spec/riscv/cpu.cc b/repos/base-hw/src/core/spec/riscv/cpu.cc index c316c29836..e182afe444 100644 --- a/repos/base-hw/src/core/spec/riscv/cpu.cc +++ b/repos/base-hw/src/core/spec/riscv/cpu.cc @@ -47,7 +47,7 @@ Mmu_context(addr_t page_table_base, Mmu_context::~Mmu_context() { - unsigned asid = Satp::Asid::get(satp); + unsigned asid = (uint16_t)Satp::Asid::get(satp); /* ASID is 16 bit */ Cpu::invalidate_tlb_by_pid(asid); _addr_space_id_alloc.free(asid); } diff --git a/repos/base-hw/src/core/spec/x86_64/cpu.cc b/repos/base-hw/src/core/spec/x86_64/cpu.cc index a6311eba13..5ef6bc2cff 100644 --- a/repos/base-hw/src/core/spec/x86_64/cpu.cc +++ b/repos/base-hw/src/core/spec/x86_64/cpu.cc @@ -130,7 +130,9 @@ unsigned Genode::Cpu::executing_id() void * const stack_ptr = nullptr; addr_t const stack_addr = reinterpret_cast(&stack_ptr); addr_t const stack_base = reinterpret_cast(&kernel_stack); - unsigned const cpu_id = (stack_addr - stack_base) / kernel_stack_size; + + unsigned const cpu_id = (unsigned)((stack_addr - stack_base) / kernel_stack_size); + return cpu_id; } diff --git a/repos/base-hw/src/core/spec/x86_64/pic.cc b/repos/base-hw/src/core/spec/x86_64/pic.cc index d238774414..b267faa870 100644 --- a/repos/base-hw/src/core/spec/x86_64/pic.cc +++ b/repos/base-hw/src/core/spec/x86_64/pic.cc @@ -212,7 +212,7 @@ void Global_interrupt_controller::_update_irt_entry(unsigned irq) Irte::Trg::set(irte, _irq_mode[irq].trigger_mode); write(IOREDTBL + 2 * irq); - write(irte); + write((Iowin::access_t)(irte)); } @@ -251,9 +251,9 @@ Global_interrupt_controller::Global_interrupt_controller() if (i < _irte_count) { Irte::access_t irte = _create_irt_entry(i); write(IOREDTBL + 2 * i + 1); - write(irte >> Iowin::ACCESS_WIDTH); + write((Iowin::access_t)(irte >> Iowin::ACCESS_WIDTH)); write(IOREDTBL + 2 * i); - write(irte); + write((Iowin::access_t)(irte)); } } }; @@ -284,5 +284,5 @@ void Global_interrupt_controller::toggle_mask(unsigned const vector, write(IOREDTBL + (2 * irq)); Irte::access_t irte = read(); Irte::Mask::set(irte, set); - write(irte); + write((Iowin::access_t)(irte)); } diff --git a/repos/base-hw/src/core/spec/x86_64/pic.h b/repos/base-hw/src/core/spec/x86_64/pic.h index eee97a058e..3f61994192 100644 --- a/repos/base-hw/src/core/spec/x86_64/pic.h +++ b/repos/base-hw/src/core/spec/x86_64/pic.h @@ -51,6 +51,8 @@ class Board::Global_interrupt_controller : public Genode::Mmio { private: + using uint8_t = Genode::uint8_t; + enum { /* Register selectors */ IOAPICVER = 0x01, @@ -82,9 +84,9 @@ class Board::Global_interrupt_controller : public Genode::Mmio struct Maximum_redirection_entry : Bitfield<16, 8> { }; }; - unsigned _irte_count = 0; /* number of redirection table entries */ - Genode::uint8_t _lapic_id[NR_OF_CPUS]; /* unique name of the LAPIC of each CPU */ - Irq_mode _irq_mode[IRQ_COUNT]; + unsigned _irte_count = 0; /* number of redirection table entries */ + uint8_t _lapic_id[NR_OF_CPUS]; /* unique name of the LAPIC of each CPU */ + Irq_mode _irq_mode[IRQ_COUNT]; /** * Return whether 'irq' is an edge-triggered interrupt @@ -137,10 +139,9 @@ class Board::Global_interrupt_controller : public Genode::Mmio ** Accessors ** ***************/ - void lapic_id(unsigned cpu_id, - Genode::uint8_t lapic_id); + void lapic_id(unsigned cpu_id, uint8_t lapic_id); - Genode::uint8_t lapic_id(unsigned cpu_id) const; + uint8_t lapic_id(unsigned cpu_id) const; }; @@ -222,7 +223,7 @@ class Board::Local_interrupt_controller : public Genode::Mmio { if (cpu_id < NR_OF_CPUS) { Id::access_t const lapic_id = read(); - _global_irq_ctrl.lapic_id(cpu_id, (lapic_id >> 24) & 0xff); + _global_irq_ctrl.lapic_id(cpu_id, (unsigned char)((lapic_id >> 24) & 0xff)); } } diff --git a/repos/base-hw/src/core/spec/x86_64/pit.cc b/repos/base-hw/src/core/spec/x86_64/pit.cc index d52a75edb6..a2f00feddd 100644 --- a/repos/base-hw/src/core/spec/x86_64/pit.cc +++ b/repos/base-hw/src/core/spec/x86_64/pit.cc @@ -30,10 +30,10 @@ uint32_t Board::Timer::pit_calc_timer_freq(void) { uint32_t t_start, t_end; - /* Set channel gate high and disable speaker */ - outb(PIT_CH2_GATE, (inb(0x61) & ~0x02) | 0x01); + /* set channel gate high and disable speaker */ + outb(PIT_CH2_GATE, (uint8_t)((inb(0x61) & ~0x02) | 0x01)); - /* Set timer counter (mode 0, binary count) */ + /* set timer counter (mode 0, binary count) */ outb(PIT_MODE, 0xb0); outb(PIT_CH2_DATA, PIT_SLEEP_TICS & 0xff); outb(PIT_CH2_DATA, PIT_SLEEP_TICS >> 8); @@ -57,7 +57,7 @@ Board::Timer::Timer(unsigned) : Mmio(Platform::mmio_to_virt(Hw::Cpu_memory_map::lapic_phys_base())) { - /* Enable LAPIC timer in one-shot mode */ + /* enable LAPIC timer in one-shot mode */ write(Board::TIMER_VECTOR_KERNEL); write(0); write(0); @@ -71,7 +71,7 @@ Board::Timer::Timer(unsigned) raw("Failed to calibrate timer frequency"); throw Calibration_failed(); } - write(div); + write((uint8_t)div); /* Calculate timer frequency */ ticks_per_ms = pit_calc_timer_freq(); @@ -88,7 +88,7 @@ Board::Timer::Timer(unsigned) void Timer::_start_one_shot(time_t const ticks) { - _device.write(ticks); } + _device.write((uint32_t)ticks); } time_t Timer::ticks_to_us(time_t const ticks) const { diff --git a/repos/base-hw/src/include/base/internal/capability_space.h b/repos/base-hw/src/include/base/internal/capability_space.h index 5eb566bb36..3998350676 100644 --- a/repos/base-hw/src/include/base/internal/capability_space.h +++ b/repos/base-hw/src/include/base/internal/capability_space.h @@ -27,8 +27,7 @@ namespace Genode { namespace Capability_space { */ static inline Kernel::capid_t capid(Native_capability const &cap) { - addr_t const index = (addr_t)cap.data(); - return index; + return (Kernel::capid_t)((addr_t)cap.data() & 0xffffU); } static inline Native_capability import(Kernel::capid_t capid) diff --git a/repos/base-hw/src/include/hw/page_table_allocator.h b/repos/base-hw/src/include/hw/page_table_allocator.h index 0cbad5dc1a..ec94f65d57 100644 --- a/repos/base-hw/src/include/hw/page_table_allocator.h +++ b/repos/base-hw/src/include/hw/page_table_allocator.h @@ -66,7 +66,7 @@ class Hw::Page_table_allocator { static_assert((sizeof(TABLE) == TABLE_SIZE), "unexpected size"); table.~TABLE(); - _free(_offset(table) / sizeof(TABLE)); + _free((unsigned)(_offset(table) / sizeof(TABLE))); } }; @@ -114,7 +114,7 @@ class Hw::Page_table_allocator::Array::Allocator unsigned _alloc() override { try { - return _free_tables.alloc(); + return (unsigned)_free_tables.alloc(); } catch (typename Bit_allocator::Out_of_indices&) {} throw Out_of_tables(); } diff --git a/repos/base-hw/src/include/hw/spec/arm_64/cpu.h b/repos/base-hw/src/include/hw/spec/arm_64/cpu.h index e280513406..d3d0ef0117 100644 --- a/repos/base-hw/src/include/hw/spec/arm_64/cpu.h +++ b/repos/base-hw/src/include/hw/spec/arm_64/cpu.h @@ -86,7 +86,7 @@ struct Hw::Arm_64_cpu struct Iss : Bitfield<0, 25> { - struct Abort : Register<32> + struct Abort : Register<64> { struct Level : Bitfield<0, 2> {}; struct Fsc : Bitfield<2, 4> @@ -231,7 +231,7 @@ struct Hw::Arm_64_cpu struct Asid : Bitfield<48, 8> { }; ); - static inline unsigned current_privilege_level() { + static Current_el::access_t current_privilege_level() { return Current_el::El::get(Current_el::read()); } diff --git a/repos/base-hw/src/include/hw/spec/arm_64/psci_call.h b/repos/base-hw/src/include/hw/spec/arm_64/psci_call.h index 5b1e7706e8..01a8acd07c 100644 --- a/repos/base-hw/src/include/hw/spec/arm_64/psci_call.h +++ b/repos/base-hw/src/include/hw/spec/arm_64/psci_call.h @@ -17,8 +17,8 @@ #include #define PSCI_CALL_IMPL(instr) \ - static inline int call(unsigned int func, unsigned long a0, \ - unsigned int a1, unsigned int a2) { \ + static inline int call(Genode::umword_t func, Genode::umword_t a0, \ + Genode::umword_t a1, Genode::umword_t a2) { \ unsigned long result = 0; \ asm volatile ("mov x0, %1 \n" \ "mov x1, %2 \n" \ @@ -30,7 +30,7 @@ : "r"(func), "r"(a0), "r"(a1), "r"(a2) \ : "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", \ "x8", "x9", "x10", "x11", "x12", "x13", "x14"); \ - return result; \ + return (int)result; \ } namespace Hw { diff --git a/repos/base-hw/src/include/hw/spec/riscv/page_table.h b/repos/base-hw/src/include/hw/spec/riscv/page_table.h index 552f05e534..93cbbcbb6e 100644 --- a/repos/base-hw/src/include/hw/spec/riscv/page_table.h +++ b/repos/base-hw/src/include/hw/spec/riscv/page_table.h @@ -181,7 +181,7 @@ class Sv39::Level_x_translation_table * Return how many entries of an alignment fit into region */ static constexpr size_t _count(size_t region, size_t alignment) { - return align_addr(region, alignment) / (1UL << alignment); } + return align_addr(region, (unsigned)alignment) / (1UL << alignment); } template diff --git a/repos/base-hw/src/include/hw/spec/x86_64/acpi.h b/repos/base-hw/src/include/hw/spec/x86_64/acpi.h index 2f6db4af6d..42c188c332 100644 --- a/repos/base-hw/src/include/hw/spec/x86_64/acpi.h +++ b/repos/base-hw/src/include/hw/spec/x86_64/acpi.h @@ -87,7 +87,7 @@ void Hw::for_each_rsdt_entry(Hw::Acpi_generic &rsdt, FUNC fn) typedef Genode::uint32_t entry_t; unsigned const table_size = rsdt.size; - unsigned const entry_count = (table_size - sizeof(rsdt)) / sizeof(entry_t); + unsigned const entry_count = (unsigned)((table_size - sizeof(rsdt)) / sizeof(entry_t)); entry_t * entries = reinterpret_cast(&rsdt + 1); for (unsigned i = 0; i < entry_count; i++) @@ -104,7 +104,7 @@ void Hw::for_each_xsdt_entry(Hw::Acpi_generic &xsdt, FUNC fn) typedef Genode::uint64_t entry_t; unsigned const table_size = xsdt.size; - unsigned const entry_count = (table_size - sizeof(xsdt)) / sizeof(entry_t); + unsigned const entry_count = (unsigned)((table_size - sizeof(xsdt)) / sizeof(entry_t)); entry_t * entries = reinterpret_cast(&xsdt + 1); for (unsigned i = 0; i < entry_count; i++) diff --git a/repos/base-hw/src/include/hw/spec/x86_64/page_table.h b/repos/base-hw/src/include/hw/spec/x86_64/page_table.h index 52f6b3b983..44bc24e67b 100644 --- a/repos/base-hw/src/include/hw/spec/x86_64/page_table.h +++ b/repos/base-hw/src/include/hw/spec/x86_64/page_table.h @@ -618,7 +618,7 @@ class Hw::Pml4_table */ static constexpr size_t _count(size_t region, size_t alignment) { - return Genode::align_addr(region, alignment) + return Genode::align_addr(region, (int)alignment) / (1UL << alignment); } diff --git a/repos/base-hw/src/lib/base/capability.cc b/repos/base-hw/src/lib/base/capability.cc index 66ed0c6bcb..3d559d4837 100644 --- a/repos/base-hw/src/lib/base/capability.cc +++ b/repos/base-hw/src/lib/base/capability.cc @@ -48,7 +48,10 @@ void Native_capability::_dec() return; spinlock_lock(&spinlock); - if (!--ref_counter[(addr_t)_data]) { Kernel::delete_cap((addr_t)_data); } + + if (!--ref_counter[(addr_t)_data]) + Kernel::delete_cap((Kernel::capid_t)((addr_t)_data & 0xffff)); + spinlock_unlock(&spinlock); } diff --git a/repos/base-hw/src/lib/base/ipc.cc b/repos/base-hw/src/lib/base/ipc.cc index 29a9478bbc..6ca6c09054 100644 --- a/repos/base-hw/src/lib/base/ipc.cc +++ b/repos/base-hw/src/lib/base/ipc.cc @@ -101,7 +101,9 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst, copy_msg_to_utcb(snd_msg, *Thread::myself()->utcb()); - switch (Kernel::send_request_msg(Capability_space::capid(dst), rcv_caps)) { + switch (Kernel::send_request_msg(Capability_space::capid(dst), + (unsigned)rcv_caps)) { + case -1: throw Blocking_canceled(); case -2: throw Allocator::Out_of_memory(); default: @@ -111,7 +113,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst, }, [&] () { upgrade_capability_slab(); }); - return Rpc_exception_code(utcb.exception_code()); + return Rpc_exception_code((int)utcb.exception_code()); } diff --git a/repos/base-hw/src/test/cpu_scheduler/test.cc b/repos/base-hw/src/test/cpu_scheduler/test.cc index 66ff0d7286..470a8ba44f 100644 --- a/repos/base-hw/src/test/cpu_scheduler/test.cc +++ b/repos/base-hw/src/test/cpu_scheduler/test.cc @@ -59,7 +59,7 @@ unsigned share_id(void * const pointer) addr_t const base = (addr_t)data()->shares; if (address < base || address >= base + sizeof(data()->shares)) { return 0; } - return (address - base) / sizeof(Cpu_share) + 1; + return (unsigned)((address - base) / sizeof(Cpu_share) + 1); } diff --git a/repos/base-hw/src/timer/hw/time_source.cc b/repos/base-hw/src/timer/hw/time_source.cc index bf0f699c71..e95c2334d4 100644 --- a/repos/base-hw/src/timer/hw/time_source.cc +++ b/repos/base-hw/src/timer/hw/time_source.cc @@ -39,16 +39,16 @@ Timer::Time_source::Time_source(Env &env) void Timer::Time_source::set_timeout(Microseconds duration, Timeout_handler &handler) { - Kernel::timeout_t duration_us = duration.value; + Kernel::timeout_t duration_us = (Kernel::timeout_t)duration.value; if (duration_us < MIN_TIMEOUT_US) { duration_us = MIN_TIMEOUT_US; } if (duration_us > _max_timeout_us) { - duration_us = _max_timeout_us; } + duration_us = (Kernel::timeout_t)_max_timeout_us; } _handler = &handler; Signal_context_capability cap = _signal_handler; - Kernel::timeout(duration_us, (addr_t)cap.data()); + Kernel::timeout(duration_us, (Kernel::capid_t)((addr_t)cap.data() & 0xffff)); } diff --git a/repos/base-linux/src/core/include/core_linux_syscalls.h b/repos/base-linux/src/core/include/core_linux_syscalls.h index 3813a93cb5..1b7adb6f3f 100644 --- a/repos/base-linux/src/core/include/core_linux_syscalls.h +++ b/repos/base-linux/src/core/include/core_linux_syscalls.h @@ -32,19 +32,19 @@ inline int lx_mkdir(char const *pathname, mode_t mode) { - return lx_syscall(SYS_mkdirat, AT_FDCWD, pathname, mode); + return (int)lx_syscall(SYS_mkdirat, AT_FDCWD, pathname, mode); } inline int lx_ftruncate(int fd, unsigned long length) { - return lx_syscall(SYS_ftruncate, fd, length); + return (int)lx_syscall(SYS_ftruncate, fd, length); } inline int lx_unlink(const char *fname) { - return lx_syscall(SYS_unlinkat, AT_FDCWD, fname, 0); + return (int)lx_syscall(SYS_unlinkat, AT_FDCWD, fname, 0); } @@ -54,7 +54,7 @@ inline int lx_unlink(const char *fname) inline int lx_open(char const *pathname, int flags, mode_t mode = 0) { - return lx_syscall(SYS_openat, AT_FDCWD, pathname, flags, mode); + return (int)lx_syscall(SYS_openat, AT_FDCWD, pathname, flags, mode); } @@ -62,16 +62,16 @@ inline int lx_stat_size(char const *path, Genode::uint64_t &out_size) { #ifdef __aarch64__ struct statx buf { }; - int result = lx_syscall(SYS_statx, AT_FDCWD, path, 0, STATX_SIZE, &buf); + int result = (int)lx_syscall(SYS_statx, AT_FDCWD, path, 0, STATX_SIZE, &buf); out_size = buf.stx_size; #else #ifdef _LP64 struct stat buf { }; - int result = lx_syscall(SYS_stat, path, &buf); + int result = (int)lx_syscall(SYS_stat, path, &buf); out_size = buf.st_size; #else struct stat64 buf { }; - int result = lx_syscall(SYS_stat64, path, &buf); + int result = (int)lx_syscall(SYS_stat64, path, &buf); out_size = buf.st_size; #endif #endif @@ -86,7 +86,7 @@ inline int lx_stat_size(char const *path, Genode::uint64_t &out_size) #if defined(__x86_64__) || defined(__i386__) inline int lx_iopl(int level) { - return lx_syscall(SYS_iopl, level); + return (int)lx_syscall(SYS_iopl, level); } #endif @@ -103,13 +103,13 @@ inline int lx_ioctl_iomem(int fd, unsigned long phys, Genode::size_t offset) Genode::size_t length; } range = {phys, offset}; - return lx_syscall(SYS_ioctl, fd, _IOW('g', 1, void *), &range); + return (int)lx_syscall(SYS_ioctl, fd, _IOW('g', 1, void *), &range); } inline int lx_ioctl_irq(int fd, int irq) { - return lx_syscall(SYS_ioctl, fd, _IOW('g', 2, int*), &irq); + return (int)lx_syscall(SYS_ioctl, fd, _IOW('g', 2, int*), &irq); } @@ -120,13 +120,13 @@ inline int lx_ioctl_irq(int fd, int irq) inline int lx_execve(const char *filename, char *const argv[], char *const envp[]) { - return lx_syscall(SYS_execve, filename, argv, envp); + return (int)lx_syscall(SYS_execve, filename, argv, envp); } inline int lx_kill(int pid, int signal) { - return lx_syscall(SYS_kill, pid, signal); + return (int)lx_syscall(SYS_kill, pid, signal); } @@ -138,19 +138,19 @@ inline int lx_create_process(int (*entry)(), void *stack) * this condition. */ int const flags = CLONE_VFORK | LX_SIGCHLD; - return lx_clone((int (*)())entry, stack, flags); + return (int)lx_clone((int (*)())entry, stack, flags); } inline int lx_setuid(unsigned int uid) { - return lx_syscall(SYS_setuid, uid); + return (int)lx_syscall(SYS_setuid, uid); } inline int lx_setgid(unsigned int gid) { - return lx_syscall(SYS_setgid, gid); + return (int)lx_syscall(SYS_setgid, gid); } @@ -164,7 +164,7 @@ inline int lx_setgid(unsigned int gid) */ inline int lx_pollpid() { - return lx_syscall(SYS_wait4, -1 /* any PID */, (int *)0, 1 /* WNOHANG */, 0); + return (int)lx_syscall(SYS_wait4, -1 /* any PID */, (int *)0, 1 /* WNOHANG */, 0); } @@ -193,7 +193,7 @@ inline void lx_boost_rlimit() { rlimit rlimit { }; - if (int const res = lx_syscall(SYS_getrlimit, RLIMIT_NOFILE, &rlimit)) { + if (int const res = (int)lx_syscall(SYS_getrlimit, RLIMIT_NOFILE, &rlimit)) { Genode::warning("unable to obtain RLIMIT_NOFILE (", res, "), keeping limit unchanged"); return; } @@ -201,7 +201,7 @@ inline void lx_boost_rlimit() /* increase soft limit to hard limit */ rlimit.rlim_cur = rlimit.rlim_max; - if (int const res = lx_syscall(SYS_setrlimit, RLIMIT_NOFILE, &rlimit)) + if (int const res = (int)lx_syscall(SYS_setrlimit, RLIMIT_NOFILE, &rlimit)) Genode::warning("unable to boost RLIMIT_NOFILE (", res, "), keeping limit unchanged"); } @@ -215,7 +215,7 @@ inline void lx_boost_rlimit() inline int lx_socket(int domain, int type, int protocol) { long args[3] = { domain, type, protocol }; - return lx_socketcall(SYS_SOCKET, args); + return (int)lx_socketcall(SYS_SOCKET, args); } @@ -223,7 +223,7 @@ inline int lx_bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { long args[3] = { sockfd, (long)addr, (long)addrlen }; - return lx_socketcall(SYS_BIND, args); + return (int)lx_socketcall(SYS_BIND, args); } @@ -231,28 +231,28 @@ inline int lx_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) { long args[3] = { sockfd, (long)serv_addr, (long)addrlen }; - return lx_socketcall(SYS_CONNECT, args); + return (int)lx_socketcall(SYS_CONNECT, args); } #else inline int lx_socket(int domain, int type, int protocol) { - return lx_syscall(SYS_socket, domain, type, protocol); + return (int)lx_syscall(SYS_socket, domain, type, protocol); } inline int lx_bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { - return lx_syscall(SYS_bind, sockfd, addr, addrlen); + return (int)lx_syscall(SYS_bind, sockfd, addr, addrlen); } inline int lx_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) { - return lx_syscall(SYS_connect, sockfd, serv_addr, addrlen); + return (int)lx_syscall(SYS_connect, sockfd, serv_addr, addrlen); } #endif /* SYS_socketcall */ @@ -264,13 +264,13 @@ inline int lx_connect(int sockfd, const struct sockaddr *serv_addr, inline int lx_pipe(int pipefd[2]) { - return lx_syscall(SYS_pipe2, pipefd, 0); + return (int)lx_syscall(SYS_pipe2, pipefd, 0); } inline int lx_read(int fd, void *buf, Genode::size_t count) { - return lx_syscall(SYS_read, fd, buf, count); + return (int)lx_syscall(SYS_read, fd, buf, count); } #endif /* _CORE__INCLUDE__CORE_LINUX_SYSCALLS_H_ */ diff --git a/repos/base-linux/src/core/native_pd_component.cc b/repos/base-linux/src/core/native_pd_component.cc index 2776627b1e..7602552c07 100644 --- a/repos/base-linux/src/core/native_pd_component.cc +++ b/repos/base-linux/src/core/native_pd_component.cc @@ -190,7 +190,7 @@ Native_pd_component::Native_pd_component(Pd_session_component &pd, const char *) Native_pd_component::~Native_pd_component() { if (_pid) - lx_kill(_pid, 9); + lx_kill((int)_pid, 9); _pd_session._ep.dissolve(this); } diff --git a/repos/base-linux/src/core/spec/linux/dataspace_component.cc b/repos/base-linux/src/core/spec/linux/dataspace_component.cc index bdc18ddf4d..045971f067 100644 --- a/repos/base-linux/src/core/spec/linux/dataspace_component.cc +++ b/repos/base-linux/src/core/spec/linux/dataspace_component.cc @@ -58,7 +58,7 @@ size_t Dataspace_component::_file_size() if (lx_stat_size(_fname.buf, size) < 0) throw Service_denied(); - return align_addr(size, 12); + return align_addr((size_t)size, 12); } diff --git a/repos/base-linux/src/include/base/internal/capability_space_tpl.h b/repos/base-linux/src/include/base/internal/capability_space_tpl.h index e856d848e6..b4c8666ed4 100644 --- a/repos/base-linux/src/include/base/internal/capability_space_tpl.h +++ b/repos/base-linux/src/include/base/internal/capability_space_tpl.h @@ -121,7 +121,7 @@ class Genode::Capability_space_tpl : Noncopyable unsigned _index(Data const &data) const { addr_t const offset = (addr_t)&data - (addr_t)_caps_data; - return offset / sizeof(_caps_data[0]); + return (unsigned)(offset / sizeof(_caps_data[0])); } Data *_lookup_unsynchronized(Rpc_obj_key key) const @@ -186,7 +186,7 @@ class Genode::Capability_space_tpl : Noncopyable * object. */ if (!data.dst.foreign) - lx_close(data.rpc_obj_key().value()); + lx_close((int)data.rpc_obj_key().value()); } diff --git a/repos/base-linux/src/lib/base/ipc.cc b/repos/base-linux/src/lib/base/ipc.cc index c0d4514018..543b0db58a 100644 --- a/repos/base-linux/src/lib/base/ipc.cc +++ b/repos/base-linux/src/lib/base/ipc.cc @@ -178,7 +178,7 @@ namespace { if (!cmsg) return 0; - return (cmsg->cmsg_len - CMSG_ALIGN(sizeof(cmsghdr)))/sizeof(int); + return (unsigned)((cmsg->cmsg_len - CMSG_ALIGN(sizeof(cmsghdr)))/sizeof(int)); } }; @@ -352,7 +352,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst, extract_sds_from_message(0, rcv_msg, rcv_header, rcv_msgbuf); - return Rpc_exception_code(rcv_header.protocol_word); + return Rpc_exception_code((int)rcv_header.protocol_word); } diff --git a/repos/base-linux/src/lib/base/native_thread.cc b/repos/base-linux/src/lib/base/native_thread.cc index 8d54bcdadc..815e0b3902 100644 --- a/repos/base-linux/src/lib/base/native_thread.cc +++ b/repos/base-linux/src/lib/base/native_thread.cc @@ -203,7 +203,7 @@ Native_capability Native_thread::Epoll::alloc_rpc_cap() void Native_thread::Epoll::free_rpc_cap(Native_capability cap) { - int const local_socket = Capability_space::ipc_cap_data(cap).rpc_obj_key.value(); + int const local_socket = (int)Capability_space::ipc_cap_data(cap).rpc_obj_key.value(); _exec_control([&] () { _remove(Lx_sd{local_socket}); }); } diff --git a/repos/base-linux/src/lib/base/platform.cc b/repos/base-linux/src/lib/base/platform.cc index d3a94f061b..70d15d7ff2 100644 --- a/repos/base-linux/src/lib/base/platform.cc +++ b/repos/base-linux/src/lib/base/platform.cc @@ -61,7 +61,7 @@ void Genode::binary_ready_hook_for_platform() }; uint64_t flags = SECCOMP_FILTER_FLAG_TSYNC; - auto ret = lx_seccomp(SECCOMP_SET_MODE_FILTER, flags, &program); + auto ret = lx_seccomp(SECCOMP_SET_MODE_FILTER, (int)flags, &program); if (ret != 0) { error("SECCOMP_SET_MODE_FILTER failed ", ret); throw Exception(); diff --git a/repos/base-linux/src/lib/base/region_map_mmap.cc b/repos/base-linux/src/lib/base/region_map_mmap.cc index 00f545d282..870baaa29b 100644 --- a/repos/base-linux/src/lib/base/region_map_mmap.cc +++ b/repos/base-linux/src/lib/base/region_map_mmap.cc @@ -33,10 +33,13 @@ */ /* Linux includes */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" #include #include #include #include +#pragma GCC diagnostic pop /* restore -Wconversion warnings */ /* Genode includes */ #include diff --git a/repos/base-linux/src/lib/syscall/linux_syscalls.h b/repos/base-linux/src/lib/syscall/linux_syscalls.h index 3b5f986dd2..8c7e96da23 100644 --- a/repos/base-linux/src/lib/syscall/linux_syscalls.h +++ b/repos/base-linux/src/lib/syscall/linux_syscalls.h @@ -46,6 +46,12 @@ */ #define size_t __SIZE_TYPE__ +/* + * Disable -Wconversion warnings caused by host headers + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" + /* Linux includes */ #include /* include first to avoid double definition of '__always_inline' */ #include @@ -60,6 +66,7 @@ #include #include +#pragma GCC diagnostic pop /* restore -Wconversion warnings */ #undef size_t @@ -92,32 +99,32 @@ extern "C" int lx_clone(int (*fn)(), void *child_stack, int flags); *****************************************/ -inline pid_t lx_getpid() { return lx_syscall(SYS_getpid); } -inline pid_t lx_gettid() { return lx_syscall(SYS_gettid); } -inline uid_t lx_getuid() { return lx_syscall(SYS_getuid); } +inline pid_t lx_getpid() { return (pid_t)lx_syscall(SYS_getpid); } +inline pid_t lx_gettid() { return (pid_t)lx_syscall(SYS_gettid); } +inline uid_t lx_getuid() { return (uid_t)lx_syscall(SYS_getuid); } inline int lx_write(int fd, const void *buf, Genode::size_t count) { - return lx_syscall(SYS_write, fd, buf, count); + return (int)lx_syscall(SYS_write, fd, buf, count); } inline int lx_close(int fd) { - return lx_syscall(SYS_close, fd); + return (int)lx_syscall(SYS_close, fd); } inline int lx_dup(int fd) { - return lx_syscall(SYS_dup, fd); + return (int)lx_syscall(SYS_dup, fd); } inline int lx_dup2(int fd, int to) { - return lx_syscall(SYS_dup3, fd, to, 0); + return (int)lx_syscall(SYS_dup3, fd, to, 0); } @@ -192,19 +199,19 @@ inline int lx_recvmsg(Lx_sd sockfd, struct msghdr *msg, int flags) inline int lx_socketpair(int domain, int type, int protocol, int sd[2]) { - return lx_syscall(SYS_socketpair, domain, type, protocol, (unsigned long)sd); + return (int)lx_syscall(SYS_socketpair, domain, type, protocol, (unsigned long)sd); } inline int lx_sendmsg(Lx_sd sockfd, const struct msghdr *msg, int flags) { - return lx_syscall(SYS_sendmsg, sockfd.value, msg, flags); + return (int)lx_syscall(SYS_sendmsg, sockfd.value, msg, flags); } inline int lx_recvmsg(Lx_sd sockfd, struct msghdr *msg, int flags) { - return lx_syscall(SYS_recvmsg, sockfd.value, msg, flags); + return (int)lx_syscall(SYS_recvmsg, sockfd.value, msg, flags); } /* TODO add missing socket system calls */ @@ -236,7 +243,7 @@ struct Lx_socketpair inline Lx_epoll_sd lx_epoll_create() { - int const ret = lx_syscall(SYS_epoll_create1, 0); + int const ret = (int)lx_syscall(SYS_epoll_create1, 0); if (ret < 0) { /* * No recovery possible, just leave a diagnostic message and block @@ -251,14 +258,14 @@ inline Lx_epoll_sd lx_epoll_create() inline int lx_epoll_ctl(Lx_epoll_sd epoll, int op, Lx_sd fd, epoll_event *event) { - return lx_syscall(SYS_epoll_ctl, epoll.value, op, fd.value, event); + return (int)lx_syscall(SYS_epoll_ctl, epoll.value, op, fd.value, event); } inline int lx_epoll_wait(Lx_epoll_sd epoll, struct epoll_event *events, int maxevents, int timeout) { - return lx_syscall(SYS_epoll_pwait, epoll.value, events, maxevents, timeout, 0); + return (int)lx_syscall(SYS_epoll_pwait, epoll.value, events, maxevents, timeout, 0); } @@ -298,7 +305,7 @@ inline void *lx_mmap(void *start, Genode::size_t length, int prot, int flags, inline int lx_munmap(void *addr, Genode::size_t length) { - return lx_syscall(SYS_munmap, addr, length); + return (int)lx_syscall(SYS_munmap, addr, length); } @@ -376,7 +383,7 @@ inline int lx_sigaction(int signum, void (*handler)(int), bool altstack) lx_sigemptyset(&act.mask); - return lx_syscall(SYS_rt_sigaction, signum, &act, 0UL, LX_NSIG/8); + return (int)lx_syscall(SYS_rt_sigaction, signum, &act, 0UL, LX_NSIG/8); } @@ -388,7 +395,7 @@ inline int lx_sigaction(int signum, void (*handler)(int), bool altstack) */ inline int lx_tgkill(int pid, int tid, int signal) { - return lx_syscall(SYS_tgkill, pid, tid, signal); + return (int)lx_syscall(SYS_tgkill, pid, tid, signal); } @@ -399,7 +406,7 @@ inline int lx_sigaltstack(void *signal_stack, Genode::size_t stack_size) { stack_t stack { signal_stack, 0, stack_size }; - return lx_syscall(SYS_sigaltstack, &stack, nullptr); + return (int)lx_syscall(SYS_sigaltstack, &stack, nullptr); } @@ -408,7 +415,7 @@ inline int lx_create_thread(void (*entry)(), void *stack) int flags = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM; - return lx_clone((int (*)())entry, stack, flags); + return (int)lx_clone((int (*)())entry, stack, flags); } @@ -420,7 +427,7 @@ struct timespec; inline int lx_nanosleep(const struct timespec *req, struct timespec *rem) { - return lx_syscall(SYS_nanosleep, req, rem); + return (int)lx_syscall(SYS_nanosleep, req, rem); } @@ -431,7 +438,7 @@ enum { inline int lx_futex(const int *uaddr, int op, int val) { - return lx_syscall(SYS_futex, uaddr, op, val, 0, 0, 0); + return (int)lx_syscall(SYS_futex, uaddr, op, val, 0, 0, 0); } @@ -523,13 +530,13 @@ inline bool lx_sigsetmask(int signum, bool state) inline int lx_prctl(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5) { - return lx_syscall(SYS_prctl, option, arg2, arg3, arg4, arg5); + return (int)lx_syscall(SYS_prctl, option, arg2, arg3, arg4, arg5); } inline int lx_seccomp(int option, int flag, void* program) { - return lx_syscall(SYS_seccomp, option, flag, program); + return (int)lx_syscall(SYS_seccomp, option, flag, program); } #endif /* _LIB__SYSCALL__LINUX_SYSCALLS_H_ */ diff --git a/repos/base-linux/src/test/lx_hybrid_ctors/main.cc b/repos/base-linux/src/test/lx_hybrid_ctors/main.cc index 9791be1e96..273b07b391 100644 --- a/repos/base-linux/src/test/lx_hybrid_ctors/main.cc +++ b/repos/base-linux/src/test/lx_hybrid_ctors/main.cc @@ -19,8 +19,11 @@ #include "testlib.h" /* Linux includes */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" #include #include +#pragma GCC diagnostic pop /* restore -Wconversion warnings */ using namespace Genode; diff --git a/repos/base-linux/src/timer/linux/time_source.cc b/repos/base-linux/src/timer/linux/time_source.cc index d2e71d4062..7aa076ac17 100644 --- a/repos/base-linux/src/timer/linux/time_source.cc +++ b/repos/base-linux/src/timer/linux/time_source.cc @@ -23,7 +23,7 @@ using namespace Genode; inline int lx_gettimeofday(struct timeval *tv, struct timeval *tz) { - return lx_syscall(SYS_gettimeofday, tv, tz); } + return (int)lx_syscall(SYS_gettimeofday, tv, tz); } Microseconds Timer::Time_source::max_timeout() const @@ -44,8 +44,8 @@ Duration Timer::Time_source::curr_time() void Timer::Time_source::_usleep(uint64_t us) { struct timespec ts; - ts.tv_sec = us / (1000 * 1000); - ts.tv_nsec = (us % (1000 * 1000)) * 1000; + ts.tv_sec = (long)us / (1000 * 1000); + ts.tv_nsec = ((long)us % (1000 * 1000)) * 1000; if (lx_nanosleep(&ts, &ts) != 0) throw Blocking_canceled(); diff --git a/repos/base-nova/include/nova/cap_map.h b/repos/base-nova/include/nova/cap_map.h index a2d3927716..4ee78bf29e 100644 --- a/repos/base-nova/include/nova/cap_map.h +++ b/repos/base-nova/include/nova/cap_map.h @@ -94,13 +94,13 @@ namespace Genode { inline void inc() { if (_range) - _range->inc(_local_name - _range->base()); + _range->inc((unsigned)(_local_name - _range->base())); } inline void dec() { if (_range) - _range->dec(_local_name - _range->base()); + _range->dec((unsigned)(_local_name - _range->base())); } }; diff --git a/repos/base-nova/include/nova/syscall-generic.h b/repos/base-nova/include/nova/syscall-generic.h index ad6c429059..9218d99393 100644 --- a/repos/base-nova/include/nova/syscall-generic.h +++ b/repos/base-nova/include/nova/syscall-generic.h @@ -184,7 +184,7 @@ namespace Nova { if (!boot || !is_cpu_enabled(boot_cpu)) return false; - map_cpus[cpu_i++] = boot_cpu; + map_cpus[cpu_i++] = (uint8_t)boot_cpu; if (cpu_i >= num_cpus) return true; @@ -204,7 +204,7 @@ namespace Nova { c->thread == thread)) continue; - map_cpus [cpu_i++] = i; + map_cpus[cpu_i++] = (uint8_t)i; if (cpu_i >= num_cpus) return true; } @@ -376,12 +376,12 @@ namespace Nova { return sel_hotspot << 12; } - mword_t addr() const { return base() << BASE_SHIFT; } - mword_t base() const { return _query(); } - mword_t order() const { return _query(); } - bool is_null() const { return (_value & TYPE_MASK) == NULL_CRD_TYPE; } - uint8_t type() const { return _query(); } - uint8_t rights() const { return _query(); } + mword_t addr() const { return base() << BASE_SHIFT; } + mword_t base() const { return _query(); } + mword_t order() const { return _query(); } + bool is_null() const { return (_value & TYPE_MASK) == NULL_CRD_TYPE; } + uint8_t type() const { return (uint8_t)_query(); } + uint8_t rights() const { return (uint8_t)_query(); } } __attribute__((packed)); @@ -606,71 +606,73 @@ namespace Nova { }; #ifdef __x86_64__ - inline mword_t read_r8() { return r8; } - inline void write_r8(mword_t value) { r8 = value; } - inline mword_t read_r9() { return r9; } - inline void write_r9(mword_t value) { r9 = value; } - inline mword_t read_r10() { return r10; } - inline void write_r10(mword_t value) { r10 = value; } - inline mword_t read_r11() { return r11; } - inline void write_r11(mword_t value) { r11 = value; } - inline mword_t read_r12() { return r12; } - inline void write_r12(mword_t value) { r12 = value; } - inline mword_t read_r13() { return r13; } - inline void write_r13(mword_t value) { r13 = value; } - inline mword_t read_r14() { return r14; } - inline void write_r14(mword_t value) { r14 = value; } - inline mword_t read_r15() { return r15; } - inline void write_r15(mword_t value) { r15 = value; } - inline mword_t read_efer() { return efer; } - inline void write_efer(mword_t value) { efer = value; } - inline mword_t read_star() { return star; } - inline void write_star(mword_t value) { star = value; } - inline mword_t read_lstar() { return lstar; } - inline void write_lstar(mword_t value) { lstar = value; } - inline mword_t read_cstar() { return cstar; } - inline void write_cstar(mword_t value) { cstar = value; } - inline mword_t read_fmask() { return fmask; } - inline void write_fmask(mword_t value) { fmask = value; } - inline mword_t read_kernel_gs_base() { return kernel_gs_base; } - inline void write_kernel_gs_base(mword_t value) { kernel_gs_base = value; } - inline uint32_t read_tpr() { return tpr; } - inline void write_tpr(uint32_t value) { tpr = value; } - inline uint32_t read_tpr_threshold() { return tpr_threshold; } - inline void write_tpr_threshold(uint32_t value) { tpr_threshold = value; } + uint64_t read_r8() const { return r8; } + uint64_t read_r9() const { return r9; } + uint64_t read_r10() const { return r10; } + uint64_t read_r11() const { return r11; } + uint64_t read_r12() const { return r12; } + uint64_t read_r13() const { return r13; } + uint64_t read_r14() const { return r14; } + uint64_t read_r15() const { return r15; } + mword_t read_efer() const { return efer; } + uint64_t read_star() const { return star; } + uint64_t read_lstar() const { return lstar; } + uint64_t read_cstar() const { return cstar; } + uint64_t read_fmask() const { return fmask; } + uint64_t read_kernel_gs_base() const { return kernel_gs_base; } + uint32_t read_tpr() const { return tpr; } + uint32_t read_tpr_threshold() const { return tpr_threshold; } + + void write_r8 (uint64_t value) { r8 = value; } + void write_r9 (uint64_t value) { r9 = value; } + void write_r10 (uint64_t value) { r10 = value; } + void write_r11 (uint64_t value) { r11 = value; } + void write_r12 (uint64_t value) { r12 = value; } + void write_r13 (uint64_t value) { r13 = value; } + void write_r14 (uint64_t value) { r14 = value; } + void write_r15 (uint64_t value) { r15 = value; } + void write_efer (mword_t value) { efer = value; } + void write_star (uint64_t value) { star = value; } + void write_lstar (uint64_t value) { lstar = value; } + void write_cstar (uint64_t value) { cstar = value; } + void write_fmask (uint64_t value) { fmask = value; } + void write_kernel_gs_base (uint64_t value) { kernel_gs_base = value; } + void write_tpr (uint32_t value) { tpr = value; } + void write_tpr_threshold (uint32_t value) { tpr_threshold = value; } #else - inline mword_t read_r8() { return 0UL; } - inline void write_r8(mword_t) { } - inline mword_t read_r9() { return 0UL; } - inline void write_r9(mword_t) { } - inline mword_t read_r10() { return 0UL; } - inline void write_r10(mword_t) { } - inline mword_t read_r11() { return 0UL; } - inline void write_r11(mword_t) { } - inline mword_t read_r12() { return 0UL; } - inline void write_r12(mword_t) { } - inline mword_t read_r13() { return 0UL; } - inline void write_r13(mword_t) { } - inline mword_t read_r14() { return 0UL; } - inline void write_r14(mword_t) { } - inline mword_t read_r15() { return 0UL; } - inline void write_r15(mword_t) { } - inline mword_t read_efer() { return 0UL; } - inline void write_efer(mword_t) { } - inline mword_t read_star() { return 0UL; } - inline void write_star(mword_t) { } - inline mword_t read_lstar() { return 0UL; } - inline void write_lstar(mword_t) { } - inline mword_t read_cstar() { return 0UL; } - inline void write_cstar(mword_t) { } - inline mword_t read_fmask() { return 0UL; } - inline void write_fmask(mword_t) { } - inline mword_t read_kernel_gs_base() { return 0UL; } - inline void write_kernel_gs_base(mword_t) { } - inline uint32_t read_tpr() { return 0; } - inline void write_tpr(uint32_t) { } - inline uint32_t read_tpr_threshold() { return 0; } - inline void write_tpr_threshold(uint32_t) { } + uint64_t read_r8() const { return 0; } + uint64_t read_r9() const { return 0; } + uint64_t read_r10() const { return 0; } + uint64_t read_r11() const { return 0; } + uint64_t read_r12() const { return 0; } + uint64_t read_r13() const { return 0; } + uint64_t read_r14() const { return 0; } + uint64_t read_r15() const { return 0; } + mword_t read_efer() const { return 0; } + uint64_t read_star() const { return 0; } + uint64_t read_lstar() const { return 0; } + uint64_t read_cstar() const { return 0; } + uint64_t read_fmask() const { return 0; } + uint64_t read_kernel_gs_base() const { return 0; } + uint32_t read_tpr() const { return 0; } + uint32_t read_tpr_threshold() const { return 0; } + + void write_r8 (uint64_t) { } + void write_r9 (uint64_t) { } + void write_r10 (uint64_t) { } + void write_r11 (uint64_t) { } + void write_r12 (uint64_t) { } + void write_r13 (uint64_t) { } + void write_r14 (uint64_t) { } + void write_r15 (uint64_t) { } + void write_efer (mword_t) { } + void write_star (uint64_t) { } + void write_lstar (uint64_t) { } + void write_cstar (uint64_t) { } + void write_fmask (uint64_t) { } + void write_kernel_gs_base (uint64_t) { } + void write_tpr (uint32_t) { } + void write_tpr_threshold (uint32_t) { } #endif /** @@ -689,7 +691,7 @@ namespace Nova { /** * Return current number of message items on UTCB */ - unsigned msg_items() { return items >> 16; } + unsigned msg_items() { return (unsigned)(items >> 16); } /** * Append message-transfer item to message buffer @@ -749,6 +751,12 @@ namespace Nova { } mword_t mtd_value() const { return static_cast(mtd).value(); } + + /** + * Return fault address and type of page-fault message + */ + mword_t pf_addr() const { return (mword_t)qual[1]; } + uint8_t pf_type() const { return (uint8_t)qual[0]; } }; static_assert(sizeof(Utcb) == 4096, "Unexpected size of UTCB"); diff --git a/repos/base-nova/include/spec/32bit/nova/syscalls.h b/repos/base-nova/include/spec/32bit/nova/syscalls.h index 5e6689e020..919214fc70 100644 --- a/repos/base-nova/include/spec/32bit/nova/syscalls.h +++ b/repos/base-nova/include/spec/32bit/nova/syscalls.h @@ -62,7 +62,7 @@ namespace Nova { : "+a" (status) : : "ecx", "edx", "memory"); - return status; + return (uint8_t)status; } @@ -83,7 +83,7 @@ namespace Nova { : : "ecx", "edx", "memory"); if (p2) *p2 = p1; - return status; + return (uint8_t)status; } @@ -102,7 +102,7 @@ namespace Nova { : "+a" (status) : "D" (p1), "S" (p2) : "ecx", "edx"); - return status; + return (uint8_t)status; } @@ -125,7 +125,7 @@ namespace Nova { : "+a" (status), "+d" (p3) : "D" (p1), "S" (p2) : "ecx"); - return status; + return (uint8_t)status; } @@ -154,7 +154,7 @@ namespace Nova { : "+a" (status), "+c" (p3), "+d" (p4) : "D" (p1), "S" (p2) : "memory"); - return status; + return (uint8_t)status; } ALWAYS_INLINE @@ -179,7 +179,7 @@ namespace Nova { : "+a" (status), "+D" (p1), "+S" (p2), "+c" (p3) : : "edx", "memory"); - return status; + return (uint8_t)status; } ALWAYS_INLINE @@ -350,7 +350,7 @@ namespace Nova { ALWAYS_INLINE inline uint8_t sm_ctrl(unsigned sm, Sem_op op, unsigned long long timeout = 0) { - return syscall_2(NOVA_SM_CTRL, op, sm, timeout >> 32, timeout); + return syscall_2(NOVA_SM_CTRL, op, sm, (mword_t)(timeout >> 32), (mword_t)timeout); } diff --git a/repos/base-nova/include/spec/64bit/nova/syscalls.h b/repos/base-nova/include/spec/64bit/nova/syscalls.h index d6177b8fe1..5576fb8d4a 100644 --- a/repos/base-nova/include/spec/64bit/nova/syscalls.h +++ b/repos/base-nova/include/spec/64bit/nova/syscalls.h @@ -57,7 +57,7 @@ namespace Nova { : "+D" (status) : : "rcx", "r11", "memory"); - return status; + return (uint8_t)status; } @@ -72,7 +72,7 @@ namespace Nova { : : "rcx", "r11", "memory"); if (p2) *p2 = p1; - return status; + return (uint8_t)status; } @@ -86,7 +86,7 @@ namespace Nova { : "+D" (status) : "S" (p1), "d" (p2) : "rcx", "r11", "memory"); - return status; + return (uint8_t)status; } @@ -100,7 +100,7 @@ namespace Nova { : "+D" (status) : "S" (p1), "d" (p2), "a" (p3) : "rcx", "r11", "memory"); - return status; + return (uint8_t)status; } @@ -115,7 +115,7 @@ namespace Nova { : "+D" (status) : "S" (p1), "d" (p2), "a" (p3), "r" (r8) : "rcx", "r11", "memory"); - return status; + return (uint8_t)status; } @@ -129,7 +129,7 @@ namespace Nova { : "+D" (status), "+S"(p1), "+d"(p2) : "a" (p3) : "rcx", "r11", "memory"); - return status; + return (uint8_t)status; } @@ -159,7 +159,7 @@ namespace Nova { inline uint8_t create_pd(mword_t pd0, mword_t pd, Crd crd, unsigned lower_limit, unsigned long upper_limit) { - return syscall_3(NOVA_CREATE_PD, 0, pd0, pd, crd.value(), + return syscall_3(NOVA_CREATE_PD, 0, (unsigned)pd0, pd, crd.value(), upper_limit << 32 | lower_limit); } @@ -202,7 +202,7 @@ namespace Nova { ALWAYS_INLINE inline uint8_t create_sc(mword_t sc, mword_t pd, mword_t ec, Qpd qpd) { - return syscall_3(NOVA_CREATE_SC, 0, sc, pd, ec, qpd.value()); + return syscall_3(NOVA_CREATE_SC, 0, (unsigned)sc, pd, ec, qpd.value()); } @@ -229,14 +229,14 @@ namespace Nova { ALWAYS_INLINE inline uint8_t create_sm(mword_t sm, mword_t pd, mword_t cnt) { - return syscall_3(NOVA_CREATE_SM, 0, sm, pd, cnt, 0); + return syscall_3(NOVA_CREATE_SM, 0, (unsigned)sm, pd, cnt, 0); } ALWAYS_INLINE inline uint8_t create_si(mword_t si, mword_t pd, mword_t value, mword_t sm) { - return syscall_3(NOVA_CREATE_SM, 0, si, pd, value, sm); + return syscall_3(NOVA_CREATE_SM, 0, (unsigned)si, pd, value, sm); } diff --git a/repos/base-nova/src/core/core_region_map.cc b/repos/base-nova/src/core/core_region_map.cc index ecae5a3606..bf6080e62a 100644 --- a/repos/base-nova/src/core/core_region_map.cc +++ b/repos/base-nova/src/core/core_region_map.cc @@ -40,7 +40,7 @@ static inline void * alloc_region(Dataspace_component &ds, const size_t size) size_t align_log2 = log2(ds.size()); for (; align_log2 >= get_page_size_log2(); align_log2--) { - platform().region_alloc().alloc_aligned(size, align_log2).with_result( + platform().region_alloc().alloc_aligned(size, (unsigned)align_log2).with_result( [&] (void *ptr) { virt_addr = ptr; }, [&] (Allocator::Alloc_error) { }); diff --git a/repos/base-nova/src/core/include/nova_util.h b/repos/base-nova/src/core/include/nova_util.h index 37f5c594cd..f5dca5ca15 100644 --- a/repos/base-nova/src/core/include/nova_util.h +++ b/repos/base-nova/src/core/include/nova_util.h @@ -115,7 +115,7 @@ lsb_bit(unsigned long const &value, unsigned char const shift = 0) unsigned long const scan = value >> shift; if (scan == 0) return 0; - unsigned char pos = __builtin_ctzl(scan); + unsigned char pos = (unsigned char)__builtin_ctzl(scan); unsigned char res = shift ? pos + shift : pos; return res; } @@ -207,7 +207,7 @@ inline void unmap_local(Nova::Utcb &, Genode::addr_t start, while (num_pages) { unsigned char const base_bit = lsb_bit(base); - unsigned char const order_bit = min(log2(num_pages), 31U); + unsigned char const order_bit = (unsigned char)min(log2(num_pages), 31U); unsigned char const order = min(order_bit, base_bit); Mem_crd const crd(base, order, rwx); diff --git a/repos/base-nova/src/core/include/pager.h b/repos/base-nova/src/core/include/pager.h index c0c9649127..9b0d350324 100644 --- a/repos/base-nova/src/core/include/pager.h +++ b/repos/base-nova/src/core/include/pager.h @@ -100,10 +100,10 @@ namespace Genode { /* convenience function to access pause/recall state */ inline bool blocked() { return _status & BLOCKED;} inline void block() { _status |= BLOCKED; } - inline void unblock() { _status &= ~BLOCKED; } + inline void unblock() { _status &= (uint8_t)(~BLOCKED); } inline bool blocked_pause_sm() { return _status & BLOCKED_PAUSE_SM;} - inline void block_pause_sm() { _status |= BLOCKED_PAUSE_SM; } - inline void unblock_pause_sm() { _status &= ~BLOCKED_PAUSE_SM; } + inline void block_pause_sm() { _status |= (uint8_t)BLOCKED_PAUSE_SM; } + inline void unblock_pause_sm() { _status &= (uint8_t)(~BLOCKED_PAUSE_SM); } inline void mark_dead() { _status |= DEAD; } inline bool is_dead() { return _status & DEAD; } @@ -118,10 +118,10 @@ namespace Genode { inline bool to_submit() { return _status & SUBMIT_SIGNAL; } inline void submit_signal() { _status |= SUBMIT_SIGNAL; } - inline void reset_submit() { _status &= ~SUBMIT_SIGNAL; } + inline void reset_submit() { _status &= (uint8_t)(~SUBMIT_SIGNAL); } bool migrate() const { return _status & MIGRATE; } - void reset_migrate() { _status &= ~MIGRATE; } + void reset_migrate() { _status &= (uint8_t)(~MIGRATE); } void request_migrate() { _status |= MIGRATE; } } _state { }; @@ -287,7 +287,7 @@ namespace Genode { if (on) _state._status |= _state.SINGLESTEP; else - _state._status &= ~_state.SINGLESTEP; + _state._status &= (uint8_t)(~_state.SINGLESTEP); _state_lock.release(); diff --git a/repos/base-nova/src/core/include/util.h b/repos/base-nova/src/core/include/util.h index 1fd1cc7554..a504ecbe22 100644 --- a/repos/base-nova/src/core/include/util.h +++ b/repos/base-nova/src/core/include/util.h @@ -26,9 +26,12 @@ namespace Genode { constexpr size_t get_super_page_size_log2() { return 22; } constexpr size_t get_super_page_size() { return 1 << get_super_page_size_log2(); } - inline addr_t trunc_page(addr_t addr) { return addr & _align_mask(get_page_size_log2()); } - inline addr_t round_page(addr_t addr) { return trunc_page(addr + get_page_size() - 1); } + template + inline T trunc_page(T addr) { return addr & _align_mask(get_page_size_log2()); } + + template + inline T round_page(T addr) { return trunc_page(addr + get_page_size() - 1); } inline addr_t map_src_addr(addr_t /* core_local */, addr_t phys) { return phys; } diff --git a/repos/base-nova/src/core/ipc_pager.cc b/repos/base-nova/src/core/ipc_pager.cc index 3c4dbb5019..7ca36b1a75 100644 --- a/repos/base-nova/src/core/ipc_pager.cc +++ b/repos/base-nova/src/core/ipc_pager.cc @@ -32,9 +32,9 @@ Ipc_pager::Ipc_pager(Nova::Utcb &utcb, addr_t pd_dst, addr_t pd_core) _pd_dst(pd_dst), _pd_core(pd_core), _fault_ip(utcb.ip), - _fault_addr(utcb.qual[1]), + _fault_addr(utcb.pf_addr()), _sp(utcb.sp), - _fault_type(utcb.qual[0]), + _fault_type(utcb.pf_type()), _syscall_res(Nova::NOVA_OK), _normal_ipc((((addr_t)&utcb.qual[2] - (addr_t)utcb.msg()) / sizeof(addr_t)) == utcb.msg_words()) diff --git a/repos/base-nova/src/core/irq_session_component.cc b/repos/base-nova/src/core/irq_session_component.cc index 75a7b2db30..e59e462282 100644 --- a/repos/base-nova/src/core/irq_session_component.cc +++ b/repos/base-nova/src/core/irq_session_component.cc @@ -225,7 +225,7 @@ Irq_session_component::Irq_session_component(Range_allocator &irq_alloc, throw Service_denied(); } - _irq_number = irq_number; + _irq_number = (unsigned)irq_number; _irq_object.start(_irq_number, device_phys); } diff --git a/repos/base-nova/src/core/pager.cc b/repos/base-nova/src/core/pager.cc index 614d8e0454..231d4c918e 100644 --- a/repos/base-nova/src/core/pager.cc +++ b/repos/base-nova/src/core/pager.cc @@ -101,8 +101,10 @@ struct Page_fault_info Page_fault_info(char const *pd, char const *thread, unsigned cpu, addr_t ip, addr_t addr, addr_t sp, unsigned type) - : pd(pd), thread(thread), cpu(cpu), ip(ip), addr(addr), - sp(sp), pf_type(type) { } + : + pd(pd), thread(thread), cpu(cpu), ip(ip), addr(addr), + sp(sp), pf_type((uint8_t)type) + { } void print(Genode::Output &out) const { @@ -191,7 +193,7 @@ void Pager_object::_page_fault_handler(Pager_object &obj) ipc_pager.fault_ip(), ipc_pager.fault_addr(), ipc_pager.sp(), - ipc_pager.fault_type()); + (uint8_t)ipc_pager.fault_type()); /* region manager fault - to be handled */ log("page fault, ", fault_info, " reason=", error); diff --git a/repos/base-nova/src/core/platform.cc b/repos/base-nova/src/core/platform.cc index ca70daaed3..beaef3b57d 100644 --- a/repos/base-nova/src/core/platform.cc +++ b/repos/base-nova/src/core/platform.cc @@ -113,10 +113,10 @@ static void page_fault_handler() { Utcb *utcb = (Utcb *)CORE_PAGER_UTCB_ADDR; - addr_t pf_addr = utcb->qual[1]; - addr_t pf_ip = utcb->ip; - addr_t pf_sp = utcb->sp; - addr_t pf_type = utcb->qual[0]; + addr_t const pf_addr = utcb->pf_addr(); + addr_t const pf_ip = utcb->ip; + addr_t const pf_sp = utcb->sp; + uint8_t const pf_type = utcb->pf_type(); error("\nPAGE-FAULT IN CORE addr=", Hex(pf_addr), " ip=", Hex(pf_ip), " (", (pf_type & Ipc_pager::ERR_W) ? "write" : "read", ")"); @@ -370,7 +370,7 @@ Platform::Platform() " vs ", sizeof(map_cpu_ids) / sizeof(map_cpu_ids[0])); nova_die(); } - if (!hip.remap_cpu_ids(map_cpu_ids, boot_cpu())) { + if (!hip.remap_cpu_ids(map_cpu_ids, (unsigned)boot_cpu())) { error("re-ording cpu_id failed"); nova_die(); } @@ -492,7 +492,7 @@ Platform::Platform() Hip::Mem_desc *boot_fb = nullptr; bool efi_boot = false; - addr_t kernel_memory = 0; + size_t kernel_memory = 0; /* * All "available" ram must be added to our physical allocator before all @@ -506,13 +506,13 @@ Platform::Platform() if (mem_desc->type == Hip::Mem_desc::FRAMEBUFFER) boot_fb = mem_desc; if (mem_desc->type == Hip::Mem_desc::MICROHYPERVISOR) - kernel_memory += mem_desc->size; + kernel_memory += (size_t)mem_desc->size; if (mem_desc->type != Hip::Mem_desc::AVAILABLE_MEMORY) continue; if (verbose_boot_info) { - addr_t const base = mem_desc->addr; - size_t const size = mem_desc->size; + uint64_t const base = mem_desc->addr; + uint64_t const size = mem_desc->size; log("detected physical memory: ", Hex(base, Hex::PREFIX, Hex::PAD), " - size: ", Hex(size, Hex::PREFIX, Hex::PAD)); } @@ -522,11 +522,11 @@ Platform::Platform() /* skip regions above 4G on 32 bit, no op on 64 bit */ if (mem_desc->addr > ~0UL) continue; - addr_t base = round_page(mem_desc->addr); - size_t size; + uint64_t base = round_page(mem_desc->addr); + uint64_t size; /* truncate size if base+size larger then natural 32/64 bit boundary */ - if (mem_desc->addr >= ~0UL - mem_desc->size + 1) - size = trunc_page(~0UL - mem_desc->addr + 1); + if (mem_desc->addr >= ~0ULL - mem_desc->size + 1) + size = trunc_page(~0ULL - mem_desc->addr + 1); else size = trunc_page(mem_desc->addr + mem_desc->size) - base; @@ -534,12 +534,12 @@ Platform::Platform() log("use physical memory: ", Hex(base, Hex::PREFIX, Hex::PAD), " - size: ", Hex(size, Hex::PREFIX, Hex::PAD)); - _io_mem_alloc.remove_range(base, size); - ram_alloc().add_range(base, size); + _io_mem_alloc.remove_range((addr_t)base, (size_t)size); + ram_alloc().add_range((addr_t)base, (size_t)size); } - uint64_t hyp_log = 0; - uint64_t hyp_log_size = 0; + addr_t hyp_log = 0; + size_t hyp_log_size = 0; /* * Exclude all non-available memory from physical allocator AFTER all @@ -551,16 +551,16 @@ Platform::Platform() if (mem_desc->type == Hip::Mem_desc::AVAILABLE_MEMORY) continue; if (mem_desc->type == Hip::Mem_desc::HYPERVISOR_LOG) { - hyp_log = mem_desc->addr; - hyp_log_size = mem_desc->size; + hyp_log = (addr_t)mem_desc->addr; + hyp_log_size = (size_t)mem_desc->size; } - addr_t base = trunc_page(mem_desc->addr); - size_t size = mem_desc->size; + uint64_t base = trunc_page(mem_desc->addr); + uint64_t size = mem_desc->size; /* remove framebuffer from available memory */ if (mem_desc->type == Hip::Mem_desc::FRAMEBUFFER) { - uint32_t const height = Resolution::Height::get(mem_desc->size); + uint32_t const height = (uint32_t)Resolution::Height::get(mem_desc->size); uint32_t const pitch = mem_desc->aux; /* calculate size of framebuffer */ size = pitch * height; @@ -585,9 +585,9 @@ Platform::Platform() /* make acpi regions as io_mem available to platform driver */ if (mem_desc->type == Hip::Mem_desc::ACPI_RECLAIM_MEMORY || mem_desc->type == Hip::Mem_desc::ACPI_NVS_MEMORY) - _io_mem_alloc.add_range(base, size); + _io_mem_alloc.add_range((addr_t)base, (size_t)size); - ram_alloc().remove_range(base, size); + ram_alloc().remove_range((addr_t)base, (size_t)size); } /* needed as I/O memory by the VESA driver */ @@ -634,9 +634,9 @@ Platform::Platform() continue; error("region overlap ", - Hex_range(mem_desc->addr, mem_desc->size), " " + Hex_range((addr_t)mem_desc->addr, (size_t)mem_desc->size), " " "(", (int)mem_desc->type, ") with ", - Hex_range(mem_d->addr, mem_d->size), " " + Hex_range((addr_t)mem_d->addr, (size_t)mem_d->size), " " "(", (int)mem_d->type, ")"); nova_die(); } @@ -659,7 +659,7 @@ Platform::Platform() if (!mem_desc->addr || !mem_desc->size) continue; /* assume core's ELF image has one-page header */ - _core_phys_start = trunc_page(mem_desc->addr + get_page_size()); + _core_phys_start = (addr_t)trunc_page(mem_desc->addr + get_page_size()); } _init_rom_modules(); @@ -842,7 +842,7 @@ Platform::Platform() cap_map().insert(range); - index = range.base() + range.elements(); + index = (unsigned)(range.base() + range.elements()); } _max_caps = index - first_index; @@ -894,15 +894,15 @@ Platform::Platform() }; new (core_mem_alloc()) Trace_source(Trace::sources(), location, - sc_idle_base + kernel_cpu_id, + (unsigned)(sc_idle_base + kernel_cpu_id), "idle"); new (core_mem_alloc()) Trace_source(Trace::sources(), location, - sc_idle_base + kernel_cpu_id, + (unsigned)(sc_idle_base + kernel_cpu_id), "cross"); new (core_mem_alloc()) Trace_source(Trace::sources(), location, - sc_idle_base + kernel_cpu_id, + (unsigned)(sc_idle_base + kernel_cpu_id), "killed"); }); @@ -988,8 +988,7 @@ unsigned Platform::pager_index(Affinity::Location location) const ** Support for core memory management ** ****************************************/ -bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr, - unsigned size) +bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr, size_t size) { /* platform_specific()->core_pd_sel() deadlocks if called from platform constructor */ Hip const &hip = *(Hip const *)__initial_sp; @@ -1003,7 +1002,7 @@ bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr, } -bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, addr_t, unsigned size) +bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, addr_t, size_t size) { unmap_local(*(Utcb *)Thread::myself()->utcb(), virt_addr, size / get_page_size()); diff --git a/repos/base-nova/src/core/platform_thread.cc b/repos/base-nova/src/core/platform_thread.cc index 405b7825b5..10b89ab62f 100644 --- a/repos/base-nova/src/core/platform_thread.cc +++ b/repos/base-nova/src/core/platform_thread.cc @@ -359,7 +359,7 @@ Platform_thread::Platform_thread(size_t, const char *name, unsigned prio, _sel_exc_base(Native_thread::INVALID_INDEX), _location(platform_specific().sanitize(affinity)), _features(0), - _priority(scale_priority(prio, name)), + _priority((uint8_t)(scale_priority(prio, name))), _name(name) { } diff --git a/repos/base-nova/src/core/ram_dataspace_support.cc b/repos/base-nova/src/core/ram_dataspace_support.cc index a72662ca2f..a850892905 100644 --- a/repos/base-nova/src/core/ram_dataspace_support.cc +++ b/repos/base-nova/src/core/ram_dataspace_support.cc @@ -41,7 +41,7 @@ static inline void * alloc_region(Dataspace_component &ds, const size_t size) size_t align_log2 = log2(ds.size()); for (; align_log2 >= get_page_size_log2(); align_log2--) { - platform().region_alloc().alloc_aligned(size, align_log2).with_result( + platform().region_alloc().alloc_aligned(size, (unsigned)align_log2).with_result( [&] (void *ptr) { virt_addr = ptr; }, [&] (Range_allocator::Alloc_error) { /* try next iteration */ } ); diff --git a/repos/base-nova/src/core/thread_start.cc b/repos/base-nova/src/core/thread_start.cc index a9aa95dfdf..f97bc2a8db 100644 --- a/repos/base-nova/src/core/thread_start.cc +++ b/repos/base-nova/src/core/thread_start.cc @@ -96,7 +96,7 @@ void Thread::start() Affinity::Location location = _affinity; if (!location.valid()) - location = Affinity::Location(boot_cpu(), 0); + location = Affinity::Location((int)boot_cpu(), 0); /* create local EC */ enum { LOCAL_THREAD = false }; diff --git a/repos/base-nova/src/core/vm_session_component.cc b/repos/base-nova/src/core/vm_session_component.cc index 76da341b4c..e269939c92 100644 --- a/repos/base-nova/src/core/vm_session_component.cc +++ b/repos/base-nova/src/core/vm_session_component.cc @@ -333,7 +333,7 @@ Capability Vm_session_component::create_vcpu(Thread_cap _constrained_md_ram_alloc, _cap_quota_guard(), vcpu_id, - kernel_cpu_id, + (unsigned)kernel_cpu_id, vcpu_location, _priority, _session_label, diff --git a/repos/base-nova/src/include/base/internal/ipc.h b/repos/base-nova/src/include/base/internal/ipc.h index d928379ee4..0d719dcf34 100644 --- a/repos/base-nova/src/include/base/internal/ipc.h +++ b/repos/base-nova/src/include/base/internal/ipc.h @@ -104,7 +104,7 @@ static inline bool copy_msgbuf_to_utcb(Nova::Utcb &utcb, for (unsigned i = 0; i < num_data_words; i++) *dst++ = *src++; - utcb.set_msg_word(num_msg_words); + utcb.set_msg_word((unsigned)num_msg_words); /* append portal capability selectors */ for (unsigned i = 0; i < snd_msg.used_caps(); i++) { diff --git a/repos/base-nova/src/include/base/internal/spin_lock.h b/repos/base-nova/src/include/base/internal/spin_lock.h index 2adbd2f27b..ee5702ac6e 100644 --- a/repos/base-nova/src/include/base/internal/spin_lock.h +++ b/repos/base-nova/src/include/base/internal/spin_lock.h @@ -35,8 +35,8 @@ static inline void spinlock_lock(volatile T *lock_variable) using Genode::cmpxchg; Genode::Thread * myself = Genode::Thread::myself(); - T const tid = myself ? myself->native_thread().ec_sel - : (Genode::addr_t)Nova::EC_SEL_THREAD; + T const tid = (T)(myself ? myself->native_thread().ec_sel + : (Genode::addr_t)Nova::EC_SEL_THREAD); unsigned help_counter = 0; diff --git a/repos/base-nova/src/include/signal_source/client.h b/repos/base-nova/src/include/signal_source/client.h index 1ff928e52b..5a0159cbd6 100644 --- a/repos/base-nova/src/include/signal_source/client.h +++ b/repos/base-nova/src/include/signal_source/client.h @@ -95,7 +95,7 @@ namespace Genode { } while (imprint == 0); - return Signal(imprint, count); + return Signal(imprint, (int)count); } }; } diff --git a/repos/base-nova/src/lib/base/cap_map.cc b/repos/base-nova/src/lib/base/cap_map.cc index 0e2044fbae..c348e9a6f0 100644 --- a/repos/base-nova/src/lib/base/cap_map.cc +++ b/repos/base-nova/src/lib/base/cap_map.cc @@ -100,9 +100,9 @@ addr_t Cap_range::alloc(size_t const num_log2) do { /* align i to num_log2 */ - unsigned i = ((_base + last + step - 1) & ~(step - 1)) - _base; + unsigned i = (unsigned)(((_base + last + step - 1) & ~(step - 1)) - _base); unsigned j; - for (; i + step < max; i += step) { + for (; i + step < max; i += (unsigned)step) { for (j = 0; j < step; j++) if (_cap_array[i+j]) break; @@ -116,7 +116,7 @@ addr_t Cap_range::alloc(size_t const num_log2) return _base + i; } - max = last; + max = (unsigned)last; last = 0; } while (max); @@ -157,7 +157,7 @@ addr_t Capability_map::insert(size_t const num_log_2, addr_t const sel) return ~0UL; for (unsigned i = 0; i < 1UL << num_log_2; i++) - range->inc(sel + i - range->base()); + range->inc((unsigned)(sel + i - range->base())); return sel; } @@ -170,13 +170,13 @@ void Capability_map::remove(Genode::addr_t const sel, uint8_t num_log_2, if (!range) return; - range->dec(sel - range->base(), revoke, num_log_2); + range->dec((unsigned)(sel - range->base()), revoke, num_log_2); Genode::addr_t last_sel = sel + (1UL << num_log_2); Genode::addr_t last_range = range->base() + range->elements(); while (last_sel > last_range) { - uint8_t left_log2 = log2(last_sel - last_range); + uint8_t left_log2 = (uint8_t)log2(last_sel - last_range); /* take care for a case which should not happen */ if (left_log2 >= sizeof(last_range)*8) { diff --git a/repos/base-nova/src/lib/base/ipc.cc b/repos/base-nova/src/lib/base/ipc.cc index a6650dd3d1..1bb6b07fe3 100644 --- a/repos/base-nova/src/lib/base/ipc.cc +++ b/repos/base-nova/src/lib/base/ipc.cc @@ -42,7 +42,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst, /* calculate max order of caps to be received during reply */ unsigned short log2_max = 0; if (rcv_caps) { - log2_max = log2(rcv_caps); + log2_max = (uint16_t)log2(rcv_caps); /* if this happens, the call is bogus and invalid */ if ((log2_max >= sizeof(rcv_caps) * 8)) @@ -93,7 +93,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst, if (utcb.msg_words() < 1) return Rpc_exception_code(Rpc_exception_code::INVALID_OBJECT); - return Rpc_exception_code(copy_utcb_to_msgbuf(utcb, rcv_window, rcv_msg)); + return Rpc_exception_code((int)copy_utcb_to_msgbuf(utcb, rcv_window, rcv_msg)); } diff --git a/repos/base-nova/src/lib/base/stack.cc b/repos/base-nova/src/lib/base/stack.cc index 3d6f8925ce..05e4544dd2 100644 --- a/repos/base-nova/src/lib/base/stack.cc +++ b/repos/base-nova/src/lib/base/stack.cc @@ -83,8 +83,8 @@ void prepare_init_main_thread() enum { CAP_RANGES = 32 }; - unsigned index = initial_cap_range().base() + - initial_cap_range().elements(); + unsigned index = (unsigned)(initial_cap_range().base() + + initial_cap_range().elements()); static char local[CAP_RANGES][sizeof(Cap_range)]; @@ -95,7 +95,7 @@ void prepare_init_main_thread() cap_map().insert(range); - index = range.base() + range.elements(); + index = (unsigned)(range.base() + range.elements()); } } } diff --git a/repos/base-nova/src/lib/base/vm.cc b/repos/base-nova/src/lib/base/vm.cc index e02092fae2..767cb4ae4e 100644 --- a/repos/base-nova/src/lib/base/vm.cc +++ b/repos/base-nova/src/lib/base/vm.cc @@ -389,7 +389,7 @@ void Nova_vcpu::_write_nova_state(Nova::Utcb &utcb) utcb.dr7 = state().dr7.value(); } - if (state().r8.charged() || state().r9.charged() || + if (state().r8 .charged() || state().r9 .charged() || state().r10.charged() || state().r11.charged() || state().r12.charged() || state().r13.charged() || state().r14.charged() || state().r15.charged()) { @@ -527,10 +527,10 @@ void Nova_vcpu::_write_nova_state(Nova::Utcb &utcb) state().pdpte_2.charged() || state().pdpte_3.charged()) { utcb.mtd |= Nova::Mtd::PDPTE; - utcb.pdpte[0] = state().pdpte_0.value(); - utcb.pdpte[1] = state().pdpte_1.value(); - utcb.pdpte[2] = state().pdpte_2.value(); - utcb.pdpte[3] = state().pdpte_3.value(); + utcb.pdpte[0] = (Nova::mword_t)state().pdpte_0.value(); + utcb.pdpte[1] = (Nova::mword_t)state().pdpte_1.value(); + utcb.pdpte[2] = (Nova::mword_t)state().pdpte_2.value(); + utcb.pdpte[3] = (Nova::mword_t)state().pdpte_3.value(); } if (state().star.charged() || state().lstar.charged() || @@ -538,7 +538,7 @@ void Nova_vcpu::_write_nova_state(Nova::Utcb &utcb) state().kernel_gs_base.charged()) { utcb.mtd |= Nova::Mtd::SYSCALL_SWAPGS; - utcb.write_star(state().star.value()); + utcb.write_star (state().star.value()); utcb.write_lstar(state().lstar.value()); utcb.write_cstar(state().cstar.value()); utcb.write_fmask(state().fmask.value()); @@ -783,7 +783,7 @@ Nova_vcpu::Nova_vcpu(Env &env, Vm_connection &vm, Allocator &alloc, Nova::Mtd mtd = _portal_mtd(i, exit_config); if (mtd.value()) { - signal_exit = _create_exit_handler(env.pd(), handler, vcpu_id, i, mtd); + signal_exit = _create_exit_handler(env.pd(), handler, vcpu_id, (uint16_t)i, mtd); } else { signal_exit = dontcare_exit; } diff --git a/repos/base-nova/src/test/platform/main.cc b/repos/base-nova/src/test/platform/main.cc index 978f3d65bf..e8748b667a 100644 --- a/repos/base-nova/src/test/platform/main.cc +++ b/repos/base-nova/src/test/platform/main.cc @@ -673,10 +673,10 @@ Main::Main(Env &env) : env(env) } /* upgrade available capability indices for this process */ - unsigned index = 512 * 1024; + addr_t index = 512 * 1024; static char local[128][sizeof(Cap_range)]; - for (unsigned i = 0; i < sizeof(local) / sizeof (local[0]); i++) { + for (addr_t i = 0; i < sizeof(local) / sizeof (local[0]); i++) { Cap_range &range = *construct_at(local[i], index); cap_map().insert(range); diff --git a/repos/base-okl4/src/core/platform.cc b/repos/base-okl4/src/core/platform.cc index c6b2dc5b61..170737f499 100644 --- a/repos/base-okl4/src/core/platform.cc +++ b/repos/base-okl4/src/core/platform.cc @@ -40,13 +40,11 @@ using namespace Genode; ** Support for core memory management ** ****************************************/ -bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr, - unsigned size) { +bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr, size_t size) { return map_local(phys_addr, virt_addr, size / get_page_size()); } -bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, addr_t, - unsigned size) { +bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, addr_t, size_t size) { return unmap_local(virt_addr, size / get_page_size()); } diff --git a/repos/base-okl4/src/include/base/internal/okl4.h b/repos/base-okl4/src/include/base/internal/okl4.h index eed31dcf8b..9b74ad0385 100644 --- a/repos/base-okl4/src/include/base/internal/okl4.h +++ b/repos/base-okl4/src/include/base/internal/okl4.h @@ -16,7 +16,10 @@ /* OKL4 includes */ namespace Okl4 { extern "C" { +#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wconversion" + #include #include #include @@ -28,6 +31,7 @@ namespace Okl4 { extern "C" { #include #include #include + #pragma GCC diagnostic pop #undef UTCB_SIZE } } diff --git a/repos/base-okl4/src/lib/base/ipc.cc b/repos/base-okl4/src/lib/base/ipc.cc index 0e27989780..f38b8913c9 100644 --- a/repos/base-okl4/src/lib/base/ipc.cc +++ b/repos/base-okl4/src/lib/base/ipc.cc @@ -106,9 +106,9 @@ static L4_Word_t extract_msg_from_utcb(L4_MsgTag_t rcv_tag, Msgbuf_base &rcv_msg */ static void copy_msg_to_utcb(Msgbuf_base const &snd_msg, L4_Word_t local_name) { - unsigned const num_header_words = 3 + 2*snd_msg.used_caps(); - unsigned const num_data_words = snd_msg.data_size()/sizeof(L4_Word_t); - unsigned const num_msg_words = num_data_words + num_header_words; + uint8_t const num_header_words = (uint8_t)(3 + 2*snd_msg.used_caps()); + uint8_t const num_data_words = (uint8_t)(snd_msg.data_size()/sizeof(L4_Word_t)); + uint8_t const num_msg_words = num_data_words + num_header_words; if (num_msg_words >= L4_GetMessageRegisters()) { raw("Message does not fit into UTCB message registers"); @@ -118,7 +118,7 @@ static void copy_msg_to_utcb(Msgbuf_base const &snd_msg, L4_Word_t local_name) L4_MsgTag_t snd_tag; snd_tag.raw = 0; - snd_tag.X.u = num_msg_words; + snd_tag.X.u = (num_msg_words & 0x3f); /* bitfield X.u has 6 bits */ L4_LoadMR(0, snd_tag.raw); L4_LoadMR(1, local_name); diff --git a/repos/base-pistachio/lib/mk/syscall-pistachio.mk b/repos/base-pistachio/lib/mk/syscall-pistachio.mk index 4631c9bb05..f97183ca69 100644 --- a/repos/base-pistachio/lib/mk/syscall-pistachio.mk +++ b/repos/base-pistachio/lib/mk/syscall-pistachio.mk @@ -3,6 +3,8 @@ PISTACHIO_USER_SRC := $(PISTACHIO_CONTRIB_DIR)/user/lib/l4 LD_PREFIX := "-Wl," +CC_CXX_WARN_STRICT_CONVERSION = + CC_WARN += -Wno-array-bounds -Wno-unused-but-set-variable \ -Wno-parentheses -Wno-format -Wno-builtin-declaration-mismatch \ -Wno-unused-function -Wno-pointer-compare diff --git a/repos/base-pistachio/src/core/include/platform_pd.h b/repos/base-pistachio/src/core/include/platform_pd.h index 7a2919d0ed..631cea8d79 100644 --- a/repos/base-pistachio/src/core/include/platform_pd.h +++ b/repos/base-pistachio/src/core/include/platform_pd.h @@ -54,7 +54,8 @@ class Genode::Platform_pd : public Address_space PD_FIRST = 0, PD_MAX = (1 << PD_BITS) - 1, THREAD_MAX = (1 << THREAD_BITS) - 1, - VERSION_MAX = (1 << VERSION_BITS) - 1, + VERSION_MASK = (1 << VERSION_BITS) - 1, + VERSION_MAX = VERSION_MASK, PD_INVALID = -1, }; @@ -124,7 +125,7 @@ class Genode::Platform_pd : public Address_space unsigned version : VERSION_BITS; Pd_alloc(bool r, bool f, unsigned v) - : reserved(r), free(f), version(v) { } + : reserved(r), free(f), version(v & VERSION_MASK) { } /* * Start with version 2 to avoid being mistaken as local or diff --git a/repos/base-pistachio/src/core/include/print_l4_thread_id.h b/repos/base-pistachio/src/core/include/print_l4_thread_id.h index 625891247d..eafd22b6aa 100644 --- a/repos/base-pistachio/src/core/include/print_l4_thread_id.h +++ b/repos/base-pistachio/src/core/include/print_l4_thread_id.h @@ -35,13 +35,13 @@ struct Genode::Formatted_tid if (L4_IsLocalId(tid)) { - unsigned char const local_id = tid.local.X.local_id; + uint8_t const local_id = (uint8_t)tid.local.X.local_id; print(out, "THREAD (local) ", Hex(local_id, Hex::OMIT_PREFIX, Hex::PAD), " " "(raw ", Hex(tid.raw, Hex::OMIT_PREFIX, Hex::PAD), ")"); } else if (L4_IsGlobalId(tid)) { - unsigned char const global_id = tid.global.X.thread_no; + uint8_t const global_id = (uint8_t)tid.global.X.thread_no; print(out, "THREAD (global) ", Hex(global_id, Hex::OMIT_PREFIX, Hex::PAD), " " "(version ", Hex(tid.global.X.version, Hex::OMIT_PREFIX), ") ", diff --git a/repos/base-pistachio/src/include/base/internal/pistachio.h b/repos/base-pistachio/src/include/base/internal/pistachio.h index 2b528cb90c..1c531e9760 100644 --- a/repos/base-pistachio/src/include/base/internal/pistachio.h +++ b/repos/base-pistachio/src/include/base/internal/pistachio.h @@ -15,6 +15,10 @@ #define _BASE__INTERNAL__PISTACHIO_H_ namespace Pistachio { + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" + #include #include #include @@ -27,6 +31,8 @@ namespace Pistachio { #include #include #include + +#pragma GCC diagnostic pop /* restore -Wconversion warnings */ } #endif /* _BASE__INTERNAL__PISTACHIO_H_ */ diff --git a/repos/base-sel4/src/core/include/cnode.h b/repos/base-sel4/src/core/include/cnode.h index 5fa6cc8b10..e905ed4f1b 100644 --- a/repos/base-sel4/src/core/include/cnode.h +++ b/repos/base-sel4/src/core/include/cnode.h @@ -34,14 +34,14 @@ class Genode::Cnode_base private: Cap_sel const _sel; - size_t const _size_log2; + uint8_t const _size_log2; public: typedef Cnode_index Index; Cap_sel sel() const { return _sel; } - size_t size_log2() const { return _size_log2; } + uint8_t size_log2() const { return _size_log2; } /** * Copy selector from another CNode @@ -60,7 +60,7 @@ class Genode::Cnode_base src_root, src_index, src_depth, rights); if (ret != 0) { warning(__FUNCTION__, ": seL4_CNode_Copy (", - (void*)from_idx.value(), ") returned ", ret); + Hex(from_idx.value()), ") returned ", ret); } } @@ -113,7 +113,7 @@ class Genode::Cnode_base src_root, src_index, src_depth); if (ret != 0) { warning(__FUNCTION__, ": seL4_CNode_Move (", - (void*)from_idx.value(), ") returned ", ret); + Hex(from_idx.value()), ") returned ", ret); } } @@ -122,7 +122,7 @@ class Genode::Cnode_base /** * Constructor */ - Cnode_base(Cap_sel sel, size_t size_log2) + Cnode_base(Cap_sel sel, uint8_t size_log2) : _sel(sel), _size_log2(size_log2) { } }; @@ -154,7 +154,7 @@ class Genode::Cnode : public Cnode_base, Noncopyable * * \deprecated */ - Cnode(Cap_sel parent_sel, Index dst_idx, size_t size_log2, + Cnode(Cap_sel parent_sel, Index dst_idx, uint8_t size_log2, Range_allocator &phys_alloc) : Cnode_base(dst_idx, size_log2) @@ -178,7 +178,7 @@ class Genode::Cnode : public Cnode_base, Noncopyable * \throw Retype_untyped_failed * \throw Initial_untyped_pool::Initial_untyped_pool_exhausted */ - Cnode(Cap_sel parent_sel, Index dst_idx, size_t size_log2, + Cnode(Cap_sel parent_sel, Index dst_idx, uint8_t size_log2, Initial_untyped_pool &untyped_pool) : Cnode_base(dst_idx, size_log2) diff --git a/repos/base-sel4/src/core/include/core_cspace.h b/repos/base-sel4/src/core/include/core_cspace.h index 9cf3534a01..509b06eea0 100644 --- a/repos/base-sel4/src/core/include/core_cspace.h +++ b/repos/base-sel4/src/core/include/core_cspace.h @@ -34,13 +34,13 @@ class Genode::Core_cspace }; /* selectors for initially created CNodes during core bootup */ - static inline unsigned long top_cnode_sel() { return sel4_boot_info().empty.start; } - static inline unsigned long core_pad_cnode_sel() { return top_cnode_sel() + 1; } - static inline unsigned long core_cnode_sel() { return core_pad_cnode_sel() + 1; } - static inline unsigned long phys_cnode_sel() { return core_cnode_sel() + 1; } - static inline unsigned long untyped_cnode_4k() { return phys_cnode_sel() + 1; } - static inline unsigned long untyped_cnode_16k() { return untyped_cnode_4k() + 1; } - static unsigned long core_static_sel_end() { return untyped_cnode_16k() + 1; } + static unsigned top_cnode_sel() { return (unsigned)sel4_boot_info().empty.start; } + static unsigned core_pad_cnode_sel() { return top_cnode_sel() + 1; } + static unsigned core_cnode_sel() { return core_pad_cnode_sel() + 1; } + static unsigned phys_cnode_sel() { return core_cnode_sel() + 1; } + static unsigned untyped_cnode_4k() { return phys_cnode_sel() + 1; } + static unsigned untyped_cnode_16k() { return untyped_cnode_4k() + 1; } + static unsigned core_static_sel_end() { return untyped_cnode_16k() + 1; } /* indices within top-level CNode */ enum Top_cnode_idx { diff --git a/repos/base-sel4/src/core/include/initial_untyped_pool.h b/repos/base-sel4/src/core/include/initial_untyped_pool.h index 4e4d070971..024dfab5ce 100644 --- a/repos/base-sel4/src/core/include/initial_untyped_pool.h +++ b/repos/base-sel4/src/core/include/initial_untyped_pool.h @@ -48,7 +48,7 @@ class Genode::Initial_untyped_pool unsigned const sel; /* index into 'untypedSizeBitsList' */ - unsigned const index = sel - sel4_boot_info().untyped.start; + unsigned const index = (unsigned)(sel - sel4_boot_info().untyped.start); /* original size of untyped memory range */ size_t const size = 1UL << sel4_boot_info().untypedList[index].sizeBits; @@ -72,7 +72,7 @@ class Genode::Initial_untyped_pool /** * Calculate free index after allocation */ - addr_t _align_offset(Range &range, size_t size_log2) + addr_t _align_offset(Range &range, unsigned size_log2) { /* * The seL4 kernel naturally aligns allocations within untuped @@ -94,8 +94,8 @@ class Genode::Initial_untyped_pool void for_each_range(FUNC const &func) { seL4_BootInfo const &bi = sel4_boot_info(); - for (unsigned sel = bi.untyped.start; sel < bi.untyped.end; sel++) { - Range range(*this, sel); + for (addr_t sel = bi.untyped.start; sel < bi.untyped.end; sel++) { + Range range(*this, (unsigned)sel); func(range); } } @@ -115,7 +115,7 @@ class Genode::Initial_untyped_pool * * \throw Initial_untyped_pool_exhausted */ - unsigned alloc(size_t size_log2) + unsigned alloc(unsigned size_log2) { enum { UNKNOWN = 0 }; unsigned sel = UNKNOWN; @@ -177,10 +177,10 @@ class Genode::Initial_untyped_pool * objects of size_log2 and up to a maximum as specified by max_memory */ template - void turn_into_untyped_object(addr_t const node_index, - FUNC const & func, - addr_t const size_log2 = get_page_size_log2(), - addr_t max_memory = 0UL - 0x1000UL) + void turn_into_untyped_object(addr_t const node_index, + FUNC const & func, + uint8_t const size_log2 = get_page_size_log2(), + addr_t max_memory = 0UL - 0x1000UL) { for_each_range([&] (Range &range) { @@ -222,7 +222,9 @@ class Genode::Initial_untyped_pool /* XXX skip memory because of limited untyped cnode range */ if (node_offset >= (1UL << (32 - get_page_size_log2()))) { - Genode::warning(range.device ? "device" : " ", " memory in range ", Hex_range(range.phys, range.size), " is unavailable (due to limited untyped cnode range)"); + warning(range.device ? "device" : " ", " memory in range ", + Hex_range(range.phys, range.size), + " is unavailable (due to limited untyped cnode range)"); return; } diff --git a/repos/base-sel4/src/core/include/kernel_object.h b/repos/base-sel4/src/core/include/kernel_object.h index 2494ff5337..7b9fc31336 100644 --- a/repos/base-sel4/src/core/include/kernel_object.h +++ b/repos/base-sel4/src/core/include/kernel_object.h @@ -28,7 +28,7 @@ namespace Genode { */ struct Cnode_index : Cap_sel { - explicit Cnode_index(addr_t value) : Cap_sel(value) { } + explicit Cnode_index(uint32_t value) : Cap_sel(value) { } Cnode_index(Cap_sel sel) : Cap_sel(sel.value()) { } }; @@ -84,16 +84,16 @@ namespace Genode { template static void create(seL4_Untyped const service, Cap_sel const dst_cnode_sel, - Cnode_index dst_idx, - size_t size_log2 = 0) + Cnode_index const dst_idx, + uint8_t const size_log2 = 0) { - int const type = KOBJ::SEL4_TYPE; - int const size_bits = size_log2; - seL4_CNode const root = dst_cnode_sel.value(); - int const node_index = 0; - int const node_depth = 0; - int const node_offset = dst_idx.value(); - int const num_objects = 1; + unsigned const type = KOBJ::SEL4_TYPE; + uint8_t const size_bits = size_log2; + seL4_CNode const root = dst_cnode_sel.value(); + unsigned const node_index = 0; + unsigned const node_depth = 0; + unsigned const node_offset = dst_idx.value(); + unsigned const num_objects = 1; int const ret = seL4_Untyped_Retype(service, type, diff --git a/repos/base-sel4/src/core/include/page_table_registry.h b/repos/base-sel4/src/core/include/page_table_registry.h index bff0c9c331..c6f5b6c3c0 100644 --- a/repos/base-sel4/src/core/include/page_table_registry.h +++ b/repos/base-sel4/src/core/include/page_table_registry.h @@ -220,23 +220,23 @@ class Genode::Page_table_registry bool page_frame_at(addr_t const vaddr) { return Frame::lookup(_frames, vaddr, LEVEL_0); } - bool page_table_at(addr_t const vaddr, addr_t const level_log2) { + bool page_table_at(addr_t const vaddr, unsigned const level_log2) { return Table::lookup(_level1, vaddr, level_log2); } - bool page_directory_at(addr_t const vaddr, addr_t const level_log2) { + bool page_directory_at(addr_t const vaddr, unsigned const level_log2) { return Table::lookup(_level2, vaddr, level_log2); } - bool page_level3_at(addr_t const vaddr, addr_t const level_log2) { + bool page_level3_at(addr_t const vaddr, unsigned const level_log2) { return Table::lookup(_level3, vaddr, level_log2); } void insert_page_frame(addr_t const vaddr, Cap_sel const sel) { _insert(vaddr, sel, Level::FRAME, 0, LEVEL_0); } void insert_page_table(addr_t const vaddr, Cap_sel const sel, - addr_t const paddr, addr_t const level_log2) { + addr_t const paddr, unsigned const level_log2) { _insert(vaddr, sel, Level::PAGE_TABLE, paddr, level_log2); } void insert_page_directory(addr_t const vaddr, Cap_sel const sel, - addr_t const paddr, addr_t const level_log2) { + addr_t const paddr, unsigned const level_log2) { _insert(vaddr, sel, Level::LEVEL2, paddr, level_log2); } void insert_page_level3(addr_t const vaddr, Cap_sel const sel, - addr_t const paddr, addr_t const level_log2) { + addr_t const paddr, unsigned const level_log2) { _insert(vaddr, sel, Level::LEVEL3, paddr, level_log2); } /** diff --git a/repos/base-sel4/src/core/include/platform.h b/repos/base-sel4/src/core/include/platform.h index 4fcc325252..5169925946 100644 --- a/repos/base-sel4/src/core/include/platform.h +++ b/repos/base-sel4/src/core/include/platform.h @@ -24,7 +24,7 @@ namespace Genode { class Platform; - template class Static_allocator; + template class Static_allocator; class Address_space; } @@ -36,7 +36,7 @@ namespace Genode { * * The size of a single ELEM must be a multiple of sizeof(long). */ -template +template class Genode::Static_allocator : public Allocator { private: @@ -69,7 +69,7 @@ class Genode::Static_allocator : public Allocator void free(void *ptr, size_t) override { Elem_space *elem = reinterpret_cast(ptr); - unsigned const index = elem - &_elements[0]; + unsigned const index = (unsigned)(elem - &_elements[0]); _used.free(index); } @@ -169,7 +169,7 @@ class Genode::Platform : public Platform_generic Mutex::Guard guard(_mutex); try { - return Cap_sel(Core_sel_bit_alloc::alloc()); } + return Cap_sel((uint32_t)Core_sel_bit_alloc::alloc()); } catch (Bit_allocator::Out_of_indices) { throw Alloc_failed(); } } @@ -246,7 +246,7 @@ class Genode::Platform : public Platform_generic Rom_fs &rom_fs() override { return _rom_fs; } Affinity::Space affinity_space() const override { - return sel4_boot_info().numNodes; } + return (unsigned)sel4_boot_info().numNodes; } bool supports_direct_unmap() const override { return true; } diff --git a/repos/base-sel4/src/core/include/untyped_memory.h b/repos/base-sel4/src/core/include/untyped_memory.h index 540fc280a5..beed7cfe5f 100644 --- a/repos/base-sel4/src/core/include/untyped_memory.h +++ b/repos/base-sel4/src/core/include/untyped_memory.h @@ -67,7 +67,7 @@ struct Genode::Untyped_memory addr_t size_log2 = get_page_size_log2()) { unsigned const upper_bits = top_idx << Core_cspace::NUM_PHYS_SEL_LOG2; - unsigned const lower_bits = phys_addr >> size_log2; + unsigned const lower_bits = (unsigned)(phys_addr >> size_log2); return Cap_sel(upper_bits | lower_bits); } @@ -141,7 +141,8 @@ struct Genode::Untyped_memory for (addr_t phys = phys_addr; phys < phys_addr + phys_size; phys += get_page_size()) { - int const index = phys >> get_page_size_log2(); + unsigned const index = (unsigned)(phys >> get_page_size_log2()); + /** * Without the revoke, one gets sporadically * Untyped Retype: Insufficient memory ( xx bytes needed, x bytes diff --git a/repos/base-sel4/src/core/include/vm_space.h b/repos/base-sel4/src/core/include/vm_space.h index 666eb9ecbe..de3b53344d 100644 --- a/repos/base-sel4/src/core/include/vm_space.h +++ b/repos/base-sel4/src/core/include/vm_space.h @@ -166,8 +166,10 @@ class Genode::Vm_space /** * Return selector for a capability slot within '_vm_cnodes' */ - addr_t _idx_to_sel(addr_t idx) const { return (_id << 20) | idx; } - + Cap_sel _idx_to_sel(addr_t idx) const + { + return Cap_sel((uint32_t)((_id << 20) | idx)); + } template void _flush(bool const flush_support, FN const &fn) @@ -181,10 +183,8 @@ class Genode::Vm_space _pd_label.string()); _page_table_registry.flush_pages(fn); - } - template bool _map_frame(addr_t const from_phys, addr_t const to_dest, Map_attr const attr, bool guest, FN const &fn) @@ -201,13 +201,13 @@ class Genode::Vm_space return true; } /* allocate page-table-entry selector */ - addr_t pte_idx; - try { pte_idx = _sel_alloc.alloc(); } + uint32_t pte_idx = 0; + try { pte_idx = (uint32_t)_sel_alloc.alloc(); } catch (Selector_allocator::Out_of_indices) { /* free all page-table-entry selectors and retry once */ _flush(attr.flush_support, fn); - pte_idx = _sel_alloc.alloc(); + pte_idx = (uint32_t)_sel_alloc.alloc(); } /* @@ -217,7 +217,7 @@ class Genode::Vm_space * inserted into only a single page table. */ _leaf_cnode(pte_idx).copy(_phys_cnode, - Cnode_index(from_phys >> get_page_size_log2()), + Cnode_index((uint32_t)(from_phys >> get_page_size_log2())), Cnode_index(_leaf_cnode_entry(pte_idx))); /* remember relationship between pte_sel and the virtual address */ @@ -256,11 +256,11 @@ class Genode::Vm_space */ template Cap_sel _alloc_and_map(addr_t const virt, - long (&map_fn)(Cap_sel, Cap_sel, addr_t), - addr_t &phys) + long (&map_fn)(Cap_sel, Cap_sel, addr_t), + addr_t &phys) { /* allocate page-* selector */ - addr_t const idx = _sel_alloc.alloc(); + uint32_t const idx = (uint32_t)_sel_alloc.alloc(); try { phys = Untyped_memory::alloc_page(_phys_alloc); @@ -272,7 +272,7 @@ class Genode::Vm_space throw Alloc_page_table_failed(); } - Cap_sel const pt_sel(_idx_to_sel(idx)); + Cap_sel const pt_sel = _idx_to_sel(idx); long const result = map_fn(pt_sel, _pd_sel, virt); if (result != seL4_NoError) diff --git a/repos/base-sel4/src/core/irq_session_component.cc b/repos/base-sel4/src/core/irq_session_component.cc index fe847ecabd..973d465d69 100644 --- a/repos/base-sel4/src/core/irq_session_component.cc +++ b/repos/base-sel4/src/core/irq_session_component.cc @@ -101,7 +101,7 @@ Irq_object::Irq_object(unsigned irq) Irq_session_component::Irq_session_component(Range_allocator &irq_alloc, const char *args) : - _irq_number(Arg_string::find_arg(args, "irq_number").long_value(-1)), + _irq_number((unsigned)Arg_string::find_arg(args, "irq_number").long_value(-1)), _irq_alloc(irq_alloc), _irq_object(_irq_number) { diff --git a/repos/base-sel4/src/core/platform.cc b/repos/base-sel4/src/core/platform.cc index 6496844959..b15f09fa0f 100644 --- a/repos/base-sel4/src/core/platform.cc +++ b/repos/base-sel4/src/core/platform.cc @@ -58,8 +58,7 @@ extern unsigned _prog_img_beg, _prog_img_end; ** Support for core memory management ** ****************************************/ -bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr, - unsigned size) +bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr, size_t size) { if (platform_in_construction) Genode::warning("need physical memory, but Platform object not constructed yet"); @@ -72,8 +71,7 @@ bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr, } -bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, addr_t phys_addr, - unsigned size) +bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, addr_t phys_addr, size_t size) { if (!unmap_local(virt_addr, size / get_page_size())) return false; @@ -197,16 +195,16 @@ void Platform::_switch_to_core_cspace() * * <> */ - for (unsigned sel = bi.untyped.start; sel < bi.untyped.end; sel++) - _core_cnode.move(initial_cspace, Cnode_index(sel)); + for (addr_t sel = bi.untyped.start; sel < bi.untyped.end; sel++) + _core_cnode.move(initial_cspace, Cnode_index((uint32_t)sel)); /* move selectors of core image */ addr_t const modules_start = reinterpret_cast(&_boot_modules_binaries_begin); addr_t const modules_end = reinterpret_cast(&_boot_modules_binaries_end); addr_t virt_addr = (addr_t)(&_prog_img_beg); - for (unsigned sel = bi.userImageFrames.start; - sel < bi.userImageFrames.end; + for (unsigned sel = (unsigned)bi.userImageFrames.start; + sel < (unsigned)bi.userImageFrames.end; sel++, virt_addr += get_page_size()) { /* remove mapping to boot modules, no access required within core */ @@ -336,8 +334,8 @@ void Platform::_init_rom_modules() */ Cnode_base const initial_cspace(Cap_sel(seL4_CapInitThreadCNode), 32); for (unsigned i = 0; i < module_num_frames; i++) - _phys_cnode.move(initial_cspace, Cnode_index(module_frame_sel + i), - Cnode_index(dst_frame + i)); + _phys_cnode.move(initial_cspace, Cnode_index((uint32_t)module_frame_sel + i), + Cnode_index((uint32_t)dst_frame + i)); log("boot module '", (char const *)header->name, "' " "(", header->size, " bytes)"); diff --git a/repos/base-sel4/src/core/platform_pd.cc b/repos/base-sel4/src/core/platform_pd.cc index 5d1a2a3b8f..c6044f03df 100644 --- a/repos/base-sel4/src/core/platform_pd.cc +++ b/repos/base-sel4/src/core/platform_pd.cc @@ -148,7 +148,7 @@ Cap_sel Platform_pd::alloc_sel() { Mutex::Guard guard(_sel_alloc_mutex); - return Cap_sel(_sel_alloc.alloc()); + return Cap_sel((uint32_t)_sel_alloc.alloc()); } @@ -191,7 +191,7 @@ void Platform_pd::flush(addr_t virt_addr, size_t size, Core_local_addr) Platform_pd::Platform_pd(Allocator &md_alloc, char const *label) : - _id(pd_id_alloc().alloc()), + _id((uint32_t)pd_id_alloc().alloc()), _page_table_registry(md_alloc), _page_directory_sel(platform_specific().core_sel_alloc().alloc()), _page_directory(_init_page_directory()), diff --git a/repos/base-sel4/src/core/platform_thread.cc b/repos/base-sel4/src/core/platform_thread.cc index d8d5ec0529..6d0a593941 100644 --- a/repos/base-sel4/src/core/platform_thread.cc +++ b/repos/base-sel4/src/core/platform_thread.cc @@ -222,7 +222,7 @@ Platform_thread::Platform_thread(size_t, const char *name, unsigned priority, _utcb(utcb), _pager_obj_sel(platform_specific().core_sel_alloc().alloc()), _location(location), - _priority(Cpu_session::scale_priority(CONFIG_NUM_PRIORITIES, priority)) + _priority((uint16_t)(Cpu_session::scale_priority(CONFIG_NUM_PRIORITIES, priority))) { static_assert(CONFIG_NUM_PRIORITIES == 256, " unknown priority configuration"); diff --git a/repos/base-sel4/src/core/signal_source_component.cc b/repos/base-sel4/src/core/signal_source_component.cc index 0f62b5fc6e..69df522588 100644 --- a/repos/base-sel4/src/core/signal_source_component.cc +++ b/repos/base-sel4/src/core/signal_source_component.cc @@ -44,7 +44,7 @@ void Signal_source_component::submit(Signal_context_component &context, * signal will be delivered as result of the next * 'wait_for_signal' call. */ - context.increment_signal_cnt(cnt); + context.increment_signal_cnt((int)cnt); if (context.enqueued()) return; diff --git a/repos/base-sel4/src/core/spec/arm/vm_space.cc b/repos/base-sel4/src/core/spec/arm/vm_space.cc index 088a41e9e2..5d28c2eee0 100644 --- a/repos/base-sel4/src/core/spec/arm/vm_space.cc +++ b/repos/base-sel4/src/core/spec/arm/vm_space.cc @@ -29,7 +29,7 @@ long Genode::Vm_space::_map_page(Genode::Cap_sel const &idx, Map_attr const map_attr, bool) { - seL4_ARM_Page const service = _idx_to_sel(idx.value()); + seL4_ARM_Page const service = _idx_to_sel(idx.value()).value(); seL4_ARM_PageDirectory const pd = _pd_sel.value(); seL4_CapRights_t const rights = map_attr.writeable ? seL4_ReadWrite : seL4_CanRead; @@ -47,7 +47,7 @@ long Genode::Vm_space::_map_page(Genode::Cap_sel const &idx, long Genode::Vm_space::_unmap_page(Genode::Cap_sel const &idx) { - seL4_ARM_Page const service = _idx_to_sel(idx.value()); + seL4_ARM_Page const service = _idx_to_sel(idx.value()).value(); return seL4_ARM_Page_Unmap(service); } @@ -56,7 +56,7 @@ long Genode::Vm_space::_invalidate_page(Genode::Cap_sel const &idx, seL4_Word const start, seL4_Word const end) { - seL4_ARM_Page const service = _idx_to_sel(idx.value()); + seL4_ARM_Page const service = _idx_to_sel(idx.value()).value(); long error = seL4_ARM_Page_CleanInvalidate_Data(service, 0, end - start); if (error == seL4_NoError) { diff --git a/repos/base-sel4/src/core/spec/x86/io_port_session_support.cc b/repos/base-sel4/src/core/spec/x86/io_port_session_support.cc index 2f74337e5a..c8c039fbf2 100644 --- a/repos/base-sel4/src/core/spec/x86/io_port_session_support.cc +++ b/repos/base-sel4/src/core/spec/x86/io_port_session_support.cc @@ -17,14 +17,12 @@ /* core includes */ #include -#include +/* base-internal includes */ +#include using namespace Genode; -/************** - ** Port API ** - **************/ unsigned char Io_port_session_component::inb(unsigned short address) { /* check boundaries */ diff --git a/repos/base-sel4/src/core/spec/x86/vm_session_component.cc b/repos/base-sel4/src/core/spec/x86/vm_session_component.cc index 80df4afcfa..65173ecf67 100644 --- a/repos/base-sel4/src/core/spec/x86/vm_session_component.cc +++ b/repos/base-sel4/src/core/spec/x86/vm_session_component.cc @@ -101,7 +101,7 @@ try _ep(ep), _constrained_md_ram_alloc(ram, _ram_quota_guard(), _cap_quota_guard()), _heap(_constrained_md_ram_alloc, local_rm), - _pd_id(Platform_pd::pd_id_alloc().alloc()), + _pd_id((uint32_t)Platform_pd::pd_id_alloc().alloc()), _vm_page_table(platform_specific().core_sel_alloc().alloc()), _vm_space(_vm_page_table, platform_specific().core_sel_alloc(), diff --git a/repos/base-sel4/src/core/spec/x86/vm_space.cc b/repos/base-sel4/src/core/spec/x86/vm_space.cc index 7a2a5673ce..ed06ab9f80 100644 --- a/repos/base-sel4/src/core/spec/x86/vm_space.cc +++ b/repos/base-sel4/src/core/spec/x86/vm_space.cc @@ -19,7 +19,7 @@ long Genode::Vm_space::_map_page(Genode::Cap_sel const &idx, Map_attr const map_attr, bool const ept) { - seL4_X86_Page const service = _idx_to_sel(idx.value()); + seL4_X86_Page const service = _idx_to_sel(idx.value()).value(); seL4_X86_PageDirectory const pd = _pd_sel.value(); seL4_CapRights_t const rights = map_attr.writeable ? seL4_ReadWrite : seL4_CanRead; @@ -40,7 +40,7 @@ long Genode::Vm_space::_map_page(Genode::Cap_sel const &idx, long Genode::Vm_space::_unmap_page(Genode::Cap_sel const &idx) { - seL4_X86_Page const service = _idx_to_sel(idx.value()); + seL4_X86_Page const service = _idx_to_sel(idx.value()).value(); return seL4_X86_Page_Unmap(service); } diff --git a/repos/base-sel4/src/core/spec/x86_64/platform.cc b/repos/base-sel4/src/core/spec/x86_64/platform.cc index 230cd6c386..9e15b8e274 100644 --- a/repos/base-sel4/src/core/spec/x86_64/platform.cc +++ b/repos/base-sel4/src/core/spec/x86_64/platform.cc @@ -34,7 +34,7 @@ void Genode::Platform::_init_core_page_table_registry() seL4_BootInfo const &bi = sel4_boot_info(); addr_t virt_addr = (addr_t)(&_prog_img_beg); - unsigned sel = bi.userImagePaging.start; + unsigned sel = (unsigned)bi.userImagePaging.start; /* we don't know the physical location of some objects XXX */ enum { XXX_PHYS_UNKNOWN = ~0UL }; diff --git a/repos/base-sel4/src/include/base/internal/capability_space_sel4.h b/repos/base-sel4/src/include/base/internal/capability_space_sel4.h index 4f96785960..1c414d8b00 100644 --- a/repos/base-sel4/src/include/base/internal/capability_space_sel4.h +++ b/repos/base-sel4/src/include/base/internal/capability_space_sel4.h @@ -31,13 +31,13 @@ namespace Genode { { private: - addr_t _value; + uint32_t _value; public: - explicit Cap_sel(addr_t value) : _value(value) { } + explicit Cap_sel(uint32_t value) : _value(value) { } - addr_t value() const { return _value; } + uint32_t value() const { return _value; } void print(Output &out) const { Genode::print(out, "sel=", _value); } }; @@ -179,7 +179,7 @@ class Genode::Capability_space_sel4 unsigned _index(Data const &data) const { addr_t const offset = (addr_t)&data - (addr_t)_caps_data; - return offset / sizeof(_caps_data[0]); + return (unsigned)(offset / sizeof(_caps_data[0])); } /** diff --git a/repos/base-sel4/src/include/base/internal/kernel_debugger.h b/repos/base-sel4/src/include/base/internal/kernel_debugger.h index 5d253ac721..3c1d2e6334 100644 --- a/repos/base-sel4/src/include/base/internal/kernel_debugger.h +++ b/repos/base-sel4/src/include/base/internal/kernel_debugger.h @@ -19,9 +19,7 @@ /* base-internal includes */ #include - -/* seL4 includes */ -#include +#include static inline void kernel_debugger_outstring(char const *msg) diff --git a/repos/base-sel4/src/include/base/internal/sel4.h b/repos/base-sel4/src/include/base/internal/sel4.h new file mode 100644 index 0000000000..16f377cea7 --- /dev/null +++ b/repos/base-sel4/src/include/base/internal/sel4.h @@ -0,0 +1,25 @@ +/* + * \brief seL4 kernel bindings + * \author Norman Feske + * \date 2021-12-02 + */ + +/* + * Copyright (C) 2021 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#ifndef _INCLUDE__BASE__INTERNAL__SEL4_H_ +#define _INCLUDE__BASE__INTERNAL__SEL4_H_ + +/* + * Disable -Wconversion warnings caused by seL4 headers + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#include +#pragma GCC diagnostic pop + +#endif /* _INCLUDE__BASE__INTERNAL__SEL4_H_ */ diff --git a/repos/base-sel4/src/lib/base/capability_space.cc b/repos/base-sel4/src/lib/base/capability_space.cc index f63f508818..a7705a398e 100644 --- a/repos/base-sel4/src/lib/base/capability_space.cc +++ b/repos/base-sel4/src/lib/base/capability_space.cc @@ -71,7 +71,7 @@ namespace { unsigned alloc() { Mutex::Guard guard(_mutex); - return Bit_allocator::alloc(); + return (unsigned)Bit_allocator::alloc(); } void free(unsigned sel) diff --git a/repos/base-sel4/src/lib/base/ipc.cc b/repos/base-sel4/src/lib/base/ipc.cc index 1e9f02107d..49b3a6e810 100644 --- a/repos/base-sel4/src/lib/base/ipc.cc +++ b/repos/base-sel4/src/lib/base/ipc.cc @@ -87,8 +87,8 @@ static seL4_MessageInfo_t new_seL4_message(Msgbuf_base const &msg) * Supply capabilities to kernel IPC message */ seL4_SetMR(MR_IDX_NUM_CAPS, msg.used_caps()); - size_t sel4_sel_cnt = 0; - for (size_t i = 0; i < msg.used_caps(); i++) { + unsigned sel4_sel_cnt = 0; + for (unsigned i = 0; i < msg.used_caps(); i++) { Native_capability const &cap = msg.cap(i); @@ -107,17 +107,17 @@ static seL4_MessageInfo_t new_seL4_message(Msgbuf_base const &msg) * Pad unused capability slots with invalid capabilities to avoid * leakage of any information that happens to be in the IPC buffer. */ - for (size_t i = msg.used_caps(); i < Msgbuf_base::MAX_CAPS_PER_MSG; i++) + for (unsigned i = (unsigned)msg.used_caps(); i < Msgbuf_base::MAX_CAPS_PER_MSG; i++) seL4_SetMR(MR_IDX_CAPS + i, Rpc_obj_key::INVALID); /* * Supply data payload */ - size_t const num_data_mwords = - align_natural(msg.data_size()) / sizeof(umword_t); + unsigned const num_data_mwords = + align_natural((unsigned)(msg.data_size() / sizeof(umword_t))); umword_t const *src = (umword_t const *)msg.data(); - for (size_t i = 0; i < num_data_mwords; i++) + for (unsigned i = 0; i < num_data_mwords; i++) seL4_SetMR(MR_IDX_DATA + i, *src++); seL4_MessageInfo_t const msg_info = @@ -139,16 +139,17 @@ static void decode_seL4_message(seL4_MessageInfo_t const &msg_info, * You must not use any Genode primitives which may corrupt the IPCBuffer * during this step, e.g. Lock or RPC for output !!! */ - size_t const num_caps = min(seL4_GetMR(MR_IDX_NUM_CAPS), - (addr_t)Msgbuf_base::MAX_CAPS_PER_MSG); - uint32_t const caps_extra = seL4_MessageInfo_get_extraCaps(msg_info); - uint32_t const caps_unwrapped = seL4_MessageInfo_get_capsUnwrapped(msg_info); - uint32_t const num_msg_words = seL4_MessageInfo_get_length(msg_info); + unsigned const num_caps = min((unsigned)seL4_GetMR(MR_IDX_NUM_CAPS), + (unsigned)Msgbuf_base::MAX_CAPS_PER_MSG); + + uint32_t const caps_extra = (uint32_t)seL4_MessageInfo_get_extraCaps(msg_info); + uint32_t const caps_unwrapped = (uint32_t)seL4_MessageInfo_get_capsUnwrapped(msg_info); + uint32_t const num_msg_words = (uint32_t)seL4_MessageInfo_get_length(msg_info); Rpc_obj_key rpc_obj_keys[Msgbuf_base::MAX_CAPS_PER_MSG]; unsigned long arg_badges[Msgbuf_base::MAX_CAPS_PER_MSG]; - for (size_t i = 0; i < num_caps; i++) { + for (unsigned i = 0; i < num_caps; i++) { rpc_obj_keys[i] = Rpc_obj_key(seL4_GetMR(MR_IDX_CAPS + i)); if (!rpc_obj_keys[i].valid()) /* @@ -169,11 +170,11 @@ static void decode_seL4_message(seL4_MessageInfo_t const &msg_info, if (num_msg_words >= MR_IDX_DATA) { /* copy data payload */ - size_t const max_words = dst_msg.capacity()/sizeof(umword_t); - size_t const num_data_words = min(num_msg_words - MR_IDX_DATA, max_words); + unsigned const max_words = (unsigned)(dst_msg.capacity() / sizeof(umword_t)); + unsigned const num_data_words = min(num_msg_words - MR_IDX_DATA, max_words); umword_t *dst = (umword_t *)dst_msg.data(); - for (size_t i = 0; i < num_data_words; i++) + for (unsigned i = 0; i < num_data_words; i++) *dst++ = seL4_GetMR(MR_IDX_DATA + i); dst_msg.data_size(num_data_words*sizeof(umword_t)); @@ -318,7 +319,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst, rcv_msg.reset(); - unsigned const dst_sel = Capability_space::ipc_cap_data(dst).sel.value(); + unsigned const dst_sel = (unsigned)Capability_space::ipc_cap_data(dst).sel.value(); /** * Do not use Genode primitives after this point until the return which may @@ -327,7 +328,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst, seL4_MessageInfo_t const request = new_seL4_message(snd_msg); seL4_MessageInfo_t const reply_msg_info = seL4_Call(dst_sel, request); - Rpc_exception_code const exc_code(seL4_GetMR(MR_IDX_EXC_CODE)); + Rpc_exception_code const exc_code((int)seL4_GetMR(MR_IDX_EXC_CODE)); decode_seL4_message(reply_msg_info, rcv_msg); diff --git a/repos/base-sel4/src/lib/base/thread_bootstrap.cc b/repos/base-sel4/src/lib/base/thread_bootstrap.cc index f6ca9bdb17..0aa24ebaa1 100644 --- a/repos/base-sel4/src/lib/base/thread_bootstrap.cc +++ b/repos/base-sel4/src/lib/base/thread_bootstrap.cc @@ -33,7 +33,7 @@ void prepare_init_main_thread() { } void Genode::Thread::_thread_bootstrap() { if (native_thread().ep_sel == 0) { - native_thread().ep_sel = _stack->utcb().ep_sel(); - native_thread().lock_sel = _stack->utcb().lock_sel(); + native_thread().ep_sel = (unsigned)_stack->utcb().ep_sel(); + native_thread().lock_sel = (unsigned)_stack->utcb().lock_sel(); } } diff --git a/repos/base-sel4/src/lib/base/x86/vm.cc b/repos/base-sel4/src/lib/base/x86/vm.cc index 59fa79ab94..0ced3693af 100644 --- a/repos/base-sel4/src/lib/base/x86/vm.cc +++ b/repos/base-sel4/src/lib/base/x86/vm.cc @@ -27,10 +27,10 @@ #include #include #include +#include /* seL4 includes */ #include -#include #include using namespace Genode; @@ -222,7 +222,7 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable if (res != SEL4_VMENTER_RESULT_FAULT) state.exit_reason = VMEXIT_RECALL; else - state.exit_reason = seL4_GetMR(SEL4_VMENTER_FAULT_REASON_MR); + state.exit_reason = (unsigned)seL4_GetMR(SEL4_VMENTER_FAULT_REASON_MR); _read_sel4_state(service, state); @@ -360,7 +360,7 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable * Convert to AMD (and Genode) format comprising 16 bits. */ uint16_t _convert_ar_16(addr_t value) { - return ((value & 0x1f000) >> 4) | (value & 0xff); } + return (uint16_t)(((value & 0x1f000) >> 4) | (value & 0xff)); } void _write_sel4_state(seL4_X86_VCPU const service, Vcpu_state &state) { @@ -455,7 +455,7 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable else ctrl_0 &= ~Vmcs::IRQ_WINDOW; - state.ctrl_primary.charge(ctrl_0); + state.ctrl_primary.charge((uint32_t)ctrl_0); } if (state.inj_error.charged()) @@ -554,16 +554,16 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable } if (state.pdpte_0.charged()) - _write_vmcs(service, Vmcs::PDPTE_0, state.pdpte_0.value()); + _write_vmcs(service, Vmcs::PDPTE_0, (addr_t)state.pdpte_0.value()); if (state.pdpte_1.charged()) - _write_vmcs(service, Vmcs::PDPTE_1, state.pdpte_1.value()); + _write_vmcs(service, Vmcs::PDPTE_1, (addr_t)state.pdpte_1.value()); if (state.pdpte_2.charged()) - _write_vmcs(service, Vmcs::PDPTE_2, state.pdpte_2.value()); + _write_vmcs(service, Vmcs::PDPTE_2, (addr_t)state.pdpte_2.value()); if (state.pdpte_3.charged()) - _write_vmcs(service, Vmcs::PDPTE_3, state.pdpte_3.value()); + _write_vmcs(service, Vmcs::PDPTE_3, (addr_t)state.pdpte_3.value()); if (state.sysenter_cs.charged()) _write_vmcs(service, Vmcs::SYSENTER_CS, state.sysenter_cs.value()); @@ -603,15 +603,15 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable void _read_sel4_state(seL4_X86_VCPU const service, Vcpu_state &state) { state.ip.charge(seL4_GetMR(SEL4_VMENTER_CALL_EIP_MR)); - state.ctrl_primary.charge(seL4_GetMR(SEL4_VMENTER_CALL_CONTROL_PPC_MR)); + state.ctrl_primary.charge((uint32_t)seL4_GetMR(SEL4_VMENTER_CALL_CONTROL_PPC_MR)); - state.ip_len.charge(seL4_GetMR(SEL4_VMENTER_FAULT_INSTRUCTION_LEN_MR)); - state.qual_primary.charge(seL4_GetMR(SEL4_VMENTER_FAULT_QUALIFICATION_MR)); + state.ip_len .charge(seL4_GetMR(SEL4_VMENTER_FAULT_INSTRUCTION_LEN_MR)); + state.qual_primary .charge(seL4_GetMR(SEL4_VMENTER_FAULT_QUALIFICATION_MR)); state.qual_secondary.charge(seL4_GetMR(SEL4_VMENTER_FAULT_GUEST_PHYSICAL_MR)); - state.flags.charge(seL4_GetMR(SEL4_VMENTER_FAULT_RFLAGS_MR)); - state.intr_state.charge(seL4_GetMR(SEL4_VMENTER_FAULT_GUEST_INT_MR)); - state.cr3.charge(seL4_GetMR(SEL4_VMENTER_FAULT_CR3_MR)); + state.flags .charge(seL4_GetMR(SEL4_VMENTER_FAULT_RFLAGS_MR)); + state.intr_state.charge((uint32_t)seL4_GetMR(SEL4_VMENTER_FAULT_GUEST_INT_MR)); + state.cr3 .charge(seL4_GetMR(SEL4_VMENTER_FAULT_CR3_MR)); state.ax.charge(seL4_GetMR(SEL4_VMENTER_FAULT_EAX)); state.bx.charge(seL4_GetMR(SEL4_VMENTER_FAULT_EBX)); @@ -629,13 +629,13 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable _recent_gpr.edi = state.di.value(); _recent_gpr.ebp = state.bp.value(); - state.sp.charge(_read_vmcs(service, Vmcs::RSP)); + state.sp .charge(_read_vmcs(service, Vmcs::RSP)); state.dr7.charge(_read_vmcs(service, Vmcs::DR7)); /* r8 - r15 not supported on seL4 */ { - addr_t const cr0 = _read_vmcs(service, Vmcs::CR0); + addr_t const cr0 = _read_vmcs(service, Vmcs::CR0); addr_t const cr0_shadow = _read_vmcs(service, Vmcs::CR0_SHADOW); state.cr0.charge((cr0 & ~cr0_mask) | (cr0_shadow & cr0_mask)); @@ -647,7 +647,7 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable state.cr2.charge(state.cr2.value()); { - addr_t const cr4 = _read_vmcs(service, Vmcs::CR4); + addr_t const cr4 = _read_vmcs(service, Vmcs::CR4); addr_t const cr4_shadow = _read_vmcs(service, Vmcs::CR4_SHADOW); state.cr4.charge((cr4 & ~cr4_mask) | (cr4_shadow & cr4_mask)); @@ -715,15 +715,15 @@ struct Sel4_vcpu : Genode::Thread, Noncopyable if (state.exit_reason == VMEXIT_INVALID || state.exit_reason == VMEXIT_RECALL) { - state.inj_info.charge(_read_vmcs(service, Vmcs::INTR_INFO)); - state.inj_error.charge(_read_vmcs(service, Vmcs::INTR_ERROR)); + state.inj_info .charge((uint32_t)_read_vmcs(service, Vmcs::INTR_INFO)); + state.inj_error.charge((uint32_t)_read_vmcs(service, Vmcs::INTR_ERROR)); } else { - state.inj_info.charge(_read_vmcs(service, Vmcs::IDT_INFO)); - state.inj_error.charge(_read_vmcs(service, Vmcs::IDT_ERROR)); + state.inj_info .charge((uint32_t)_read_vmcs(service, Vmcs::IDT_INFO)); + state.inj_error.charge((uint32_t)_read_vmcs(service, Vmcs::IDT_ERROR)); } - state.intr_state.charge(_read_vmcs(service, Vmcs::STATE_INTR)); - state.actv_state.charge(_read_vmcs(service, Vmcs::STATE_ACTV)); + state.intr_state.charge((uint32_t)_read_vmcs(service, Vmcs::STATE_INTR)); + state.actv_state.charge((uint32_t)_read_vmcs(service, Vmcs::STATE_ACTV)); state.pdpte_0.charge(_read_vmcs(service, Vmcs::PDPTE_0)); state.pdpte_1.charge(_read_vmcs(service, Vmcs::PDPTE_1)); diff --git a/repos/base/include/base/allocator_avl.h b/repos/base/include/base/allocator_avl.h index 1bf4b1f04a..81e73d430e 100644 --- a/repos/base/include/base/allocator_avl.h +++ b/repos/base/include/base/allocator_avl.h @@ -279,7 +279,7 @@ class Genode::Allocator_avl_base : public Range_allocator Alloc_result try_alloc(size_t size) override { - return Allocator_avl_base::alloc_aligned(size, log2(sizeof(addr_t))); + return Allocator_avl_base::alloc_aligned(size, (unsigned)log2(sizeof(addr_t))); } void free(void *addr, size_t) override { free(addr); } diff --git a/repos/base/include/base/ipc.h b/repos/base/include/base/ipc.h index ccc07c9892..6838d2f703 100644 --- a/repos/base/include/base/ipc.h +++ b/repos/base/include/base/ipc.h @@ -51,7 +51,7 @@ class Genode::Ipc_unmarshaller : Noncopyable protected: Msgbuf_base &_rcv_msg; - unsigned _read_offset = 0; + size_t _read_offset = 0; unsigned _read_cap_index = 0; private: diff --git a/repos/base/include/base/ipc_msgbuf.h b/repos/base/include/base/ipc_msgbuf.h index c4059c3fc0..6b636824f3 100644 --- a/repos/base/include/base/ipc_msgbuf.h +++ b/repos/base/include/base/ipc_msgbuf.h @@ -193,7 +193,7 @@ class Genode::Msgbuf_base : Noncopyable /** * Write bytes to message buffer */ - void insert(char const *src_addr, unsigned num_bytes) + void insert(char const *src_addr, size_t num_bytes) { /* check buffer range */ if (_data_size + num_bytes > _capacity) return; diff --git a/repos/base/include/base/output.h b/repos/base/include/base/output.h index 119c79a9cd..44f8d9ef50 100644 --- a/repos/base/include/base/output.h +++ b/repos/base/include/base/output.h @@ -248,7 +248,7 @@ void Genode::Hex_range::print(Output &out) const Hex const from(base, Hex::OMIT_PREFIX, Hex::PAD); - T const end = base + len; + T const end = (T)(base + len); /* if end at integer limit, use ']' as closing delimiter */ if (base && end == 0) { diff --git a/repos/base/include/base/session_label.h b/repos/base/include/base/session_label.h index d5e752d120..e5728ed7a7 100644 --- a/repos/base/include/base/session_label.h +++ b/repos/base/include/base/session_label.h @@ -51,7 +51,7 @@ struct Genode::Session_label : String<160> if (full_len < _separator_len()) return full; - unsigned i = full_len - _separator_len(); + size_t i = full_len - _separator_len(); do { if (!strcmp(_separator(), full + i, _separator_len())) return full + i + _separator_len(); @@ -69,7 +69,7 @@ struct Genode::Session_label : String<160> return Session_label(); /* search for last occurrence of the separator */ - unsigned prefix_len = length() - _separator_len() - 1; + size_t prefix_len = length() - _separator_len() - 1; char const * const full = string(); for (; prefix_len > 0; prefix_len--) @@ -89,7 +89,7 @@ namespace Genode { */ inline Session_label label_from_args(char const *args) { - char buf[Session_label::capacity()]; + char buf[Session_label::capacity()] { }; Arg_string::find_arg(args, "label").string(buf, sizeof(buf), ""); return Session_label(Cstring(buf)); diff --git a/repos/base/include/base/snprintf.h b/repos/base/include/base/snprintf.h index 999dbe19ef..67c2220952 100644 --- a/repos/base/include/base/snprintf.h +++ b/repos/base/include/base/snprintf.h @@ -18,7 +18,7 @@ #include namespace Genode { - + class String_console; /** @@ -30,8 +30,8 @@ namespace Genode { * * \return number of characters written to destination buffer */ - inline int snprintf(char *dst, size_t dst_size, const char *format, ...) - __attribute__((format(printf, 3, 4))); + inline size_t snprintf(char *dst, size_t dst_size, const char *format, ...) + __attribute__((format(printf, 3, 4))); } @@ -83,7 +83,7 @@ class Genode::String_console : public Console }; -inline int Genode::snprintf(char *dst, size_t dst_len, const char *format, ...) +inline Genode::size_t Genode::snprintf(char *dst, size_t dst_len, const char *format, ...) { va_list list; va_start(list, format); diff --git a/repos/base/include/base/trace/buffer.h b/repos/base/include/base/trace/buffer.h index ae7772763f..0dfb38b6d9 100644 --- a/repos/base/include/base/trace/buffer.h +++ b/repos/base/include/base/trace/buffer.h @@ -27,8 +27,8 @@ class Genode::Trace::Buffer { private: - unsigned volatile _head_offset; /* in bytes, relative to 'entries' */ - unsigned volatile _size; /* in bytes */ + size_t volatile _head_offset; /* in bytes, relative to 'entries' */ + size_t volatile _size; /* in bytes */ unsigned volatile _wrapped; /* count of buffer wraps */ struct _Entry @@ -105,7 +105,7 @@ class Genode::Trace::Buffer _head_entry()->len = 0; } - unsigned wrapped() const { return _wrapped; } + size_t wrapped() const { return _wrapped; } /******************************************** diff --git a/repos/base/include/base/trace/types.h b/repos/base/include/base/trace/types.h index 206ffb093b..7a414924a4 100644 --- a/repos/base/include/base/trace/types.h +++ b/repos/base/include/base/trace/types.h @@ -79,19 +79,24 @@ struct Genode::Trace::Subject_id */ struct Genode::Trace::Execution_time { - uint64_t thread_context; - addr_t scheduling_context; - uint16_t quantum { 0 }; - uint16_t priority { 0 }; + uint64_t thread_context = 0; + uint64_t scheduling_context = 0; + unsigned quantum { 0 }; + unsigned priority { 0 }; + + Execution_time() { } - Execution_time() : thread_context(0), scheduling_context(0) { } Execution_time(uint64_t thread_context, uint64_t scheduling_context) - : thread_context(thread_context), scheduling_context(scheduling_context) { } + : + thread_context(thread_context), scheduling_context(scheduling_context) + { } Execution_time(uint64_t thread_context, uint64_t scheduling_context, unsigned quantum, unsigned priority) - : thread_context(thread_context), scheduling_context(scheduling_context), - quantum(quantum), priority(priority) { } + : + thread_context(thread_context), scheduling_context(scheduling_context), + quantum(quantum), priority(priority) + { } }; diff --git a/repos/base/include/cpu_session/cpu_session.h b/repos/base/include/cpu_session/cpu_session.h index e66deb293b..67389f49e1 100644 --- a/repos/base/include/cpu_session/cpu_session.h +++ b/repos/base/include/cpu_session/cpu_session.h @@ -210,7 +210,7 @@ struct Genode::Cpu_session : Session */ template static size_t quota_lim_downscale(size_t const value, size_t const limit) { - return ((T)value * limit) >> Cpu_session::QUOTA_LIMIT_LOG2; } + return (size_t)(((T)value * limit) >> Cpu_session::QUOTA_LIMIT_LOG2); } /***************************************** diff --git a/repos/base/include/drivers/uart/x86_pc.h b/repos/base/include/drivers/uart/x86_pc.h index 8e2e84bef2..2d6719c423 100644 --- a/repos/base/include/drivers/uart/x86_pc.h +++ b/repos/base/include/drivers/uart/x86_pc.h @@ -56,9 +56,10 @@ class Genode::X86_uart public: - X86_uart(addr_t const port, unsigned /* clock */, + X86_uart(uint16_t const port, unsigned /* clock */, unsigned const baud_rate) - : _port(port) + : + _port(port) { /** @@ -70,20 +71,20 @@ class Genode::X86_uart if (!port) return; - const unsigned - IER = port + 1, - EIR = port + 2, - LCR = port + 3, - MCR = port + 4, - LSR = port + 5, - MSR = port + 6, - DLLO = port + 0, - DLHI = port + 1; + uint16_t const + IER = (uint16_t)(port + 1), + EIR = (uint16_t)(port + 2), + LCR = (uint16_t)(port + 3), + MCR = (uint16_t)(port + 4), + LSR = (uint16_t)(port + 5), + MSR = (uint16_t)(port + 6), + DLLO = (uint16_t)(port + 0), + DLHI = (uint16_t)(port + 1); _outb(LCR, 0x80); /* select bank 1 */ for (volatile int i = 10000000; i--; ); - _outb(DLLO, (115200/baud_rate) >> 0); - _outb(DLHI, (115200/baud_rate) >> 8); + _outb(DLLO, (uint8_t)((115200/baud_rate) >> 0)); + _outb(DLHI, (uint8_t)((115200/baud_rate) >> 8)); _outb(LCR, 0x03); /* set 8,N,1 */ _outb(IER, 0x00); /* disable interrupts */ _outb(EIR, 0x07); /* enable FIFOs */ @@ -103,8 +104,8 @@ class Genode::X86_uart return; /* wait until serial port is ready */ - Genode::uint8_t ready = STATUS_THR_EMPTY; - while ((_inb(_port + COMPORT_STATUS_OFFSET) & ready) != ready); + uint8_t ready = STATUS_THR_EMPTY; + while ((_inb((uint16_t)(_port + COMPORT_STATUS_OFFSET)) & ready) != ready); /* output character */ _outb(_port + COMPORT_DATA_OFFSET, c); diff --git a/repos/base/include/spec/riscv/cpu/cpu_state.h b/repos/base/include/spec/riscv/cpu/cpu_state.h index c3175e74e5..592d0100b7 100644 --- a/repos/base/include/spec/riscv/cpu/cpu_state.h +++ b/repos/base/include/spec/riscv/cpu/cpu_state.h @@ -83,7 +83,7 @@ struct Genode::Cpu_state addr_t last_fetch_fault = 0; bool is_irq() { return cpu_exception & IRQ_FLAG; } - unsigned irq() { return cpu_exception ^ IRQ_FLAG; } + unsigned irq() { return (unsigned)(cpu_exception ^ IRQ_FLAG); } }; #endif /* _INCLUDE__RISCV__CPU__CPU_STATE_H_ */ diff --git a/repos/base/include/spec/x86/bios_data_area.h b/repos/base/include/spec/x86/bios_data_area.h index b2cc4f2d9d..b4b36739c8 100644 --- a/repos/base/include/spec/x86/bios_data_area.h +++ b/repos/base/include/spec/x86/bios_data_area.h @@ -43,7 +43,7 @@ class Genode::Bios_data_area : Mmio /** * Obtain I/O ports of COM interfaces from BDA */ - addr_t serial_port() const + uint16_t serial_port() const { Equipment::access_t count = read(); return count ? read() : 0; diff --git a/repos/base/include/util/arg_string.h b/repos/base/include/util/arg_string.h index 51a3168873..907134492e 100644 --- a/repos/base/include/util/arg_string.h +++ b/repos/base/include/util/arg_string.h @@ -186,7 +186,7 @@ class Genode::Arg /* unpack string to dst */ size_t num_chars = min(dst_len - 1, _value.len()); - if (unpack_string(_value.start(), dst, num_chars) < 0) + if (unpack_string(_value.start(), dst, num_chars) == 0UL) copy_cstring(dst, default_string, dst_len); } @@ -240,7 +240,7 @@ class Genode::Arg_string */ static char *_append(char *dst, const char *src) { - unsigned src_len = strlen(src); + size_t const src_len = strlen(src); while (*dst) dst++; memcpy(dst, src, src_len + 1); return dst + src_len; @@ -288,13 +288,13 @@ class Genode::Arg_string /** * Add new argument */ - static bool add_arg(char *args, unsigned args_len, - const char *key, const char *value, - Token::Type type = Token::Type::IDENT) + static bool add_arg(char *args, size_t const args_len, + const char * const key, const char * const value, + Token::Type const type = Token::Type::IDENT) { if (!args || !key || !value) return false; - unsigned old_len = strlen(args); + size_t const old_len = strlen(args); /* check if args string has enough capacity */ if ((type == Token::Type::STRING @@ -317,7 +317,7 @@ class Genode::Arg_string /** * Assign new value to argument */ - static bool set_arg(char *args, unsigned args_len, + static bool set_arg(char *args, size_t args_len, const char *key, const char *value) { return remove_arg(args, key) && add_arg(args, args_len, key, value); @@ -326,7 +326,7 @@ class Genode::Arg_string /** * Assign new integer argument */ - static bool set_arg(char *args, unsigned args_len, + static bool set_arg(char *args, size_t args_len, const char *key, int value) { enum { STRING_LONG_MAX = 32 }; @@ -338,7 +338,7 @@ class Genode::Arg_string /** * Assign new string argument */ - static bool set_arg_string(char *args, unsigned args_len, + static bool set_arg_string(char *args, size_t args_len, const char *key, const char *value) { return remove_arg(args, key) diff --git a/repos/base/include/util/misc_math.h b/repos/base/include/util/misc_math.h index 043bfbe8c4..3f9162b778 100644 --- a/repos/base/include/util/misc_math.h +++ b/repos/base/include/util/misc_math.h @@ -69,7 +69,7 @@ namespace Genode { inline T align_natural(T value) { T mask = sizeof(long) - 1; - return (value + mask) & ~mask; + return (T)(value + mask) & (T)(~mask); } } diff --git a/repos/base/include/util/register.h b/repos/base/include/util/register.h index 4cc25d6cc7..469da04798 100644 --- a/repos/base/include/util/register.h +++ b/repos/base/include/util/register.h @@ -201,7 +201,7 @@ struct Genode::Register /** * Get register value 'reg' with this bitfield set to zero */ - static inline void clear(access_t & reg) { reg &= clear_mask(); } + static inline void clear(access_t & reg) { reg = reg & clear_mask(); } /** * Get register value 'reg' with this bitfield set to 'value' @@ -209,7 +209,7 @@ struct Genode::Register static inline void set(access_t & reg, access_t const value = ~0) { clear(reg); - reg |= (value & mask()) << SHIFT; + reg = reg | (access_t)((value & mask()) << SHIFT); }; }; }; diff --git a/repos/base/include/util/string.h b/repos/base/include/util/string.h index 8a656c5b70..2f549a4b99 100644 --- a/repos/base/include/util/string.h +++ b/repos/base/include/util/string.h @@ -227,9 +227,9 @@ namespace Genode { * with gcc 10. */ __attribute((optimize("no-tree-loop-distribute-patterns"))) - inline void *memset(void *dst, int i, size_t size) + inline void *memset(void *dst, uint8_t i, size_t size) { - while (size--) ((char *)dst)[size] = i; + while (size--) ((uint8_t *)dst)[size] = i; return dst; } @@ -289,9 +289,9 @@ namespace Genode { * a base of 16 is used, otherwise a base of 10. */ template - inline size_t ascii_to_unsigned(const char *s, T &result, unsigned base) + inline size_t ascii_to_unsigned(const char *s, T &result, uint8_t base) { - T i = 0, value = 0; + size_t i = 0; if (!*s) return i; @@ -307,13 +307,19 @@ namespace Genode { } /* read number */ - for (int d; ; s++, i++) { + T value = 0; + while (true) { /* read digit, stop when hitting a non-digit character */ - if ((d = digit(*s, base == 16)) < 0) break; + int const d = digit(*s, base == 16); + if (d < 0) + break; /* append digit to integer value */ - value = value*base + d; + uint8_t const valid_digit = (uint8_t)d; + value = (T)(value*base + valid_digit); + + s++, i++; } result = value; @@ -379,7 +385,7 @@ namespace Genode { */ inline size_t ascii_to(const char *s, unsigned long long &result) { - return ascii_to_unsigned(s, result, 0); + return ascii_to_unsigned(s, result, 0ULL); } @@ -409,12 +415,12 @@ namespace Genode { if (*s == '-' || *s == '+') { s++; i++; } - int j = 0; unsigned long value = 0; - j = ascii_to_unsigned(s, value, 0); + size_t const j = ascii_to_unsigned(s, value, 0); - if (!j) return i; + if (!j) + return i; result = sign*value; return i + j; @@ -434,7 +440,7 @@ namespace Genode { unsigned long res = 0; /* convert numeric part of string */ - int i = ascii_to_unsigned(s, res, 0); + size_t i = ascii_to_unsigned(s, res, 0); /* handle suffixes */ if (i > 0) @@ -504,16 +510,17 @@ namespace Genode { * \param src source string including the quotation marks ("...") * \param dst destination buffer * - * \return number of characters or negative error code + * \return number of characters or ~0UL on error */ - inline int unpack_string(const char *src, char *dst, int dst_len) + inline size_t unpack_string(const char *src, char *dst, size_t const dst_len) { /* check if quoted string */ - if (*src != '"') return -1; + if ((*src != '"') || (dst_len < 1)) + return ~0UL; src++; - int i = 0; + size_t i = 0; for (; *src && !end_of_quote(src - 1) && (i < dst_len - 1); i++) { /* transform '\"' to '"' */ diff --git a/repos/base/include/util/token.h b/repos/base/include/util/token.h index 24c9619aee..44982342b1 100644 --- a/repos/base/include/util/token.h +++ b/repos/base/include/util/token.h @@ -204,7 +204,7 @@ class Genode::Token /** * Return length of token */ - int _calc_len(size_t max_len) const + size_t _calc_len(size_t max_len) const { switch (_type(max_len)) { diff --git a/repos/base/include/util/xml_generator.h b/repos/base/include/util/xml_generator.h index b3b4915a7a..16e1926623 100644 --- a/repos/base/include/util/xml_generator.h +++ b/repos/base/include/util/xml_generator.h @@ -125,7 +125,7 @@ class Genode::Xml_generator * * \return empty buffer spanning the gap */ - Out_buffer insert_gap(unsigned const at, size_t const len) + Out_buffer insert_gap(size_t const at, size_t const len) { /* don't allow the insertion into non-populated part */ if (at > _used) @@ -176,7 +176,7 @@ class Genode::Xml_generator /** * Cursor position of next attribute to insert */ - unsigned _attr_offset = 0; + size_t _attr_offset = 0; /** * Called by sub node diff --git a/repos/base/src/core/core_log.cc b/repos/base/src/core/core_log.cc index 453d87f7ae..8df8613bd3 100644 --- a/repos/base/src/core/core_log.cc +++ b/repos/base/src/core/core_log.cc @@ -29,7 +29,7 @@ static void out_mem(char const c) { pos.value = cur_pos; data[cur_pos++] = c; - return cur_pos % (range.size - sizeof(Log_memory::Header)); + return (unsigned)(cur_pos % (range.size - sizeof(Log_memory::Header))); } } __attribute__((packed)) * mem = reinterpret_cast(range.start); diff --git a/repos/base/src/core/core_mem_alloc.cc b/repos/base/src/core/core_mem_alloc.cc index 133171d0d4..e352ab6337 100644 --- a/repos/base/src/core/core_mem_alloc.cc +++ b/repos/base/src/core/core_mem_alloc.cc @@ -37,7 +37,7 @@ Range_allocator::Alloc_result Mapped_mem_allocator::alloc_aligned(size_t size, unsigned align, Range range) { size_t page_rounded_size = align_addr(size, get_page_size_log2()); - align = max((size_t)align, get_page_size_log2()); + align = max((int)align, (int)get_page_size_log2()); /* allocate physical pages */ return _phys_alloc->alloc_aligned(page_rounded_size, align, range) diff --git a/repos/base/src/core/cpu_session_component.cc b/repos/base/src/core/cpu_session_component.cc index e16fb25e1f..959e1ab113 100644 --- a/repos/base/src/core/cpu_session_component.cc +++ b/repos/base/src/core/cpu_session_component.cc @@ -270,10 +270,10 @@ Cpu_session_component::Cpu_session_component(Rpc_entrypoint &session_ep, { Arg a = Arg_string::find_arg(args, "priority"); if (a.valid()) { - _priority = a.ulong_value(0); + _priority = (unsigned)a.ulong_value(0); /* clamp priority value to valid range */ - _priority = min((unsigned)PRIORITY_LIMIT - 1, _priority); + _priority = min((unsigned)(PRIORITY_LIMIT - 1), _priority); } } diff --git a/repos/base/src/core/include/constrained_core_ram.h b/repos/base/src/core/include/constrained_core_ram.h index 9558b6ed72..02ff3fb8ab 100644 --- a/repos/base/src/core/include/constrained_core_ram.h +++ b/repos/base/src/core/include/constrained_core_ram.h @@ -81,7 +81,7 @@ class Genode::Constrained_core_ram : public Allocator core_mem_allocated -= page_aligned_size; } - size_t consumed() const override { return core_mem_allocated; } + size_t consumed() const override { return (size_t)core_mem_allocated; } size_t overhead(size_t) const override { return 0; } bool need_size_for_free() const override { return true; } }; diff --git a/repos/base/src/core/include/core_mem_alloc.h b/repos/base/src/core/include/core_mem_alloc.h index 6e970d32e0..dcd317e75f 100644 --- a/repos/base/src/core/include/core_mem_alloc.h +++ b/repos/base/src/core/include/core_mem_alloc.h @@ -134,7 +134,7 @@ class Genode::Mapped_mem_allocator : public Genode::Core_mem_translator * \param phys_addr start address of physical range * \param size size of range */ - bool _map_local(addr_t virt_addr, addr_t phys_addr, unsigned size); + bool _map_local(addr_t virt_addr, addr_t phys_addr, size_t size); /** * Destroy mapping between physical and virtual address range @@ -145,7 +145,7 @@ class Genode::Mapped_mem_allocator : public Genode::Core_mem_translator * \param phys_addr start address of physical range * \param size size of range */ - bool _unmap_local(addr_t virt_addr, addr_t phys_addr, unsigned size); + bool _unmap_local(addr_t virt_addr, addr_t phys_addr, size_t size); /*********************************** @@ -180,7 +180,7 @@ class Genode::Mapped_mem_allocator : public Genode::Core_mem_translator *************************/ Alloc_result try_alloc(size_t size) override { - return alloc_aligned(size, log2(sizeof(addr_t))); } + return alloc_aligned(size, (unsigned)log2(sizeof(addr_t))); } void free(void *addr, size_t) override; size_t consumed() const override { return _phys_alloc->consumed(); } size_t overhead(size_t size) const override { @@ -304,7 +304,7 @@ class Genode::Core_mem_allocator : public Genode::Core_mem_translator Alloc_result try_alloc(size_t size) override { - return alloc_aligned(size, log2(sizeof(addr_t))); + return alloc_aligned(size, (unsigned)log2(sizeof(addr_t))); } void free(void *addr, size_t size) override diff --git a/repos/base/src/core/include/trace/root.h b/repos/base/src/core/include/trace/root.h index d4008b6a9c..57bb453bba 100644 --- a/repos/base/src/core/include/trace/root.h +++ b/repos/base/src/core/include/trace/root.h @@ -38,7 +38,7 @@ class Genode::Trace::Root : public Genode::Root_component { size_t ram_quota = Arg_string::find_arg(args, "ram_quota").ulong_value(0); size_t arg_buffer_size = Arg_string::find_arg(args, "arg_buffer_size").ulong_value(0); - unsigned parent_levels = Arg_string::find_arg(args, "parent_levels").ulong_value(0); + unsigned parent_levels = (unsigned)Arg_string::find_arg(args, "parent_levels").ulong_value(0); if (arg_buffer_size > ram_quota) throw Service_denied(); diff --git a/repos/base/src/core/include/vm_root.h b/repos/base/src/core/include/vm_root.h index 18acd254e6..46bf5c67bd 100644 --- a/repos/base/src/core/include/vm_root.h +++ b/repos/base/src/core/include/vm_root.h @@ -38,7 +38,7 @@ class Genode::Vm_root : public Root_component unsigned priority = 0; Arg a = Arg_string::find_arg(args, "priority"); if (a.valid()) { - priority = a.ulong_value(0); + priority = (unsigned)a.ulong_value(0); /* clamp priority value to valid range */ priority = min((unsigned)Cpu_session::PRIORITY_LIMIT - 1, priority); diff --git a/repos/base/src/core/ram_dataspace_factory.cc b/repos/base/src/core/ram_dataspace_factory.cc index c5c39ffee8..9832f52a8e 100644 --- a/repos/base/src/core/ram_dataspace_factory.cc +++ b/repos/base/src/core/ram_dataspace_factory.cc @@ -52,7 +52,7 @@ Ram_dataspace_factory::try_alloc(size_t ds_size, Cache cache) Phys_range const range { .start = high_start, .end = _phys_range.end }; for (size_t align_log2 = log2(ds_size); align_log2 >= 12; align_log2--) { - allocated_range = _phys_alloc.alloc_aligned(ds_size, align_log2, range); + allocated_range = _phys_alloc.alloc_aligned(ds_size, (unsigned)align_log2, range); if (allocated_range.ok()) break; } @@ -61,7 +61,7 @@ Ram_dataspace_factory::try_alloc(size_t ds_size, Cache cache) /* apply constraints, or retry if larger memory allocation failed */ if (!allocated_range.ok()) { for (size_t align_log2 = log2(ds_size); align_log2 >= 12; align_log2--) { - allocated_range = _phys_alloc.alloc_aligned(ds_size, align_log2, _phys_range); + allocated_range = _phys_alloc.alloc_aligned(ds_size, (unsigned)align_log2, _phys_range); if (allocated_range.ok()) break; } diff --git a/repos/base/src/core/region_map_component.cc b/repos/base/src/core/region_map_component.cc index a5ef5ec62e..7cf5c9d293 100644 --- a/repos/base/src/core/region_map_component.cc +++ b/repos/base/src/core/region_map_component.cc @@ -424,7 +424,7 @@ Region_map_component::attach(Dataspace_capability ds_cap, size_t size, continue; /* try allocating the align region */ - _map.alloc_aligned(size, align_log2).with_result( + _map.alloc_aligned(size, (unsigned)align_log2).with_result( [&] (void *ptr) { attach_at = ptr; diff --git a/repos/base/src/core/signal_source_component.cc b/repos/base/src/core/signal_source_component.cc index d4c75c5831..7b91c0be78 100644 --- a/repos/base/src/core/signal_source_component.cc +++ b/repos/base/src/core/signal_source_component.cc @@ -39,7 +39,7 @@ void Signal_source_component::submit(Signal_context_component &context, * signal will be delivered as result of the next * 'wait_for_signal' call. */ - context.increment_signal_cnt(cnt); + context.increment_signal_cnt((int)cnt); /* * If the client is blocking at the signal source (indicated by diff --git a/repos/base/src/core/spec/x86/io_port_session_component.cc b/repos/base/src/core/spec/x86/io_port_session_component.cc index bafbb208b7..200fcf6b2a 100644 --- a/repos/base/src/core/spec/x86/io_port_session_component.cc +++ b/repos/base/src/core/spec/x86/io_port_session_component.cc @@ -31,8 +31,8 @@ Io_port_session_component::Io_port_session_component(Range_allocator &io_port_al : _io_port_alloc(io_port_alloc) { /* parse for port properties */ - unsigned base = Arg_string::find_arg(args, "io_port_base").ulong_value(0); - unsigned size = Arg_string::find_arg(args, "io_port_size").ulong_value(0); + uint16_t const base = (uint16_t)Arg_string::find_arg(args, "io_port_base").ulong_value(0); + uint16_t const size = (uint16_t)Arg_string::find_arg(args, "io_port_size").ulong_value(0); /* allocate region (also checks out-of-bounds regions) */ io_port_alloc.alloc_addr(size, base).with_error( diff --git a/repos/base/src/include/base/internal/output.h b/repos/base/src/include/base/internal/output.h index 28d31f072b..97770cc920 100644 --- a/repos/base/src/include/base/internal/output.h +++ b/repos/base/src/include/base/internal/output.h @@ -23,9 +23,9 @@ static inline char ascii(int digit, int uppercase = 0) { if (digit > 9) - return digit + (uppercase ? 'A' : 'a') - 10; + return (char)(digit + (uppercase ? 'A' : 'a') - 10); - return digit + '0'; + return (char)(digit + '0'); } @@ -57,7 +57,7 @@ static inline void out_signed(T value, unsigned base, OUT_CHAR_FN const &out_cha /* fill buffer starting with the least significant digits */ else for (; value > 0; value /= base) - buf[i++] = ascii(value % base); + buf[i++] = ascii((int)(value % base)); /* add sign to buffer for negative values */ if (neg) @@ -93,7 +93,7 @@ static inline void out_unsigned(T value, unsigned base, int pad, /* fill buffer starting with the least significant digits */ for (; value > 0; value /= base, pad--) - buf[i++] = ascii(value % base); + buf[i++] = ascii((int)(value % base)); /* add padding zeros */ for (; pad-- > 0; ) @@ -143,11 +143,11 @@ static inline void out_float(T value, unsigned base, unsigned length, OUT_CHAR_F if (length) { do { - volatile_value -= integer; - volatile_value = volatile_value*base; + volatile_value = (T)(volatile_value - (T)integer); + volatile_value = (T)(volatile_value * (T)base); integer = (int64_t)volatile_value; - out_char(ascii(integer)); + out_char(ascii((int)integer)); length--; } while (length && (volatile_value > 0.0)); diff --git a/repos/base/src/lib/base/avl_tree.cc b/repos/base/src/lib/base/avl_tree.cc index 4e20c0e3fb..42d4b35c65 100644 --- a/repos/base/src/lib/base/avl_tree.cc +++ b/repos/base/src/lib/base/avl_tree.cc @@ -19,8 +19,8 @@ using namespace Genode; inline void Avl_node_base::_recompute_depth(Policy &policy) { - unsigned char old_depth = _depth; - _depth = max(_child_depth(LEFT), _child_depth(RIGHT)) + 1; + uint8_t old_depth = _depth; + _depth = (uint8_t)(max(_child_depth(LEFT), _child_depth(RIGHT)) + 1); /* if our own value changes, update parent */ if (_depth != old_depth && _parent) diff --git a/repos/base/src/lib/base/child.cc b/repos/base/src/lib/base/child.cc index e7a8ac9904..42e557a09e 100644 --- a/repos/base/src/lib/base/child.cc +++ b/repos/base/src/lib/base/child.cc @@ -171,7 +171,7 @@ Session_capability Child::session(Parent::Client::Id id, Ram_quota const forward_ram_quota { ram_quota.value - keep_ram_quota }; /* adjust the session information as presented to the server */ - Arg_string::set_arg(argbuf, sizeof(argbuf), "ram_quota", forward_ram_quota.value); + Arg_string::set_arg(argbuf, sizeof(argbuf), "ram_quota", (int)forward_ram_quota.value); /* may throw a 'Service_denied' exception */ Child_policy::Route route = diff --git a/repos/base/src/lib/base/console.cc b/repos/base/src/lib/base/console.cc index c04b6987de..b3f49fc058 100644 --- a/repos/base/src/lib/base/console.cc +++ b/repos/base/src/lib/base/console.cc @@ -212,7 +212,7 @@ void Console::vprintf(const char *format, va_list list) out_signed(numeric_arg, cmd.base, [&] (char c) { _out_char(c); }); else - out_signed(numeric_arg, cmd.base, + out_signed((long)numeric_arg, cmd.base, [&] (char c) { _out_char(c); }); break; @@ -228,13 +228,13 @@ void Console::vprintf(const char *format, va_list list) case Format_command::PTR: - out_unsigned(numeric_arg, cmd.base, cmd.padding, + out_unsigned((long)numeric_arg, cmd.base, cmd.padding, [&] (char c) { _out_char(c); }); break; case Format_command::CHAR: - _out_char(va_arg(list, int)); + _out_char((char)va_arg(list, int)); break; case Format_command::STRING: diff --git a/repos/base/src/lib/base/output.cc b/repos/base/src/lib/base/output.cc index d44df295fe..1887b78432 100644 --- a/repos/base/src/lib/base/output.cc +++ b/repos/base/src/lib/base/output.cc @@ -96,7 +96,7 @@ void Genode::Hex::print(Output &output) const unsigned long long mask = 0; for (size_t i = 0; i < _digits; ++i) mask = (mask << 4) | 0xf; - out_unsigned(_value & mask, 16, pad_len, + out_unsigned(_value & mask, 16, (int)pad_len, [&] (char c) { output.out_char(c); }); } diff --git a/repos/base/src/lib/base/rpc_entrypoint.cc b/repos/base/src/lib/base/rpc_entrypoint.cc index d1dabffe62..8ad8cceedb 100644 --- a/repos/base/src/lib/base/rpc_entrypoint.cc +++ b/repos/base/src/lib/base/rpc_entrypoint.cc @@ -52,7 +52,7 @@ void Rpc_entrypoint::reply_signal_info(Untyped_capability reply_cap, unsigned long imprint, unsigned long cnt) { Msgbuf snd_buf; - snd_buf.insert(Signal_source::Signal(imprint, cnt)); + snd_buf.insert(Signal_source::Signal(imprint, (int)cnt)); ipc_reply(reply_cap, Rpc_exception_code(Rpc_exception_code::SUCCESS), snd_buf); } diff --git a/repos/base/src/lib/base/slab.cc b/repos/base/src/lib/base/slab.cc index a404870f83..f790b911d4 100644 --- a/repos/base/src/lib/base/slab.cc +++ b/repos/base/src/lib/base/slab.cc @@ -93,7 +93,7 @@ class Genode::Slab::Block /** * Request number of available entries in block */ - unsigned avail() const { return _avail; } + unsigned avail() const { return (unsigned)_avail; } /** * Allocate slab entry from block @@ -151,16 +151,20 @@ Slab::Entry *Slab::Block::_slab_entry(int idx) * address. */ - size_t const entry_size = sizeof(Entry) + _slab._slab_size; - return (Entry *)&_data[align_addr(_slab._entries_per_block, log2(sizeof(addr_t))) - + entry_size*idx]; + int const alignment = (int)log2(sizeof(addr_t)); + size_t const slots_start = align_addr(_slab._entries_per_block, alignment); + size_t const entry_size = sizeof(Entry) + _slab._slab_size; + + return (Entry *)&_data[slots_start + entry_size*idx]; } int Slab::Block::_slab_entry_idx(Slab::Entry *e) { - size_t const entry_size = sizeof(Entry) + _slab._slab_size; - return ((addr_t)e - (addr_t)_slab_entry(0))/entry_size; + size_t const slot_size = sizeof(Entry) + _slab._slab_size; + addr_t const slot_offset = ((addr_t)e - (addr_t)_slab_entry(0)); + + return (int)(slot_offset / slot_size); } diff --git a/repos/base/src/lib/cxx/misc.cc b/repos/base/src/lib/cxx/misc.cc index 3a1fd09cd6..d3ca7ee6be 100644 --- a/repos/base/src/lib/cxx/misc.cc +++ b/repos/base/src/lib/cxx/misc.cc @@ -147,7 +147,7 @@ void *memmove(void *dst, const void *src, size_t n) extern "C" __attribute__((weak)) void *memset(void *s, int c, size_t n) { - return Genode::memset(s, c, n); + return Genode::memset(s, (char)c, n); } diff --git a/repos/base/src/lib/ldso/exception.cc b/repos/base/src/lib/ldso/exception.cc index 049253f5a3..2d906a3829 100644 --- a/repos/base/src/lib/ldso/exception.cc +++ b/repos/base/src/lib/ldso/exception.cc @@ -107,7 +107,7 @@ extern "C" unsigned long dl_unwind_find_exidx(unsigned long pc, int *pcount) if (!exidx) return; - *pcount = exidx->p_memsz / EXIDX_ENTRY_SIZE; + *pcount = (int)(exidx->p_memsz / EXIDX_ENTRY_SIZE); value = exidx->p_vaddr + obj.reloc_base(); }); diff --git a/repos/base/src/lib/ldso/include/dynamic.h b/repos/base/src/lib/ldso/include/dynamic.h index 8bfafe00d5..94ee9e8be0 100644 --- a/repos/base/src/lib/ldso/include/dynamic.h +++ b/repos/base/src/lib/ldso/include/dynamic.h @@ -249,7 +249,7 @@ class Linker::Dynamic if (!h->buckets()) return nullptr; - unsigned long sym_index = h->buckets()[hash % h->nbuckets()]; + unsigned sym_index = h->buckets()[hash % h->nbuckets()]; /* traverse hash chain */ for (; sym_index != STN_UNDEF; sym_index = h->chains()[sym_index]) @@ -285,7 +285,7 @@ class Linker::Dynamic { addr_t const reloc_base = _obj.reloc_base(); - for (unsigned long i = 0; i < _hash_table->nchains(); i++) + for (unsigned i = 0; i < _hash_table->nchains(); i++) { Elf::Sym const *sym = symbol(i); if (!sym) diff --git a/repos/base/src/lib/ldso/include/elf.h b/repos/base/src/lib/ldso/include/elf.h index cb487efb24..e0b1c86a3b 100644 --- a/repos/base/src/lib/ldso/include/elf.h +++ b/repos/base/src/lib/ldso/include/elf.h @@ -308,7 +308,7 @@ namespace Linker { /** * Binding information */ - unsigned char bind() const { return st_info >> 4; } + unsigned char bind() const { return (st_info >> 4) & 0xffu; } /** * Type information @@ -404,12 +404,12 @@ namespace Linker { /** * Relocation type */ - int type() const { return info & 0xffffffffL; } + int type() const { return (int)(info & 0xffffffffL); } /** * Symbol table index */ - unsigned sym() const { return (info >> 16) >> 16; } + unsigned sym() const { return (unsigned)((info >> 16) >> 16); } }; /** @@ -427,7 +427,7 @@ namespace Linker { /** * Binding information */ - unsigned char bind() const { return st_info >> 4; } + unsigned char bind() const { return (st_info >> 4) & 0xffu; } /** * Type information diff --git a/repos/base/src/lib/ldso/include/file.h b/repos/base/src/lib/ldso/include/file.h index 1c9ce53ca3..cee8fed73e 100644 --- a/repos/base/src/lib/ldso/include/file.h +++ b/repos/base/src/lib/ldso/include/file.h @@ -45,7 +45,7 @@ struct Linker::Phdr enum { MAX_PHDR = 10 }; Elf::Phdr phdr[MAX_PHDR]; - unsigned count = 0; + uint16_t count = 0; }; diff --git a/repos/base/src/lib/timeout/hw/timer_connection_timestamp.cc b/repos/base/src/lib/timeout/hw/timer_connection_timestamp.cc index 46bce911f0..d32f8cfacd 100644 --- a/repos/base/src/lib/timeout/hw/timer_connection_timestamp.cc +++ b/repos/base/src/lib/timeout/hw/timer_connection_timestamp.cc @@ -25,5 +25,5 @@ using namespace Genode; Trace::Timestamp Timer::Connection::_timestamp() { - return Kernel::time(); + return (Trace::Timestamp)Kernel::time(); } diff --git a/repos/base/src/lib/timeout/timer_connection.cc b/repos/base/src/lib/timeout/timer_connection.cc index ef9196b3a5..8d90e56459 100644 --- a/repos/base/src/lib/timeout/timer_connection.cc +++ b/repos/base/src/lib/timeout/timer_connection.cc @@ -68,7 +68,7 @@ uint64_t Timer::Connection::_ts_to_us_ratio(Timestamp ts, * the calculation. This upscaling must be considered when using * the result. */ - Timestamp const result = (ts << shift) / us; + Timestamp const result = (Timestamp)((ts << shift) / us); uint64_t const result_ul = (uint64_t)result; if (result != result_ul) { warning("Timestamp-to-time ratio too big"); diff --git a/repos/base/src/lib/timeout/timer_connection_time.cc b/repos/base/src/lib/timeout/timer_connection_time.cc index 0997c19ed2..b433afdaed 100644 --- a/repos/base/src/lib/timeout/timer_connection_time.cc +++ b/repos/base/src/lib/timeout/timer_connection_time.cc @@ -177,8 +177,8 @@ Duration Timer::Connection::curr_time() interpolated_time.add(Microseconds(us_diff)); } else { - Timestamp const us = elapsed_us(); - Timestamp const us_diff = (us < _us) ? 0 : us - _us; + Timestamp const us = (Timestamp)elapsed_us(); + Timestamp const us_diff = (Timestamp)((us < _us) ? 0 : us - _us); /* use remote timer instead of timestamps */ interpolated_time.add(Microseconds(us_diff)); diff --git a/repos/base/src/test/mmio/target.mk b/repos/base/src/test/mmio/target.mk index 4eff71c9f2..4d952c684e 100644 --- a/repos/base/src/test/mmio/target.mk +++ b/repos/base/src/test/mmio/target.mk @@ -1,14 +1,5 @@ -# -# \brief Diversified test of the Register and MMIO framework -# \author Martin Stein -# \date 2012-04-25 -# - -# Set program name TARGET = test-mmio +SRC_CC = main.cc +LIBS += base -# Add C++ sources -SRC_CC += main.cc - -# Add libraries -LIBS += base +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/base/src/test/timeout_smp/target.mk b/repos/base/src/test/timeout_smp/target.mk index e8f4eaf79e..e7820bfbd8 100644 --- a/repos/base/src/test/timeout_smp/target.mk +++ b/repos/base/src/test/timeout_smp/target.mk @@ -1,3 +1,5 @@ TARGET = test-timeout_smp SRC_CC = main.cc LIBS = base + +CC_CXX_WARN_STRICT_CONVERSION = diff --git a/repos/base/src/test/xml_generator/main.cc b/repos/base/src/test/xml_generator/main.cc index c1b29d282d..f6004df19b 100644 --- a/repos/base/src/test/xml_generator/main.cc +++ b/repos/base/src/test/xml_generator/main.cc @@ -202,7 +202,7 @@ void Component::construct(Genode::Env &env) /* generate pattern that contains all possible byte values */ char pattern[256]; for (unsigned i = 0; i < sizeof(pattern); i++) - pattern[i] = i; + pattern[i] = (char)i; /* generate XML with the pattern as content */ Xml_generator xml(dst, sizeof(dst), "data", [&] () { diff --git a/repos/base/src/timer/epit/time_source.cc b/repos/base/src/timer/epit/time_source.cc index 38ece8408a..f51eb02312 100644 --- a/repos/base/src/timer/epit/time_source.cc +++ b/repos/base/src/timer/epit/time_source.cc @@ -23,7 +23,7 @@ using namespace Genode; void Timer::Time_source::set_timeout(Genode::Microseconds duration, Genode::Timeout_handler &handler) { - unsigned long const ticks = (1ULL * duration.value * TICKS_PER_MS) / 1000; + unsigned long const ticks = (unsigned long)((1ULL * duration.value * TICKS_PER_MS) / 1000); _handler = &handler; _timer_irq.ack_irq(); _cleared_ticks = 0; diff --git a/repos/base/src/timer/fiasco/time_source.cc b/repos/base/src/timer/fiasco/time_source.cc index dd4a484f2f..efa588f775 100644 --- a/repos/base/src/timer/fiasco/time_source.cc +++ b/repos/base/src/timer/fiasco/time_source.cc @@ -17,6 +17,9 @@ #include #include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" + /* Fiasco includes */ namespace Fiasco { #include @@ -34,6 +37,7 @@ namespace Fiasco { #include } #endif /* L4_SYS_KIP_H__ */ +#pragma GCC diagnostic pop /* local includes */ #include @@ -52,17 +56,20 @@ static l4_timeout_s mus_to_timeout(uint64_t mus) return L4_IPC_TIMEOUT_NEVER; long e = Genode::log2((unsigned long)mus) - 7; - unsigned long m; + if (e < 0) e = 0; - m = mus / (1UL << e); + + uint64_t m = mus / (1UL << e); + + enum { M_MASK = 0x3ff }; /* check corner case */ - if ((e > 31 ) || (m > 1023)) { + if ((e > 31 ) || (m > M_MASK)) { Genode::warning("invalid timeout ", mus, ", using max. values"); e = 0; - m = 1023; + m = M_MASK; } - return l4_timeout_rel(m, e); + return l4_timeout_rel(m & M_MASK, (unsigned)e); } diff --git a/repos/base/src/timer/gpt/time_source.cc b/repos/base/src/timer/gpt/time_source.cc index 6ce5814ebb..7580152b6f 100644 --- a/repos/base/src/timer/gpt/time_source.cc +++ b/repos/base/src/timer/gpt/time_source.cc @@ -21,10 +21,10 @@ void Timer::Time_source::set_timeout(Genode::Microseconds duration, Timeout_handler &handler) { _handler = &handler; - + /* set to minimum ticks value to not miss a too short timeout */ - Genode::uint32_t const ticks = - Genode::max(1UL, (duration.value * TICKS_PER_MS) / 1000); + uint32_t const ticks = + max((uint32_t)1, (uint32_t)((duration.value * TICKS_PER_MS) / 1000)); /* clear interrupts */ if (read()) { @@ -40,15 +40,14 @@ void Timer::Time_source::set_timeout(Genode::Microseconds duration, Duration Timer::Time_source::curr_time() { Cnt::access_t cur_cnt = read(); - Genode::Microseconds us(timer_ticks_to_us(cur_cnt - _last_cnt, - TICKS_PER_MS)); + Genode::Microseconds us(timer_ticks_to_us(cur_cnt - _last_cnt, TICKS_PER_MS)); _last_cnt = cur_cnt; _curr_time.add(us); return _curr_time; } -Genode::Microseconds Timer::Time_source::max_timeout() const +Microseconds Timer::Time_source::max_timeout() const { static unsigned long max = timer_ticks_to_us(0xffffffff, TICKS_PER_MS); return Genode::Microseconds(max); diff --git a/repos/base/src/timer/pit/time_source.cc b/repos/base/src/timer/pit/time_source.cc index 4db3d25fce..83b47bc72d 100644 --- a/repos/base/src/timer/pit/time_source.cc +++ b/repos/base/src/timer/pit/time_source.cc @@ -24,8 +24,8 @@ using namespace Genode; void Timer::Time_source::_set_counter(uint16_t value) { _handled_wrap = false; - _io_port.outb(PIT_DATA_PORT_0, value & 0xff); - _io_port.outb(PIT_DATA_PORT_0, (value >> 8) & 0xff); + _io_port.outb(PIT_DATA_PORT_0, (uint8_t)(value & 0xff)); + _io_port.outb(PIT_DATA_PORT_0, (uint8_t)((value >> 8) & 0xff)); } @@ -45,7 +45,7 @@ uint16_t Timer::Time_source::_read_counter(bool *wrapped) uint16_t hi = _io_port.inb(PIT_DATA_PORT_0); *wrapped = status & PIT_STAT_INT_LINE ? true : false; - return (hi << 8) | lo; + return (uint16_t)((hi << 8) | lo); } @@ -69,7 +69,7 @@ void Timer::Time_source::set_timeout(Microseconds duration, duration_us = max_timeout().value; } - _counter_init_value = (PIT_TICKS_PER_MSEC * duration_us) / 1000; + _counter_init_value = (uint16_t)((PIT_TICKS_PER_MSEC * duration_us) / 1000); _set_counter(_counter_init_value); if (duration.value) diff --git a/repos/os/src/drivers/nic/spec/linux/main.cc b/repos/os/src/drivers/nic/spec/linux/main.cc index 6fd9ac7153..450059faee 100644 --- a/repos/os/src/drivers/nic/spec/linux/main.cc +++ b/repos/os/src/drivers/nic/spec/linux/main.cc @@ -27,12 +27,15 @@ #include /* Linux */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" #include #include #include #include #include #include +#pragma GCC diagnostic pop /* restore -Wconversion warnings */ using namespace Genode;