From: Xiao Guangrong <xiaoguangrong.eric@gmail.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>,
avi.kivity@gmail.com, mtosatti@redhat.com, pbonzini@redhat.com,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH v3 3/6] KVM: MMU: make return value of mmio page fault handler more readable
Date: Mon, 10 Jun 2013 16:45:51 +0800 [thread overview]
Message-ID: <51B5923F.9050801@gmail.com> (raw)
In-Reply-To: <20130610075750.GZ4725@redhat.com>
On 06/10/2013 03:57 PM, Gleb Natapov wrote:
> On Fri, Jun 07, 2013 at 04:51:25PM +0800, Xiao Guangrong wrote:
>> Define some meaningful names instead of raw code
>>
>> Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
>> ---
>> arch/x86/kvm/mmu.c | 15 +++++----------
>> arch/x86/kvm/mmu.h | 14 ++++++++++++++
>> arch/x86/kvm/vmx.c | 4 ++--
>> 3 files changed, 21 insertions(+), 12 deletions(-)
>>
>> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
>> index eca91bd..044d8c0 100644
>> --- a/arch/x86/kvm/mmu.c
>> +++ b/arch/x86/kvm/mmu.c
>> @@ -3222,17 +3222,12 @@ static u64 walk_shadow_page_get_mmio_spte(struct kvm_vcpu *vcpu, u64 addr)
>> return spte;
>> }
>>
>> -/*
>> - * If it is a real mmio page fault, return 1 and emulat the instruction
>> - * directly, return 0 to let CPU fault again on the address, -1 is
>> - * returned if bug is detected.
>> - */
>> int handle_mmio_page_fault_common(struct kvm_vcpu *vcpu, u64 addr, bool direct)
>> {
>> u64 spte;
>>
>> if (quickly_check_mmio_pf(vcpu, addr, direct))
>> - return 1;
>> + return RET_MMIO_PF_EMULATE;
>>
>> spte = walk_shadow_page_get_mmio_spte(vcpu, addr);
>>
>> @@ -3245,7 +3240,7 @@ int handle_mmio_page_fault_common(struct kvm_vcpu *vcpu, u64 addr, bool direct)
>>
>> trace_handle_mmio_page_fault(addr, gfn, access);
>> vcpu_cache_mmio_info(vcpu, addr, gfn, access);
>> - return 1;
>> + return RET_MMIO_PF_EMULATE;
>> }
>>
>> /*
>> @@ -3253,13 +3248,13 @@ int handle_mmio_page_fault_common(struct kvm_vcpu *vcpu, u64 addr, bool direct)
>> * it's a BUG if the gfn is not a mmio page.
>> */
>> if (direct && !check_direct_spte_mmio_pf(spte))
>> - return -1;
>> + return RET_MMIO_PF_BUG;
>>
>> /*
>> * If the page table is zapped by other cpus, let CPU fault again on
>> * the address.
>> */
>> - return 0;
>> + return RET_MMIO_PF_RETRY;
>> }
>> EXPORT_SYMBOL_GPL(handle_mmio_page_fault_common);
>>
>> @@ -3269,7 +3264,7 @@ static int handle_mmio_page_fault(struct kvm_vcpu *vcpu, u64 addr,
>> int ret;
>>
>> ret = handle_mmio_page_fault_common(vcpu, addr, direct);
>> - WARN_ON(ret < 0);
>> + WARN_ON(ret == RET_MMIO_PF_BUG);
>> return ret;
>> }
>>
>> diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
>> index 922bfae..ba6a19c 100644
>> --- a/arch/x86/kvm/mmu.h
>> +++ b/arch/x86/kvm/mmu.h
>> @@ -52,6 +52,20 @@
>>
>> int kvm_mmu_get_spte_hierarchy(struct kvm_vcpu *vcpu, u64 addr, u64 sptes[4]);
>> void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask);
>> +
>> +/*
>> + * Return values of handle_mmio_page_fault_common:
>> + * RET_MMIO_PF_EMULATE: it is a real mmio page fault, emulate the instruction
>> + * directly.
>> + * RET_MMIO_PF_RETRY: let CPU fault again on the address.
>> + * RET_MMIO_PF_BUG: bug is detected.
>> + */
>> +enum {
>> + RET_MMIO_PF_EMULATE = 1,
>> + RET_MMIO_PF_RETRY = 0,
>> + RET_MMIO_PF_BUG = -1
>> +};
> I would order them from -1 to 1 and rename RET_MMIO_PF_BUG to
> RET_MMIO_PF_ERROR, but no need to resend just for that.
Fine to me. Will make a separate patch to update it later. Thanks for your review!
next prev parent reply other threads:[~2013-06-10 8:46 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-07 8:51 [PATCH v3 0/6] KVM: MMU: fast invalidate all mmio sptes Xiao Guangrong
2013-06-07 8:51 ` [PATCH v3 1/6] KVM: MMU: retain more available bits on mmio spte Xiao Guangrong
2013-06-07 8:51 ` [PATCH v3 2/6] KVM: MMU: store generation-number into " Xiao Guangrong
2013-06-07 8:51 ` [PATCH v3 3/6] KVM: MMU: make return value of mmio page fault handler more readable Xiao Guangrong
2013-06-10 7:57 ` Gleb Natapov
2013-06-10 8:45 ` Xiao Guangrong [this message]
2013-06-10 13:16 ` Takuya Yoshikawa
2013-06-11 9:18 ` Gleb Natapov
2013-06-07 8:51 ` [PATCH v3 4/6] KVM: MMU: fast invalidate all mmio sptes Xiao Guangrong
2013-06-27 8:29 ` Gleb Natapov
2013-06-27 9:01 ` Gleb Natapov
2013-06-27 9:14 ` Gleb Natapov
2013-06-27 9:21 ` Gleb Natapov
2013-06-27 9:50 ` Xiao Guangrong
2013-06-27 10:19 ` Gleb Natapov
2013-06-27 11:05 ` Xiao Guangrong
2013-06-27 11:10 ` Gleb Natapov
2013-06-07 8:51 ` [PATCH v3 5/6] KVM: MMU: add tracepoint for check_mmio_spte Xiao Guangrong
2013-06-07 8:51 ` [PATCH v3 6/6] KVM: MMU: init kvm generation close to mmio wrap-around value Xiao Guangrong
2013-06-10 7:56 ` [PATCH v3 0/6] KVM: MMU: fast invalidate all mmio sptes Gleb Natapov
2013-06-10 8:39 ` Xiao Guangrong
2013-06-10 13:43 ` Takuya Yoshikawa
2013-06-10 17:03 ` Gleb Natapov
2013-06-19 11:08 ` Paolo Bonzini
2013-06-19 11:27 ` Xiao Guangrong
2013-06-14 0:08 ` Marcelo Tosatti
2013-06-15 2:22 ` Takuya Yoshikawa
2013-06-17 11:59 ` Xiao Guangrong
2013-06-18 22:21 ` Marcelo Tosatti
2013-06-18 14:26 ` Paolo Bonzini
2013-06-19 2:47 ` Xiao Guangrong
2013-06-19 17:40 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51B5923F.9050801@gmail.com \
--to=xiaoguangrong.eric@gmail.com \
--cc=avi.kivity@gmail.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=xiaoguangrong@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).