From nobody Fri Dec 19 14:31:23 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=1624293280; cv=none; d=zohomail.com; s=zohoarc; b=UTS/M/bJte2EZObJM8Olqz4W4I2UZDvyFR0MeNxjbgiitGi+bbnESifGOZJAoNVA+2MvaxTg6UzIpoITeS0NgImv0sdYNhv+tLkeD4anlQ0c1wth+XaVQqIDWErk152l11i3aHekO/9adJLW7rhqPwpvnNBf7LyDMqqh+LddLLk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624293280; 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=mBhVixobv9evawUK2zvyZAJjFLCIliw3J90zk8FNS6M=; b=FAhyUblbrSD15PO2SHN3WUE+3eHUz9IqMEWhFuy/omfiSk627poyIInsZQDec9X2d6LCMmOgQ8HLnHPb2X3RFV/FOmy3dkJKB4wGyHDwkqzym4ilQExcCqGHIUv/Nj5pF5+vrFawPLTU/AqRqgKfaxsUz+k66jjLnbkhNKXrocA= 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 1624293280731116.7797053295509; Mon, 21 Jun 2021 09:34:40 -0700 (PDT) Received: from localhost ([::1]:47586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvMsh-0007K9-Jd for importer@patchew.org; Mon, 21 Jun 2021 12:34:39 -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) 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) 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-Google-Smtp-Source: ABdhPJyw9chfFF/HYNNwoy72KPJPRy6+Ub1gWEUcRr0XjeU7qsp8YcSIwCZQHc2qDRyYgnq/3UoPaA== X-Received: by 2002:a05:600c:2306:: with SMTP id 6mr27189745wmo.32.1624292916652; 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 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::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" 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(+) 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 { =20 typedef struct AcpiGhesState { uint64_t ghes_addr_le; + bool present; /* True if GHES is present at all on this board */ } AcpiGhesState; =20 void build_ghes_error_table(GArray *hardware_errors, BIOSLinker *linker); @@ -72,4 +73,12 @@ void acpi_build_hest(GArray *table_data, BIOSLinker *lin= ker, 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 p= hysical_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, FWCfgStat= e *s, /* 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); + + ags->present =3D true; } =20 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) =20 return ret; } + +bool acpi_ghes_present(void) +{ + AcpiGedState *acpi_ged_state; + AcpiGhesState *ags; + + acpi_ged_state =3D ACPI_GED(object_resolve_path_type("", TYPE_ACPI_GED, + NULL)); + + if (!acpi_ged_state) { + return false; + } + ags =3D &acpi_ged_state->ghes_state; + return ags->present; +} --=20 2.20.1