Commit ebc88ea7 authored by Jordan Niethe's avatar Jordan Niethe Committed by Michael Ellerman

KVM: PPC: Book3S HV: Use accessors for VCPU registers

Introduce accessor generator macros for Book3S HV VCPU registers. Use
the accessor functions to replace direct accesses to this registers.

This will be important later for Nested APIv2 support which requires
additional functionality for accessing and modifying VCPU state.
Signed-off-by: default avatarJordan Niethe <jniethe5@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230914030600.16993-7-jniethe5@gmail.com
parent c8ae9b3c
......@@ -15,6 +15,7 @@
#include <asm/kvm_ppc.h>
#include <asm/kvm_book3s.h>
#include "book3s_hv.h"
#include <asm/page.h>
#include <asm/mmu.h>
#include <asm/pgalloc.h>
......@@ -294,9 +295,9 @@ int kvmppc_mmu_radix_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
} else {
if (!(pte & _PAGE_PRIVILEGED)) {
/* Check AMR/IAMR to see if strict mode is in force */
if (vcpu->arch.amr & (1ul << 62))
if (kvmppc_get_amr_hv(vcpu) & (1ul << 62))
gpte->may_read = 0;
if (vcpu->arch.amr & (1ul << 63))
if (kvmppc_get_amr_hv(vcpu) & (1ul << 63))
gpte->may_write = 0;
if (vcpu->arch.iamr & (1ul << 62))
gpte->may_execute = 0;
......
This diff is collapsed.
......@@ -50,3 +50,61 @@ void accumulate_time(struct kvm_vcpu *vcpu, struct kvmhv_tb_accumulator *next);
#define start_timing(vcpu, next) do {} while (0)
#define end_timing(vcpu) do {} while (0)
#endif
#define KVMPPC_BOOK3S_HV_VCPU_ACCESSOR_SET(reg, size) \
static inline void kvmppc_set_##reg ##_hv(struct kvm_vcpu *vcpu, u##size val) \
{ \
vcpu->arch.reg = val; \
}
#define KVMPPC_BOOK3S_HV_VCPU_ACCESSOR_GET(reg, size) \
static inline u##size kvmppc_get_##reg ##_hv(struct kvm_vcpu *vcpu) \
{ \
return vcpu->arch.reg; \
}
#define KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(reg, size) \
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR_SET(reg, size) \
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR_GET(reg, size) \
#define KVMPPC_BOOK3S_HV_VCPU_ARRAY_ACCESSOR_SET(reg, size) \
static inline void kvmppc_set_##reg ##_hv(struct kvm_vcpu *vcpu, int i, u##size val) \
{ \
vcpu->arch.reg[i] = val; \
}
#define KVMPPC_BOOK3S_HV_VCPU_ARRAY_ACCESSOR_GET(reg, size) \
static inline u##size kvmppc_get_##reg ##_hv(struct kvm_vcpu *vcpu, int i) \
{ \
return vcpu->arch.reg[i]; \
}
#define KVMPPC_BOOK3S_HV_VCPU_ARRAY_ACCESSOR(reg, size) \
KVMPPC_BOOK3S_HV_VCPU_ARRAY_ACCESSOR_SET(reg, size) \
KVMPPC_BOOK3S_HV_VCPU_ARRAY_ACCESSOR_GET(reg, size) \
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(mmcra, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(hfscr, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(fscr, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dscr, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(purr, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(spurr, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(amr, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(uamor, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(siar, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(sdar, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(iamr, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawr0, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawr1, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawrx0, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(dawrx1, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(ciabr, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(wort, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(ppr, 64)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(ctrl, 64)
KVMPPC_BOOK3S_HV_VCPU_ARRAY_ACCESSOR(mmcr, 64)
KVMPPC_BOOK3S_HV_VCPU_ARRAY_ACCESSOR(sier, 64)
KVMPPC_BOOK3S_HV_VCPU_ARRAY_ACCESSOR(pmc, 32)
KVMPPC_BOOK3S_HV_VCPU_ACCESSOR(pspb, 32)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment