Skip to content
  • Peter Maydell's avatar
    61b82973
    hw/arm/highbank: Drop use of secure_board_setup · 61b82973
    Peter Maydell authored
    
    
    Guest code on highbank may make non-PSCI SMC calls in order to
    enable/disable the L2x0 cache controller (see the Linux kernel's
    arch/arm/mach-highbank/highbank.c highbank_l2c310_write_sec()
    function).  The ABI for this is documented in kernel commit
    8e56130dcb as being borrowed from the OMAP44xx ROM.  The OMAP44xx TRM
    documents this function ID as having no return value and potentially
    trashing all guest registers except SP and PC. For QEMU's purposes
    (where our L2x0 model is a stub and enabling or disabling it doesn't
    affect the guest behaviour) a simple "do nothing" SMC is fine.
    
    We currently implement this NOP behaviour using a little bit of
    Secure code we run before jumping to the guest kernel, which is
    written by arm_write_secure_board_setup_dummy_smc().  The code sets
    up a set of Secure vectors where the SMC entry point returns without
    doing anything.
    
    Now that the PSCI SMC emulation handles all SMC calls (setting r0 to
    an error code if the input r0 function identifier is not recognized),
    we can use that default behaviour as sufficient for the highbank
    cache controller call.  (Because the guest code assumes r0 has no
    interesting value on exit it doesn't matter that we set it to the
    error code).  We can therefore delete the highbank board code that
    sets secure_board_setup to true and writes the secure-code bootstub.
    
    (Note that because the OMAP44xx ABI puts function-identifiers in
    r12 and PSCI uses r0, we only avoid a clash because Linux's code
    happens to put the function-identifier in both registers. But this
    is true also when the kernel is running on real firmware that
    implements both ABIs as far as I can see.)
    
    This change fixes in passing booting on the 'midway' board model,
    which has been completely broken since we added support for Hyp
    mode to the Cortex-A15 CPU. When we did that boot.c was made to
    start running the guest code in Hyp mode; this includes the
    board_setup hook, which instantly UNDEFs because the NSACR is
    not accessible from Hyp. (Put another way, we never made the
    secure_board_setup hook support cope with Hyp mode.)
    
    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 avatarCédric Le Goater <clg@kaod.org>
    Tested-by: default avatarNiek Linnenbank <nieklinnenbank@gmail.com>
    Message-id: 20220127154639.2090164-12-peter.maydell@linaro.org
    61b82973
    hw/arm/highbank: Drop use of secure_board_setup
    Peter Maydell authored
    
    
    Guest code on highbank may make non-PSCI SMC calls in order to
    enable/disable the L2x0 cache controller (see the Linux kernel's
    arch/arm/mach-highbank/highbank.c highbank_l2c310_write_sec()
    function).  The ABI for this is documented in kernel commit
    8e56130dcb as being borrowed from the OMAP44xx ROM.  The OMAP44xx TRM
    documents this function ID as having no return value and potentially
    trashing all guest registers except SP and PC. For QEMU's purposes
    (where our L2x0 model is a stub and enabling or disabling it doesn't
    affect the guest behaviour) a simple "do nothing" SMC is fine.
    
    We currently implement this NOP behaviour using a little bit of
    Secure code we run before jumping to the guest kernel, which is
    written by arm_write_secure_board_setup_dummy_smc().  The code sets
    up a set of Secure vectors where the SMC entry point returns without
    doing anything.
    
    Now that the PSCI SMC emulation handles all SMC calls (setting r0 to
    an error code if the input r0 function identifier is not recognized),
    we can use that default behaviour as sufficient for the highbank
    cache controller call.  (Because the guest code assumes r0 has no
    interesting value on exit it doesn't matter that we set it to the
    error code).  We can therefore delete the highbank board code that
    sets secure_board_setup to true and writes the secure-code bootstub.
    
    (Note that because the OMAP44xx ABI puts function-identifiers in
    r12 and PSCI uses r0, we only avoid a clash because Linux's code
    happens to put the function-identifier in both registers. But this
    is true also when the kernel is running on real firmware that
    implements both ABIs as far as I can see.)
    
    This change fixes in passing booting on the 'midway' board model,
    which has been completely broken since we added support for Hyp
    mode to the Cortex-A15 CPU. When we did that boot.c was made to
    start running the guest code in Hyp mode; this includes the
    board_setup hook, which instantly UNDEFs because the NSACR is
    not accessible from Hyp. (Put another way, we never made the
    secure_board_setup hook support cope with Hyp mode.)
    
    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 avatarCédric Le Goater <clg@kaod.org>
    Tested-by: default avatarNiek Linnenbank <nieklinnenbank@gmail.com>
    Message-id: 20220127154639.2090164-12-peter.maydell@linaro.org
Loading