Skip to contentSkip to conversation

KVM: Fix asm constraints

PATCH New Avi Kivity 1 participant 1 message Nov 12, 2006 KVM

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 KVM: Fix asm constraints

The change to directly encoded vmx opcodes (rather than asm instructions) forced us to pass the address of phys_addr as an operand, rather than its contents. However, nothing forces gcc to commit the contents of the variable to memory, so add an explicit "m" constraint.

drivers/kvm/kvm_main.c +6 -3
Index: linux-2.6/drivers/kvm/kvm_main.c
===================================================================
@@ -371,7 +371,8 @@ static void vmcs_clear(struct vmcs *vmcs
 	u8 error;
 
 	asm volatile (ASM_VMX_VMCLEAR_RAX "; setna %0"
-		       : "=g"(error) : "a"(&phys_addr) : "cc", "memory" );
+		      : "=g"(error) : "a"(&phys_addr), "m"(phys_addr)
+		      : "cc", "memory");
 	if (error)
 		printk(KERN_ERR "kvm: vmclear fail: %p/%llx\n",
 		       vmcs, phys_addr);
@@ -414,7 +415,8 @@ static struct kvm_vcpu *__vcpu_load(stru
 
 		per_cpu(current_vmcs, cpu) = vcpu->vmcs;
 		asm volatile (ASM_VMX_VMPTRLD_RAX "; setna %0"
-			       : "=g"(error) : "a"(&phys_addr) : "cc" );
+			      : "=g"(error) : "a"(&phys_addr), "m"(phys_addr)
+			      : "cc");
 		if (error)
 			printk(KERN_ERR "kvm: vmptrld %p/%llx fail\n",
 			       vcpu->vmcs, phys_addr);
@@ -537,7 +539,8 @@ static __init void kvm_enable(void *garb
 		/* enable and lock */
 		wrmsrl(MSR_IA32_FEATURE_CONTROL, old | 5);
 	write_cr4(read_cr4() | CR4_VMXE); /* FIXME: not cpu hotplug safe */
-	asm volatile (ASM_VMX_VMXON_RAX : : "a"(&phys_addr) : "memory", "cc");
+	asm volatile (ASM_VMX_VMXON_RAX : : "a"(&phys_addr), "m"(phys_addr)
+		      : "memory", "cc");
 }
 
 static void kvm_disable(void *garbage)

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642