Skip to contentSkip to conversation

some question in function do_vmx_vcpu_run, if anyone knows , please tell me,thanks.

DISCUSSION jemmy858585 1 participant 1 message Oct 31, 2010 KVM

lore
Share & tools
lore
#0 lore raw

in the function do_vmx_vcpu_run , there are some code which i didn't understand.

question one:

		".Lkvm_vmx_return: "
		/* Save guest registers, load host registers, keep flags */
		"xchg %0,     (%%"R"sp) \n\t"
		"mov %%"R"ax, %c[rax](%0) \n\t"
		"mov %%"R"bx, %c[rbx](%0) \n\t"
		"push"Q" (%%"R"sp); pop"Q" %c[rcx](%0) \n\t"
		"mov %%"R"dx, %c[rdx](%0) \n\t"
		"mov %%"R"si, %c[rsi](%0) \n\t"
		"mov %%"R"di, %c[rdi](%0) \n\t"
		"mov %%"R"bp, %c[rbp](%0) \n\t"

why need
"xchg %0, (%%"R"sp) \n\t"
and
"push"Q" (%%"R"sp); pop"Q" %c[rcx](%0) \n\t"
I think rsp will restore when vm exits, why we change it?

question two:
before vm entry

		/* Store host registers */
		"push %%"R"dx; push %%"R"bp;"
		"push %%"R"cx \n\t"
and  after vm exit
		"pop  %%"R"bp; pop  %%"R"bp; pop  %%"R"dx \n\t"

why we need push rdx,rbp,rcx, and didn't pop rcx; and why we didn't save other register?

--------------
jemmy858585
2010-10-31