aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
diff options
context:
space:
mode:
authorLaurent Vivier <Laurent.Vivier@bull.net>2007-07-30 06:41:19 -0400
committerAvi Kivity <avi@qumranet.com>2007-10-13 04:18:21 -0400
commite7d5d76cae970117affe07f809faf0f18bbac675 (patch)
tree3410ce6d12e1095affcd4e6f7fd36716587916c6 /drivers/kvm/kvm_main.c
parentcebff02b11b02a81d21b6cc8390938dc9bdf0a12 (diff)
KVM: Remove kvm_{read,write}_guest()
... in favor of the more general emulator_{read,write}_*. Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r--drivers/kvm/kvm_main.c74
1 files changed, 4 insertions, 70 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index a65a145f3050..4bbd89e03324 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -146,74 +146,6 @@ static inline int valid_vcpu(int n)
146 return likely(n >= 0 && n < KVM_MAX_VCPUS); 146 return likely(n >= 0 && n < KVM_MAX_VCPUS);
147} 147}
148 148
149int kvm_read_guest(struct kvm_vcpu *vcpu, gva_t addr, unsigned long size,
150 void *dest)
151{
152 unsigned char *host_buf = dest;
153 unsigned long req_size = size;
154
155 while (size) {
156 hpa_t paddr;
157 unsigned now;
158 unsigned offset;
159 hva_t guest_buf;
160
161 paddr = gva_to_hpa(vcpu, addr);
162
163 if (is_error_hpa(paddr))
164 break;
165
166 guest_buf = (hva_t)kmap_atomic(
167 pfn_to_page(paddr >> PAGE_SHIFT),
168 KM_USER0);
169 offset = addr & ~PAGE_MASK;
170 guest_buf |= offset;
171 now = min(size, PAGE_SIZE - offset);
172 memcpy(host_buf, (void*)guest_buf, now);
173 host_buf += now;
174 addr += now;
175 size -= now;
176 kunmap_atomic((void *)(guest_buf & PAGE_MASK), KM_USER0);
177 }
178 return req_size - size;
179}
180EXPORT_SYMBOL_GPL(kvm_read_guest);
181
182int kvm_write_guest(struct kvm_vcpu *vcpu, gva_t addr, unsigned long size,
183 void *data)
184{
185 unsigned char *host_buf = data;
186 unsigned long req_size = size;
187
188 while (size) {
189 hpa_t paddr;
190 unsigned now;
191 unsigned offset;
192 hva_t guest_buf;
193 gfn_t gfn;
194
195 paddr = gva_to_hpa(vcpu, addr);
196
197 if (is_error_hpa(paddr))
198 break;
199
200 gfn = vcpu->mmu.gva_to_gpa(vcpu, addr) >> PAGE_SHIFT;
201 mark_page_dirty(vcpu->kvm, gfn);
202 guest_buf = (hva_t)kmap_atomic(
203 pfn_to_page(paddr >> PAGE_SHIFT), KM_USER0);
204 offset = addr & ~PAGE_MASK;
205 guest_buf |= offset;
206 now = min(size, PAGE_SIZE - offset);
207 memcpy((void*)guest_buf, host_buf, now);
208 host_buf += now;
209 addr += now;
210 size -= now;
211 kunmap_atomic((void *)(guest_buf & PAGE_MASK), KM_USER0);
212 }
213 return req_size - size;
214}
215EXPORT_SYMBOL_GPL(kvm_write_guest);
216
217void kvm_load_guest_fpu(struct kvm_vcpu *vcpu) 149void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
218{ 150{
219 if (!vcpu->fpu_active || vcpu->guest_fpu_loaded) 151 if (!vcpu->fpu_active || vcpu->guest_fpu_loaded)
@@ -1017,7 +949,7 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
1017 } 949 }
1018} 950}
1019 951
1020static int emulator_read_std(unsigned long addr, 952int emulator_read_std(unsigned long addr,
1021 void *val, 953 void *val,
1022 unsigned int bytes, 954 unsigned int bytes,
1023 struct kvm_vcpu *vcpu) 955 struct kvm_vcpu *vcpu)
@@ -1051,6 +983,7 @@ static int emulator_read_std(unsigned long addr,
1051 983
1052 return X86EMUL_CONTINUE; 984 return X86EMUL_CONTINUE;
1053} 985}
986EXPORT_SYMBOL_GPL(emulator_read_std);
1054 987
1055static int emulator_write_std(unsigned long addr, 988static int emulator_write_std(unsigned long addr,
1056 const void *val, 989 const void *val,
@@ -1169,7 +1102,7 @@ static int emulator_write_emulated_onepage(unsigned long addr,
1169 return X86EMUL_CONTINUE; 1102 return X86EMUL_CONTINUE;
1170} 1103}
1171 1104
1172static int emulator_write_emulated(unsigned long addr, 1105int emulator_write_emulated(unsigned long addr,
1173 const void *val, 1106 const void *val,
1174 unsigned int bytes, 1107 unsigned int bytes,
1175 struct kvm_vcpu *vcpu) 1108 struct kvm_vcpu *vcpu)
@@ -1188,6 +1121,7 @@ static int emulator_write_emulated(unsigned long addr,
1188 } 1121 }
1189 return emulator_write_emulated_onepage(addr, val, bytes, vcpu); 1122 return emulator_write_emulated_onepage(addr, val, bytes, vcpu);
1190} 1123}
1124EXPORT_SYMBOL_GPL(emulator_write_emulated);
1191 1125
1192static int emulator_cmpxchg_emulated(unsigned long addr, 1126static int emulator_cmpxchg_emulated(unsigned long addr,
1193 const void *old, 1127 const void *old,