Skip to content
  • Peter Maydell's avatar
    5202861b
    semihosting: Allow optional use of semihosting from userspace · 5202861b
    Peter Maydell authored
    
    
    Currently our semihosting implementations generally prohibit use of
    semihosting calls in system emulation from the guest userspace.  This
    is a very long standing behaviour justified originally "to provide
    some semblance of security" (since code with access to the
    semihosting ABI can do things like read and write arbitrary files on
    the host system).  However, it is sometimes useful to be able to run
    trusted guest code which performs semihosting calls from guest
    userspace, notably for test code.  Add a command line suboption to
    the existing semihosting-config option group so that you can
    explicitly opt in to semihosting from guest userspace with
     -semihosting-config userspace=on
    
    (There is no equivalent option for the user-mode emulator, because
    there by definition all code runs in userspace and has access to
    semihosting already.)
    
    This commit adds the infrastructure for the command line option and
    adds a bool 'is_user' parameter to the function
    semihosting_userspace_enabled() that target code can use to check
    whether it should be permitting the semihosting call for userspace.
    It mechanically makes all the callsites pass 'false', so they
    continue checking "is semihosting enabled in general".  Subsequent
    commits will make each target that implements semihosting honour the
    userspace=on option by passing the correct value and removing
    whatever "don't do this for userspace" checking they were doing by
    hand.
    
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    Acked-by: default avatarAlex Bennée <alex.bennee@linaro.org>
    Reviewed-by: default avatarAlistair Francis <alistair.francis@wdc.com>
    Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
    Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
    Message-Id: <20220822141230.3658237-2-peter.maydell@linaro.org>
    Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
    5202861b
    semihosting: Allow optional use of semihosting from userspace
    Peter Maydell authored
    
    
    Currently our semihosting implementations generally prohibit use of
    semihosting calls in system emulation from the guest userspace.  This
    is a very long standing behaviour justified originally "to provide
    some semblance of security" (since code with access to the
    semihosting ABI can do things like read and write arbitrary files on
    the host system).  However, it is sometimes useful to be able to run
    trusted guest code which performs semihosting calls from guest
    userspace, notably for test code.  Add a command line suboption to
    the existing semihosting-config option group so that you can
    explicitly opt in to semihosting from guest userspace with
     -semihosting-config userspace=on
    
    (There is no equivalent option for the user-mode emulator, because
    there by definition all code runs in userspace and has access to
    semihosting already.)
    
    This commit adds the infrastructure for the command line option and
    adds a bool 'is_user' parameter to the function
    semihosting_userspace_enabled() that target code can use to check
    whether it should be permitting the semihosting call for userspace.
    It mechanically makes all the callsites pass 'false', so they
    continue checking "is semihosting enabled in general".  Subsequent
    commits will make each target that implements semihosting honour the
    userspace=on option by passing the correct value and removing
    whatever "don't do this for userspace" checking they were doing by
    hand.
    
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    Acked-by: default avatarAlex Bennée <alex.bennee@linaro.org>
    Reviewed-by: default avatarAlistair Francis <alistair.francis@wdc.com>
    Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
    Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
    Message-Id: <20220822141230.3658237-2-peter.maydell@linaro.org>
    Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
Loading