amd64: Protect the kernel text, data, and BSS by setting the RW/NX bitscorrectly for the data contained on each memory page.There are several components to this change: * Add a variable to indica
amd64: Protect the kernel text, data, and BSS by setting the RW/NX bitscorrectly for the data contained on each memory page.There are several components to this change: * Add a variable to indicate the start of the R/W portion of the initial memory. * Stop detecting NX bit support for each AP. Instead, use the value from the BSP and, if supported, activate the feature on the other APs just before loading the correct page table. (Functionally, we already assume that the BSP and all APs had the same support or lack of support for the NX bit.) * Set the RW and NX bits correctly for the kernel text, data, and BSS (subject to some caveats below). * Ensure DDB can write to memory when necessary (such as to set a breakpoint). * Ensure GDB can write to memory when necessary (such as to set a breakpoint). For this purpose, add new MD functions gdb_begin_write() and gdb_end_write() which the GDB support code can call before and after writing to memory.This change is not comprehensive: * It doesn't do anything to protect modules. * It doesn't do anything for kernel memory allocated after the kernel starts running. * In order to avoid excessive memory inefficiency, it may let multiple types of data share a 2M page, and assigns the most permissions needed for data on that page.Reviewed by: jhb, kibDiscussed with: emasteMFC after: 2 weeksSponsored by: NetflixDifferential Revision: https://reviews.freebsd.org/D14282
show more ...
sys/gdb: further adoption of SPDX licensing ID tags.Mainly focus on files that use BSD 2-Clause license, however the tool Iwas using misidentified many licenses so this was mostly a manual - error
sys/gdb: further adoption of SPDX licensing ID tags.Mainly focus on files that use BSD 2-Clause license, however the tool Iwas using misidentified many licenses so this was mostly a manual - errorprone - task.The Software Package Data Exchange (SPDX) group provides a specificationto make it easier for automated tools to detect and summarize well knownopensource licenses. We are gradually adopting the specification, notingthat the tags are considered only advisory and do not, in any way,superceed or replace the license texts.
gdb kernel server: fixup Search:memory styleThis is a NFC patch to move around the Search:memory implementation sothat it doesn't exceed the standard column width and doesn't take somuch vertical
gdb kernel server: fixup Search:memory styleThis is a NFC patch to move around the Search:memory implementation sothat it doesn't exceed the standard column width and doesn't take somuch vertical space in gdb_trap.Submitted by: Daniel O'Connor <[email protected]>Reviewed by: cem, jhbSponsored by: Dell EMC IsilonDifferential Revision: https://reviews.freebsd.org/D12684
CALLOUT_MPSAFE has lost its meaning since r141428, i.e., for more than tenyears for head. However, it is continuously misused as the mpsafe argumentfor callout_init(9). Deprecate the flag and cle
CALLOUT_MPSAFE has lost its meaning since r141428, i.e., for more than tenyears for head. However, it is continuously misused as the mpsafe argumentfor callout_init(9). Deprecate the flag and clean up callout_init() callsto make them more consistent.Differential Revision: https://reviews.freebsd.org/D2613Reviewed by: jhbMFC after: 2 weeks
Add support for gdb's memory searching capabilities to our in-kernel gdbserver.Submitted by: Daniel O'Connor <[email protected]>Reviewed by: jhbSponsored by: EMC Isilon Storage Division
Pull in r267961 and r267973 again. Fix for issues reported will follow.
Revert r267961, r267973:These changes prevent sysctl(8) from returning proper output,such as: 1) no output from sysctl(8) 2) erroneously returning ENOMEM with tools like truss(1) or uname(1
Revert r267961, r267973:These changes prevent sysctl(8) from returning proper output,such as: 1) no output from sysctl(8) 2) erroneously returning ENOMEM with tools like truss(1) or uname(1) truss: can not get etype: Cannot allocate memory
Extend the meaning of the CTLFLAG_TUN flag to automatically check ifthere is an environment variable which shall initialize the SYSCTLduring early boot. This works for all SYSCTL types both statica
Extend the meaning of the CTLFLAG_TUN flag to automatically check ifthere is an environment variable which shall initialize the SYSCTLduring early boot. This works for all SYSCTL types both statically anddynamically created ones, except for the SYSCTL NODE type and SYSCTLswhich belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added tobe used in the case a tunable sysctl has a custom initialisationfunction allowing the sysctl to still be marked as a tunable. Thekernel SYSCTL API is mostly the same, with a few exceptions for somespecial operations like iterating childrens of a static/extern SYSCTLnode. This operation should probably be made into a factored outcommon macro, hence some device drivers use this. The reason forchanging the SYSCTL API was the need for a SYSCTL parent OID pointerand not only the SYSCTL parent OID list pointer in order to quicklygenerate the sysctl path. The motivation behind this patch is to avoidparameter loading cludges inside the OFED driver subsystem. Instead ofadding special code to the OFED driver subsystem to post-load tunablesinto dynamically created sysctls, we generalize this in the kernel.Other changes:- Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask"to "hw.pcic.intr_mask".- Removed redundant TUNABLE statements throughout the kernel.- Some minor code rewrites in connection to removing not neededTUNABLE statements.- Added a missing SYSCTL_DECL().- Wrapped two very long lines.- Avoid malloc()/free() inside sysctl string handling, in case it iscalled to initialize a sysctl from a tunable, hence malloc()/free() isnot ready when sysctls from the sysctl dataset are registered.- Bumped FreeBSD version to indicate SYSCTL API change.MFC after: 2 weeksSponsored by: Mellanox Technologies
rename scheduler->swapper and SI_SUB_RUN_SCHEDULER->SI_SUB_LASTAlso directly call swapper() at the end of mi_startup instead ofrelying on swapper being the last thing in sysinits order.Rationale
rename scheduler->swapper and SI_SUB_RUN_SCHEDULER->SI_SUB_LASTAlso directly call swapper() at the end of mi_startup instead ofrelying on swapper being the last thing in sysinits order.Rationale:- "RUN_SCHEDULER" was misleading, scheduling already takes place at that stage- "scheduler" was misleading, the function swaps in the swapped out processes- another SYSINIT(SI_SUB_RUN_SCHEDULER, SI_ORDER_ANY) could never be invoked depending on its relative order with scheduler; this was not obvious and the bug actually used to existReviewed by: kib (ealier version)MFC after: 14 days
Update the ddb and gdb backends for the new 'trace_thread' hook.It is implemented via db_trace_thread() for DDB and not implementedfor GDB. This should have been part of r234190.Pointy hat to: j
Update the ddb and gdb backends for the new 'trace_thread' hook.It is implemented via db_trace_thread() for DDB and not implementedfor GDB. This should have been part of r234190.Pointy hat to: jhbReported by: jkimMFC after: 1 week
kern cons: introduce infrastructure for console grabbing by kernelAt the moment grab and ungrab methods of all console drivers are no-ops.Current intended meaning of the calls is that the kernel
kern cons: introduce infrastructure for console grabbing by kernelAt the moment grab and ungrab methods of all console drivers are no-ops.Current intended meaning of the calls is that the kernel takes control ofconsole input. In the future the semantics may be extended to mean thatthe calling thread takes full ownership of the console (e.g. consoleoutput from other threads could be suspended).Inspired by: bdeMFC after: 2 months
Modify kdb_trap() so that it re-calls the dbbe_trap function as long asthe debugger back-end has changed. This means that switching from ddbto gdb no longer requires a "step" which can be dangerou
Modify kdb_trap() so that it re-calls the dbbe_trap function as long asthe debugger back-end has changed. This means that switching from ddbto gdb no longer requires a "step" which can be dangerous on analready-crashed kernel.Also add a capability to get from the gdb back-end back to ddb, bytyping ^C in the console window.While here, simplify kdb_sysctl_available() by usingsbuf_new_for_sysctl(), and use strlcpy() instead of strncpy() since thestrlcpy semantic is desired.MFC after: 1 month
there must be only one SYSINIT with SI_SUB_RUN_SCHEDULER+SI_ORDER_ANY orderSI_SUB_RUN_SCHEDULER+SI_ORDER_ANY should only be used to callscheduler() function which turns the initial thread into swa
there must be only one SYSINIT with SI_SUB_RUN_SCHEDULER+SI_ORDER_ANY orderSI_SUB_RUN_SCHEDULER+SI_ORDER_ANY should only be used to callscheduler() function which turns the initial thread into swapper properand thus there is no further SYSINIT processing.Other SYSINITs with SI_SUB_RUN_SCHEDULER+SI_ORDER_ANY may get orderedafter scheduler() and thus never executed. That particular relativeorder is semi-arbitrary.Thus, change such places to use SI_ORDER_MIDDLE.Also, use SI_ORDER_MIDDLE instead of correct, but less appealing,SI_ORDER_ANY - 1.MFC after: 1 week
Commit SYSINIT() ;-adding patch missed in previous pass.MFC after: 1 monthCaught by: tinderbox
Add support for kgdb's 'detach' command.Reviewed by: marcelSponsored by: Network Appliance
Add kdb_cpu_sync_icache(), intended to synchronize instructioncaches with data caches after writing to memory. This typicallyis required to make breakpoints work on ia64 and powerpc. Forthose arch
Add kdb_cpu_sync_icache(), intended to synchronize instructioncaches with data caches after writing to memory. This typicallyis required to make breakpoints work on ia64 and powerpc. Forthose architectures the function is implemented.
Convert to new console api
Eliminate gdb_checkc member from GDB_DBGPORT(), it is never used.Use polling behaviour for gdb_getc() where convenient, this edges uscloser to the console code.
Don't use GDB_DBGPORT() macro to fill in dummy element in gdb_dbgport_set.
Wrap our drivers gdb_getc() function so that if it returns -1 wetry again. This way it matches the console behaviour and allows usto share more code.
add support for copying console messages to a remote gdbReviewed by: kan
check return value of gdb_rx_varhexNoticed by: Coverity Prevent analysis toolReviewed by: kan
/* -> /*- for copyright notices, minor format tweaks as necessary
Change gdb_cpu_setreg() to not take the value to which to set thespecified register, but a pointer to the in-memory representation ofthat value. The reason for this is twofold:1. Not all registers
Change gdb_cpu_setreg() to not take the value to which to set thespecified register, but a pointer to the in-memory representation ofthat value. The reason for this is twofold:1. Not all registers can be represented by a register_t. In particular FP registers fall in that category. Passing the new register value by reference instead of by value makes this point moot.2. When we receive a G or P packet, both are for writing a register, the packet will have the register value in target-byte order and in the memory representation (modulo the fact that bytes are sent as 2 printable hexadecimal numbers of course). We only need to decode the packet to have a pointer to the register value.This change fixes the bug of extracting the register value of the Ppacket as a hexadecimal number instead of as a bit array. The quick(and dirty) fix to bswap the register value in gdb_cpu_setreg() asit has been added on i386 and amd64 can therefore be removed and hasin fact been that.Tested on: alpha, amd64, i386, ia64, sparc64
Comment-out the debugging printf I left in in case there were somepacket related problems. No problems have been reported.
12