Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1022fc3d authored by Alexander Graf's avatar Alexander Graf Committed by Avi Kivity
Browse files

KVM: PPC: Add support for explicit HIOR setting



Until now, we always set HIOR based on the PVR, but this is just wrong.
Instead, we should be setting HIOR explicitly, so user space can decide
what the initial HIOR value is - just like on real hardware.

We keep the old PVR based way around for backwards compatibility, but
once user space uses the SET_ONE_REG based method, we drop the PVR logic.

Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent e24ed81f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1610,6 +1610,7 @@ registers, find a list below:

  Arch  |       Register        | Width (bits)
        |                       |
  PPC   | KVM_REG_PPC_HIOR      | 64

4.69 KVM_GET_ONE_REG

+2 −0
Original line number Diff line number Diff line
@@ -331,4 +331,6 @@ struct kvm_book3e_206_tlb_params {
	__u32 reserved[8];
};

#define KVM_REG_PPC_HIOR	(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x1)

#endif /* __LINUX_KVM_POWERPC_H */
+2 −0
Original line number Diff line number Diff line
@@ -90,6 +90,8 @@ struct kvmppc_vcpu_book3s {
#endif
	int context_id[SID_CONTEXTS];

	bool hior_explicit;		/* HIOR is set by ioctl, not PVR */

	struct hlist_head hpte_hash_pte[HPTEG_HASH_NUM_PTE];
	struct hlist_head hpte_hash_pte_long[HPTEG_HASH_NUM_PTE_LONG];
	struct hlist_head hpte_hash_vpte[HPTEG_HASH_NUM_VPTE];
+4 −2
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ void kvmppc_set_pvr(struct kvm_vcpu *vcpu, u32 pvr)
#ifdef CONFIG_PPC_BOOK3S_64
	if ((pvr >= 0x330000) && (pvr < 0x70330000)) {
		kvmppc_mmu_book3s_64_init(vcpu);
		if (!to_book3s(vcpu)->hior_explicit)
			to_book3s(vcpu)->hior = 0xfff00000;
		to_book3s(vcpu)->msr_mask = 0xffffffffffffffffULL;
		vcpu->arch.cpu_type = KVM_CPU_3S_64;
@@ -164,6 +165,7 @@ void kvmppc_set_pvr(struct kvm_vcpu *vcpu, u32 pvr)
#endif
	{
		kvmppc_mmu_book3s_32_init(vcpu);
		if (!to_book3s(vcpu)->hior_explicit)
			to_book3s(vcpu)->hior = 0;
		to_book3s(vcpu)->msr_mask = 0xffffffffULL;
		vcpu->arch.cpu_type = KVM_CPU_3S_32;
+13 −0
Original line number Diff line number Diff line
@@ -212,6 +212,7 @@ int kvm_dev_ioctl_check_extension(long ext)
	case KVM_CAP_PPC_BOOKE_SREGS:
#else
	case KVM_CAP_PPC_SEGSTATE:
	case KVM_CAP_PPC_HIOR:
	case KVM_CAP_PPC_PAPR:
#endif
	case KVM_CAP_PPC_UNSET_IRQ:
@@ -652,6 +653,11 @@ static int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu,
	int r = -EINVAL;

	switch (reg->id) {
#ifdef CONFIG_PPC_BOOK3S
	case KVM_REG_PPC_HIOR:
		r = put_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);
		break;
#endif
	default:
		break;
	}
@@ -665,6 +671,13 @@ static int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu,
	int r = -EINVAL;

	switch (reg->id) {
#ifdef CONFIG_PPC_BOOK3S
	case KVM_ONE_REG_PPC_HIOR:
		r = get_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);
		if (!r)
			to_book3s(vcpu)->hior_explicit = true;
		break;
#endif
	default:
		break;
	}
Loading