• Paul Mackerras's avatar
    KVM: PPC: Fetch prefixed instructions from the guest · 953e3739
    Paul Mackerras authored
    In order to handle emulation of prefixed instructions in the guest,
    this first makes vcpu->arch.last_inst be an unsigned long, i.e. 64
    bits on 64-bit platforms.  For prefixed instructions, the upper 32
    bits are used for the prefix and the lower 32 bits for the suffix, and
    both halves are byte-swapped if the guest endianness differs from the
    host.
    
    Next, vcpu->arch.emul_inst is now 64 bits wide, to match the HEIR
    register on POWER10.  Like HEIR, for a prefixed instruction it is
    defined to have the prefix is in the top 32 bits and the suffix in the
    bottom 32 bits, with both halves in the correct byte order.
    
    kvmppc_get_last_inst is extended on 64-bit machines to put the prefix
    and suffix in the right places in the ppc_inst_t being returned.
    
    kvmppc_load_last_inst now returns the instruction in an unsigned long
    in the same format as vcpu->arch.last_inst.  It makes the decision
    about whether to fetch a suffix based on the SRR1_PREFIXED bit in the
    MSR image stored in the vcpu struct, which generally comes from SRR1
    or HSRR1 on an interrupt.  This bit is defined in Power ISA v3.1B to
    be set if the interrupt occurred due to a prefixed instruction and
    cleared otherwise for all interrupts except for instruction storage
    interrupt, which does not come to the hypervisor.  It is set to zero
    for asynchronous interrupts such as external interrupts.  In previous
    ISA versions it was always set to 0 for all interrupts except
    instruction storage interrupt.
    
    The code in book3s_hv_rmhandlers.S that loads the faulting instruction
    on a HDSI is only used on POWER8 and therefore doesn't ever need to
    load a suffix.
    
    [npiggin@gmail.com - check that the is-prefixed bit in SRR1 matches the
    type of instruction that was fetched.]
    Reviewed-by: default avatarNicholas Piggin <npiggin@gmail.com>
    Tested-by: default avatarNicholas Piggin <npiggin@gmail.com>
    Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Link: https://msgid.link/ZAgsq9h1CCzouQuV@cleo
    953e3739
emulate_loadstore.c 9.1 KB