Commit d77c26fc authored by Mike Day's avatar Mike Day Committed by Avi Kivity
Browse files

KVM: CodingStyle cleanup



Signed-off-by: default avatarMike D. Day <ncmike@ncultra.org>
Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
parent 7e620d16
Loading
Loading
Loading
Loading
+30 −28
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ static struct dentry *debugfs_dir;
#define EFER_RESERVED_BITS 0xfffffffffffff2fe

#ifdef CONFIG_X86_64
// LDT or TSS descriptor in the GDT. 16 bytes.
/* LDT or TSS descriptor in the GDT. 16 bytes. */
struct segment_descriptor_64 {
	struct segment_descriptor s;
	u32 base_higher;
@@ -121,7 +121,6 @@ unsigned long segment_base(u16 selector)
	struct descriptor_table gdt;
	struct segment_descriptor *d;
	unsigned long table_base;
	typedef unsigned long ul;
	unsigned long v;

	if (selector == 0)
@@ -137,11 +136,12 @@ unsigned long segment_base(u16 selector)
		table_base = segment_base(ldt_selector);
	}
	d = (struct segment_descriptor *)(table_base + (selector & ~7));
	v = d->base_low | ((ul)d->base_mid << 16) | ((ul)d->base_high << 24);
	v = d->base_low | ((unsigned long)d->base_mid << 16) |
		((unsigned long)d->base_high << 24);
#ifdef CONFIG_X86_64
	if (d->system == 0
	    && (d->type == 2 || d->type == 9 || d->type == 11))
		v |= ((ul)((struct segment_descriptor_64 *)d)->base_higher) << 32;
	if (d->system == 0 && (d->type == 2 || d->type == 9 || d->type == 11))
		v |= ((unsigned long) \
		      ((struct segment_descriptor_64 *)d)->base_higher) << 32;
#endif
	return v;
}
@@ -2089,7 +2089,7 @@ static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
	int r;

	if (unlikely(vcpu->mp_state == VCPU_MP_STATE_SIPI_RECEIVED)) {
		printk("vcpu %d received sipi with vector # %x\n",
		pr_debug("vcpu %d received sipi with vector # %x\n",
		       vcpu->vcpu_id, vcpu->sipi_vector);
		kvm_lapic_reset(vcpu);
		kvm_x86_ops->vcpu_reset(vcpu);
@@ -2363,7 +2363,8 @@ static int kvm_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
		       sizeof sregs->interrupt_bitmap);
		pending_vec = kvm_x86_ops->get_irq(vcpu);
		if (pending_vec >= 0)
			set_bit(pending_vec, (unsigned long *)sregs->interrupt_bitmap);
			set_bit(pending_vec,
				(unsigned long *)sregs->interrupt_bitmap);
	} else
		memcpy(sregs->interrupt_bitmap, vcpu->irq_pending,
		       sizeof sregs->interrupt_bitmap);
@@ -2436,7 +2437,8 @@ static int kvm_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
		/* Only pending external irq is handled here */
		if (pending_vec < max_bits) {
			kvm_x86_ops->set_irq(vcpu, pending_vec);
			printk("Set back pending irq %d\n", pending_vec);
			pr_debug("Set back pending irq %d\n",
				 pending_vec);
		}
	}

@@ -3155,8 +3157,7 @@ static long kvm_vm_ioctl(struct file *filp,
				kvm->vpic = NULL;
				goto out;
			}
		}
		else
		} else
			goto out;
		break;
	case KVM_IRQ_LINE: {
@@ -3683,6 +3684,7 @@ int kvm_init_x86(struct kvm_x86_ops *ops, unsigned int vcpu_size,
	kvm_x86_ops = NULL;
	return r;
}
EXPORT_SYMBOL_GPL(kvm_init_x86);

void kvm_exit_x86(void)
{
@@ -3696,6 +3698,7 @@ void kvm_exit_x86(void)
	kvm_x86_ops->hardware_unsetup();
	kvm_x86_ops = NULL;
}
EXPORT_SYMBOL_GPL(kvm_exit_x86);

static __init int kvm_init(void)
{
@@ -3710,7 +3713,9 @@ static __init int kvm_init(void)

	kvm_init_msr_list();

	if ((bad_page = alloc_page(GFP_KERNEL)) == NULL) {
	bad_page = alloc_page(GFP_KERNEL);

	if (bad_page == NULL) {
		r = -ENOMEM;
		goto out;
	}
@@ -3736,6 +3741,3 @@ static __exit void kvm_exit(void)

module_init(kvm_init)
module_exit(kvm_exit)

EXPORT_SYMBOL_GPL(kvm_init_x86);
EXPORT_SYMBOL_GPL(kvm_exit_x86);
+1 −2
Original line number Diff line number Diff line
@@ -906,8 +906,7 @@ static int __apic_timer_fn(struct kvm_lapic *apic)
	wait_queue_head_t *q = &apic->vcpu->wq;

	atomic_inc(&apic->timer.pending);
	if (waitqueue_active(q))
	{
	if (waitqueue_active(q)) {
		apic->vcpu->mp_state = VCPU_MP_STATE_RUNNABLE;
		wake_up_interruptible(q);
	}
+6 −4
Original line number Diff line number Diff line
@@ -90,7 +90,8 @@ static int dbg = 1;

#define PT32_DIR_PSE36_SIZE 4
#define PT32_DIR_PSE36_SHIFT 13
#define PT32_DIR_PSE36_MASK (((1ULL << PT32_DIR_PSE36_SIZE) - 1) << PT32_DIR_PSE36_SHIFT)
#define PT32_DIR_PSE36_MASK \
	(((1ULL << PT32_DIR_PSE36_SIZE) - 1) << PT32_DIR_PSE36_SHIFT)


#define PT_FIRST_AVAIL_BITS_SHIFT 9
@@ -1489,7 +1490,8 @@ static void audit_mappings_page(struct kvm_vcpu *vcpu, u64 page_pte,
				printk(KERN_ERR "xx audit error: (%s) levels %d"
				       " gva %lx gpa %llx hpa %llx ent %llx %d\n",
				       audit_msg, vcpu->mmu.root_level,
				       va, gpa, hpa, ent, is_shadow_present_pte(ent));
				       va, gpa, hpa, ent,
				       is_shadow_present_pte(ent));
			else if (ent == shadow_notrap_nonpresent_pte
				 && !is_error_hpa(hpa))
				printk(KERN_ERR "audit: (%s) notrap shadow,"
+23 −25
Original line number Diff line number Diff line
@@ -229,12 +229,11 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu)
		printk(KERN_DEBUG "%s: NOP\n", __FUNCTION__);
		return;
	}
	if (svm->next_rip - svm->vmcb->save.rip > MAX_INST_SIZE) {
	if (svm->next_rip - svm->vmcb->save.rip > MAX_INST_SIZE)
		printk(KERN_ERR "%s: ip 0x%llx next 0x%llx\n",
		       __FUNCTION__,
		       svm->vmcb->save.rip,
		       svm->next_rip);
	}

	vcpu->rip = svm->vmcb->save.rip = svm->next_rip;
	svm->vmcb->control.int_state &= ~SVM_INTERRUPT_SHADOW_MASK;
@@ -544,7 +543,6 @@ static void init_vmcb(struct vmcb *vmcb)
	init_sys_seg(&save->tr, SEG_TYPE_BUSY_TSS16);

	save->efer = MSR_EFER_SVME_MASK;

	save->dr6 = 0xffff0ff0;
	save->dr7 = 0x400;
	save->rflags = 2;
@@ -1010,7 +1008,7 @@ static int shutdown_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)

static int io_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
{
	u32 io_info = svm->vmcb->control.exit_info_1; //address size bug?
	u32 io_info = svm->vmcb->control.exit_info_1; /* address size bug? */
	int size, down, in, string, rep;
	unsigned port;

@@ -1316,7 +1314,7 @@ static void reload_tss(struct kvm_vcpu *vcpu)
	int cpu = raw_smp_processor_id();

	struct svm_cpu_data *svm_data = per_cpu(svm_data, cpu);
	svm_data->tss_desc->type = 9; //available 32/64-bit TSS
	svm_data->tss_desc->type = 9; /* available 32/64-bit TSS */
	load_TR_desc();
}

@@ -1434,9 +1432,9 @@ static void do_interrupt_requests(struct kvm_vcpu *vcpu,
	 * Interrupts blocked.  Wait for unblock.
	 */
	if (!svm->vcpu.interrupt_window_open &&
	    (svm->vcpu.irq_summary || kvm_run->request_interrupt_window)) {
	    (svm->vcpu.irq_summary || kvm_run->request_interrupt_window))
		control->intercept |= 1ULL << INTERCEPT_VINTR;
	} else
	 else
		control->intercept &= ~(1ULL << INTERCEPT_VINTR);
}

+1 −1
Original line number Diff line number Diff line
@@ -311,7 +311,7 @@ struct __attribute__ ((__packed__)) vmcb {

#define SVM_EXIT_ERR		-1

#define SVM_CR0_SELECTIVE_MASK (1 << 3 | 1) // TS and MP
#define SVM_CR0_SELECTIVE_MASK (1 << 3 | 1) /* TS and MP */

#define SVM_VMLOAD ".byte 0x0f, 0x01, 0xda"
#define SVM_VMRUN  ".byte 0x0f, 0x01, 0xd8"
Loading