-/* $OpenBSD: sysctl.c,v 1.15 2023/05/22 09:29:54 kn Exp $ */
+/* $OpenBSD: sysctl.c,v 1.16 2024/02/03 16:21:20 deraadt Exp $ */
/*
* Copyright (c) 2009 Theo de Raadt <deraadt@openbsd.org>
{ CTL_HW, HW_DISKNAMES }},
{ "hw.ncpufound", pint, 2,
{ CTL_HW, HW_NCPUFOUND }},
+#ifdef __amd64__
+ { "machdep.retpoline", pint, 2,
+ { CTL_MACHDEP, CPU_RETPOLINE }},
+#endif
#ifdef CPU_COMPATIBLE
{ "machdep.compatible", pstring, 2,
{ CTL_MACHDEP, CPU_COMPATIBLE }},
-/* $OpenBSD: cpu.c,v 1.177 2023/11/22 18:50:10 bluhm Exp $ */
+/* $OpenBSD: cpu.c,v 1.178 2024/02/03 16:21:22 deraadt Exp $ */
/* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */
/*-
int ecpu_ecxfeature = 0; /* cpuid(0x80000001).ecx */
int cpu_meltdown = 0;
int cpu_use_xsaves = 0;
+int need_retpoline = 1; /* most systems need retpoline */
void
replacesmap(void)
if (ibrs == 2 || (ci->ci_feature_sefflags_edx & SEFF0EDX_IBT)) {
extern const char _jmprax, _jmpr11, _jmpr13;
extern const short _jmprax_len, _jmpr11_len, _jmpr13_len;
+
codepatch_replace(CPTAG_RETPOLINE_RAX, &_jmprax, _jmprax_len);
codepatch_replace(CPTAG_RETPOLINE_R11, &_jmpr11, _jmpr11_len);
codepatch_replace(CPTAG_RETPOLINE_R13, &_jmpr13, _jmpr13_len);
+ need_retpoline = 0;
}
if (!cpu_meltdown)
-/* $OpenBSD: machdep.c,v 1.289 2024/01/19 18:38:16 kettenis Exp $ */
+/* $OpenBSD: machdep.c,v 1.290 2024/02/03 16:21:22 deraadt Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*-
extern int tsc_is_invariant;
extern int amd64_has_xcrypt;
+extern int need_retpoline;
const struct sysctl_bounded_args cpuctl_vars[] = {
{ CPU_LIDACTION, &lid_action, 0, 2 },
{ CPU_CPUFEATURE, &cpu_feature, SYSCTL_INT_READONLY },
{ CPU_XCRYPT, &amd64_has_xcrypt, SYSCTL_INT_READONLY },
{ CPU_INVARIANTTSC, &tsc_is_invariant, SYSCTL_INT_READONLY },
+ { CPU_RETPOLINE, &need_retpoline, SYSCTL_INT_READONLY },
};
/*
-/* $OpenBSD: cpu.h,v 1.160 2024/01/24 19:23:39 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.161 2024/02/03 16:21:22 deraadt Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
#define CPU_TSCFREQ 16 /* TSC frequency */
#define CPU_INVARIANTTSC 17 /* has invariant TSC */
#define CPU_PWRACTION 18 /* action caused by power button */
-#define CPU_MAXID 19 /* number of valid machdep ids */
+#define CPU_RETPOLINE 19 /* cpu requires retpoline pattern */
+#define CPU_MAXID 20 /* number of valid machdep ids */
#define CTL_MACHDEP_NAMES { \
{ 0, 0 }, \
{ "tscfreq", CTLTYPE_QUAD }, \
{ "invarianttsc", CTLTYPE_INT }, \
{ "pwraction", CTLTYPE_INT }, \
+ { "retpoline", CTLTYPE_INT }, \
}
#endif /* !_MACHINE_CPU_H_ */