From patchwork Sun May 28 13:57:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: BALATON Zoltan X-Patchwork-Id: 13257827 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C0DF5C77B7E for ; Sun, 28 May 2023 13:58:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3GuG-0007q7-HM; Sun, 28 May 2023 09:58:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3GuE-0007oi-Vz for qemu-devel@nongnu.org; Sun, 28 May 2023 09:57:59 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3Gu9-00009k-N8 for qemu-devel@nongnu.org; Sun, 28 May 2023 09:57:58 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 757D374638A; Sun, 28 May 2023 15:57:50 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 4145574633D; Sun, 28 May 2023 15:57:50 +0200 (CEST) From: BALATON Zoltan Subject: [PATCH] hw/acpi: Fix PM control register access MIME-Version: 1.0 To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Michael S. Tsirkin , Igor Mammedov , Ani Sinha Message-Id: <20230528135750.4145574633D@zero.eik.bme.hu> Date: Sun, 28 May 2023 15:57:50 +0200 (CEST) Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On pegasos2 which has ACPI as part of VT8231 south bridge the board firmware writes PM control register by accessing the second byte so addr will be 1. This wasn't handled correctly and the write went to addr 0 instead. This fixes ACPI shutdown with pegasos2 firmware. Signed-off-by: BALATON Zoltan --- This is replacing the previous attempt which changed enduanness to NATIVE_ENDIAN that was found to be wrong. I'm still not sure what's happening as these functions are called with addr = 1 and size = 2 but maybe the guest really does word access to addr 1 when wanting to write 1 byte. This fixes the problem and should not break anything else but please review. hw/acpi/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/acpi/core.c b/hw/acpi/core.c index 6da275c599..bbc599a252 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -593,13 +593,13 @@ void acpi_pm1_cnt_update(ACPIREGS *ar, static uint64_t acpi_pm_cnt_read(void *opaque, hwaddr addr, unsigned width) { ACPIREGS *ar = opaque; - return ar->pm1.cnt.cnt; + return ar->pm1.cnt.cnt >> addr * 8; } static void acpi_pm_cnt_write(void *opaque, hwaddr addr, uint64_t val, unsigned width) { - acpi_pm1_cnt_write(opaque, val); + acpi_pm1_cnt_write(opaque, val << addr * 8); } static const MemoryRegionOps acpi_pm_cnt_ops = {