diff options
author | Laurent Vivier <Laurent.Vivier@bull.net> | 2007-10-25 08:18:53 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-01-30 10:52:56 -0500 |
commit | 54a08c0449683f763dc69e653d17e8c120e16299 (patch) | |
tree | 959fd4654d64837d2eeb87d37fe1506a295f5cb7 /drivers/kvm/svm.c | |
parent | ff593e5abebd899b0b41c11280e2fbeff4103375 (diff) |
KVM: SVM: Let gcc to choose which registers to save (x86_64)
This patch lets GCC to determine which registers to save when we
switch to/from a VCPU in the case of AMD x86_64.
* Original code saves following registers:
rbx, rcx, rdx, rsi, rdi, rbp,
r8, r9, r10, r11, r12, r13, r14, r15
* Patched code:
- informs GCC that we modify following registers
using the clobber description:
rbx, rcx, rdx, rsi, rdi
r8, r9, r10, r11, r12, r13, r14, r15
- rbp is saved (pop/push) because GCC seems to ignore its use in the clobber
description.
Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/svm.c')
-rw-r--r-- | drivers/kvm/svm.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c index beb1e684b68a..debd0912a016 100644 --- a/drivers/kvm/svm.c +++ b/drivers/kvm/svm.c | |||
@@ -1499,10 +1499,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
1499 | 1499 | ||
1500 | asm volatile ( | 1500 | asm volatile ( |
1501 | #ifdef CONFIG_X86_64 | 1501 | #ifdef CONFIG_X86_64 |
1502 | "push %%rbx; push %%rcx; push %%rdx;" | 1502 | "push %%rbp; \n\t" |
1503 | "push %%rsi; push %%rdi; push %%rbp;" | ||
1504 | "push %%r8; push %%r9; push %%r10; push %%r11;" | ||
1505 | "push %%r12; push %%r13; push %%r14; push %%r15;" | ||
1506 | #else | 1503 | #else |
1507 | "push %%ebx; push %%ecx; push %%edx;" | 1504 | "push %%ebx; push %%ecx; push %%edx;" |
1508 | "push %%esi; push %%edi; push %%ebp;" | 1505 | "push %%esi; push %%edi; push %%ebp;" |
@@ -1567,10 +1564,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
1567 | "mov %%r14, %c[r14](%[svm]) \n\t" | 1564 | "mov %%r14, %c[r14](%[svm]) \n\t" |
1568 | "mov %%r15, %c[r15](%[svm]) \n\t" | 1565 | "mov %%r15, %c[r15](%[svm]) \n\t" |
1569 | 1566 | ||
1570 | "pop %%r15; pop %%r14; pop %%r13; pop %%r12;" | 1567 | "pop %%rbp; \n\t" |
1571 | "pop %%r11; pop %%r10; pop %%r9; pop %%r8;" | ||
1572 | "pop %%rbp; pop %%rdi; pop %%rsi;" | ||
1573 | "pop %%rdx; pop %%rcx; pop %%rbx; \n\t" | ||
1574 | #else | 1568 | #else |
1575 | "mov %%ebx, %c[rbx](%[svm]) \n\t" | 1569 | "mov %%ebx, %c[rbx](%[svm]) \n\t" |
1576 | "mov %%ecx, %c[rcx](%[svm]) \n\t" | 1570 | "mov %%ecx, %c[rcx](%[svm]) \n\t" |
@@ -1601,7 +1595,12 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
1601 | [r14]"i"(offsetof(struct vcpu_svm, vcpu.regs[VCPU_REGS_R14])), | 1595 | [r14]"i"(offsetof(struct vcpu_svm, vcpu.regs[VCPU_REGS_R14])), |
1602 | [r15]"i"(offsetof(struct vcpu_svm, vcpu.regs[VCPU_REGS_R15])) | 1596 | [r15]"i"(offsetof(struct vcpu_svm, vcpu.regs[VCPU_REGS_R15])) |
1603 | #endif | 1597 | #endif |
1604 | : "cc", "memory"); | 1598 | : "cc", "memory" |
1599 | #ifdef CONFIG_X86_64 | ||
1600 | , "rbx", "rcx", "rdx", "rsi", "rdi" | ||
1601 | , "r8", "r9", "r10", "r11" , "r12", "r13", "r14", "r15" | ||
1602 | #endif | ||
1603 | ); | ||
1605 | 1604 | ||
1606 | if ((svm->vmcb->save.dr7 & 0xff)) | 1605 | if ((svm->vmcb->save.dr7 & 0xff)) |
1607 | load_db_regs(svm->host_db_regs); | 1606 | load_db_regs(svm->host_db_regs); |