OS-7084: fast_syscall state should be tracked


Issue Type:Improvement
Priority:4 - Normal
Created at:2018-07-18T20:33:34.927Z
Updated at:2018-07-20T19:57:11.501Z


Created by:Former user
Reported by:Former user
Assigned to:Former user


Fixed: A fix for this issue is checked into the tree and tested.
(Resolution Date: 2018-07-20T19:57:11.488Z)

Fix Versions

2018-08-02 XCannon (Release Date: 2018-08-02)


The i86pc platform disables fast syscalls on a CPU (SYSENTER/SYSCALL) via cpu_fast_syscall_disable when an LDT is configured in a 32-bit process. Process-wide ctxops will re-enable that functionality when its threads are departing the CPU. This disabled state is kept only in the relevant MSRs, not tracked in a structure that's easily accessible from mdb (on a live system or a dump).

It would be nice to track that in the struct machcpu for inspection.


Comment by Former user
Created at 2018-07-20T19:36:34.389Z

To test, I booted a machine up on a PI with the fix. In its normal state, all CPUs reported having SYSCALL/SYSENTER enabled:

> ::walk cpu | ::print cpu_t cpu_m.mcpu_fast_syscall_state ! uniq -c
  40 cpu_m.mcpu_fast_syscall_state = 0x3 (FSS_{ASYSC_ENABLED|SEP_ENABLED})

I modified a copy of ldt.c from the in-gate tests to busy-spin in its worker threads (rather than sleeping like the original test). With 10 threads active in a 32-bit process utilizing a custom LDT, the OS reported SYSCALL/SYSENTER as disabled for the CPUs in question:

> ::walk cpu | ::print cpu_t cpu_m.mcpu_fast_syscall_state ! sort | uniq -c
  10 cpu_m.mcpu_fast_syscall_state = 0 (0)
  30 cpu_m.mcpu_fast_syscall_state = 0x3 (FSS_{ASYSC_ENABLED|SEP_ENABLED})

Comment by Former user
Created at 2018-07-20T19:48:34.937Z

The updated donothing function in ldt.c which definitely does something now:

static void *
donothing(void *nothing)
        timespec_t start, ts;

        clock_gettime(CLOCK_REALTIME, &start);

        for (;;) {
                clock_gettime(CLOCK_REALTIME, &ts);
                if ((ts.tv_sec - start.tv_sec) > 10)
        return (NULL);

Comment by Jira Bot
Created at 2018-07-20T19:56:33.027Z

illumos-joyent commit 1b703d2054b19cc7cf25feb9f9c8742700d130f8 (branch master, by Patrick Mooney)

OS-7084 fast_syscall state should be tracked
Reviewed by: John Levon <john.levon@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Jason King <jason.king@joyent.com>