[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH 02/21] PPC: KVM: Update HIOR code to new interface
From: |
Alexander Graf |
Subject: |
[Qemu-ppc] [PATCH 02/21] PPC: KVM: Update HIOR code to new interface |
Date: |
Thu, 2 Feb 2012 02:49:25 +0100 |
Unfortunately the HIOR setting code slipped into upstream QEMU
before it was pulled into upstream KVM. And since Murphy is always
right, comments on the patches only emerged on the pull request
leading to changes in the interface.
So here's an update to the HIOR setting. While at it, I also relaxed
it a bit since for HV KVM we can already run fine without and 3.2
works just fine with HV KVM but when not setting HIOR. We will only
need this when running PAPR in PR KVM.
Since we accidently changed the ABI and API along the way, we have
to update the underlying kernel headers together with the code that
uses it to not break bisectability.
Signed-off-by: Alexander Graf <address@hidden>
---
linux-headers/asm-powerpc/kvm.h | 2 +-
linux-headers/linux/kvm.h | 37 ++++++++++++++++++++-----------------
target-ppc/kvm.c | 10 +++++++---
3 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/linux-headers/asm-powerpc/kvm.h b/linux-headers/asm-powerpc/kvm.h
index 1f0cb55..b921c3f 100644
--- a/linux-headers/asm-powerpc/kvm.h
+++ b/linux-headers/asm-powerpc/kvm.h
@@ -324,6 +324,6 @@ struct kvm_book3e_206_tlb_params {
__u32 reserved[8];
};
-#define KVM_ONE_REG_PPC_HIOR KVM_ONE_REG_PPC | 0x100
+#define KVM_REG_PPC_HIOR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x1)
#endif /* __LINUX_KVM_POWERPC_H */
diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index 4847813..f6b5343 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -684,30 +684,33 @@ struct kvm_dirty_tlb {
/* Available with KVM_CAP_ONE_REG */
-#define KVM_ONE_REG_GENERIC 0x0000000000000000ULL
+#define KVM_REG_ARCH_MASK 0xff00000000000000ULL
+#define KVM_REG_GENERIC 0x0000000000000000ULL
/*
* Architecture specific registers are to be defined in arch headers and
* ORed with the arch identifier.
*/
-#define KVM_ONE_REG_PPC 0x1000000000000000ULL
-#define KVM_ONE_REG_X86 0x2000000000000000ULL
-#define KVM_ONE_REG_IA64 0x3000000000000000ULL
-#define KVM_ONE_REG_ARM 0x4000000000000000ULL
-#define KVM_ONE_REG_S390 0x5000000000000000ULL
+#define KVM_REG_PPC 0x1000000000000000ULL
+#define KVM_REG_X86 0x2000000000000000ULL
+#define KVM_REG_IA64 0x3000000000000000ULL
+#define KVM_REG_ARM 0x4000000000000000ULL
+#define KVM_REG_S390 0x5000000000000000ULL
+
+#define KVM_REG_SIZE_SHIFT 52
+#define KVM_REG_SIZE_MASK 0x00f0000000000000ULL
+#define KVM_REG_SIZE_U8 0x0000000000000000ULL
+#define KVM_REG_SIZE_U16 0x0010000000000000ULL
+#define KVM_REG_SIZE_U32 0x0020000000000000ULL
+#define KVM_REG_SIZE_U64 0x0030000000000000ULL
+#define KVM_REG_SIZE_U128 0x0040000000000000ULL
+#define KVM_REG_SIZE_U256 0x0050000000000000ULL
+#define KVM_REG_SIZE_U512 0x0060000000000000ULL
+#define KVM_REG_SIZE_U1024 0x0070000000000000ULL
struct kvm_one_reg {
__u64 id;
- union {
- __u8 reg8;
- __u16 reg16;
- __u32 reg32;
- __u64 reg64;
- __u8 reg128[16];
- __u8 reg256[32];
- __u8 reg512[64];
- __u8 reg1024[128];
- } u;
+ __u64 addr;
};
/*
@@ -850,7 +853,7 @@ struct kvm_s390_ucas_mapping {
/* Available with KVM_CAP_SW_TLB */
#define KVM_DIRTY_TLB _IOW(KVMIO, 0xaa, struct kvm_dirty_tlb)
/* Available with KVM_CAP_ONE_REG */
-#define KVM_GET_ONE_REG _IOWR(KVMIO, 0xab, struct kvm_one_reg)
+#define KVM_GET_ONE_REG _IOW(KVMIO, 0xab, struct kvm_one_reg)
#define KVM_SET_ONE_REG _IOW(KVMIO, 0xac, struct kvm_one_reg)
#define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index ce8ac5b..50cfa02 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -740,6 +740,7 @@ void kvmppc_set_papr(CPUState *env)
struct kvm_one_reg reg = {};
struct kvm_sregs sregs = {};
int ret;
+ uint64_t hior = env->spr[SPR_HIOR];
cap.cap = KVM_CAP_PPC_PAPR;
ret = kvm_vcpu_ioctl(env, KVM_ENABLE_CAP, &cap);
@@ -755,11 +756,14 @@ void kvmppc_set_papr(CPUState *env)
* Once we have qdev CPUs, move HIOR to a qdev property and
* remove this chunk.
*/
- reg.id = KVM_ONE_REG_PPC_HIOR;
- reg.u.reg64 = env->spr[SPR_HIOR];
+ reg.id = KVM_REG_PPC_HIOR;
+ reg.addr = (uintptr_t)&hior;
ret = kvm_vcpu_ioctl(env, KVM_SET_ONE_REG, ®);
if (ret) {
- goto fail;
+ fprintf(stderr, "Couldn't set HIOR. Maybe you're running an old \n"
+ "kernel with support for HV KVM but no PAPR PR \n"
+ "KVM in which case things will work. If they don't \n"
+ "please update your host kernel!\n");
}
/* Set SDR1 so kernel space finds the HTAB */
--
1.6.0.2
- [Qemu-ppc] [PATCH 03/21] PPC: Add IVOR 38-42, (continued)
- [Qemu-ppc] [PATCH 03/21] PPC: Add IVOR 38-42, Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 16/21] PPC: Add CPU feature for processor control, Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 18/21] PPC: E500: Implement msgclr, Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 21/21] PPC: E500: Populate L1CFG0 SPR, Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 11/21] PPC: booke206: Check for TLB overrun, Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 07/21] PPC: booke206: allow NULL raddr in ppcmas_tlb_check, Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 10/21] PPC: booke206: Implement tlbilx, Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 20/21] PPC: e500mc: Enable processor control, Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 17/21] PPC: Enable doorbell excp handlers, Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 09/21] PPC: booke206: Check for min/max TLB entry size, Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 02/21] PPC: KVM: Update HIOR code to new interface,
Alexander Graf <=
- [Qemu-ppc] [PATCH 08/21] PPC: booke: add tlbnps handling, Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 04/21] PPC: e500mc: add missing IVORs to bitmap, Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 05/21] PPC: e500: msync is 440 only, e500 has real sync, Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 01/21] KVM: Update headers (except HIOR mess), Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 14/21] PPC: E500: Add some more excp vectors, Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 06/21] PPC: rename msync to msync_4xx, Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 15/21] PPC: E500: Add doorbell defines, Alexander Graf, 2012/02/01
- [Qemu-ppc] [PATCH 13/21] KVM: Fix compilation on non-x86, Alexander Graf, 2012/02/01
- Re: [Qemu-ppc] [Qemu-devel] [PULL 00/21] ppc patch queue 2012-02-02, Andreas Färber, 2012/02/02
- Re: [Qemu-ppc] [PULL 00/21] ppc patch queue 2012-02-02, Blue Swirl, 2012/02/04