Commit Graph

6055 Commits

Author SHA1 Message Date
Liav A
2a4a19aed8 Kernel: Fixing PCI MMIO access mechanism
During initialization of PCI MMIO access mechanism we ensure that we
have an allocation from the kernel virtual address space that cannot be
taken by other components in the OS.
Also, now we ensure that interrupts are disabled so mapping the region
doesn't fail.
In order to reduce overhead, map_device() will map the requested PCI
address only if it's not mapped already.

The run script has been changed so now we can boot a Q35 machine, that
supports PCI ECAM.
To ensure we will be able to load the machine, a PIIX3 IDE controller
was added to the Q35 machine configuration in the run script.
An AHCI controller was added to the i440fx machine configuration.
2020-01-02 21:45:04 +01:00
joshua stein
5e430e4eb4 Build: add support for building on OpenBSD
This requires gcc8 from ports to build the Toolchain.
2020-01-02 21:03:53 +01:00
joshua stein
d61131945d Build: HOST_CXX -> USE_HOST_CXX
Allow HOST_CXX to be passed to make which will be the actual host
C++ compiler used, such as 'make HOST_CXX=clang++'.
2020-01-02 21:03:53 +01:00
Andreas Kling
c6170070ed LibGUI: Clear out a GJsonArrayModel if it fails to open the JSON source
This fixes an issue in SystemMonitor where old data would linger in the
table views after selecting a process owned by another user.

Since we can no longer read /proc/PID/* unless PID belongs to us,
we will now present empty views for these processes. :^)
2020-01-02 20:57:55 +01:00
Andreas Kling
efbdaaaa65 ProfileViewer: Interpret addresses >= 0xc0000000 as kernel frames 2020-01-02 20:51:31 +01:00
Andreas Kling
32ec1e5aed Kernel: Mask kernel addresses in backtraces and profiles
Addresses outside the userspace virtual range will now show up as
0xdeadc0de in backtraces and profiles generated by unprivileged users.
2020-01-02 20:51:31 +01:00
Andreas Kling
8eb20bdfa2 Kernel: Move kernel symbols to /res/kernel.map and make it root-only
Let's lock down access to the kernel symbol table, since it trivializes
learning where the kernel functions are.

Of course, you can just build the same revision yourself locally and
learn the information, but we're taking one step at a time here. :^)
2020-01-02 20:51:31 +01:00
Chyza
51a9e31fb2 WindowServer: Make tiled windows actually centered.
The right window had a few pixels on the right cut off, i don't know how
i didn't notice this earlier.
2020-01-02 20:40:07 +01:00
Shannon Booth
fe67ba032d PaintBrush: Select tool button on context menu event
This means that (for example) if you change the line width of the line
tool, you now switch to the line tool, instead of sticking with the
currently "checked" tool.
2020-01-02 20:12:55 +01:00
Andreas Kling
0ac95ec510 WindowServer: Close all menus belonging to a client when it disconnects
Previously we would be left with a menu stack containing nulled-out
WeakPtr's to menus in the now-disconnected clients.

This was tripping up an assertion when clicking anywhere after shutting
down a program while it had a menu open.
2020-01-02 20:03:32 +01:00
Andreas Kling
9fe316c2d8 Kernel: Add some missing error checks to the setpgid() syscall 2020-01-02 19:40:04 +01:00
Andreas Kling
7cdfb9c6b4 Browser+LibHTML: Add resolved element style to the DOM inspector
When selecting an element in the browser's DOM inspector, we now also
show the resolved CSS properties (and their values) for that element.

Since the inspector was growing a bit more complex, I moved it out of
the "show inspector" action callback and into its own class.

In the future, we will probably want to migrate the inspector down to
LibHTML to make it accessible to other clients of the library, but for
now we can keep working on it inside Browser. :^)
2020-01-02 14:55:19 +01:00
Andreas Kling
0ff07980ae LibHTML: Include element attributes in the DOMTreeModel
We simply expand the attributes inside the element item name, so they
look like natural "tags" :^)
2020-01-02 14:53:38 +01:00
Andreas Kling
ffcd395afc LibHTML: Have element keep a pointer to their resolved style
This will make it easy to implement a simple element style inspector.
2020-01-02 14:52:34 +01:00
Andreas Kling
285130cc55 Kernel: Remove debug spam about marking threads for death 2020-01-02 13:45:22 +01:00
Andreas Kling
7f843ef3b2 Kernel: Make the purge() syscall superuser-only
I don't think we need to give unprivileged users access to what is
essentially a kernel testing mechanism.
2020-01-02 13:39:49 +01:00
Andreas Kling
907b090ddf LibC+Userland: Add a proper syscall wrapper for purge() 2020-01-02 13:37:02 +01:00
Andreas Kling
c01f766fb2 Kernel: writev() should fail with EINVAL if total length > INT32_MAX 2020-01-02 13:01:41 +01:00
Andreas Kling
7f04334664 Kernel: Remove broken implementation of Unix SHM
This code never worked, as was never used for anything. We can build
a much better SHM implementation on top of TmpFS or similar when we
get to the point when we need one.
2020-01-02 12:44:21 +01:00
Andreas Kling
4fa7146da1 Base: Move the modload and modunload command documentation to man8
These are system administration commands, not intended for use by
all users. These tend to go in section 8.
2020-01-02 12:37:19 +01:00
Andreas Kling
05b004ec64 Base: Remove "idle" priority note from SystemServer(5)
The "idle" priority was never meant to be exposed to userspace, as it's
only used by the kernel's internal idle thread.
2020-01-02 12:36:15 +01:00
Andreas Kling
0c22646e2b Base: Document EPERM error in module_load(2) and module_unload(2)
Only the superuser can use these system calls.
2020-01-02 12:35:19 +01:00
Andrew Kaster
4698a10dd1 Demos: DynamicLink makefile now respects $(QUIET)
At a later date we'll probably want a template for SHLIB_OBJS and
SHLIB or some such, but for now at least the library demo isn't
printing compile commands all over the user's terminal.
2020-01-02 12:28:29 +01:00
Andrew Kaster
2c4f837428 LibELF: Simplify R_386_32 relocations to ignore symbol bind value
For dynamic loading, the symbol bind of a symbol actually doesn't
matter. We could do what old glibc did and try to find a strong
symbol for any weak definitions, but the ELF spec doesn't require
it and they changed that a few years ago anyway. So, moot point. :)
2020-01-02 12:28:29 +01:00
Andrew Kaster
bc50a10cc9 Kernel: sys$mprotect protects sub-regions as well as whole ones
Split a region into two/three if the desired mprotect range is a strict
subset of an existing region. We can then set the access bits on a new
region that is just our desired range and add both the new
desired subregion and the leftovers back to our page tables.
2020-01-02 12:27:13 +01:00
joshua stein
9b516e3fb4 Userland: ifconfig: include netinet/in.h 2020-01-02 04:09:56 +01:00
joshua stein
288fa07d85 LibCore: CSocketAddress: pull in netinet/in.h 2020-01-02 04:09:56 +01:00
joshua stein
f22322a06c LibC: move in_addr and sockaddr_in to netinet/in.h 2020-01-02 04:09:56 +01:00
Andreas Kling
93e1728818 WindowServer: Remove unused WSEvent::WM_DeferredCompose
This was an old event type in the early days of userspace WindowServer.
2020-01-02 03:35:48 +01:00
Andreas Kling
8c8118fbf8 WindowServer+LibGUI: Taskbar should show all windows from each process
We were not sending the ID of the window that was listening for window
management (WM) events along with the WM messages. They only included
the "target" window's ID.

Since the taskbar's single window had the first window ID for its own
connection to the WindowServer, it meant that it would only receive
WM events for the first window ID in other processes as well.

This broke when I ported WindowServer to LibIPC.

Fix this by including the WM listener ID in all WM messages, and since
we're here anyway, get rid of a bunch of unnecessary indirection where
we were passing WM events through the WindowServer event loop before
sending them to the listener.
2020-01-02 03:29:21 +01:00
Andreas Kling
9619dab727 LibGUI: Tweak GAboutDialog text 2020-01-02 02:55:10 +01:00
Andreas Kling
3f7de2713e Kernel: Make mknod() respect the process umask
Otherwise the /bin/mknod command would create world-writable inodes
by default (when run by superuser) which you probably don't want.
2020-01-02 02:40:43 +01:00
Andreas Kling
c7eb3ff1b3 Kernel: mknod() should not allow unprivileged users to create devices
In fact, unless you are superuser, you may only create a regular file,
a named pipe, or a local domain socket. Anything else should EPERM.
2020-01-02 02:36:12 +01:00
Andreas Kling
3dcec260ed Kernel: Validate the full range of user memory passed to syscalls
We now validate the full range of userspace memory passed into syscalls
instead of just checking that the first and last byte of the memory are
in process-owned regions.

This fixes an issue where it was possible to avoid rejection of invalid
addresses that sat between two valid ones, simply by passing a valid
address and a size large enough to put the end of the range at another
valid address.

I added a little test utility that tries to provoke EFAULT in various
ways to help verify this. I'm sure we can think of more ways to test
this but it's at least a start. :^)

Thanks to mozjag for pointing out that this code was still lacking!

Incidentally this also makes backtraces work again.

Fixes #989.
2020-01-02 02:17:12 +01:00
Liav A
e5ffa960d7 Kernel: Create support for PCI ECAM
The new PCI subsystem is initialized during runtime.
PCI::Initializer is supposed to be called during early boot, to
perform a few tests, and initialize the proper configuration space
access mechanism. Kernel boot parameters can be specified by a user to
determine what tests will occur, to aid debugging on problematic
machines.
After that, PCI::Initializer should be dismissed.

PCI::IOAccess is a class that is derived from PCI::Access
class and implements PCI configuration space access mechanism via x86
IO ports.
PCI::MMIOAccess is a class that is derived from PCI::Access
and implements PCI configurtaion space access mechanism via memory
access.

The new PCI subsystem also supports determination of IO/MMIO space
needed by a device by checking a given BAR.
In addition, Every device or component that use the PCI subsystem has
changed to match the last changes.
2020-01-02 00:50:09 +01:00
Liav A
d85874be4b Kernel: Create a basic SMBIOS Decoder
We use DMI decoding now just to determine if PCI is available.
The DMIDecoder is initialized during early boot, thus making it possible
to probe useful data about the machine.

Other purposes are not supported yet.
2020-01-02 00:50:09 +01:00
Liav A
1e1a6a57ed Kernel: Introduce the ACPI subsystem
ACPI subsystem includes 3 types of parsers that are created during
runtime, each one capable of parsing ACPI tables at different level.

ACPIParser is the most basic parser which is essentialy a parser that
can't parse anything useful, due to a user request to disable ACPI
support in a kernel boot parameter.

ACPIStaticParser is a derived class from ACPIParser, which is able to
parse only static data (e.g. FADT, HPET, MCFG and other tables), thus
making it not able to parse AML (ACPI Machine Language) nor to support
handling of hardware events and power management. This type of parser
can be created with a kernel boot parameter.

ACPIDynamicParser is a derived class from ACPIStaticParser, which
includes all the capabilities of the latter, but *should* implement an
AML interpretation, (by building the ACPI AML namespace) and handling
power & hardware events. Currently the methods to support AML
interpretation are not implemented.
This type of parser is created automatically during runtime if the user
didn't specify a boot parameter related to ACPI initialization.

Also, adding strncmp function definition in StdLib.h, to be able to use
it in ACPIStaticParser class.
2020-01-02 00:50:09 +01:00
Andrew Kaster
331f37d1a8 LibELF: Re-organize ELFDynamicObject::load and add PLT trampoline
ELFDynamicObject::load looks a lot better with all the steps
re-organized into helpers.

Add plt_trampoline.S to handle PLT fixups for lazy loading.
Add the needed trampoline-trampolines in ELFDynamicObject to get to
the proper relocations and to return the symbol back to the assembly
method to call into from the PLT once we return back to user code.
2020-01-01 23:54:06 +01:00
joshua stein
5fa0291a05 Build: fix building Kernel/TestModule object 2020-01-01 23:33:03 +01:00
Andreas Kling
1d94b5eb04 Kernel: Add a random offset to kernel stacks upon syscall entry
When entering the kernel from a syscall, we now insert a small bit of
stack padding after the RegisterDump. This makes kernel stacks less
deterministic across syscalls and may make some bugs harder to exploit.

Inspired by Elena Reshetova's talk on kernel stack exploitation.
2020-01-01 23:21:24 +01:00
Andrew Kaster
f23dc4ea69 LibELF: Call DT_INIT method now that startfiles are correct for DSOs
We weren't calling the method here before because it was ill-formed.
No start files meant that we got the front half of the init section but
not the back half (no 'ret' in _init!). Now that we have the proper
crtbeginS and crtendS files from libgcc to help us out, we can assume
that DSOs will have the proper _init method defined.
2020-01-01 23:05:17 +01:00
Andrew Kaster
a755b80057 Demos: Link our normal startfiles into the dynamic lib demo
Now that gcc knows about crtbeginS and crtendS, and knows not to link
crt0.o into shared objects, we can get rid of the hacks required due to
--nostartfiles.
2020-01-01 23:05:17 +01:00
Andrew Kaster
2979491512 Toolchain: Use crtbeginS and crtendS for shared objects
Turns out the reason GCC wasn't as smart about startup code for
shared objects as we hoped is because nobody told it to be :D

Change the STARTFILE_SPEC and ENDFILE_SPEC in gcc/config/serenity.h to
skip crt0.o and to link the S variants of crtbegin
and crtend for shared objects.

Because we're using the crtbegin and crtend from libgcc, also tell
libgcc in libgcc/config.host to compile crtbeginS and crtendS from
crtstuff.c.
2020-01-01 23:05:17 +01:00
joshua stein
99e06c53e5 Build: show directory during compilation, remove default rules
When using -j, it can be confusing to see files being compiled out
of order, so prefix compilation with the directory it's building
for.
2020-01-01 22:21:50 +01:00
joshua stein
a1fd2eb237 Build: Userland: no need for duplicate .cpp->.o rule 2020-01-01 22:21:50 +01:00
joshua stein
31732d163f Build: Enter Libraries before AK, clean tests as separate step 2020-01-01 22:21:50 +01:00
joshua stein
e7de8af379 Build: Demos/DynamicLink: use EXTRA_CLEAN 2020-01-01 22:21:50 +01:00
joshua stein
f06d0da39f Build: AK/Tests: use Makefile.common 2020-01-01 22:21:50 +01:00
Andreas Kling
a005f14a73 WindowServer: Don't tile non-resizable windows
Thanks Tibor for pointing this out. :^)
2020-01-01 21:11:27 +01:00
Chyza
93ce1bb4a1 WindowServer: Windows tile when moved onto the edge of the screen 2020-01-01 19:46:37 +01:00