diff options
author | Alexander Graf <agraf@suse.de> | 2014-04-24 07:46:24 -0400 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2014-05-30 08:26:21 -0400 |
commit | 5deb8e7ad8ac7e3fcdfa042acff617f461b361c2 (patch) | |
tree | ccfc251ffbadfa4297aefcfe17dee807eba7ce73 /arch/powerpc/kvm/book3s_interrupts.S | |
parent | 2743103f91e20d4c4d4f1a8d00821289c4c6ff62 (diff) |
KVM: PPC: Make shared struct aka magic page guest endian
The shared (magic) page is a data structure that contains often used
supervisor privileged SPRs accessible via memory to the user to reduce
the number of exits we have to take to read/write them.
When we actually share this structure with the guest we have to maintain
it in guest endianness, because some of the patch tricks only work with
native endian load/store operations.
Since we only share the structure with either host or guest in little
endian on book3s_64 pr mode, we don't have to worry about booke or book3s hv.
For booke, the shared struct stays big endian. For book3s_64 hv we maintain
the struct in host native endian, since it never gets shared with the guest.
For book3s_64 pr we introduce a variable that tells us which endianness the
shared struct is in and route every access to it through helper inline
functions that evaluate this variable.
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/kvm/book3s_interrupts.S')
-rw-r--r-- | arch/powerpc/kvm/book3s_interrupts.S | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/arch/powerpc/kvm/book3s_interrupts.S b/arch/powerpc/kvm/book3s_interrupts.S index 3533c999194a..e2c29e381dc7 100644 --- a/arch/powerpc/kvm/book3s_interrupts.S +++ b/arch/powerpc/kvm/book3s_interrupts.S | |||
@@ -104,8 +104,27 @@ kvm_start_lightweight: | |||
104 | stb r3, HSTATE_RESTORE_HID5(r13) | 104 | stb r3, HSTATE_RESTORE_HID5(r13) |
105 | 105 | ||
106 | /* Load up guest SPRG3 value, since it's user readable */ | 106 | /* Load up guest SPRG3 value, since it's user readable */ |
107 | ld r3, VCPU_SHARED(r4) | 107 | lwz r3, VCPU_SHAREDBE(r4) |
108 | ld r3, VCPU_SHARED_SPRG3(r3) | 108 | cmpwi r3, 0 |
109 | ld r5, VCPU_SHARED(r4) | ||
110 | beq sprg3_little_endian | ||
111 | sprg3_big_endian: | ||
112 | #ifdef __BIG_ENDIAN__ | ||
113 | ld r3, VCPU_SHARED_SPRG3(r5) | ||
114 | #else | ||
115 | addi r5, r5, VCPU_SHARED_SPRG3 | ||
116 | ldbrx r3, 0, r5 | ||
117 | #endif | ||
118 | b after_sprg3_load | ||
119 | sprg3_little_endian: | ||
120 | #ifdef __LITTLE_ENDIAN__ | ||
121 | ld r3, VCPU_SHARED_SPRG3(r5) | ||
122 | #else | ||
123 | addi r5, r5, VCPU_SHARED_SPRG3 | ||
124 | ldbrx r3, 0, r5 | ||
125 | #endif | ||
126 | |||
127 | after_sprg3_load: | ||
109 | mtspr SPRN_SPRG3, r3 | 128 | mtspr SPRN_SPRG3, r3 |
110 | #endif /* CONFIG_PPC_BOOK3S_64 */ | 129 | #endif /* CONFIG_PPC_BOOK3S_64 */ |
111 | 130 | ||