diff mbox series

[1/6] hw/arm/virt: Check that the CPU realize method succeeded

Message ID 1512670493-18114-2-git-send-email-peter.maydell@linaro.org
State Accepted
Commit c88bc3e0dbe7d460a0be723379fce63a9dc6a6f5
Headers show
Series arm: support -cpu max (and gic-version=max) | expand

Commit Message

Peter Maydell Dec. 7, 2017, 6:14 p.m. UTC
We were passing a NULL error pointer to the object_property_set_bool()
call that realizes the CPU object. This meant that we wouldn't detect
failure, and would plough blindly on to crash later trying to use a
NULL CPU object pointer. Detect errors and fail instead.

In particular, this will be necessary to detect the user error
of using "-cpu host" without "-enable-kvm" once we make the host
CPU type be registered unconditionally rather than only in
kvm_arch_init().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

---
 hw/arm/virt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.7.4

Comments

Eduardo Habkost Dec. 9, 2017, 1:08 a.m. UTC | #1
On Thu, Dec 07, 2017 at 06:14:48PM +0000, Peter Maydell wrote:
> We were passing a NULL error pointer to the object_property_set_bool()

> call that realizes the CPU object. This meant that we wouldn't detect

> failure, and would plough blindly on to crash later trying to use a

> NULL CPU object pointer. Detect errors and fail instead.

> 

> In particular, this will be necessary to detect the user error

> of using "-cpu host" without "-enable-kvm" once we make the host

> CPU type be registered unconditionally rather than only in

> kvm_arch_init().

> 

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>


-- 
Eduardo
Philippe Mathieu-Daudé Jan. 26, 2018, 2:32 p.m. UTC | #2
On 12/07/2017 03:14 PM, Peter Maydell wrote:
> We were passing a NULL error pointer to the object_property_set_bool()

> call that realizes the CPU object. This meant that we wouldn't detect

> failure, and would plough blindly on to crash later trying to use a

> NULL CPU object pointer. Detect errors and fail instead.

> 

> In particular, this will be necessary to detect the user error

> of using "-cpu host" without "-enable-kvm" once we make the host

> CPU type be registered unconditionally rather than only in

> kvm_arch_init().

> 

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


> ---

>  hw/arm/virt.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/hw/arm/virt.c b/hw/arm/virt.c

> index 151592b..62af013 100644

> --- a/hw/arm/virt.c

> +++ b/hw/arm/virt.c

> @@ -1402,7 +1402,7 @@ static void machvirt_init(MachineState *machine)

>                                       "secure-memory", &error_abort);

>          }

>  

> -        object_property_set_bool(cpuobj, true, "realized", NULL);

> +        object_property_set_bool(cpuobj, true, "realized", &error_fatal);

>          object_unref(cpuobj);

>      }

>      fdt_add_timer_nodes(vms);

>
Peter Maydell Jan. 26, 2018, 2:34 p.m. UTC | #3
On 26 January 2018 at 14:32, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> On 12/07/2017 03:14 PM, Peter Maydell wrote:

>> We were passing a NULL error pointer to the object_property_set_bool()

>> call that realizes the CPU object. This meant that we wouldn't detect

>> failure, and would plough blindly on to crash later trying to use a

>> NULL CPU object pointer. Detect errors and fail instead.

>>

>> In particular, this will be necessary to detect the user error

>> of using "-cpu host" without "-enable-kvm" once we make the host

>> CPU type be registered unconditionally rather than only in

>> kvm_arch_init().

>>

>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

>

> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


Thanks; I already put this patch in master (commit c88bc3e0dbe7), though.

-- PMM
diff mbox series

Patch

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 151592b..62af013 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1402,7 +1402,7 @@  static void machvirt_init(MachineState *machine)
                                      "secure-memory", &error_abort);
         }
 
-        object_property_set_bool(cpuobj, true, "realized", NULL);
+        object_property_set_bool(cpuobj, true, "realized", &error_fatal);
         object_unref(cpuobj);
     }
     fdt_add_timer_nodes(vms);