• Dave Martin's avatar
    KVM: arm64: Support runtime sysreg visibility filtering · 7f34e409
    Dave Martin authored
    Some optional features of the Arm architecture add new system
    registers that are not present in the base architecture.
    
    Where these features are optional for the guest, the visibility of
    these registers may need to depend on some runtime configuration,
    such as a flag passed to KVM_ARM_VCPU_INIT.
    
    For example, ZCR_EL1 and ID_AA64ZFR0_EL1 need to be hidden if SVE
    is not enabled for the guest, even though these registers may be
    present in the hardware and visible to the host at EL2.
    
    Adding special-case checks all over the place for individual
    registers is going to get messy as the number of conditionally-
    visible registers grows.
    
    In order to help solve this problem, this patch adds a new sysreg
    method visibility() that can be used to hook in any needed runtime
    visibility checks.  This method can currently return
    REG_HIDDEN_USER to inhibit enumeration and ioctl access to the
    register for userspace, and REG_HIDDEN_GUEST to inhibit runtime
    access by the guest using MSR/MRS.  Wrappers are added to allow
    these flags to be conveniently queried.
    
    This approach allows a conditionally modified view of individual
    system registers such as the CPU ID registers, in addition to
    completely hiding register where appropriate.
    Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
    Tested-by: default avatarzhang.lei <zhang.lei@jp.fujitsu.com>
    Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
    7f34e409
sys_regs.c 73.4 KB