From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 2/5] kvm/svm: enhance MOV CR intercept handler Date: Tue, 07 Dec 2010 16:41:37 +0200 Message-ID: <4CFE47A1.1010209@redhat.com> References: <1291719586-22533-1-git-send-email-andre.przywara@amd.com> <1291719586-22533-3-git-send-email-andre.przywara@amd.com> <4CFE3581.20305@redhat.com> <4CFE44EE.7000807@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "kvm@vger.kernel.org" , "mtosatti@redhat.com" To: Andre Przywara Return-path: Received: from mx1.redhat.com ([209.132.183.28]:50457 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752018Ab0LGOlo (ORCPT ); Tue, 7 Dec 2010 09:41:44 -0500 In-Reply-To: <4CFE44EE.7000807@amd.com> Sender: kvm-owner@vger.kernel.org List-ID: On 12/07/2010 04:30 PM, Andre Przywara wrote: > Avi Kivity wrote: >> On 12/07/2010 12:59 PM, Andre Przywara wrote: >>> Newer SVM implementations provide the GPR number in the VMCB, so >>> that the emulation path is no longer necesarry to handle CR >>> register access intercepts. Implement the handling in svm.c and >>> use it when the info is provided. >>> >>> Signed-off-by: Andre Przywara >>> --- >>> arch/x86/include/asm/svm.h | 2 + >>> arch/x86/kvm/svm.c | 74 >>> +++++++++++++++++++++++++++++++++++++++----- >>> 2 files changed, 68 insertions(+), 8 deletions(-) >>> >>> diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h >>> index 11dbca7..589fc25 100644 >>> --- a/arch/x86/include/asm/svm.h >>> +++ b/arch/x86/include/asm/svm.h >>> ... >>> @@ -2864,14 +2922,14 @@ static int pause_interception(struct >>> vcpu_svm *svm) >>> } >>> >>> static int (*svm_exit_handlers[])(struct vcpu_svm *svm) = { >>> - [SVM_EXIT_READ_CR0] = emulate_on_interception, >>> - [SVM_EXIT_READ_CR3] = emulate_on_interception, >>> - [SVM_EXIT_READ_CR4] = emulate_on_interception, >>> - [SVM_EXIT_READ_CR8] = emulate_on_interception, >>> + [SVM_EXIT_READ_CR0] = cr_interception, >>> + [SVM_EXIT_READ_CR3] = cr_interception, >>> + [SVM_EXIT_READ_CR4] = cr_interception, >>> + [SVM_EXIT_READ_CR8] = cr_interception, >>> [SVM_EXIT_CR0_SEL_WRITE] = emulate_on_interception, >>> [SVM_EXIT_WRITE_CR0] = cr0_write_interception, >>> - [SVM_EXIT_WRITE_CR3] = emulate_on_interception, >>> - [SVM_EXIT_WRITE_CR4] = emulate_on_interception, >>> + [SVM_EXIT_WRITE_CR3] = cr_interception, >>> + [SVM_EXIT_WRITE_CR4] = cr_interception, >>> [SVM_EXIT_WRITE_CR8] = cr8_write_interception, >> >> We could move cr[08]_write_interception into cr_interception, but >> that takes a bit more thought. Best done later. > Yes, I thought about that, too. But since we still have to deal with > the emulation code path, it would not make the code easier. But if we > overwrite the svm_exit_handlers[] on detecting the SVM feature, this > could make more sense. I will check this out. > In fact the correct thing is to make sure kvm_set_cr0() and kvm_set_cr8() do the right thing, so that the emulation path invoked directly (not through a cr intercept) works. -- error compiling committee.c: too many arguments to function