Skip to content
  • Peter Maydell's avatar
    e4b0bb80
    hw/arm/boot: Drop existing dtb /psci node rather than retaining it · e4b0bb80
    Peter Maydell authored
    
    
    If we're using PSCI emulation, we add a /psci node to the device tree
    we pass to the guest.  At the moment, if the dtb already has a /psci
    node in it, we retain it, rather than replacing it. (This behaviour
    was added in commit c39770cd in 2018.)
    
    This is a problem if the existing node doesn't match our PSCI
    emulation.  In particular, it might specify the wrong method (HVC vs
    SMC), or wrong function IDs for cpu_suspend/cpu_off/etc, in which
    case the guest will not get the behaviour it wants when it makes PSCI
    calls.
    
    An example of this is trying to boot the highbank or midway board
    models using the device tree supplied in the kernel sources: this
    device tree includes a /psci node that specifies function IDs that
    don't match the (PSCI 0.2 compliant) IDs that QEMU uses.  The dtb
    cpu_suspend function ID happens to match the PSCI 0.2 cpu_off ID, so
    the guest hangs after booting when the kernel tries to idle the CPU
    and instead it gets turned off.
    
    Instead of retaining an existing /psci node, delete it entirely
    and replace it with a node whose properties match QEMU's PSCI
    emulation behaviour. This matches the way we handle /memory nodes,
    where we also delete any existing nodes and write in ones that
    match the way QEMU is going to behave.
    
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
    Reviewed-by: default avatarNiek Linnenbank <nieklinnenbank@gmail.com>
    Tested-by: default avatarEdgar E. Iglesias <edgar.iglesias@xilinx.com>
    Tested-by: default avatarCédric Le Goater <clg@kaod.org>
    Tested-by: default avatarNiek Linnenbank <nieklinnenbank@gmail.com>
    Message-id: 20220127154639.2090164-17-peter.maydell@linaro.org
    e4b0bb80
    hw/arm/boot: Drop existing dtb /psci node rather than retaining it
    Peter Maydell authored
    
    
    If we're using PSCI emulation, we add a /psci node to the device tree
    we pass to the guest.  At the moment, if the dtb already has a /psci
    node in it, we retain it, rather than replacing it. (This behaviour
    was added in commit c39770cd in 2018.)
    
    This is a problem if the existing node doesn't match our PSCI
    emulation.  In particular, it might specify the wrong method (HVC vs
    SMC), or wrong function IDs for cpu_suspend/cpu_off/etc, in which
    case the guest will not get the behaviour it wants when it makes PSCI
    calls.
    
    An example of this is trying to boot the highbank or midway board
    models using the device tree supplied in the kernel sources: this
    device tree includes a /psci node that specifies function IDs that
    don't match the (PSCI 0.2 compliant) IDs that QEMU uses.  The dtb
    cpu_suspend function ID happens to match the PSCI 0.2 cpu_off ID, so
    the guest hangs after booting when the kernel tries to idle the CPU
    and instead it gets turned off.
    
    Instead of retaining an existing /psci node, delete it entirely
    and replace it with a node whose properties match QEMU's PSCI
    emulation behaviour. This matches the way we handle /memory nodes,
    where we also delete any existing nodes and write in ones that
    match the way QEMU is going to behave.
    
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
    Reviewed-by: default avatarNiek Linnenbank <nieklinnenbank@gmail.com>
    Tested-by: default avatarEdgar E. Iglesias <edgar.iglesias@xilinx.com>
    Tested-by: default avatarCédric Le Goater <clg@kaod.org>
    Tested-by: default avatarNiek Linnenbank <nieklinnenbank@gmail.com>
    Message-id: 20220127154639.2090164-17-peter.maydell@linaro.org
Loading