hv: pm: fix acpi register size calculation

The Access Size field in ACPI GAS was not introduced before ACPI 2.0,
Errata C. It is not guaranteed to be a non zero value, like QEMU
programs it to 0. As it only indicates how many bytes it can be
accessed at once, the register size should be determined by Bit Width
and Bit Offset. In IO space, Bit Offset is always 0, the size is
(Bit Width / 8).

Tracked-On: #8771
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
Reviewed-by: Li Fei <fei1.li@intel.com>
This commit is contained in:
Jiaqing Zhao 2025-02-19 06:23:23 +00:00
parent ef49283e51
commit e5c9a743e6
No known key found for this signature in database
GPG Key ID: 9A7FFB14458B0C3A

View File

@ -251,13 +251,11 @@ static bool pm1ab_io_write(struct acrn_vcpu *vcpu, uint16_t addr, size_t width,
static void register_gas_io_handler(struct acrn_vm *vm, uint32_t pio_idx, const struct acrn_acpi_generic_address *gas)
{
uint8_t io_len[5] = {0U, 1U, 2U, 4U, 8U};
struct vm_io_range gas_io;
if ((gas->address != 0UL) && (gas->space_id == SPACE_SYSTEM_IO)
&& (gas->access_size != 0U) && (gas->access_size <= 4U)) {
if ((gas->address != 0UL) && (gas->space_id == SPACE_SYSTEM_IO) && (gas->bit_width != 0U)) {
gas_io.base = (uint16_t)gas->address;
gas_io.len = io_len[gas->access_size];
gas_io.len = gas->bit_width / 8;
register_pio_emulation_handler(vm, pio_idx, &gas_io, &pm1ab_io_read, &pm1ab_io_write);