From patchwork Mon Jun 21 16:27:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 464535 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp2752025jao; Mon, 21 Jun 2021 09:33:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEzblabR5upQDiJKZasLSvzTIQaU5dazQdVb/5a4/aeamTcl8DHxzwH5P7WccgMHkomytw X-Received: by 2002:a05:6402:51cf:: with SMTP id r15mr22604176edd.263.1624293185220; Mon, 21 Jun 2021 09:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624293185; cv=none; d=google.com; s=arc-20160816; b=K63Ptkjzq+cT/wuaGx7SlA3XADK3oG12QywtyC6oZiV0Kkz9cCwmtUgytyuX7jtW+s jaiW3gic4Uq1l3BE1yMvWkVDuU1vXh1R9Rl6Wflz7aZ61S5k662H4zzxKGCvhJGj7ZrC dLnvTJVcvV4nz2/HLqWILe5jDbBAMY7AY/xINl/AxCK5pblNLb/3IXLGiNpEBOqcmbHS /227eFe3JD0A2gKLNWznsWyQmLZJr4C2gYJzBaNkBlAhmVWgmHwJeA3cHkussjugEwaF 51DoMTYSkKFNuorpjlvqEnJUPzSerGYR6KnWc+of72EmvAgZSGMJPeQ38FCcGzlR4+0z NJyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=mBhVixobv9evawUK2zvyZAJjFLCIliw3J90zk8FNS6M=; b=1JXIm35U/cTc5ljqjKItFRJvBREaF2ydJkkAnRlBVNXX3HBsXjKSRxDAbUBwireiqD 4pPO94UbtEpANXbZrCtnd+zIBWuwzBmcoheVNN6a5QUyLIveXYmIsdR6VuBsnVfSaDWY +U3IBTn4ACHJYO3vrgj+eA9/XeAT3n1FTLllUBf+9g8XINIlh9ttl55E4wyz0l72pHMz 3RoIcIi4SlTWSESi35VK7QIsbVN7SAfUsZFEQ0lKpuHMywXFY81iWe4KdmZABhaJilMv fNuHVz6UEtjQH0Jsy4aBoE6PN8lsOmlOIVmEc7wMcKqnPQNHF9yKNP7G6R2+w4qdzOT6 3juA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dhjarrI8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p7si17191445edq.96.2021.06.21.09.33.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jun 2021 09:33:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dhjarrI8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvMr9-0004cL-U4 for patch@linaro.org; Mon, 21 Jun 2021 12:33:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvMmw-0006zs-QR for qemu-devel@nongnu.org; Mon, 21 Jun 2021 12:28:42 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:53124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvMms-0007S8-1V for qemu-devel@nongnu.org; Mon, 21 Jun 2021 12:28:42 -0400 Received: by mail-wm1-x331.google.com with SMTP id n23so10946992wms.2 for ; Mon, 21 Jun 2021 09:28:37 -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=mBhVixobv9evawUK2zvyZAJjFLCIliw3J90zk8FNS6M=; b=dhjarrI8TnnODyU36HOJ9P88LTW5VYFVnT1dlxkw/6JFuHSgWGOuH7cflSXzneq2fv ClSDcNZuGkXldQGFn5hur15LgKYvpsUzeeRcr3diJdqIyNKlzl5HkcZdM9n5uChtbwaH UTtkq+/VnPxX81/tMNIVqiHMonFe+VYrB1k9tAGJpEg79vTT5VCYxNbXoLZrG8sX0fsy GiywPXkeHeyIItWw0ZAlwDZJGgmCTFqxsMogUCPMy40OTYbOnvYxHra59k6gKmmyyZnX zTaJl6laYpA+2ogodkOYcalo0fsDNXTJTHzaeZ2GBwpR/y25s3CdsW2WVUce22YSlDKu tPYg== 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=mBhVixobv9evawUK2zvyZAJjFLCIliw3J90zk8FNS6M=; b=Bvy3KB43p7OljrAqDW90tkEpwP5W/8MHX9HwdX7bTnBTJm5oRIrjMQZQmnn9JPJmm2 5s1cOU4UhI0eK08ba+rMQvSQWHujUdRqX05GeTRjYko/I2oUO151a5J8kJhuS4AoJZih 0htCJFJdH99O6YRkt4hoSTu+g8sFcsFVHDY0NzbO8ePAr7w7c9aMQfzJVTefahUkF8Gi K3XW6gKXGl2o/4l1AA+WwjTQS/v8rZ/79rWAfuhIUqXoG/M8oZISpLoTp4KVZPafa7jm ysL4TdzsCk1iJaIEdbZNaxoo2XZP7JqQaaLhF9xmVidPPJFEi2lEQ2wmhntGYqbBRKqM Qblg== X-Gm-Message-State: AOAM531kSj2SSWTv8hrtg9dMVk4GBaqVvSy7R2wZMxIvIlSV8k1T8dt3 xI6FAEMh+1mpkRhFJMYSkegavJQq+y9hmGi8 X-Received: by 2002:a05:600c:2306:: with SMTP id 6mr27189745wmo.32.1624292916652; Mon, 21 Jun 2021 09:28:36 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id n65sm11615496wme.21.2021.06.21.09.28.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 09:28:36 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/57] hw/acpi: Provide function acpi_ghes_present() Date: Mon, 21 Jun 2021 17:27:38 +0100 Message-Id: <20210621162833.32535-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210621162833.32535-1-peter.maydell@linaro.org> References: <20210621162833.32535-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.google.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, 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Allow code elsewhere in the system to check whether the ACPI GHES table is present, so it can determine whether it is OK to try to record an error by calling acpi_ghes_record_errors(). (We don't need to migrate the new 'present' field in AcpiGhesState, because it is set once at system initialization and doesn't change.) Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Dongjiu Geng Message-id: 20210603171259.27962-3-peter.maydell@linaro.org --- include/hw/acpi/ghes.h | 9 +++++++++ hw/acpi/ghes-stub.c | 5 +++++ hw/acpi/ghes.c | 17 +++++++++++++++++ 3 files changed, 31 insertions(+) -- 2.20.1 diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 2ae8bc1ded3..674f6958e90 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -64,6 +64,7 @@ enum { typedef struct AcpiGhesState { uint64_t ghes_addr_le; + bool present; /* True if GHES is present at all on this board */ } AcpiGhesState; void build_ghes_error_table(GArray *hardware_errors, BIOSLinker *linker); @@ -72,4 +73,12 @@ void acpi_build_hest(GArray *table_data, BIOSLinker *linker, void acpi_ghes_add_fw_cfg(AcpiGhesState *vms, FWCfgState *s, GArray *hardware_errors); int acpi_ghes_record_errors(uint8_t notify, uint64_t error_physical_addr); + +/** + * acpi_ghes_present: Report whether ACPI GHES table is present + * + * Returns: true if the system has an ACPI GHES table and it is + * safe to call acpi_ghes_record_errors() to record a memory error. + */ +bool acpi_ghes_present(void); #endif diff --git a/hw/acpi/ghes-stub.c b/hw/acpi/ghes-stub.c index 9faba043b85..c315de1802d 100644 --- a/hw/acpi/ghes-stub.c +++ b/hw/acpi/ghes-stub.c @@ -15,3 +15,8 @@ int acpi_ghes_record_errors(uint8_t source_id, uint64_t physical_address) { return -1; } + +bool acpi_ghes_present(void) +{ + return false; +} diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index a4dac6bf15e..a749b84d624 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -386,6 +386,8 @@ void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgState *s, /* Create a read-write fw_cfg file for Address */ fw_cfg_add_file_callback(s, ACPI_GHES_DATA_ADDR_FW_CFG_FILE, NULL, NULL, NULL, &(ags->ghes_addr_le), sizeof(ags->ghes_addr_le), false); + + ags->present = true; } int acpi_ghes_record_errors(uint8_t source_id, uint64_t physical_address) @@ -443,3 +445,18 @@ int acpi_ghes_record_errors(uint8_t source_id, uint64_t physical_address) return ret; } + +bool acpi_ghes_present(void) +{ + AcpiGedState *acpi_ged_state; + AcpiGhesState *ags; + + acpi_ged_state = ACPI_GED(object_resolve_path_type("", TYPE_ACPI_GED, + NULL)); + + if (!acpi_ged_state) { + return false; + } + ags = &acpi_ged_state->ghes_state; + return ags->present; +}