cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

booke.h (3686B)


      1/* SPDX-License-Identifier: GPL-2.0-only */
      2/*
      3 *
      4 * Copyright IBM Corp. 2008
      5 *
      6 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
      7 */
      8
      9#ifndef __KVM_BOOKE_H__
     10#define __KVM_BOOKE_H__
     11
     12#include <linux/types.h>
     13#include <linux/kvm_host.h>
     14#include <asm/kvm_ppc.h>
     15#include <asm/switch_to.h>
     16#include "timing.h"
     17
     18/* interrupt priortity ordering */
     19#define BOOKE_IRQPRIO_DATA_STORAGE 0
     20#define BOOKE_IRQPRIO_INST_STORAGE 1
     21#define BOOKE_IRQPRIO_ALIGNMENT 2
     22#define BOOKE_IRQPRIO_PROGRAM 3
     23#define BOOKE_IRQPRIO_FP_UNAVAIL 4
     24#ifdef CONFIG_SPE_POSSIBLE
     25#define BOOKE_IRQPRIO_SPE_UNAVAIL 5
     26#define BOOKE_IRQPRIO_SPE_FP_DATA 6
     27#define BOOKE_IRQPRIO_SPE_FP_ROUND 7
     28#endif
     29#ifdef CONFIG_PPC_E500MC
     30#define BOOKE_IRQPRIO_ALTIVEC_UNAVAIL 5
     31#define BOOKE_IRQPRIO_ALTIVEC_ASSIST 6
     32#endif
     33#define BOOKE_IRQPRIO_SYSCALL 8
     34#define BOOKE_IRQPRIO_AP_UNAVAIL 9
     35#define BOOKE_IRQPRIO_DTLB_MISS 10
     36#define BOOKE_IRQPRIO_ITLB_MISS 11
     37#define BOOKE_IRQPRIO_MACHINE_CHECK 12
     38#define BOOKE_IRQPRIO_DEBUG 13
     39#define BOOKE_IRQPRIO_CRITICAL 14
     40#define BOOKE_IRQPRIO_WATCHDOG 15
     41#define BOOKE_IRQPRIO_EXTERNAL 16
     42#define BOOKE_IRQPRIO_FIT 17
     43#define BOOKE_IRQPRIO_DECREMENTER 18
     44#define BOOKE_IRQPRIO_PERFORMANCE_MONITOR 19
     45/* Internal pseudo-irqprio for level triggered externals */
     46#define BOOKE_IRQPRIO_EXTERNAL_LEVEL 20
     47#define BOOKE_IRQPRIO_DBELL 21
     48#define BOOKE_IRQPRIO_DBELL_CRIT 22
     49#define BOOKE_IRQPRIO_MAX 23
     50
     51#define BOOKE_IRQMASK_EE ((1 << BOOKE_IRQPRIO_EXTERNAL_LEVEL) | \
     52			  (1 << BOOKE_IRQPRIO_PERFORMANCE_MONITOR) | \
     53			  (1 << BOOKE_IRQPRIO_DBELL) | \
     54			  (1 << BOOKE_IRQPRIO_DECREMENTER) | \
     55			  (1 << BOOKE_IRQPRIO_FIT) | \
     56			  (1 << BOOKE_IRQPRIO_EXTERNAL))
     57
     58#define BOOKE_IRQMASK_CE ((1 << BOOKE_IRQPRIO_DBELL_CRIT) | \
     59			  (1 << BOOKE_IRQPRIO_WATCHDOG) | \
     60			  (1 << BOOKE_IRQPRIO_CRITICAL))
     61
     62extern unsigned long kvmppc_booke_handlers;
     63extern unsigned long kvmppc_booke_handler_addr[];
     64
     65void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr);
     66void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr);
     67
     68void kvmppc_set_epcr(struct kvm_vcpu *vcpu, u32 new_epcr);
     69void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr);
     70void kvmppc_set_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
     71void kvmppc_clr_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
     72
     73int kvmppc_booke_emulate_op(struct kvm_vcpu *vcpu,
     74                            unsigned int inst, int *advance);
     75int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val);
     76int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val);
     77
     78/* low-level asm code to transfer guest state */
     79void kvmppc_load_guest_spe(struct kvm_vcpu *vcpu);
     80void kvmppc_save_guest_spe(struct kvm_vcpu *vcpu);
     81
     82/* high-level function, manages flags, host state */
     83void kvmppc_vcpu_disable_spe(struct kvm_vcpu *vcpu);
     84
     85void kvmppc_booke_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
     86void kvmppc_booke_vcpu_put(struct kvm_vcpu *vcpu);
     87
     88enum int_class {
     89	INT_CLASS_NONCRIT,
     90	INT_CLASS_CRIT,
     91	INT_CLASS_MC,
     92	INT_CLASS_DBG,
     93};
     94
     95void kvmppc_set_pending_interrupt(struct kvm_vcpu *vcpu, enum int_class type);
     96
     97extern int kvmppc_core_emulate_op_e500(struct kvm_vcpu *vcpu,
     98				       unsigned int inst, int *advance);
     99extern int kvmppc_core_emulate_mtspr_e500(struct kvm_vcpu *vcpu, int sprn,
    100					  ulong spr_val);
    101extern int kvmppc_core_emulate_mfspr_e500(struct kvm_vcpu *vcpu, int sprn,
    102					  ulong *spr_val);
    103extern int kvmppc_core_emulate_mtspr_e500(struct kvm_vcpu *vcpu, int sprn,
    104					  ulong spr_val);
    105extern int kvmppc_core_emulate_mfspr_e500(struct kvm_vcpu *vcpu, int sprn,
    106					  ulong *spr_val);
    107
    108static inline void kvmppc_clear_dbsr(void)
    109{
    110	mtspr(SPRN_DBSR, mfspr(SPRN_DBSR));
    111}
    112#endif /* __KVM_BOOKE_H__ */