• Paul Mackerras's avatar
    KVM: PPC: Book3S HV: Cope with host using large decrementer mode · 1e0d7996
    Paul Mackerras authored
    commit 2f272463 upstream.
    
    POWER9 introduces a new mode for the decrementer register, called
    large decrementer mode, in which the decrementer counter is 56 bits
    wide rather than 32, and reads are sign-extended rather than
    zero-extended.  For the decrementer, this new mode is optional and
    controlled by a bit in the LPCR.  The hypervisor decrementer (HDEC)
    is 56 bits wide on POWER9 and has no mode control.
    
    Since KVM code reads and writes the decrementer and hypervisor
    decrementer registers in a few places, it needs to be aware of the
    need to treat the decrementer value as a 64-bit quantity, and only do
    a 32-bit sign extension when large decrementer mode is not in effect.
    Similarly, the HDEC should always be treated as a 64-bit quantity on
    POWER9.  We define a new EXTEND_HDEC macro to encapsulate the feature
    test for POWER9 and the sign extension.
    
    To enable the sign extension to be removed in large decrementer mode,
    we test the LPCR_LD bit in the host LPCR image stored in the struct
    kvm for the guest.  If is set then large decrementer mode is enabled
    and the sign extension should be skipped.
    
    This is partly based on an earlier patch by Oliver O'Halloran.
    Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    1e0d7996
book3s_hv_rmhandlers.S 72.6 KB