[PATCH 12/15] acpi/ghes: don't crash QEMU if ghes GED is not found

Mauro Carvalho Chehab posted 15 patches 3 weeks, 6 days ago
There is a newer version of this series
[PATCH 12/15] acpi/ghes: don't crash QEMU if ghes GED is not found
Posted by Mauro Carvalho Chehab 3 weeks, 6 days ago
Instead, produce an error and continue working

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 hw/acpi/ghes.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c
index 3af1cd16d4d7..209095f67e9a 100644
--- a/hw/acpi/ghes.c
+++ b/hw/acpi/ghes.c
@@ -418,7 +418,10 @@ void ghes_record_cper_errors(const void *cper, size_t len,
 
     acpi_ged_state = ACPI_GED(object_resolve_path_type("", TYPE_ACPI_GED,
                                                        NULL));
-    g_assert(acpi_ged_state);
+    if (!acpi_ged_state) {
+        error_setg(errp, "Can't find ACPI_GED object");
+        return;
+    }
     ags = &acpi_ged_state->ghes_state;
 
     get_ghes_offsets(le64_to_cpu(ags->ghes_addr_le),
-- 
2.46.1
Re: [PATCH 12/15] acpi/ghes: don't crash QEMU if ghes GED is not found
Posted by Jonathan Cameron 3 weeks, 5 days ago
On Wed, 25 Sep 2024 06:04:17 +0200
Mauro Carvalho Chehab <mchehab+huawei@kernel.org> wrote:

> Instead, produce an error and continue working
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Make sense as defense in depth. Can we actually hit this for existing
systems, or is the injection stuff disabled if the ged isn't configured?

Jonathan

> ---
>  hw/acpi/ghes.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c
> index 3af1cd16d4d7..209095f67e9a 100644
> --- a/hw/acpi/ghes.c
> +++ b/hw/acpi/ghes.c
> @@ -418,7 +418,10 @@ void ghes_record_cper_errors(const void *cper, size_t len,
>  
>      acpi_ged_state = ACPI_GED(object_resolve_path_type("", TYPE_ACPI_GED,
>                                                         NULL));
> -    g_assert(acpi_ged_state);
> +    if (!acpi_ged_state) {
> +        error_setg(errp, "Can't find ACPI_GED object");
> +        return;
> +    }
>      ags = &acpi_ged_state->ghes_state;
>  
>      get_ghes_offsets(le64_to_cpu(ags->ghes_addr_le),
Re: [PATCH 12/15] acpi/ghes: don't crash QEMU if ghes GED is not found
Posted by Mauro Carvalho Chehab 3 weeks, 5 days ago
Em Thu, 26 Sep 2024 13:09:09 +0100
Jonathan Cameron <Jonathan.Cameron@Huawei.com> escreveu:

> On Wed, 25 Sep 2024 06:04:17 +0200
> Mauro Carvalho Chehab <mchehab+huawei@kernel.org> wrote:
> 
> > Instead, produce an error and continue working
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>  
> Make sense as defense in depth. Can we actually hit this for existing
> systems, or is the injection stuff disabled if the ged isn't configured?

What happens is that:

- with memory errors, this logic at acpi_ghes_memory_errors() will
  report the error, just like error_report():

	    if (errp) {
	        error_report_err(errp);
	        return -1;
	    }

  so, no practical changes.

- for injections via script, this will return the error via QMP
  interface, preventing the guest crash.

The script can then handle it the way it wants (right now, it just
prints the error).

Thanks,
Mauro