Skip to contentSkip to conversation

E500 core-specific code

PATCH In review Liu Yu 2 participants 3 messages Dec 11, 2008 – Dec 16, 2008

Subsystems (2)
lore
Share & tools
lore

Liu Yu

author
#0 lore raw

PATCH 5/11 E500 core-specific code

---
 arch/powerpc/include/asm/kvm_e500.h |   67 +++++++++++++++
 arch/powerpc/kvm/e500.c             |  151 +++++++++++++++++++++++++++++++++++
 2 files changed, 218 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/include/asm/kvm_e500.h
 create mode 100644 arch/powerpc/kvm/e500.c
arch/powerpc/include/asm/kvm_e500.h new file +67 -0
new file mode 100644
index 0000000..9d497ce
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2008 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * Author: Yu Liu, <[email protected]>
+ *
+ * Description:
+ * This file is derived from arch/powerpc/include/asm/kvm_44x.h,
+ * by Hollis Blanchard <[email protected]>.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_KVM_E500_H__
+#define __ASM_KVM_E500_H__
+
+#include <linux/kvm_host.h>
+
+#define BOOKE_INTERRUPT_SIZE 36
+
+#define E500_PID_NUM   3
+#define E500_TLB_NUM   2
+
+struct tlbe{
+	u32 mas1;
+	u32 mas2;
+	u32 mas3;
+	u32 mas7;
+};
+
+struct kvmppc_vcpu_e500 {
+	/* Unmodified copy of the guest's TLB. */
+	struct tlbe *guest_tlb[E500_TLB_NUM];
+	/* TLB that's actually used when the guest is running. */
+	struct tlbe *shadow_tlb[E500_TLB_NUM];
+	/* Pages which are referenced in the shadow TLB. */
+	struct page **shadow_pages[E500_TLB_NUM];
+
+	unsigned int guest_tlb_size[E500_TLB_NUM];
+	unsigned int shadow_tlb_size[E500_TLB_NUM];
+	unsigned int guest_tlb_nv[E500_TLB_NUM];
+
+	u32 host_pid[E500_PID_NUM];
+	u32 pid[E500_PID_NUM];
+
+	u32 mas0;
+	u32 mas1;
+	u32 mas2;
+	u32 mas3;
+	u32 mas4;
+	u32 mas5;
+	u32 mas6;
+	u32 mas7;
+	u32 l1csr1;
+	u32 hid0;
+	u32 hid1;
+
+	struct kvm_vcpu vcpu;
+};
+
+static inline struct kvmppc_vcpu_e500 *to_e500(struct kvm_vcpu *vcpu)
+{
+	return container_of(vcpu, struct kvmppc_vcpu_e500, vcpu);
+}
+
+#endif /* __ASM_KVM_E500_H__ */
arch/powerpc/kvm/e500.c new file +151 -0

151 lines not on this page · raw message

Signature · 1 line
1.5.4
#1 lore raw

(By the way, I know you split these patches because they're different files, but since patch 5 can't possibly work (or even build) without patches 6 and 7, they should be joined together.)

arch/powerpc/kvm/e500.c line 81

Quoted 13 lines · Liu Yu
arch/powerpc/kvm/e500.c new file +13 -0
+int kvmppc_core_vcpu_translate(struct kvm_vcpu *vcpu,
+                               struct kvm_translation *tr)
+{
+       int index;
+       gva_t eaddr;
+       u8 pid;
+       u8 as;
+
+       eaddr = tr->linear_address;
+       pid = (tr->linear_address >> 32) & 0xff;
+       as = (tr->linear_address >> 40) & 0x1;
+
+       index = kvmppc_e500_tlb_search(vcpu, eaddr, as);

Why are you discarding pid here? Which brings up the next point, from a later patch:

Quoted 5 lines
(quoted diff) +5 -0
+int kvmppc_e500_tlb_search(struct kvm_vcpu *vcpu,
+                                               gva_t eaddr, int as)
+{
+       struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
+       int esel, tlbsel;

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+       for (tlbsel = 0; tlbsel < 2; tlbsel++) {
+               esel = e500_tlb_index(vcpu_e500, eaddr, tlbsel,
+                               get_cur_pid(vcpu), as);
+               if (esel >= 0)
+                       return index_of(tlbsel, esel);
+       }
+
+       return -1;
+}

You can't possibly search a TLB without knowing the EA, AS, *and* PID. accordingly, PID should be a parameter to this function.

Now, if you told me you wanted to support e500's multiple PID registers, I could understand that's something of an interface issue. But you're not, so...

By the way, do you happen to know if any major operating systems use PID1 or PID2?

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
author
#2 lore raw
In reply to Liu Yu
Quoted 23 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hollis Blanchard
Sent: Tuesday, December 16, 2008 7:03 AM
To: Liu Yu-B13201
Cc: [email protected]
Subject: Re: [PATCH 05/11] E500 core-specific code

(By the way, I know you split these patches because they're different files, but since patch 5 can't possibly work (or even build) without patches 6 and 7, they should be joined together.)

Quoted 9 lines · Liu Yu
arch/powerpc/kvm/e500.c new file +9 -0
+int kvmppc_core_vcpu_translate(struct kvm_vcpu *vcpu,
+                               struct kvm_translation *tr)
+{
+       int index;
+       gva_t eaddr;
+       u8 pid;
+       u8 as;
+
+       eaddr = tr->linear_address;
Quoted 8 lines

arch/powerpc/kvm/e500.c line 81

Quoted 4 lines
arch/powerpc/kvm/e500.c new file +4 -0
+       pid = (tr->linear_address >> 32) & 0xff;
+       as = (tr->linear_address >> 40) & 0x1;
+
+       index = kvmppc_e500_tlb_search(vcpu, eaddr, as);

Why are you discarding pid here? Which brings up the next point, from a
later patch:

My mistake...
Fixed. Thanks.

Quoted 20 lines
Quoted 6 lines
(quoted diff) +5 -0
+int kvmppc_e500_tlb_search(struct kvm_vcpu *vcpu,
+                                               gva_t eaddr, int as)
+{
+       struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
+       int esel, tlbsel;

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+       for (tlbsel = 0; tlbsel < 2; tlbsel++) {
+               esel = e500_tlb_index(vcpu_e500, eaddr, tlbsel,
+                               get_cur_pid(vcpu), as);
+               if (esel >= 0)
+                       return index_of(tlbsel, esel);
+       }
+
+       return -1;
+}

You can't possibly search a TLB without knowing the EA, AS, *and* PID. accordingly, PID should be a parameter to this function.

Quoted 7 lines

Now, if you told me you wanted to support e500's multiple PID registers,
I could understand that's something of an interface issue. But you're not, so...

By the way, do you happen to know if any major operating systems use PID1 or PID2?

Seems no operating system uses them.
E500-mc core has already removed them...

But head_fsl_booke.S accesses PID1 and PID2 at _start just in order to clear them.