From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C33C3C28CBC for ; Wed, 6 May 2020 20:23:48 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 820E4206D5 for ; Wed, 6 May 2020 20:23:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="L7F+KnKf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 820E4206D5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jWQa3-0001zo-L8 for qemu-devel@archiver.kernel.org; Wed, 06 May 2020 16:23:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jWQZA-0000kK-2f for qemu-devel@nongnu.org; Wed, 06 May 2020 16:22:52 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:40836 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jWQZ8-0008MO-5Y for qemu-devel@nongnu.org; Wed, 06 May 2020 16:22:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588796568; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/soio6tKr4qkWf6sw7ixJ8P4+vJX0+Y+vZgXjVDXGFU=; b=L7F+KnKf38KEs5yMxwG0ouIKaD/8plXrwENwBF6iu67jb8lCLHQ2//bbBBU21dTQhaVU2G wWiioCclMwNF8myo0t3qVvRvPMq0ekrGVovP8eAZSt2mC1KLVdfdsd6Mvmmmpx+j1Yo89M nAJOkQQHynbapXTXigaCcv5ZnhhZQh0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-109-z0OftuiBNmWjereaK3Pt3Q-1; Wed, 06 May 2020 16:22:44 -0400 X-MC-Unique: z0OftuiBNmWjereaK3Pt3Q-1 Received: by mail-wm1-f71.google.com with SMTP id h184so1855739wmf.5 for ; Wed, 06 May 2020 13:22:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=U+1bCSviFwcdpe08mjhiimwDdJ7yxmjwmBMzGnTCUCI=; b=RiAmxWGHYuC+dKeEh+qFJQ5+yqG09kpdLJeGT/MtXwbIjdzCovvSMpTrBhl1dab1/l Fb+54JnRQNqtXKbBDHLKPnDu3bKJyE4IoTY19+sCV9Qu5zZLyyUqj4fekAi1QLRJIEWg j8iR19xYNYmvCPdSnUyMWirBsTvPPUltBtxhS0k2mNRpn2kCHratfQeV9sr1YFhSguIx E3TTlAr76s6HlEvopMy3HIVeJUOIcP1KpPN6wfJTaLKL0/Dcct6KybvX5m5NEAl0Lqmr tiqNuWZ8jQKblcyyRjKyQRzLe3ZonPmK9MnB9TeGhjjKffODAhb6c0KwdaURfTzQjdUS 3dxw== X-Gm-Message-State: AGi0PubRLdv02liJWA8fyrKCrbTug6gmKjeKlrQWHuBlm96rmrA4Y2tG lZ344ibZR3ddV8MSW7NqPz7tlxI6xxlgXZxpcnsQIBL7JGD2AJST/m0BuC8o6hNrBMy9noz5AAD A4xaw84Nndc04v5s= X-Received: by 2002:adf:ab57:: with SMTP id r23mr12312823wrc.180.1588796563252; Wed, 06 May 2020 13:22:43 -0700 (PDT) X-Google-Smtp-Source: APiQypKsG/6G0HlElYxbWp6ObmCaRkdfbfKZhgV0OSZkWsR5YxOIPzhRBRDsOzaIXyA2tNa7IaCe1g== X-Received: by 2002:adf:ab57:: with SMTP id r23mr12312789wrc.180.1588796562842; Wed, 06 May 2020 13:22:42 -0700 (PDT) Received: from redhat.com (bzq-109-66-7-121.red.bezeqint.net. [109.66.7.121]) by smtp.gmail.com with ESMTPSA id z18sm4203551wrw.41.2020.05.06.13.22.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 13:22:42 -0700 (PDT) Date: Wed, 6 May 2020 16:22:39 -0400 From: "Michael S. Tsirkin" To: Dongjiu Geng Subject: Re: [PATCH v25 04/10] ACPI: Build related register address fields via hardware error fw_cfg blob Message-ID: <20200506162234-mutt-send-email-mst@kernel.org> References: <20200410114639.32844-1-gengdongjiu@huawei.com> <20200410114639.32844-5-gengdongjiu@huawei.com> MIME-Version: 1.0 In-Reply-To: <20200410114639.32844-5-gengdongjiu@huawei.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Received-SPF: pass client-ip=207.211.31.81; envelope-from=mst@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/06 02:39:40 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: , Cc: fam@euphon.net, peter.maydell@linaro.org, xiaoguangrong.eric@gmail.com, kvm@vger.kernel.org, mtosatti@redhat.com, qemu-devel@nongnu.org, ehabkost@redhat.com, linuxarm@huawei.com, shannon.zhaosl@gmail.com, zhengxiang9@huawei.com, qemu-arm@nongnu.org, Jonathan.Cameron@huawei.com, pbonzini@redhat.com, imammedo@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Fri, Apr 10, 2020 at 07:46:33PM +0800, Dongjiu Geng wrote: > This patch builds error_block_address and read_ack_register fields > in hardware errors table , the error_block_address points to Generic > Error Status Block(GESB) via bios_linker. The max size for one GESB > is 1kb, For more detailed information, please refer to > document: docs/specs/acpi_hest_ghes.rst >=20 > Now we only support one Error source, if necessary, we can extend to > support more. >=20 > Suggested-by: Laszlo Ersek > Signed-off-by: Xiang Zheng > Reviewed-by: Jonathan Cameron > Reviewed-by: Igor Mammedov > Signed-off-by: Dongjiu Geng Reviewed-by: Michael S. Tsirkin > --- > change since v24: > 1.move acpi_add_table() to the patch that adds acpi_build_hest() > --- > default-configs/arm-softmmu.mak | 1 + > hw/acpi/Kconfig | 4 ++ > hw/acpi/Makefile.objs | 1 + > hw/acpi/aml-build.c | 2 + > hw/acpi/ghes.c | 89 +++++++++++++++++++++++++++++++++++= ++++++ > hw/arm/virt-acpi-build.c | 5 +++ > include/hw/acpi/aml-build.h | 1 + > include/hw/acpi/ghes.h | 28 +++++++++++++ > 8 files changed, 131 insertions(+) > create mode 100644 hw/acpi/ghes.c > create mode 100644 include/hw/acpi/ghes.h >=20 > diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmm= u.mak > index 36a0e89..8fc09a4 100644 > --- a/default-configs/arm-softmmu.mak > +++ b/default-configs/arm-softmmu.mak > @@ -42,3 +42,4 @@ CONFIG_FSL_IMX7=3Dy > CONFIG_FSL_IMX6UL=3Dy > CONFIG_SEMIHOSTING=3Dy > CONFIG_ALLWINNER_H3=3Dy > +CONFIG_ACPI_APEI=3Dy > diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig > index 54209c6..1932f66 100644 > --- a/hw/acpi/Kconfig > +++ b/hw/acpi/Kconfig > @@ -28,6 +28,10 @@ config ACPI_HMAT > bool > depends on ACPI > =20 > +config ACPI_APEI > + bool > + depends on ACPI > + > config ACPI_PCI > bool > depends on ACPI && PCI > diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs > index 777da07..28c5ddb 100644 > --- a/hw/acpi/Makefile.objs > +++ b/hw/acpi/Makefile.objs > @@ -8,6 +8,7 @@ common-obj-$(CONFIG_ACPI_NVDIMM) +=3D nvdimm.o > common-obj-$(CONFIG_ACPI_VMGENID) +=3D vmgenid.o > common-obj-$(CONFIG_ACPI_HW_REDUCED) +=3D generic_event_device.o > common-obj-$(CONFIG_ACPI_HMAT) +=3D hmat.o > +common-obj-$(CONFIG_ACPI_APEI) +=3D ghes.o > common-obj-$(call lnot,$(CONFIG_ACPI_X86)) +=3D acpi-stub.o > common-obj-$(call lnot,$(CONFIG_PC)) +=3D acpi-x86-stub.o > =20 > diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c > index 2c3702b..3681ec6 100644 > --- a/hw/acpi/aml-build.c > +++ b/hw/acpi/aml-build.c > @@ -1578,6 +1578,7 @@ void acpi_build_tables_init(AcpiBuildTables *tables= ) > tables->table_data =3D g_array_new(false, true /* clear */, 1); > tables->tcpalog =3D g_array_new(false, true /* clear */, 1); > tables->vmgenid =3D g_array_new(false, true /* clear */, 1); > + tables->hardware_errors =3D g_array_new(false, true /* clear */, 1); > tables->linker =3D bios_linker_loader_init(); > } > =20 > @@ -1588,6 +1589,7 @@ void acpi_build_tables_cleanup(AcpiBuildTables *tab= les, bool mfre) > g_array_free(tables->table_data, true); > g_array_free(tables->tcpalog, mfre); > g_array_free(tables->vmgenid, mfre); > + g_array_free(tables->hardware_errors, mfre); > } > =20 > /* > diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c > new file mode 100644 > index 0000000..e1b3f8f > --- /dev/null > +++ b/hw/acpi/ghes.c > @@ -0,0 +1,89 @@ > +/* > + * Support for generating APEI tables and recording CPER for Guests > + * > + * Copyright (c) 2020 HUAWEI TECHNOLOGIES CO., LTD. > + * > + * Author: Dongjiu Geng > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + > + * You should have received a copy of the GNU General Public License alo= ng > + * with this program; if not, see . > + */ > + > +#include "qemu/osdep.h" > +#include "qemu/units.h" > +#include "hw/acpi/ghes.h" > +#include "hw/acpi/aml-build.h" > + > +#define ACPI_GHES_ERRORS_FW_CFG_FILE "etc/hardware_errors" > +#define ACPI_GHES_DATA_ADDR_FW_CFG_FILE "etc/hardware_errors_addr" > + > +/* The max size in bytes for one error block */ > +#define ACPI_GHES_MAX_RAW_DATA_LENGTH (1 * KiB) > + > +/* Now only support ARMv8 SEA notification type error source */ > +#define ACPI_GHES_ERROR_SOURCE_COUNT 1 > + > +/* > + * Build table for the hardware error fw_cfg blob. > + * Initialize "etc/hardware_errors" and "etc/hardware_errors_addr" fw_cf= g blobs. > + * See docs/specs/acpi_hest_ghes.rst for blobs format. > + */ > +void build_ghes_error_table(GArray *hardware_errors, BIOSLinker *linker) > +{ > + int i, error_status_block_offset; > + > + /* Build error_block_address */ > + for (i =3D 0; i < ACPI_GHES_ERROR_SOURCE_COUNT; i++) { > + build_append_int_noprefix(hardware_errors, 0, sizeof(uint64_t)); > + } > + > + /* Build read_ack_register */ > + for (i =3D 0; i < ACPI_GHES_ERROR_SOURCE_COUNT; i++) { > + /* > + * Initialize the value of read_ack_register to 1, so GHES can b= e > + * writeable after (re)boot. > + * ACPI 6.2: 18.3.2.8 Generic Hardware Error Source version 2 > + * (GHESv2 - Type 10) > + */ > + build_append_int_noprefix(hardware_errors, 1, sizeof(uint64_t)); > + } > + > + /* Generic Error Status Block offset in the hardware error fw_cfg bl= ob */ > + error_status_block_offset =3D hardware_errors->len; > + > + /* Reserve space for Error Status Data Block */ > + acpi_data_push(hardware_errors, > + ACPI_GHES_MAX_RAW_DATA_LENGTH * ACPI_GHES_ERROR_SOURCE_COUNT); > + > + /* Tell guest firmware to place hardware_errors blob into RAM */ > + bios_linker_loader_alloc(linker, ACPI_GHES_ERRORS_FW_CFG_FILE, > + hardware_errors, sizeof(uint64_t), false); > + > + for (i =3D 0; i < ACPI_GHES_ERROR_SOURCE_COUNT; i++) { > + /* > + * Tell firmware to patch error_block_address entries to point t= o > + * corresponding "Generic Error Status Block" > + */ > + bios_linker_loader_add_pointer(linker, > + ACPI_GHES_ERRORS_FW_CFG_FILE, sizeof(uint64_t) * i, > + sizeof(uint64_t), ACPI_GHES_ERRORS_FW_CFG_FILE, > + error_status_block_offset + i * ACPI_GHES_MAX_RAW_DATA_LENGT= H); > + } > + > + /* > + * tell firmware to write hardware_errors GPA into > + * hardware_errors_addr fw_cfg, once the former has been initialized= . > + */ > + bios_linker_loader_write_pointer(linker, ACPI_GHES_DATA_ADDR_FW_CFG_= FILE, > + 0, sizeof(uint64_t), ACPI_GHES_ERRORS_FW_CFG_FILE, 0); > +} > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c > index 7ef0733..cc6ffcd 100644 > --- a/hw/arm/virt-acpi-build.c > +++ b/hw/arm/virt-acpi-build.c > @@ -48,6 +48,7 @@ > #include "sysemu/reset.h" > #include "kvm_arm.h" > #include "migration/vmstate.h" > +#include "hw/acpi/ghes.h" > =20 > #define ARM_SPI_BASE 32 > =20 > @@ -817,6 +818,10 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuil= dTables *tables) > acpi_add_table(table_offsets, tables_blob); > build_spcr(tables_blob, tables->linker, vms); > =20 > + if (vms->ras) { > + build_ghes_error_table(tables->hardware_errors, tables->linker); > + } > + > if (ms->numa_state->num_nodes > 0) { > acpi_add_table(table_offsets, tables_blob); > build_srat(tables_blob, tables->linker, vms); > diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h > index de4a406..8f13620 100644 > --- a/include/hw/acpi/aml-build.h > +++ b/include/hw/acpi/aml-build.h > @@ -220,6 +220,7 @@ struct AcpiBuildTables { > GArray *rsdp; > GArray *tcpalog; > GArray *vmgenid; > + GArray *hardware_errors; > BIOSLinker *linker; > } AcpiBuildTables; > =20 > diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h > new file mode 100644 > index 0000000..50379b0 > --- /dev/null > +++ b/include/hw/acpi/ghes.h > @@ -0,0 +1,28 @@ > +/* > + * Support for generating APEI tables and recording CPER for Guests > + * > + * Copyright (c) 2020 HUAWEI TECHNOLOGIES CO., LTD. > + * > + * Author: Dongjiu Geng > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + > + * You should have received a copy of the GNU General Public License alo= ng > + * with this program; if not, see . > + */ > + > +#ifndef ACPI_GHES_H > +#define ACPI_GHES_H > + > +#include "hw/acpi/bios-linker-loader.h" > + > +void build_ghes_error_table(GArray *hardware_errors, BIOSLinker *linker)= ; > +#endif > --=20 > 1.8.3.1