Commit Graph

1617 Commits

Author SHA1 Message Date
Drew Stratford
3014fdf3bd ProcFS: make procfs$pid_fds always returns a valid JSON array.
Previously, procfs$pid_fds would return nothing when called
for a process that had either no open files or a non-existent
handle. This could cause problems when a userspace program
expected a valid Json response.

Procfs$pid_fs now returns an empty array in the aforementioned
cases.
2019-10-23 07:45:13 +02:00
Drew Stratford
d063734f69 ProcFS: Check for empty Optional in read_bytes()
In read_bytes() we now check that the Optional "data" actually
contains a value before use, avoiding a failing asserting in
kernel space.
2019-10-23 07:45:13 +02:00
Andreas Kling
0782c60fe5 Kernel: Update the mtime after a successful InodeFile::write()
Well this was pretty silly. We were not updating the modification time
of files.. after modifying them. :^)
2019-10-22 22:23:58 +02:00
Andreas Kling
0311e8d50a HackStudio: Start working on an IDE for SerenityOS
This will be fun. :^)
2019-10-21 18:46:55 +02:00
Andrew Kaster
138abb9098 ELF: Fail layout when program header hooks return nullptr (#673)
ELFLoader::layout() had a "failed" variable that was never set. This
patch checks the return value of each hook (alloc/map section and tls)
and fails the load if they return null.

I also needed to patch Process so that the alloc_section_hook and 
map_section_hook actually return nullptr when allocating a region fails.

Fixes #664 :)
2019-10-20 16:24:42 +02:00
Drew Stratford
4c35c8d7fd TTY: Implement Canonical mode and basic echoing.
The TTY driver now respects the ICANON flag, enabling basic line
editing like VKILL, VERASE, VEOF and VWERASE. Additionally,
ICANON is now set by default.

Basic echoing has can now be enabled via the ECHO flag, though
more complicated echoing like ECHOCTL or ECHONL has not been
implemented.
2019-10-20 10:51:12 +02:00
Tidux
d09a28856f Kernel: Move Boot/ into Arch/i386/Boot (#667) 2019-10-20 08:15:39 +02:00
Andreas Kling
e08991319a Net: Put a bunch of socket debug logging behind FOO_DEBUG
Also remove an unused Socket::listen() implementation.
2019-10-18 16:50:23 +02:00
Andreas Kling
ec65b8db2e Revert "Kernel: Make DoubleBuffer use a KBuffer instead of kmalloc()ing"
This reverts commit 1cca5142af.

This appears to be causing intermittent triple-faults and I don't know
why yet, so I'll just revert it to keep the tree in decent shape.
2019-10-18 15:58:06 +02:00
Andreas Kling
1cca5142af Kernel: Make DoubleBuffer use a KBuffer instead of kmalloc()ing
Background: DoubleBuffer is a handy buffer class in the kernel that
allows you to keep writing to it from the "outside" while the "inside"
reads from it. It's used for things like LocalSocket and PTY's.
Internally, it has a read buffer and a write buffer, but the two will
swap places when the read buffer is exhausted (by reading from it.)

Before this patch, it was internally implemented as two Vector<u8>
that we would swap between when the reader side had exhausted the data
in the read buffer. Now instead we preallocate a large KBuffer (64KB*2)
on DoubleBuffer construction and use that throughout its lifetime.

This removes all the kmalloc heap traffic caused by DoubleBuffers :^)
2019-10-18 14:55:04 +02:00
Andreas Kling
4027a64fc5 Kernel: VirtualConsole can use kmalloc_eternal() for permanent stuff
Less pressure on kmalloc heap.
2019-10-18 14:14:54 +02:00
Andreas Kling
2f37fa487d Kernel: Keep TTY names in character buffers instead of Strings
Just going over some little unnecessary little kmalloc allocations.
2019-10-18 14:13:43 +02:00
Andreas Kling
340b524c0d Kernel: Minor cleanup in TCPSocket::send_tcp_packet() 2019-10-17 23:39:31 +02:00
Nufflee
7b6aba4284 KeyboardDevice: Rename 0xe0 flag for clarity. 2019-10-17 23:39:24 +02:00
Nufflee
0979f372a6 KeyboardDevice: Support whole numpad and Num Lock.
We now support all numpad keys and the Num Lock key.
2019-10-17 23:39:24 +02:00
Nufflee
9d5792b73d KeyboardDevice: Implement Caps Lock handling. 2019-10-17 23:39:24 +02:00
Tom
00a7c48d6e APIC: Enable APIC and start APs 2019-10-16 19:14:02 +02:00
Andreas Kling
e4015ab7cc Kernel: Remove unused FileBackedDiskDevice class 2019-10-14 12:47:08 +02:00
Andreas Kling
98c7fd7aed Kernel: Clarify code that saves FPU state after FNINIT
After we clear the FPU state in a thread when it uses the FPU for the
first time, we also save the clean slate in the thread's FPU state
buffer. When we're doing that, let's write through current->fpu_state()
just to make it clear what's going on.

It was actually safe, since we'd just overwritten the g_last_fpu_thread
pointer anyway, but this patch improves the communication of intent.

Spotted by Bryan Steele, thanks!
2019-10-13 20:39:59 +02:00
Calvin Buckley
5050f7b5ee Kernel: Use word-sized entropy as much as possible in syscall 2019-10-13 18:03:21 +02:00
Calvin Buckley
7e4e092653 Kernel: Add a Linux-style getrandom syscall
The way it gets the entropy and blasts it to the buffer is pretty
ugly IMHO, but it does work for now. (It should be replaced, by
not truncating a u32.)

It implements an (unused for now) flags argument, like Linux but
instead of OpenBSD's. This is in case we want to distinguish
between entropy sources or any other reason and have to implement
a new syscall later. Of course, learn from Linux's struggles with
entropy sourcing too.
2019-10-13 18:03:21 +02:00
Andreas Kling
16e66716ba Runner: Enable QEMU's KVM mode by default
This makes QEMU run significantly faster on Linux systems with KVM.
2019-10-13 15:07:23 +02:00
Andreas Kling
44fb71261a Kernel: Fix accidental restore of bogus FPU state after fork
Cloned threads (basically, forked processes) inherit the complete FPU
state of their origin thread. There was a bug in the lazy FPU state
save/restore mechanism where a cloned thread would believe it had a
buffer full of valid FPU state (because the inherited flag said so)
but the origin thread had never actually copied any FPU state into it.

This patch fixes that by forcing out an FPU state save after doing
the initial FPU initialization (FNINIT) in a thread. :^)
2019-10-13 14:39:04 +02:00
Andreas Kling
40beb4c5c0 Kernel: Don't leak an FPU state buffer for every spawned thread
We were leaking 512 bytes of kmalloc memory for every new thread.
This patch fixes that, and also makes sure to zero out the FPU state
buffer after allocating it, and finally also makes the LogStream
operator<< for Thread look a little bit nicer. :^)
2019-10-13 14:36:55 +02:00
Brandon Scott
48ef1d1bd1 HexEditor: Initial application release
The very first release of the Hex Editor for Serenity.
2019-10-13 08:45:49 +02:00
Tom
b0773a8ea6 AK: Add Atomic.h
Use gcc built-in atomics
2019-10-12 19:30:59 +02:00
Andreas Kling
a6e4c504e2 Kernel: Make SlabAllocator fall back to kmalloc() when slabs run out
This is obviously not ideal, and it would be better to teach it how to
allocate more pages, etc. But since the physical page allocator itself
currently uses SlabAllocator, it's a little bit tricky :^)
2019-10-10 11:58:15 +02:00
Andreas Kling
9bb0374d7d Kernel: Delay moving accepted sockets to SetupState::Completed a bit
Make sure we don't move accepted sockets to the Completed setup state
until we've actually constructed a FileDescription for them.

This is important, since this state transition will trigger connect()
to unblock on the client side, and the client may try writing to the
socket right away.

This makes DNS lookups way more reliable since we don't just fail to
write() right after connect()ing to LookupServer sometimes. :^)
2019-10-08 21:44:50 +02:00
Andreas Kling
3aa27b5b0e Kernel: Don't put LocalSocket in SetupState::Completed in bind()
This was causing connect() to unblock immediately for local sockets,
since that's exactly what ConnectBlocker checks for.

Instead, just move to SetupState::Completed when it's accept()ed.
2019-10-08 21:32:04 +02:00
Jesse Buhagiar
06b6af61c6 Kernel: Made DiskCache entries a KBuffer
The Cache entries found in `DiskBackedFileSystem` are now stored in a
`KBuffer` object, instead of relying on `kmalloc_eternal`. The number
of entries was exceeding that of the number of bytes allocated to
`kmalloc_eternal`, which in turn caused `mount()` to fail epically
when called.
2019-10-08 11:10:30 +02:00
Drew Stratford
c136fd3fe2 Kernel: Send SIGSEGV on seg-fault
Now programs can catch the SIGSEGV signal when they segfault.

This commit also introduced the send_urgent_signal_to_self method,
which is needed to send signals to a thread when handling exceptions
caused by the same thread.
2019-10-07 16:39:47 +02:00
Drew Stratford
7fc903b97a Kernel: Add exception_code to RegisterDump.
Added the exception_code field to RegisterDump, removing the need
for RegisterDumpWithExceptionCode. To accomplish this, I had to
push a dummy exception code during some interrupt entries to properly
pad out the RegisterDump. Note that we also needed to change some code
in sys$sigreturn to deal with the new RegisterDump layout.
2019-10-07 16:39:47 +02:00
supercomputer7
334e039294 PartitionTable: Removing unnecessary declarations from GPT & MBR classes 2019-10-07 11:32:42 +02:00
supercomputer7
de49714f36 PartitionTable: Initial GPT Support, Adding Block Limit
Also added a script to handle creation of GPT partitioned disk (with
GRUB config file). Block limit will be used to disallow potential access
to other partitions.
2019-10-07 10:11:39 +02:00
Andreas Kling
0a38e0028f Browser: Start working on a simple browser using LibHTML
This was inevitable. :^)
2019-10-05 10:20:17 +02:00
Andreas Kling
3f2c1a2e3d Kernel: Add SIOCGIFHWADDR ioctl to get the MAC address of an adapter 2019-10-02 18:20:11 +02:00
Andreas Kling
345086ab72 BXVGADevice: Log a debug message whenever the resolution changes
Fixes #618.
2019-10-02 17:16:46 +02:00
Andreas Kling
35138437ef Kernel+SystemMonitor: Add fault counters
This patch adds three separate per-process fault counters:

- Inode faults

    An inode fault happens when we've memory-mapped a file from disk
    and we end up having to load 1 page (4KB) of the file into memory.

- Zero faults

    Memory returned by mmap() is lazily zeroed out. Every time we have
    to zero out 1 page, we count a zero fault.

- CoW faults

    VM objects can be shared by multiple mappings that make their own
    unique copy iff they want to modify it. The typical reason here is
    memory shared between a parent and child process.
2019-10-02 14:13:49 +02:00
Andreas Kling
c33ac7f170 Kernel: Don't update Thread TSS if scheduler tick reschedules it
If we didn't find anything else that wants to run, we don't need to
update the current thread's TSS since we're just gonna return to the
same thread anyway.
2019-10-02 13:47:44 +02:00
Andreas Kling
5ab044beae Ext2FS: Make Ext2FSInode::is_directory() fast
This patch overloads Inode::is_directory() with a faster version that
doesn't require instantiating the whole InodeMetadata.

If you have an Ext2FSInode&, calling is_directory() should be instant
since we can just look directly at the raw inode bits.
2019-10-02 13:47:44 +02:00
Andreas Kling
d553bae749 Kernel: Allocate more 8-byte slabs than anything else
We need these for PhysicalPage objects. Ultimately I'd like to get rid
of these objects entirely, but while we still have to deal with them,
let's at least handle large demand a bit better.
2019-10-02 13:47:40 +02:00
Andreas Kling
d481ae95b5 Kernel: Defer creation of Region CoW bitmaps until they're needed
Instead of allocating and populating a Copy-on-Write bitmap for each
Region up front, wait until we actually clone the Region for sharing
with another process.

In most cases, we never need any CoW bits and we save ourselves a lot
of kmalloc() memory and time.
2019-10-01 19:58:41 +02:00
Andreas Kling
3d4ed7f38d Kernel: mmap() with both MAP_PRIVATE and MAP_SHARED is an error 2019-10-01 19:31:55 +02:00
Andreas Kling
c58d1868cb Kernel: Fix munmap() bad splitting of already-split Regions
When splitting an Region that's already the result of an earlier split,
we have to take the Region's offset-in-VMObject into account since it
may be non-zero.
2019-10-01 11:40:40 +02:00
Andreas Kling
4bfd4dc6c7 AK: Remove empty files JsonArray.cpp and JsonObject.cpp 2019-10-01 11:24:54 +02:00
Andreas Kling
ac20919b13 Kernel: Make it possible to turn off VM guard pages at compile time
This might be useful for debugging since guard pages introduce a fair
amount of noise in the virtual address space.
2019-09-30 17:22:16 +02:00
Andreas Kling
c5e057438c MBVGADevice: Log address/pitch/width/height when created 2019-09-30 15:04:16 +02:00
Andreas Kling
8e775d241e Kernel: Make DiskBackedFS flush writes if cache is completely dirty
If we want to make a new entry in the disk cache when it's completely
full of dirty blocks, we'll now synchronously flush the writes at that
point. Maybe it's not ideal, but at least we can keep going.
2019-09-30 11:46:56 +02:00
Andreas Kling
922fd703c9 Kernel: Convert the DiskBackedFS write API to take "const u8*"
This way clients are not required to have instantiated ByteBuffers
and can choose whatever memory scheme works best for them.

Also converted some of the Ext2FS code to use stack buffers instead.
2019-09-30 11:23:36 +02:00
Andreas Kling
1fc2612667 Kernel: Make DiskBackedFS::read_block() write to client-provided memory
Instead of having DiskBackedFS allocate a ByteBuffer, leave it to each
client to provide buffer space.

This is significantly faster in many cases where we can use a stack
buffer and avoid heap allocation entirely.
2019-09-30 11:04:30 +02:00