Module Name: src Committed By: jmcneill Date: Tue Apr 28 10:04:32 UTC 2020
Modified Files: src/sys/dev/acpi: acpi_ec.c Log Message: kern/55206: acpibat reporting broken by acpi_ec.c r1.81 Assume byte instead of qword alignment of the buffer passed to the EC space handler. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/dev/acpi/acpi_ec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/acpi/acpi_ec.c diff -u src/sys/dev/acpi/acpi_ec.c:1.81 src/sys/dev/acpi/acpi_ec.c:1.82 --- src/sys/dev/acpi/acpi_ec.c:1.81 Sun Apr 12 01:12:03 2020 +++ src/sys/dev/acpi/acpi_ec.c Tue Apr 28 10:04:32 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_ec.c,v 1.81 2020/04/12 01:12:03 riastradh Exp $ */ +/* $NetBSD: acpi_ec.c,v 1.82 2020/04/28 10:04:32 jmcneill Exp $ */ /*- * Copyright (c) 2007 Joerg Sonnenberger <jo...@netbsd.org>. @@ -59,7 +59,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_ec.c,v 1.81 2020/04/12 01:12:03 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_ec.c,v 1.82 2020/04/28 10:04:32 jmcneill Exp $"); #include <sys/param.h> #include <sys/callout.h> @@ -659,32 +659,30 @@ acpiec_space_handler(uint32_t func, ACPI { device_t dv; ACPI_STATUS rv; - uint8_t addr, reg; + uint8_t addr, *buf; unsigned int i; - if (paddr > 0xff || width % 8 != 0 || width > sizeof(ACPI_INTEGER)*8 || + if (paddr > 0xff || width % 8 != 0 || value == NULL || arg == NULL || paddr + width / 8 > 0x100) return AE_BAD_PARAMETER; addr = paddr; dv = arg; + buf = (uint8_t *)value; rv = AE_OK; switch (func) { case ACPI_READ: - *value = 0; - for (i = 0; i < width; i += 8, ++addr) { - rv = acpiec_read(dv, addr, ®); + for (i = 0; i < width; i += 8, ++addr, ++buf) { + rv = acpiec_read(dv, addr, buf); if (rv != AE_OK) break; - *value |= (ACPI_INTEGER)reg << i; } break; case ACPI_WRITE: - for (i = 0; i < width; i += 8, ++addr) { - reg = (*value >> i) & 0xff; - rv = acpiec_write(dv, addr, reg); + for (i = 0; i < width; i += 8, ++addr, ++buf) { + rv = acpiec_write(dv, addr, *buf); if (rv != AE_OK) break; }