7227 Commits

Autor SHA1 Mensagem Data
Sean Klein a12054ffc9 [fs][minfs] Replace the vfs-dispatcher with libasync
Change-Id: Icfc3566510ae0e5f29ac2f0615681c00c831ece9
2017-09-08 20:17:09 +00:00
George Kulakowski b8f10eeced [utest][port] Just port-test, it's cleaner
Change-Id: I824cb7e978a0b16aa43f620e7c70a2cde1f1ae78
2017-09-08 20:08:29 +00:00
George Kulakowski a3e9ff7db2 [kernel][arena] Add diagnostic count to fbl::{Arena,TypedArena}
Change-Id: I8e8977b4ac1e529020991e4c8fd3fd0519d9537f
2017-09-08 18:55:20 +00:00
Jeff Brown 56fa14eb52 [async] Add RAII helpers for waits and tasks.
This makes the API a bit more convenient to use.

Fixed an inconsistency in the handling of cancelation errors.
We were previously checking for MX_ERR_BAD_STATE which can't happen
during cancelation.

Fixed some minor formatting inconsistencies introduced by the
mxtl->fbl rename.

Added some clarification around thread-safety.

Change-Id: If273a42eea2b869d63c79e47782c28fade339c92
2017-09-08 11:14:57 -07:00
Mark Seaborn f9bf25111c [utest][x86] Add test to check that gs_base is preserved across context switches
This is in preparation for changing the kernel code that saves and
restores gs_base.

Change-Id: I26668f6239390b7d916e2ec1f0190b97e2205f9b
2017-09-08 17:34:03 +00:00
Mike Voydanoff c1f5c118c7 [dev][usb-bus] Switch to new DDK dprintf() logging calls
Change-Id: Ia8d967dcea84935467f9950f637963ff534de1d1
2017-09-08 17:10:54 +00:00
Mike Voydanoff bc6afa00b9 [dev][xhci] Switch to new DDK dprintf() logging calls
Change-Id: I629e2b486de24749fb217e63d4ca40cb39b14390
2017-09-08 07:19:38 -07:00
Brian Swetland d8431aec14 [bootfs] streamline the bootfs format
- provide common header and entry structs in bootdata.h
  along with documentation comments
- stop treating bootdata headers as part of bootfs
- introduce a simple header with magic and directory size
  (allows easy mmap'ing of just the directory)
- align bootdata directory entries on U32 boundaries
- adjust mxio and userboot to deal with the changes

Change-Id: I09f96088f939dd541a6b23d70fcd8606d1af4f28
2017-09-08 01:13:54 +00:00
Mark Seaborn 7d939a45f7 [kernel][x86] Use shorter encodings for some instructions
"xor %eax, %eax" and "xor %rax, %rax" both set %rax=0, but the former
is one byte shorter because it lacks the REX prefix of the latter.
This is not a big win, but it bugs me whenever I look through this
assembly code!

Change-Id: I7eedfc2570c9144d29d229dd92ce2ec15060c707
2017-09-08 00:59:53 +00:00
Mark Seaborn 55921bc1fb [cleanup] Fix typo: "underling" -> "underlying"
Change-Id: I393d2ff3c898cacbd0f5a0acc9bf4d8f9f9ac91c
2017-09-08 00:33:01 +00:00
Abdulla Kamar 0a7dba0138 [x86] Move hypervisor assembly to hypervisor dir.
Also rename the file to vmx.S. This is to mirror the upcoming changes
to the arm64 side.

Change-Id: Id97ecbc71b0f7d5fc7fd2371a8e79b32ade6003b
2017-09-08 00:16:56 +00:00
Mark Seaborn d98372ba40 [kernel][x86] Remove unnecessary pushf/popf in context switch
On an Acer12, this saves about 10 cycles for pushf and 25 cycles for popf.

The pushf+popf had two effects:

 1) Preserving flags across kernel scheduler invocations.  This
    shouldn't be necessary, because the important flags should always
    have the same values when the context switch code is called.  It
    is always called with interrupts disabled; other flags are now
    documented in docs/kernel_invariants.md.

 2) Setting the initial flags for new kernel threads to the value that
    was set in arch_thread_initialize().  This appears not to be
    necessary, because the flag values inherited from another kernel
    thread ought to be OK.

    It appears this popf wasn't sufficient by itself for ensuring that
    all kernel threads run with certain flag values, because not all
    threads are started via thread_create().  The primary CPU enters
    the scheduler via thread_become_idle()'s call to
    thread_reschedule(), so the pushf/popf in the context switch would
    preserve whatever flags thread_become_idle() was called with.
    (Secondary CPUs behave differently: they enter the scheduler via
    thread_secondary_cpu_entry()'s call to thread_exit().)

    We address that by explicitly resetting flags on CPU startup.

This CL does happen to change the value of IOPL for some kernel code
from 3 to 0, but the value of IOPL doesn't affect ring 0 code.

Change-Id: I330657bfb34ab14a8578062dde42bdc38d27104a
2017-09-07 23:46:15 +00:00
Todd Eisenberger 3b808d8cfc [dprintf] Correct documentation of commandline args
Change-Id: I9d1d06e85668e6c9000f480150df8889510192b2
2017-09-07 22:17:14 +00:00
Tim Detwiler 1a10fa241c [hypervisor][virtio] Add Virtio 1.0 PCI support.
This implementation is sufficient to boot linux with block and balloon
devices, however Magenta guests currently fail to map PCI bars that
don't map MMIO space. For this reason we still default to using the
legacy interface for now.

Change-Id: I873f0bd2285ee1c999a90ec2819b3a512d128039
2017-09-07 22:11:14 +00:00
Dave Bort e892dc2182 [libobject] Remove the remaining "magenta" strings from kernel/object
* Comment tweaks
* magenta_thread_process_name -> get_user_thread_process_name
  * Made its user_thread* param const as well, along with
    ThreadDispatcher::process().

Remaining "magenta" instances refer to public/magenta or to the name of
the project, not to the old libmagenta.

Change-Id: Idf192c92e559c354a823d35b1f641b80caef8d7f
2017-09-07 22:06:15 +00:00
Jocelyn Dang 90f33bb15d [dev][usb-device] Add functions for claiming interfaces.
Removes special casing for usb-audio and usb-cdc-ecm.

Those drivers will instead call usb_claim_additional_interfaces,
indicating what additional interfaces they require.

usb_claim_additional_interfaces will request the list of
descriptors following the interface's existing descriptor list,
and then check whether to claim the interface.

Claiming an interface appends the descriptors to the descriptor list,
and removes any existing child device.

There can be a race condition between a device being created for a child
interface, and an interface claiming that same interface, so there is a
interface mutex and we track the current availability of an interface
via the interface_statuses array.

Change-Id: I3a9599f21c76b85e9a21f561eb259415bde97308
2017-09-07 22:02:20 +00:00
George Kulakowski aeab97fdf7 [musl] Remove some unused files
Change-Id: I0e4d9b63efa56cd8498d6a3bb9e75b458142dd33
2017-09-07 21:53:34 +00:00
Dave Bort 05b8056b72 [arch][libobject] object/exception.h -> arch/exception.h
The file really defines the arch interface to exception dispatching.

Remove "magenta" from function names.

Change-Id: I026c6effe2e140f341bfe4fe6e54057e84efda96
2017-09-07 21:40:55 +00:00
Mike Voydanoff 90ce7185fa [scripts][hikey] Add -m option to flash-hikey script for enabling mexec
Change-Id: Id8566910ae2a0214c06d2de6ddc2d6e8a078f17c
2017-09-07 21:39:15 +00:00
Mark Seaborn a60b33cf3f [docs][x86] Add notes about CPU state invariants required for kernel code
Change-Id: Ic293a79166f4130ef0620e6bea009ef88db34a20
2017-09-07 21:32:54 +00:00
Mike Voydanoff 1d105a4c87 [ddk][usb] Various improvements to USB peripheral mode support
- Changes to support USB functions that have multiple interface descriptors
  (like USB audio and CDC ethernet)

- Support for enabling/disabling endpoints when alternate interfaces are selected

- Add support for USB functions allocating string descriptors

- Add API for stalling/unstalling endpoints

- Fixes for disconnect handling

- Use new DDK dprintf() in usb-device and ums-function drivers

Change-Id: Id88e8e3816c2dba5dde83d6dbee02c2cde774bff
2017-09-07 21:26:55 +00:00
Tim Kilbourn 77a265be6f [hid] Include report id if it was in the descriptor
The USB HID spec says that if any report ID is given in the report
descriptor, it should be used in every report. We were previously
assuming that it would only be included if more than one report ID was
specified.

Change-Id: I206340ff53579ef6aa6019b97362f2198326b55d
2017-09-07 21:14:11 +00:00
George Kulakowski 59e644b1dc [zircon][mxtl->fbl] Rename mxtl to fbl
Change-Id: Ie21b6498e1bfb0a7fa0315e40b9e5c3ee78646be
2017-09-07 13:57:27 -07:00
George Kulakowski 77a89c40ca [gn] gn format all BUILD.gn files
Change-Id: Ibf190b9304343df41219f4f40c1ee9eb54c83678
2017-09-07 20:07:13 +00:00
Doug Evans 9f52d8cb88 [kernel][ports] Rename MakeObservers -> MakeObserver
Change-Id: If249a4bcf8a0378b340731c5c9048b9d913f6596
2017-09-07 12:31:43 -07:00
Roland McGrath c98a3f35ed [kernel] Define AutoThreadLock class and use it in C++ THREAD_LOCK cases
Like AutoLock but for the thread_lock.

Change-Id: I6ce34c58243b85d9cd527e4723b8b2ca16c1469e
2017-09-07 18:22:11 +00:00
Mark Seaborn 2852278863 [kernel][x86] Add a global variable to cache x86_feature_test(X86_FEATURE_SMAP)
This simplifies the check in _x86_copy_to_or_from_user().  The
assembly code can access the global rather than having to take
smap_avail as an argument.

This is more of a cleanup than a performance improvement.  Though
x86_feature_test() isn't trivial, it doesn't appear to add noticeable
overhead to the context switch.

Change-Id: I93529a0093366a212ae9214ac0e0ffc886ff1595
2017-09-07 17:48:40 +00:00
Mike Voydanoff a69c4fb9b9 [ddk] Fix DDK_LOG_LTRACE macro copy & paste error
Change-Id: I03e4c90ec4f27b423e74608361d9c2f5b0b8bba2
2017-09-07 01:23:33 -07:00
Andy Mutton 950ddb93b3 [hypervisor] Fix backspace on Linux.
Change-Id: I3c221eeed42a74232f6ed2ad9fc6467047e2222f
2017-09-07 04:52:51 +00:00
Andy Mutton e1a41a3aba [hypervisor] Use AutoLocks in UART.
Change-Id: Ide5e26009aa07c486bbb30558e2a9c8b048d0b78
2017-09-07 04:01:30 +00:00
Abdulla Kamar 42e0cd3d22 [arm64] Check boot EL2 when creating a guest.
This mirrors the VMX check in the x86, and helps us to early exit when
creating a hypervisor guest if it's not supported on the device.

Also split the hypervisor.cpp file into guest.cpp and vcpu.cpp. It's
still a skeleton, but it helps while we flesh it out.

Change-Id: I482f55b5a448c6b26acb363ec3bad76a9ed8c5dc
2017-09-07 03:37:40 +00:00
Brian Swetland 257d672b2a [devhost] don't dprintf() blank lines
Change-Id: I5f7848a9ca09e3cbed03d7f627f2d091744ee47f
2017-09-07 02:16:19 +00:00
Roland McGrath dc9db3fe55 [kernel][syscalls] vmar_allocate: Diagnose bad result pointers last
This makes vmar_allocate consistent with all other system calls,
where a bad user pointer for a result parameter is not diagnosed
until the call has succeeded in every other way.

Change-Id: I7d7c3c51665d8b81370c9da3349f90f502963bdb
2017-09-07 01:24:28 +00:00
Brian Swetland d0b411e10f [fs] name dispatcher threads a bit more distinctly
Change-Id: Ib602da6b4f0da82937281c75ab229b239f0b1b40
2017-09-07 01:04:29 +00:00
Todd Eisenberger 8c4beceed6 [hidtouch] Add test for new touchpanel
Change-Id: I955740f047e94df4d78ffbbbb231e5c4bc3a3e59
2017-09-07 00:45:30 +00:00
Todd Eisenberger edc8098b07 [ulib][hid] Add new touchpanel descriptor
MG-1102 #comment Add HID parsing structs

Change-Id: Icb1214de77041cc7364e2d2a90ec9fe2c9bed5d5
2017-09-07 00:44:08 +00:00
Jeff Brown cc83cdd94f [async] API and assertion cleanups.
Added some more documentation especially to clarify destructor behavior.

Removed virtual destructors since the classes were made final by the
previous refactoring.

Tidied up some assertions to be more consistent and informative.

Change-Id: Ifa7c1a99e22548c59baf9bb666219790b3096b73
2017-09-07 00:40:30 +00:00
Travis Geiselbrecht a070956ca8 [kernel][arm][dev] print some timer info on boot and squelch some GIC info
It's useful to see what resolution the timer is running at on any given
platform.

Change-Id: If07356a26e05d688a6a99d19b77da0e7835dc048
2017-09-07 00:26:29 +00:00
Travis Geiselbrecht e4542588be [kernel][benchmarks] spiff up the old benchmark code a bit
-Disable interrupts around the memset/memcpy tests to improve the results
-Switch some macroized stuff to templates
-Increase the buffer sizes to generally include all of the platform's L2 cache

Change-Id: I098c82547171dcdc68ca26096bd6fdfd327edf04
2017-09-07 00:25:42 +00:00
Sean Klein 85dce33bd0 [fs] Decouple VFS unmount from process exit
This allows filesystems themselves to decide
what 'unmount' means for their lifecycle (i.e., clean
up and exit process, hang, do nothing, etc).

The VFS layer, managing mounts, still invokes
"UninstallAll".

MG-1115 #done

Change-Id: I9460563d060b447da0e2d478e643fe1f4a419975
2017-09-06 16:19:47 -07:00
Sean Klein d8cc9a6334 [devmgr] Create one dispatcher for the global root
"vfs_create_root_handle" should *only* create a new
handle to the root -- it should assume the root
is using a preexisting dispatcher, and not try to
create another.

Change-Id: I07da60571d9cee40d4bcaa0059557952c6d0acfe
2017-09-06 16:13:15 -07:00
Dave Bort 2db36fe305 [libobject] Axe magenta.h; magenta.cpp -> glue.cpp
Change-Id: I58486667266fd25dac29c17c054f940ab4b521d6
2017-09-06 22:15:20 +00:00
Eric Holland 9ad9c0c5fc [hikey][efi] scripts for efi workflow
Change-Id: If125285d6f229b6acf17e5c41bddc4a77dcd3c67
2017-09-06 22:05:38 +00:00
Mike Voydanoff 6f402d4d68 [syscalls][log] Correctly include flags when writing to log
Change-Id: Id2baa0c236d38dc9b364cc4b0888d54eda814960
2017-09-06 21:42:31 +00:00
George Kulakowski e4a97c6cd6 [mxio] Make opening or stating the "" path errno with ENOENT
MG-1062 #done

Change-Id: I65d2c2cff2572b2e56ee7ae8d87368cc115e00ea
2017-09-06 21:22:49 +00:00
Abdulla Kamar 6b0084b4c9 [arm64] Remove arm64_el3_to_el1.
arm64_elX_to_el1 is already called from arm_reset in start.S before
lk_main is invoked, and neither the hikey960 or qemu seem to require
arm64_el3_to_el1.

This also removes some duplication between the two functions, for
example with hypervisor setup.

Change-Id: If94ce0e298e52ca39bed1a4a0b5a06f2e3eab5c6
2017-09-06 21:22:02 +00:00
Tim Kilbourn b1da6f2e96 [hid] Use dprintf for logging
Change-Id: Ife7a74cfa7342ebc8ea50cb6f365ff5136defb52
2017-09-06 20:54:18 +00:00
Todd Eisenberger 4bd73433d4 [lib][explicit-memory] Properly export static lib
Change-Id: I024b054b0b38f28bde048ba408f734ba7c4eaf6a
2017-09-06 20:43:48 +00:00
George Kulakowski baa705bf0e [mxio] Move lstat out of mxio's stub file
We aren't supporting symlinks, so the TODO and assumption that lstat
is incomplete is just wrong.

Change-Id: I710f8fe0d2651f44573188356274d42df4783abe
2017-09-06 20:31:09 +00:00
Dave Bort 70ceb70593 [libobject] Move resource fns to resources.h from magenta.h
Change-Id: Ib26e46f23c8e1c42ca7ea10411af4309f1339d6a
2017-09-06 19:47:39 +00:00