From nobody Sun Feb 8 18:08:43 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1687782633; cv=none; d=zohomail.com; s=zohoarc; b=XrKnjHTO8ZWtYisyOqfYY3txxr9BBAOvYqTQCRfBgpYhIzyFsFdcpQts0wIElPuDDgXNCfAK2/UNVB3ws3DddMpaIGrK9g0i5/bc7+CRnKtFMcDefkoU0izN19pe3E7SAX3M2Y2aKGUgaEvyNUNf75q3EVzH+sicBNSof8LtEpQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687782633; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p/UK6aQi1zp/6MKRVyY3fLV1bQBOfN+OI1GJ+WI2VHU=; b=TYPeKEatR0FRuAjBlRB5ap53zF+hyPEVN9/EohXd6Jl8CUz4KZMu+bGHa6i6tqPmlTRN3IJJYqyoxn/FKlRGQMpPg9RcotwC906x7H5VjkZnWImDdMFTgOgK1JPJlN5mkZB7adzz6WkgUd6lFLsc0+J8eN06mPzeIgMuxOPxrJc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1687782633084783.4009326737245; Mon, 26 Jun 2023 05:30:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qDlMF-0004WL-Te; Mon, 26 Jun 2023 08:30:17 -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 1qDlLU-0002ud-Rx for qemu-devel@nongnu.org; Mon, 26 Jun 2023 08:29:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qDlLS-00036X-CP for qemu-devel@nongnu.org; Mon, 26 Jun 2023 08:29:28 -0400 Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-470-XH8wV9X0NXSD-jPqPVMDiQ-1; Mon, 26 Jun 2023 08:29:24 -0400 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-4ecb00906d0so2231990e87.1 for ; Mon, 26 Jun 2023 05:29:24 -0700 (PDT) Received: from redhat.com ([2.52.156.102]) by smtp.gmail.com with ESMTPSA id v14-20020a1cf70e000000b003f9b2c602c0sm10542462wmh.37.2023.06.26.05.29.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 05:29:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687782565; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=p/UK6aQi1zp/6MKRVyY3fLV1bQBOfN+OI1GJ+WI2VHU=; b=UbiQM+Nz+RZnYjyib34D1jANsJ8L46RWWhTmQrXkG43vjtyBMsZ+majZGqpTn3a6p+b4Ue dc/lE49StefqX5HIj1XeEOdr5eNSzGIfT9x9f8IjCyMD3OPMMb43oNKaqREc51sWZmoJON Pn/TlkShDZrLl8+2I+g3m35a2o4Xv7I= X-MC-Unique: XH8wV9X0NXSD-jPqPVMDiQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687782563; x=1690374563; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=p/UK6aQi1zp/6MKRVyY3fLV1bQBOfN+OI1GJ+WI2VHU=; b=aue3879HYlogO9sR3eX1AfIV+SHP32vh2nRNmP3D0cN8IuxQ/WlEPSPDbZIUEH/8u/ UUJqYJCP56h25mxAlAeuuR0mdX4u6ILcgLyYBqfLmiLc1iax8kUcW8NI0A2xo9seBLz7 BjsWiOfvKF2WuVzo/81n7XFEzjCPiLOfnbrERHl3NJhjYojF+a2cNL5Ia3MQVDGWQgPU 5bH2XYYiA7aKVGYiu76U9j8m8Pe4Xf9X9j4SNQoBV3rEoREefkBtnQOKQ1ozhKfu+2L0 ztqSwAvw97DLsOItUTcnerJiaRTEsK0kKN/BClxF351orB+FXlBPm9x+nGN8RK87DANI 8FWA== X-Gm-Message-State: AC+VfDznnjgoIA0oE8vrFXLmfDRctUHWWcSdF4pjVxBgj7cwdY3YUhJW cMSYwhpoVGMOPuihNncRBko/BJi/GL+1vDvLFe1CbOSZGTtxfLlgHuoczIhIdpuKZquLi1KjsQo xaKZ8V5LfY2fgO0rmXe5rO7eTIqpc7EGo2++avmEckvQPSNpqBjdZ2pxvHqR2DB6vyNsZ X-Received: by 2002:a05:6512:39cc:b0:4f9:652d:e839 with SMTP id k12-20020a05651239cc00b004f9652de839mr8404629lfu.50.1687782562724; Mon, 26 Jun 2023 05:29:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6JYEqCW8s6dsRVRA89s0FV/LBfa6EoiScvesSPBx1SSIjHaFAakeJgH6TR41K73XcLUeRq3w== X-Received: by 2002:a05:6512:39cc:b0:4f9:652d:e839 with SMTP id k12-20020a05651239cc00b004f9652de839mr8404614lfu.50.1687782562361; Mon, 26 Jun 2023 05:29:22 -0700 (PDT) Date: Mon, 26 Jun 2023 08:29:19 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , BALATON Zoltan , Igor Mammedov , Ani Sinha Subject: [PULL 30/53] hw/acpi: Fix PM control register access Message-ID: <3d563fc68732179b86eff2b87f2d7dbef150315f.1687782442.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1687782634493100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan 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. Remove the acpi_pm1_cnt_write() function which is used only once and does not take addr into account and handle non-zero address in acpi_pm_cnt_{read|write}. This fixes ACPI shutdown with pegasos2 firmware. The issue below is possibly related to the same memory core bug. Link: https://gitlab.com/qemu-project/qemu/-/issues/360 Signed-off-by: BALATON Zoltan Message-Id: <20230607200125.A9988746377@zero.eik.bme.hu> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov --- hw/acpi/core.c | 56 +++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/hw/acpi/core.c b/hw/acpi/core.c index 6da275c599..00b1e79a30 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -551,8 +551,35 @@ void acpi_pm_tmr_reset(ACPIREGS *ar) } =20 /* ACPI PM1aCNT */ -static void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val) +void acpi_pm1_cnt_update(ACPIREGS *ar, + bool sci_enable, bool sci_disable) { + /* ACPI specs 3.0, 4.7.2.5 */ + if (ar->pm1.cnt.acpi_only) { + return; + } + + if (sci_enable) { + ar->pm1.cnt.cnt |=3D ACPI_BITMASK_SCI_ENABLE; + } else if (sci_disable) { + ar->pm1.cnt.cnt &=3D ~ACPI_BITMASK_SCI_ENABLE; + } +} + +static uint64_t acpi_pm_cnt_read(void *opaque, hwaddr addr, unsigned width) +{ + ACPIREGS *ar =3D opaque; + return ar->pm1.cnt.cnt >> addr * 8; +} + +static void acpi_pm_cnt_write(void *opaque, hwaddr addr, uint64_t val, + unsigned width) +{ + ACPIREGS *ar =3D opaque; + + if (addr =3D=3D 1) { + val =3D val << 8 | (ar->pm1.cnt.cnt & 0xff); + } ar->pm1.cnt.cnt =3D val & ~(ACPI_BITMASK_SLEEP_ENABLE); =20 if (val & ACPI_BITMASK_SLEEP_ENABLE) { @@ -575,33 +602,6 @@ static void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t = val) } } =20 -void acpi_pm1_cnt_update(ACPIREGS *ar, - bool sci_enable, bool sci_disable) -{ - /* ACPI specs 3.0, 4.7.2.5 */ - if (ar->pm1.cnt.acpi_only) { - return; - } - - if (sci_enable) { - ar->pm1.cnt.cnt |=3D ACPI_BITMASK_SCI_ENABLE; - } else if (sci_disable) { - ar->pm1.cnt.cnt &=3D ~ACPI_BITMASK_SCI_ENABLE; - } -} - -static uint64_t acpi_pm_cnt_read(void *opaque, hwaddr addr, unsigned width) -{ - ACPIREGS *ar =3D opaque; - return ar->pm1.cnt.cnt; -} - -static void acpi_pm_cnt_write(void *opaque, hwaddr addr, uint64_t val, - unsigned width) -{ - acpi_pm1_cnt_write(opaque, val); -} - static const MemoryRegionOps acpi_pm_cnt_ops =3D { .read =3D acpi_pm_cnt_read, .write =3D acpi_pm_cnt_write, --=20 MST