On 10/15/2009 11:41 PM, [email protected] wrote:
+static int nested_map_shadow_vmcs(struct kvm_vcpu *vcpu)
+{
+ struct vcpu_vmx *vmx = to_vmx(vcpu);
+ struct page *vmcs_page = nested_get_page(vcpu, vmx->nested.vmptr);
+
+ if (vmcs_page == NULL) {
+ printk(KERN_INFO "%s: failure in nested_get_page\n",__func__);
+ return 0;
+ }
+
+ if (vmx->nested.l2_state->shadow_vmcs) {
+ printk(KERN_INFO "%s: shadow vmcs already mapped\n",__func__);
+ return 0;
+ }
+
Consider dropping shadow_vmcs from l2_state and just passing it
everywhere. Less convenient but safer.
+ vmx->nested.l2_state->shadow_vmcs = kmap_atomic(vmcs_page, KM_USER0);
+
+ if (!vmx->nested.l2_state->shadow_vmcs) {
+ printk(KERN_INFO "%s: error in kmap_atomic\n",__func__);
+ return 0;
+ }
kmap_atomic() can't fail.
+static int handle_vmread(struct kvm_vcpu *vcpu)
+{
+#ifndef CONFIG_X86_64
+ u64 value;
+#endif
+
+ if (!nested_vmx_check_permission(vcpu))
+ return 1;
+
+ if (!nested_map_shadow_vmcs(vcpu)) {
+ printk(KERN_INFO "%s invalid shadow vmcs\n", __func__);
+ set_rflags_to_vmx_fail_invalid(vcpu);
+ return 1;
+ }
return an error.
+
+ switch (vmcs_field_length(vcpu->arch.regs[VCPU_REGS_RDX])) {
+ case VMCS_FIELD_TYPE_U16:
+ vcpu->arch.regs[VCPU_REGS_RAX] =
+ nested_vmcs_read16(vcpu,
+ vcpu->arch.regs[VCPU_REGS_RDX]);
+ break;
Use the emulator to decode operands.
--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html