Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: src/sys/arch



Module Name:    src
Committed By:   maxv
Date:           Thu Feb 22 08:56:52 UTC 2018

Modified Files:
        src/sys/arch/amd64/amd64: locore.S
        src/sys/arch/amd64/include: frameasm.h
        src/sys/arch/x86/x86: cpu.c patch.c svs.c x86_machdep.c

Log Message:
Add a dynamic detection for SVS.

The SVS_* macros are now compiled as skip-noopt. When the system boots, if
the cpu is from Intel, they are hotpatched to their real content.
Typically:

                jmp     1f
                int3
                int3
                int3
                ... int3 ...
        1:

gets hotpatched to:

                movq    SVS_UTLS+UTLS_KPDIRPA,%rax
                movq    %rax,%cr3
                movq    CPUVAR(KRSP0),%rsp

These two chunks of code being of the exact same size. We put int3 (0xCC)
to make sure we never execute there.

In the non-SVS (ie non-Intel) case, all it costs is one jump. Given that
the SVS_* macros are small, this jump will likely leave us in the same
icache line, so it's pretty fast.

The syscall entry point is special, because there we use a scratch uint64_t
not in curcpu but in the UTLS page, and it's difficult to hotpatch this
properly. So instead of hotpatching we declare the entry point as an ASM
macro, and define two functions: syscall and syscall_svs, the latter being
the one used in the SVS case.

While here 'syscall' is optimized not to contain an SVS_ENTER - this way
we don't even need to do a jump on the non-SVS case.

When adding pages in the user page tables, make sure we don't have PG_G,
now that it's dynamic.

A read-only sysctl is added, machdep.svs_enabled, that tells whether the
kernel uses SVS or not.

More changes to come, svs_init() is not very clean.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/amd64/include/frameasm.h
cvs rdiff -u -r1.147 -r1.148 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/x86/x86/patch.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/x86/svs.c
cvs rdiff -u -r1.103 -r1.104 src/sys/arch/x86/x86/x86_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index