diff options
author | Lv Zheng <lv.zheng@intel.com> | 2015-12-31 11:29:50 +0800 |
---|---|---|
committer | Lv Zheng <lv.zheng@intel.com> | 2016-11-09 04:05:05 +0800 |
commit | f7e7a208521265b14bcd9bb632f99a433d4f3f09 (patch) | |
tree | 193d6745b702dc2c59c3c75388371a1671618b38 | |
parent | cfca5fb4c9c843c176e94a364c4b75b5d9b0f39e (diff) | |
download | acpica-f7e7a208521265b14bcd9bb632f99a433d4f3f09.tar.gz |
Hardware: Enhance AcpiHwValidateRegister() with AccessWidth/BitOffset awareness
This patch enhances AcpiHwValidateRegister() to sanitize register
accesses with awareness of AccessWidth and BitOffset. Lv Zheng.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
-rw-r--r-- | source/components/hardware/hwregs.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/source/components/hardware/hwregs.c b/source/components/hardware/hwregs.c index ffad33fcf..89094f4cf 100644 --- a/source/components/hardware/hwregs.c +++ b/source/components/hardware/hwregs.c @@ -163,6 +163,9 @@ AcpiHwValidateRegister ( UINT8 MaxBitWidth, UINT64 *Address) { + UINT8 BitWidth; + UINT8 AccessWidth; + /* Must have a valid pointer to a GAS structure */ @@ -192,24 +195,26 @@ AcpiHwValidateRegister ( return (AE_SUPPORT); } - /* Validate the BitWidth */ + /* Validate the AccessWidth */ - if ((Reg->BitWidth != 8) && - (Reg->BitWidth != 16) && - (Reg->BitWidth != 32) && - (Reg->BitWidth != MaxBitWidth)) + if (Reg->AccessWidth > 4) { ACPI_ERROR ((AE_INFO, - "Unsupported register bit width: 0x%X", Reg->BitWidth)); + "Unsupported register access width: 0x%X", Reg->AccessWidth)); return (AE_SUPPORT); } - /* Validate the BitOffset. Just a warning for now. */ + /* Validate the BitWidth, convert AccessWidth into number of bits */ - if (Reg->BitOffset != 0) + AccessWidth = Reg->AccessWidth ? Reg->AccessWidth : 1; + AccessWidth = 1 << (AccessWidth + 2); + BitWidth = ACPI_ROUND_UP (Reg->BitOffset + Reg->BitWidth, AccessWidth); + if (MaxBitWidth < BitWidth) { ACPI_WARNING ((AE_INFO, - "Unsupported register bit offset: 0x%X", Reg->BitOffset)); + "Requested bit width 0x%X is smaller than register bit width 0x%X", + MaxBitWidth, BitWidth)); + return (AE_SUPPORT); } return (AE_OK); |