sync with OpenBSD -current
This commit is contained in:
parent
7d66fd8cb0
commit
3f3212838f
122 changed files with 1363 additions and 8580 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: cacheinfo.c,v 1.11 2022/07/12 04:46:00 jsg Exp $ */
|
||||
/* $OpenBSD: cacheinfo.c,v 1.12 2024/02/03 09:53:15 jsg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022 Jonathan Gray <jsg@openbsd.org>
|
||||
|
@ -43,10 +43,7 @@ amd64_print_l1_cacheinfo(struct cpu_info *ci)
|
|||
|
||||
printf("%s: ", ci->ci_dev->dv_xname);
|
||||
|
||||
if (totalsize < 1024)
|
||||
printf("%dKB ", totalsize);
|
||||
else
|
||||
printf("%dMB ", totalsize >> 10);
|
||||
printf("%dKB ", totalsize);
|
||||
printf("%db/line ", linesize);
|
||||
|
||||
switch (ways) {
|
||||
|
@ -70,10 +67,7 @@ amd64_print_l1_cacheinfo(struct cpu_info *ci)
|
|||
ways = (edx >> 16) & 0xff;
|
||||
totalsize = (edx >> 24) & 0xff; /* KB */
|
||||
|
||||
if (totalsize < 1024)
|
||||
printf("%dKB ", totalsize);
|
||||
else
|
||||
printf("%dMB ", totalsize >> 10);
|
||||
printf("%dKB ", totalsize);
|
||||
printf("%db/line ", linesize);
|
||||
|
||||
switch (ways) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $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 $ */
|
||||
|
||||
/*-
|
||||
|
@ -163,6 +163,7 @@ int cpu_apmi_edx = 0; /* cpuid(0x80000007).edx */
|
|||
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)
|
||||
|
@ -232,9 +233,11 @@ replacemeltdown(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)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $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 $ */
|
||||
|
||||
/*-
|
||||
|
@ -486,6 +486,7 @@ bios_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
|
|||
|
||||
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 },
|
||||
|
@ -494,6 +495,7 @@ const struct sysctl_bounded_args cpuctl_vars[] = {
|
|||
{ 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 },
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $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 $ */
|
||||
|
||||
/*-
|
||||
|
@ -481,7 +481,8 @@ void mp_setperf_init(void);
|
|||
#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 }, \
|
||||
|
@ -503,6 +504,7 @@ void mp_setperf_init(void);
|
|||
{ "tscfreq", CTLTYPE_QUAD }, \
|
||||
{ "invarianttsc", CTLTYPE_INT }, \
|
||||
{ "pwraction", CTLTYPE_INT }, \
|
||||
{ "retpoline", CTLTYPE_INT }, \
|
||||
}
|
||||
|
||||
#endif /* !_MACHINE_CPU_H_ */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: acpipci.c,v 1.41 2023/09/16 23:25:16 jmatthew Exp $ */
|
||||
/* $OpenBSD: acpipci.c,v 1.42 2024/02/03 10:37:25 kettenis Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2018 Mark Kettenis
|
||||
*
|
||||
|
@ -207,6 +207,7 @@ acpipci_attach(struct device *parent, struct device *self, void *aux)
|
|||
sc->sc_pc->pc_intr_v = sc;
|
||||
sc->sc_pc->pc_intr_map = acpipci_intr_map;
|
||||
sc->sc_pc->pc_intr_map_msi = _pci_intr_map_msi;
|
||||
sc->sc_pc->pc_intr_map_msivec = _pci_intr_map_msivec;
|
||||
sc->sc_pc->pc_intr_map_msix = _pci_intr_map_msix;
|
||||
sc->sc_pc->pc_intr_string = acpipci_intr_string;
|
||||
sc->sc_pc->pc_intr_establish = acpipci_intr_establish;
|
||||
|
@ -629,7 +630,7 @@ acpipci_intr_establish(void *v, pci_intr_handle_t ih, int level,
|
|||
if (ih.ih_type != PCI_INTX) {
|
||||
struct interrupt_controller *ic = sc->sc_msi_ic;
|
||||
bus_dma_segment_t seg;
|
||||
uint64_t addr, data;
|
||||
uint64_t addr = 0, data;
|
||||
|
||||
KASSERT(ic);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: agintc.c,v 1.54 2023/09/22 01:10:43 jsg Exp $ */
|
||||
/* $OpenBSD: agintc.c,v 1.55 2024/02/03 10:37:25 kettenis Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2007, 2009, 2011, 2017 Dale Rahn <drahn@dalerahn.com>
|
||||
* Copyright (c) 2018 Mark Kettenis <kettenis@openbsd.org>
|
||||
|
@ -1540,7 +1540,7 @@ struct agintc_msi_device {
|
|||
LIST_ENTRY(agintc_msi_device) md_list;
|
||||
|
||||
uint32_t md_deviceid;
|
||||
uint32_t md_eventid;
|
||||
uint32_t md_events;
|
||||
struct agintc_dmamem *md_itt;
|
||||
};
|
||||
|
||||
|
@ -1949,7 +1949,15 @@ agintc_intr_establish_msi(void *self, uint64_t *addr, uint64_t *data,
|
|||
if (md == NULL)
|
||||
return NULL;
|
||||
|
||||
eventid = md->md_eventid++;
|
||||
eventid = *addr;
|
||||
if (eventid > 0 && (md->md_events & (1U << eventid)))
|
||||
return NULL;
|
||||
for (; eventid < 32; eventid++) {
|
||||
if ((md->md_events & (1U << eventid)) == 0) {
|
||||
md->md_events |= (1U << eventid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (eventid >= 32)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: aplpcie.c,v 1.18 2023/12/28 13:32:56 kettenis Exp $ */
|
||||
/* $OpenBSD: aplpcie.c,v 1.19 2024/02/03 10:37:25 kettenis Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
|
||||
*
|
||||
|
@ -405,6 +405,7 @@ aplpcie_attach(struct device *parent, struct device *self, void *aux)
|
|||
sc->sc_pc.pc_intr_v = sc;
|
||||
sc->sc_pc.pc_intr_map = aplpcie_intr_map;
|
||||
sc->sc_pc.pc_intr_map_msi = _pci_intr_map_msi;
|
||||
sc->sc_pc.pc_intr_map_msivec = _pci_intr_map_msivec;
|
||||
sc->sc_pc.pc_intr_map_msix = _pci_intr_map_msix;
|
||||
sc->sc_pc.pc_intr_string = aplpcie_intr_string;
|
||||
sc->sc_pc.pc_intr_establish = aplpcie_intr_establish;
|
||||
|
@ -939,6 +940,7 @@ aplpcie_intr_establish(void *v, pci_intr_handle_t ih, int level,
|
|||
if (ih.ih_type != PCI_INTX) {
|
||||
uint64_t addr, data;
|
||||
|
||||
addr = data = 0;
|
||||
cookie = fdt_intr_establish_msi_cpu(sc->sc_node, &addr,
|
||||
&data, level, ci, func, arg, name);
|
||||
if (cookie == NULL)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: pci_machdep.c,v 1.5 2021/03/22 20:30:21 patrick Exp $ */
|
||||
/* $OpenBSD: pci_machdep.c,v 1.6 2024/02/03 10:37:25 kettenis Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2019 Mark Kettenis <kettenis@openbsd.org>
|
||||
|
@ -24,16 +24,45 @@
|
|||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/pci/pcireg.h>
|
||||
|
||||
int
|
||||
pci_intr_enable_msivec(struct pci_attach_args *pa, int num_vec)
|
||||
{
|
||||
pci_chipset_tag_t pc = pa->pa_pc;
|
||||
pcitag_t tag = pa->pa_tag;
|
||||
pcireg_t reg;
|
||||
int mmc, mme, off;
|
||||
|
||||
if ((pa->pa_flags & PCI_FLAGS_MSI_ENABLED) == 0 ||
|
||||
pci_get_capability(pc, tag, PCI_CAP_MSI, &off, ®) == 0)
|
||||
return 1;
|
||||
|
||||
mmc = ((reg & PCI_MSI_MC_MMC_MASK) >> PCI_MSI_MC_MMC_SHIFT);
|
||||
if (num_vec > (1 << mmc))
|
||||
return 1;
|
||||
|
||||
mme = ((reg & PCI_MSI_MC_MME_MASK) >> PCI_MSI_MC_MME_SHIFT);
|
||||
while ((1 << mme) < num_vec)
|
||||
mme++;
|
||||
reg &= ~PCI_MSI_MC_MME_MASK;
|
||||
reg |= (mme << PCI_MSI_MC_MME_SHIFT);
|
||||
pci_conf_write(pc, tag, off, reg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
pci_msi_enable(pci_chipset_tag_t pc, pcitag_t tag,
|
||||
bus_addr_t addr, uint32_t data)
|
||||
{
|
||||
pcireg_t reg;
|
||||
int off;
|
||||
int mme, off;
|
||||
|
||||
if (pci_get_capability(pc, tag, PCI_CAP_MSI, &off, ®) == 0)
|
||||
panic("%s: no msi capability", __func__);
|
||||
|
||||
mme = ((reg & PCI_MSI_MC_MME_MASK) >> PCI_MSI_MC_MME_SHIFT);
|
||||
data &= ~((1 << mme) - 1);
|
||||
|
||||
if (reg & PCI_MSI_MC_C64) {
|
||||
pci_conf_write(pc, tag, off + PCI_MSI_MA, addr);
|
||||
pci_conf_write(pc, tag, off + PCI_MSI_MAU32, addr >> 32);
|
||||
|
@ -128,6 +157,33 @@ _pci_intr_map_msi(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
|
|||
|
||||
ihp->ih_pc = pa->pa_pc;
|
||||
ihp->ih_tag = pa->pa_tag;
|
||||
ihp->ih_intrpin = 0;
|
||||
ihp->ih_type = PCI_MSI;
|
||||
ihp->ih_dmat = pa->pa_dmat;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_pci_intr_map_msivec(struct pci_attach_args *pa, int vec,
|
||||
pci_intr_handle_t *ihp)
|
||||
{
|
||||
pci_chipset_tag_t pc = pa->pa_pc;
|
||||
pcitag_t tag = pa->pa_tag;
|
||||
pcireg_t reg;
|
||||
int mme, off;
|
||||
|
||||
if ((pa->pa_flags & PCI_FLAGS_MSIVEC_ENABLED) == 0 ||
|
||||
pci_get_capability(pc, tag, PCI_CAP_MSI, &off, ®) == 0)
|
||||
return -1;
|
||||
|
||||
mme = ((reg & PCI_MSI_MC_MME_MASK) >> PCI_MSI_MC_MME_SHIFT);
|
||||
if (vec >= (1 << mme))
|
||||
return -1;
|
||||
|
||||
ihp->ih_pc = pa->pa_pc;
|
||||
ihp->ih_tag = pa->pa_tag;
|
||||
ihp->ih_intrpin = vec;
|
||||
ihp->ih_type = PCI_MSI;
|
||||
ihp->ih_dmat = pa->pa_dmat;
|
||||
|
||||
|
@ -164,4 +220,3 @@ _pci_intr_map_msix(struct pci_attach_args *pa, int vec,
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: pci_machdep.h,v 1.11 2021/06/11 12:23:52 kettenis Exp $ */
|
||||
/* $OpenBSD: pci_machdep.h,v 1.12 2024/02/03 10:37:26 kettenis Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
|
||||
|
@ -70,6 +70,8 @@ struct machine_pci_chipset {
|
|||
pci_intr_handle_t *);
|
||||
int (*pc_intr_map_msi)(struct pci_attach_args *,
|
||||
pci_intr_handle_t *);
|
||||
int (*pc_intr_map_msivec)(struct pci_attach_args *,
|
||||
int, pci_intr_handle_t *);
|
||||
int (*pc_intr_map_msix)(struct pci_attach_args *,
|
||||
int, pci_intr_handle_t *);
|
||||
const char *(*pc_intr_string)(void *, pci_intr_handle_t);
|
||||
|
@ -102,6 +104,8 @@ struct machine_pci_chipset {
|
|||
(*(c)->pa_pc->pc_intr_map)((c), (ihp))
|
||||
#define pci_intr_map_msi(c, ihp) \
|
||||
(*(c)->pa_pc->pc_intr_map_msi)((c), (ihp))
|
||||
#define pci_intr_map_msivec(c, vec, ihp) \
|
||||
(*(c)->pa_pc->pc_intr_map_msivec)((c), (vec), (ihp))
|
||||
#define pci_intr_map_msix(c, vec, ihp) \
|
||||
(*(c)->pa_pc->pc_intr_map_msix)((c), (vec), (ihp))
|
||||
#define pci_intr_string(c, ih) \
|
||||
|
@ -123,10 +127,14 @@ struct machine_pci_chipset {
|
|||
void pci_mcfg_init(bus_space_tag_t, bus_addr_t, int, int, int);
|
||||
pci_chipset_tag_t pci_lookup_segment(int);
|
||||
|
||||
int pci_intr_enable_msivec(struct pci_attach_args *, int);
|
||||
|
||||
void pci_msi_enable(pci_chipset_tag_t, pcitag_t, bus_addr_t, uint32_t);
|
||||
void pci_msix_enable(pci_chipset_tag_t, pcitag_t, bus_space_tag_t,
|
||||
int, bus_addr_t, uint32_t);
|
||||
int _pci_intr_map_msi(struct pci_attach_args *, pci_intr_handle_t *);
|
||||
int _pci_intr_map_msivec(struct pci_attach_args *, int,
|
||||
pci_intr_handle_t *);
|
||||
int _pci_intr_map_msix(struct pci_attach_args *, int, pci_intr_handle_t *);
|
||||
|
||||
#define __HAVE_PCI_MSIX
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue