Skip to contentSkip to conversation

lmsw sets lower 16 bits of cr0, not just lower 4

PATCH In review Rusty Russell 2 participants 3 messages Aug 1, 2007 2 messages not in the archive KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lmsw sets lower 16 bits of cr0, not just lower 4

According to my Intel manual, although lmsw only causes an exit when trying to set the bottom 4 bits, it is supposed to set the bottom 16 bits of cr0.

drivers/kvm/kvm_main.c +1 -1
diff -r f06a5d7dc984 drivers/kvm/kvm_main.c
@@ -526,7 +526,7 @@ EXPORT_SYMBOL_GPL(set_cr0);
 
 void lmsw(struct kvm_vcpu *vcpu, unsigned long msw)
 {
-	set_cr0(vcpu, (vcpu->cr0 & ~0x0ful) | (msw & 0x0f));
+	set_cr0(vcpu, (vcpu->cr0 & ~0xffffUL) | (msw & 0xffff));
 }
 EXPORT_SYMBOL_GPL(lmsw);
 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

A message that is not in the archive (sent off-list or not yet received): 1185928308.6131.116.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]

#2 lore raw
Quoted 5 lines · Rusty Russell

According to my Intel manual, although lmsw only causes an exit when trying to set the bottom 4 bits, it is supposed to set the bottom 16 bits of cr0.

Well, _my_ Intel manual (2A) says:

Quoted 9 lines

Loads the source operand into the machine status word, bits 0 through 15 of register CR0. The
source operand can be a 16-bit general-purpose register or a memory location. Only the low-
order 4 bits of the source operand (which contains the PE, MP, EM, and TS flags) are loaded
into CR0. The PG, CD, NW, AM, WP, NE, and ET flags of CR0 are not affected. The operand-
size attribute has no effect on this instruction.

Signature · 8 lines
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

A message that is not in the archive (sent off-list or not yet received): 46B0D4A8.7040001-atKUWr5tajBWk0Htik3J/[email protected]

#4 lore raw
Quoted 15 lines · Avi Kivity
Quoted 5 lines · Rusty Russell

According to my Intel manual, although lmsw only causes an exit when trying to set the bottom 4 bits, it is supposed to set the bottom 16 bits of cr0.

Well, _my_ Intel manual (2A) says:

Quoted 6 lines

Loads the source operand into the machine status word, bits 0 through 15 of register CR0. The
source operand can be a 16-bit general-purpose register or a memory location. Only the low-
order 4 bits of the source operand (which contains the PE, MP, EM, and TS flags) are loaded

Damn, I should have kept reading.

Sorry for the noise!
Rusty.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/