diff --git a/sys/dev/acpica/acpi_apei.c b/sys/dev/acpica/acpi_apei.c index 5cc08b4137f1..c67b02ca84ac 100644 --- a/sys/dev/acpica/acpi_apei.c +++ b/sys/dev/acpica/acpi_apei.c @@ -348,7 +348,7 @@ apei_ge_handler(struct apei_ge *ge, bool copy) uint32_t sev; int i, c, off; - if (ges->BlockStatus == 0) + if (ges == NULL || ges->BlockStatus == 0) return (0); c = (ges->BlockStatus >> 4) & 0x3ff; @@ -363,7 +363,8 @@ apei_ge_handler(struct apei_ge *ge, bool copy) /* Acknowledge the error has been processed. */ ges->BlockStatus = 0; - if (!copy && ge->v1.Header.Type == ACPI_HEST_TYPE_GENERIC_ERROR_V2) { + if (!copy && ge->v1.Header.Type == ACPI_HEST_TYPE_GENERIC_ERROR_V2 && + ge->res2) { uint64_t val = READ8(ge->res2, 0); val &= ge->v2.ReadAckPreserve; val |= ge->v2.ReadAckWrite; @@ -395,7 +396,7 @@ apei_nmi_handler(void) return (0); ges = (ACPI_HEST_GENERIC_STATUS *)ge->buf; - if (ges->BlockStatus == 0) + if (ges == NULL || ges->BlockStatus == 0) return (0); /* If ACPI told the error is fatal -- make it so. */ @@ -409,7 +410,8 @@ apei_nmi_handler(void) /* Acknowledge the error has been processed. */ ges->BlockStatus = 0; - if (ge->v1.Header.Type == ACPI_HEST_TYPE_GENERIC_ERROR_V2) { + if (ge->v1.Header.Type == ACPI_HEST_TYPE_GENERIC_ERROR_V2 && + ge->res2) { uint64_t val = READ8(ge->res2, 0); val &= ge->v2.ReadAckPreserve; val |= ge->v2.ReadAckWrite; @@ -608,13 +610,19 @@ apei_attach(device_t dev) ge->res_rid = rid++; acpi_bus_alloc_gas(dev, &ge->res_type, &ge->res_rid, &ge->v1.ErrorStatusAddress, &ge->res, 0); + if (ge->res) { + ge->buf = pmap_mapdev_attr(READ8(ge->res, 0), + ge->v1.ErrorBlockLength, VM_MEMATTR_WRITE_COMBINING); + } else { + device_printf(dev, "Can't allocate status resource.\n"); + } if (ge->v1.Header.Type == ACPI_HEST_TYPE_GENERIC_ERROR_V2) { ge->res2_rid = rid++; acpi_bus_alloc_gas(dev, &ge->res2_type, &ge->res2_rid, &ge->v2.ReadAckRegister, &ge->res2, 0); + if (ge->res2 == NULL) + device_printf(dev, "Can't allocate ack resource.\n"); } - ge->buf = pmap_mapdev_attr(READ8(ge->res, 0), - ge->v1.ErrorBlockLength, VM_MEMATTR_WRITE_COMBINING); if (ge->v1.Notify.Type == ACPI_HEST_NOTIFY_POLLED) { callout_init(&ge->poll, 1); callout_reset(&ge->poll, @@ -652,7 +660,10 @@ apei_detach(device_t dev) while ((ge = TAILQ_FIRST(&sc->ges)) != NULL) { TAILQ_REMOVE(&sc->ges, ge, link); - bus_release_resource(dev, ge->res_type, ge->res_rid, ge->res); + if (ge->res) { + bus_release_resource(dev, ge->res_type, + ge->res_rid, ge->res); + } if (ge->res2) { bus_release_resource(dev, ge->res2_type, ge->res2_rid, ge->res2); @@ -663,7 +674,10 @@ apei_detach(device_t dev) swi_remove(&ge->swi_ih); free(ge->copybuf, M_DEVBUF); } - pmap_unmapdev((vm_offset_t)ge->buf, ge->v1.ErrorBlockLength); + if (ge->buf) { + pmap_unmapdev((vm_offset_t)ge->buf, + ge->v1.ErrorBlockLength); + } free(ge, M_DEVBUF); } return (0); diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 379ad427b6b6..89e484404727 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -408,7 +408,7 @@ static int pci_enable_ari = 1; SYSCTL_INT(_hw_pci, OID_AUTO, enable_ari, CTLFLAG_RDTUN, &pci_enable_ari, 0, "Enable support for PCIe Alternative RID Interpretation"); -int pci_enable_aspm; +int pci_enable_aspm = 1; SYSCTL_INT(_hw_pci, OID_AUTO, enable_aspm, CTLFLAG_RDTUN, &pci_enable_aspm, 0, "Enable support for PCIe Active State Power Management"); diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 4bf772a9a94a..8f3e9f90325d 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -860,8 +860,6 @@ sysctl_devctl_queue(SYSCTL_HANDLER_ARGS) * The devctl protocol relies on quoted strings having matching quotes. * This routine quotes any internal quotes so the resulting string * is safe to pass to snprintf to construct, for example pnp info strings. - * Strings are always terminated with a NUL, but may be truncated if longer - * than @p len bytes after quotes. * * @param sb sbuf to place the characters into * @param src Original buffer. diff --git a/sys/powerpc/aim/mmu_radix.c b/sys/powerpc/aim/mmu_radix.c index ee30c3e52b82..1b7d7412b234 100644 --- a/sys/powerpc/aim/mmu_radix.c +++ b/sys/powerpc/aim/mmu_radix.c @@ -183,7 +183,7 @@ ttusync(void) * Invalidate a range of translations */ -static __inline void +static __always_inline void radix_tlbie(uint8_t ric, uint8_t prs, uint16_t is, uint32_t pid, uint32_t lpid, vm_offset_t va, uint16_t ap) { @@ -715,7 +715,7 @@ static struct md_page pv_dummy; static int powernv_enabled = 1; -static inline void +static __always_inline void tlbiel_radix_set_isa300(uint32_t set, uint32_t is, uint32_t pid, uint32_t ric, uint32_t prs) { diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c index d05bd3d6040a..8d22ea4251e7 100644 --- a/usr.bin/script/script.c +++ b/usr.bin/script/script.c @@ -427,6 +427,33 @@ consume(FILE *fp, off_t len, char *buf, int reg) } \ } while (0/*CONSTCOND*/) +static void +termset(void) +{ + struct termios traw; + + if (tcgetattr(STDOUT_FILENO, &tt) == -1) { + if (errno == EBADF) + err(1, "%d not valid fd", STDOUT_FILENO); + /* errno == ENOTTY */ + return; + } + ttyflg = 1; + traw = tt; + cfmakeraw(&traw); + traw.c_lflag |= ISIG; + (void)tcsetattr(STDOUT_FILENO, TCSANOW, &traw); +} + +static void +termreset(void) +{ + if (ttyflg) { + tcsetattr(STDOUT_FILENO, TCSADRAIN, &tt); + ttyflg = 0; + } +} + static void playback(FILE *fp) { @@ -470,8 +497,11 @@ playback(FILE *fp) ctime(&tclock)); tsi = tso; (void)consume(fp, stamp.scr_len, buf, reg); + termset(); + atexit(termreset); break; case 'e': + termreset(); if (!qflg) (void)printf("\nScript done on %s", ctime(&tclock));