Print this page
OS-8347 Update SmartOS to support illumos 13917
@@ -22,11 +22,11 @@
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
- * Copyright 2019 Joyent, Inc.
+ * Copyright 2022 Joyent, Inc.
*/
#include <sys/errno.h>
#include <sys/systm.h>
#include <sys/archsystm.h>
@@ -55,13 +55,21 @@
#include <sys/sunddi.h>
#include <sys/dlpi.h>
#include <sys/sysmacros.h>
/* Linux specific functions and definitions */
-static void lx_save(klwp_t *);
-static void lx_restore(klwp_t *);
+static void lx_save(void *);
+static void lx_restore(void *);
+/* Context op template. */
+static const struct ctxop_template lx_ctxop_template = {
+ .ct_rev = CTXOP_TPL_REV,
+ .ct_save = lx_save,
+ .ct_restore = lx_restore,
+ .ct_exit = lx_save,
+};
+
/*
* Set the return code for the forked child, always zero
*/
/*ARGSUSED*/
void
@@ -118,12 +126,11 @@
*/
lwpd->br_stack_mode = LX_STACK_MODE_PREINIT;
lwpd->br_ntv_stack = 0;
lwpd->br_ntv_stack_current = 0;
- installctx(lwptot(lwp), lwp, lx_save, lx_restore, NULL, NULL, lx_save,
- NULL, NULL);
+ ctxop_install(lwptot(lwp), &lx_ctxop_template, lwp);
/*
* clear out the tls array
*/
bzero(lwpd->br_tls, sizeof (lwpd->br_tls));
@@ -344,12 +351,16 @@
/*
* Remove our system call interposer.
*/
lwp->lwp_brand_syscall = NULL;
- (void) removectx(lwptot(lwp), lwp, lx_save, lx_restore, NULL, NULL,
- lx_save, NULL);
+ /*
+ * If this process is being de-branded during an exec(),
+ * the LX ctxops may have already been removed, so the result
+ * from ctxop_remove is irrelevant.
+ */
+ (void) ctxop_remove(lwptot(lwp), &lx_ctxop_template, lwp);
if (lwpd->br_pid != 0) {
lx_pid_rele(lwptoproc(lwp)->p_pid, lwptot(lwp)->t_tid);
}
/*
@@ -496,12 +507,11 @@
* Having performed the lx pid assignement, the lpid reference is no
* longer needed. The underlying data will be freed during lx_freelwp.
*/
lwpd->br_lpid = NULL;
- installctx(lwptot(lwp), lwp, lx_save, lx_restore, NULL, NULL,
- lx_save, NULL, NULL);
+ ctxop_install(lwptot(lwp), &lx_ctxop_template, lwp);
/*
* Install branded system call hooks for this LWP:
*/
lwp->lwp_brand_syscall = lx_syscall_enter;
@@ -611,12 +621,13 @@
/*
* When switching a Linux process off the CPU, clear its GDT entries.
*/
/* ARGSUSED */
static void
-lx_save(klwp_t *t)
+lx_save(void *arg)
{
+ klwp_t *t = (klwp_t *)arg;
int i;
#if defined(__amd64)
reset_sregs();
#endif
@@ -631,12 +642,13 @@
* %fsbase via wrmsr(MSR_AMD_FSBASE) here. Instead, that should happen
* automatically in update_sregs if we are executing in user-land. If this
* is the case then pcb_rupdate should be set.
*/
static void
-lx_restore(klwp_t *t)
+lx_restore(void *arg)
{
+ klwp_t *t = (klwp_t *)arg;
struct lx_lwp_data *lwpd = lwptolxlwp(t);
user_desc_t *tls;
int i;
ASSERT(lwpd);