From nobody Fri Dec 19 14:29:32 2025 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1589467358; cv=none; d=zohomail.com; s=zohoarc; b=ZaRJl277o/EH8hWPCkNeaCiwT+i+IU5jqmRvpz/0p3QCwMgQHlnzIe90jq8T/0lfztvyFDAzfKZpysk9OafxXGJneoz7ERa8xVcrezppKKm+u5ukvxz2xClvrDR+shuh7XXGmay7tzN63lMS+mdLDxGjpwq/SRVsXlxOKJRtV88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589467358; h=Content-Transfer-Encoding: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=WElA4C7QqPHgi5yCVB6e73Tx0Mqbzxjdbg2stZVJDhM=; b=ZAsfOTnFNRJO19grqPdWee7CcCQX0wqpojMN3V0C88947PLonUtsJ91fPtEI51AY+EmfdC5iZpQCHrrYxCnnr7UpxIFCJ6NQxq5k43bDi+XJrCf7rPhGMNSf2wnWqG7bN8Uq4UrVu+XLpACXYjHruG+lbxLN5HkIZoiBRNkYkOw= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589467358627673.7125227353663; Thu, 14 May 2020 07:42:38 -0700 (PDT) Received: from localhost ([::1]:40284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZF4H-00086J-La for importer@patchew.org; Thu, 14 May 2020 10:42:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZEkc-0003Wt-PF for qemu-devel@nongnu.org; Thu, 14 May 2020 10:22:18 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:38926) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jZEkZ-0005w2-6Q for qemu-devel@nongnu.org; Thu, 14 May 2020 10:22:18 -0400 Received: by mail-wm1-x332.google.com with SMTP id w64so628510wmg.4 for ; Thu, 14 May 2020 07:22:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id 88sm4077443wrq.77.2020.05.14.07.22.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 May 2020 07:22:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=WElA4C7QqPHgi5yCVB6e73Tx0Mqbzxjdbg2stZVJDhM=; b=dFiR1MogyIl92c2dVVGVz4qfXkMpCVOZZtn3GqKBuOQdDWx2sqHHW9rkwM1Nkgv78/ ehEWBBJHMiM4AC8RfTBBwGNL52VIoLNhMpNZjiIJKgXTdmds1ij80zYmnkyMyzgqhYK0 T3Sg/MQxSCjD5fvOLdvUj1G1rdxg5VGOIfXuVwHGP5GarKrWvYZeSPvwycfDdb+Qtu4j sSLnH49CXkw2VBWTs/BYrJT/ZPo59wj8BkGB1WG5nwrV7N1g/FxnzigfAL5o0FyCqziq uEt64rzn3KOO0GzCu1G7VHsP8o+Rc6xUWoPdTsRLmJZrpwVUDNfvaXbeTV7pq3tBqWAh vH3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WElA4C7QqPHgi5yCVB6e73Tx0Mqbzxjdbg2stZVJDhM=; b=RI8QVgMkVhbbdFqyT+TPZ9RxJ4xixfr9zy7mlZ69s86sqPWlceE9zjPg44o0f1Nk1j ub9u76Pz/8fk0iZb2UAQgn4fFBh5bhQuxP5L2VlCTj15ExUFsvc+bYEDFBGSM2GNuW4T EcP+iBONsRHCsmtgGqr5qKL2LMM0rcDy511mYbBDe5zTwAVsEDjLdQTbhprSQp7Cz3gA U8UFtNAq61WoKk5nObV7xIyVlCRa2lOgQzRoEHpdkQGY0Z6lA2zKs9o1EG7wVwfpBF3e E31EsgTOhaIWJfokJLaMr/c2y6Vy5F3cD6YVcAQUd5+qOjZZPvp/PO+K7mhJDLBK+hs0 IOIQ== X-Gm-Message-State: AGi0PuZTk6i3JlaVtI8A275zRv45nBtFeRmmJH6O/LevSeQ4ld6x9WzF 6vT7wrQgASajOgwAZtsogvNntPK+l0+d0A== X-Google-Smtp-Source: APiQypLfeX9zP8ci4ec6o9axgS5P/6pqCAwBAvQ8VauYaWutT/fUeWd7vLGTJl1puovHFjLyArEV9A== X-Received: by 2002:a05:600c:218e:: with SMTP id e14mr51472731wme.140.1589466132174; Thu, 14 May 2020 07:22:12 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 24/45] ACPI: Record the Generic Error Status Block address Date: Thu, 14 May 2020 15:21:17 +0100 Message-Id: <20200514142138.20875-25-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200514142138.20875-1-peter.maydell@linaro.org> References: <20200514142138.20875-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Dongjiu Geng Record the GHEB address via fw_cfg file, when recording a error to CPER, it will use this address to find out Generic Error Data Entries and write the error. In order to avoid migration failure, make hardware error table address to a part of GED device instead of global variable, then this address will be migrated to target QEMU. Acked-by: Xiang Zheng Signed-off-by: Dongjiu Geng Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Message-id: 20200512030609.19593-7-gengdongjiu@huawei.com Signed-off-by: Peter Maydell --- include/hw/acpi/generic_event_device.h | 2 ++ include/hw/acpi/ghes.h | 6 ++++++ hw/acpi/generic_event_device.c | 19 +++++++++++++++++++ hw/acpi/ghes.c | 14 ++++++++++++++ hw/arm/virt-acpi-build.c | 8 ++++++++ 5 files changed, 49 insertions(+) diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/gener= ic_event_device.h index 9eb86ca4fd9..83917de0242 100644 --- a/include/hw/acpi/generic_event_device.h +++ b/include/hw/acpi/generic_event_device.h @@ -61,6 +61,7 @@ =20 #include "hw/sysbus.h" #include "hw/acpi/memory_hotplug.h" +#include "hw/acpi/ghes.h" =20 #define ACPI_POWER_BUTTON_DEVICE "PWRB" =20 @@ -96,6 +97,7 @@ typedef struct AcpiGedState { GEDState ged_state; uint32_t ged_event_bitmap; qemu_irq irq; + AcpiGhesState ghes_state; } AcpiGedState; =20 void build_ged_aml(Aml *table, const char* name, HotplugHandler *hotplug_d= ev, diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 18debd8cf7c..a3420fc9be8 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -62,6 +62,12 @@ enum { ACPI_HEST_SRC_ID_RESERVED, }; =20 +typedef struct AcpiGhesState { + uint64_t ghes_addr_le; +} AcpiGhesState; + void build_ghes_error_table(GArray *hardware_errors, BIOSLinker *linker); void acpi_build_hest(GArray *table_data, BIOSLinker *linker); +void acpi_ghes_add_fw_cfg(AcpiGhesState *vms, FWCfgState *s, + GArray *hardware_errors); #endif diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 5d17f78a1e0..b1cbdd86b66 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -247,6 +247,24 @@ static const VMStateDescription vmstate_ged_state =3D { } }; =20 +static bool ghes_needed(void *opaque) +{ + AcpiGedState *s =3D opaque; + return s->ghes_state.ghes_addr_le; +} + +static const VMStateDescription vmstate_ghes_state =3D { + .name =3D "acpi-ged/ghes", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D ghes_needed, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT(ghes_state, AcpiGedState, 1, + vmstate_ghes_state, AcpiGhesState), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_acpi_ged =3D { .name =3D "acpi-ged", .version_id =3D 1, @@ -257,6 +275,7 @@ static const VMStateDescription vmstate_acpi_ged =3D { }, .subsections =3D (const VMStateDescription * []) { &vmstate_memhp_state, + &vmstate_ghes_state, NULL } }; diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index 091fd87094e..e74af23c366 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -24,6 +24,8 @@ #include "hw/acpi/ghes.h" #include "hw/acpi/aml-build.h" #include "qemu/error-report.h" +#include "hw/acpi/generic_event_device.h" +#include "hw/nvram/fw_cfg.h" =20 #define ACPI_GHES_ERRORS_FW_CFG_FILE "etc/hardware_errors" #define ACPI_GHES_DATA_ADDR_FW_CFG_FILE "etc/hardware_errors_addr" @@ -213,3 +215,15 @@ void acpi_build_hest(GArray *table_data, BIOSLinker *l= inker) build_header(linker, table_data, (void *)(table_data->data + hest_star= t), "HEST", table_data->len - hest_start, 1, NULL, NULL); } + +void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgState *s, + GArray *hardware_error) +{ + /* Create a read-only fw_cfg file for GHES */ + fw_cfg_add_file(s, ACPI_GHES_ERRORS_FW_CFG_FILE, hardware_error->data, + hardware_error->len); + + /* Create a read-write fw_cfg file for Address */ + fw_cfg_add_file_callback(s, ACPI_GHES_DATA_ADDR_FW_CFG_FILE, NULL, NUL= L, + NULL, &(ags->ghes_addr_le), sizeof(ags->ghes_addr_le), false); +} diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index ef94e034f6d..1b0a584c7b6 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -917,6 +917,7 @@ void virt_acpi_setup(VirtMachineState *vms) { AcpiBuildTables tables; AcpiBuildState *build_state; + AcpiGedState *acpi_ged_state; =20 if (!vms->fw_cfg) { trace_virt_acpi_setup(); @@ -947,6 +948,13 @@ void virt_acpi_setup(VirtMachineState *vms) fw_cfg_add_file(vms->fw_cfg, ACPI_BUILD_TPMLOG_FILE, tables.tcpalog->d= ata, acpi_data_len(tables.tcpalog)); =20 + if (vms->ras) { + assert(vms->acpi_dev); + acpi_ged_state =3D ACPI_GED(vms->acpi_dev); + acpi_ghes_add_fw_cfg(&acpi_ged_state->ghes_state, + vms->fw_cfg, tables.hardware_errors); + } + build_state->rsdp_mr =3D acpi_add_rom_blob(virt_acpi_build_update, build_state, tables.rsdp, ACPI_BUILD_RSDP_FILE, 0); --=20 2.20.1