From: Xiao Guangrong <guangrong.xiao@linux.intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: gleb@kernel.org, mtosatti@redhat.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 8/9] KVM: MMU: fix MTRR update
Date: Mon, 11 May 2015 21:02:37 +0800 [thread overview]
Message-ID: <5550A86D.6000601@linux.intel.com> (raw)
In-Reply-To: <554B987E.2060603@redhat.com>
On 05/08/2015 12:53 AM, Paolo Bonzini wrote:
>
>
> On 30/04/2015 12:24, guangrong.xiao@linux.intel.com wrote:
>> +static void vmx_set_msr_mtrr(struct kvm_vcpu *vcpu, u32 msr)
>> +{
>> + struct mtrr_state_type *mtrr_state = &vcpu->arch.mtrr_state;
>> + unsigned char mtrr_enabled = mtrr_state->enabled;
>> + gfn_t start, end, mask;
>> + int index;
>> + bool is_fixed = true;
>> +
>> + if (msr == MSR_IA32_CR_PAT || !enable_ept ||
>> + !kvm_arch_has_noncoherent_dma(vcpu->kvm))
>> + return;
>> +
>> + if (!(mtrr_enabled & 0x2) && msr != MSR_MTRRdefType)
>> + return;
>> +
>> + switch (msr) {
>> + case MSR_MTRRfix64K_00000:
>> + start = 0x0;
>> + end = 0x80000;
>> + break;
>> + case MSR_MTRRfix16K_80000:
>> + start = 0x80000;
>> + end = 0xa0000;
>> + break;
>> + case MSR_MTRRfix16K_A0000:
>> + start = 0xa0000;
>> + end = 0xc0000;
>> + break;
>> + case MSR_MTRRfix4K_C0000 ... MSR_MTRRfix4K_F8000:
>> + index = msr - MSR_MTRRfix4K_C0000;
>> + start = 0xc0000 + index * (32 << 10);
>> + end = start + (32 << 10);
>> + break;
>> + case MSR_MTRRdefType:
>> + is_fixed = false;
>> + start = 0x0;
>> + end = ~0ULL;
>> + break;
>> + default:
>> + /* variable range MTRRs. */
>> + is_fixed = false;
>> + index = (msr - 0x200) / 2;
>> + start = (((u64)mtrr_state->var_ranges[index].base_hi) << 32) +
>> + (mtrr_state->var_ranges[index].base_lo & PAGE_MASK);
>> + mask = (((u64)mtrr_state->var_ranges[index].mask_hi) << 32) +
>> + (mtrr_state->var_ranges[index].mask_lo & PAGE_MASK);
>> + mask |= ~0ULL << cpuid_maxphyaddr(vcpu);
>> +
>> + end = ((start & mask) | ~mask) + 1;
>> + }
>> +
>> + if (is_fixed && !(mtrr_enabled & 0x1))
>> + return;
>> +
>> + kvm_zap_gfn_range(vcpu->kvm, gpa_to_gfn(start), gpa_to_gfn(end));
>> +}
>
> I think this should all be generic logic, even if it causes some extra
> zaps on AMD. (It's AMD's bug that it doesn't honor MTRRs).
Okay, will move the function to x86.c and kill the callback in x86_ops.
>
> Even !enable_ept can be handled in a vendor-independent manner, as
> "vcpu->arch.mmu.page_fault == tdp_page_fault".
We can directly use 'tdp_enabled', it has already been extern-ed. :)
next prev parent reply other threads:[~2015-05-11 13:06 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-30 10:24 [PATCH 0/9] KVM: MTRR fixes and some cleanups guangrong.xiao
2015-04-30 10:24 ` [PATCH 1/9] KVM: MMU: fix decoding cache type from MTRR guangrong.xiao
2015-04-30 10:24 ` [PATCH 2/9] KVM: MMU: introduce slot_handle_level() and its helper guangrong.xiao
2015-05-07 12:04 ` Paolo Bonzini
2015-05-11 13:00 ` Xiao Guangrong
2015-04-30 10:24 ` [PATCH 3/9] KVM: MMU: use slot_handle_level and its helper to clean up the code guangrong.xiao
2015-04-30 10:24 ` [PATCH 4/9] KVM: MMU: introduce for_each_rmap_spte() guangrong.xiao
2015-04-30 10:24 ` [PATCH 5/9] KVM: MMU: KVM: introduce for_each_slot_rmap guangrong.xiao
2015-04-30 10:24 ` [PATCH 6/9] KVM: MMU: introduce kvm_zap_rmapp guangrong.xiao
2015-04-30 10:24 ` [PATCH 7/9] KVM: MMU: introduce kvm_zap_gfn_range() guangrong.xiao
2015-04-30 10:24 ` [PATCH 8/9] KVM: MMU: fix MTRR update guangrong.xiao
2015-05-06 21:36 ` David Matlack
2015-05-07 1:57 ` Xiao Guangrong
2015-05-07 16:53 ` Paolo Bonzini
2015-05-11 13:02 ` Xiao Guangrong [this message]
2015-04-30 10:24 ` [PATCH 9/9] KVM: x86: do not reset mmu if CR0.CD and CR0.NW are changed guangrong.xiao
2015-04-30 10:24 ` [PATCH 0/9] KVM: MTRR fixes and some cleanups guangrong.xiao
2015-04-30 10:24 ` [PATCH 1/9] KVM: MMU: fix decoding cache type from MTRR guangrong.xiao
2015-05-06 21:42 ` David Matlack
2015-05-07 2:07 ` Xiao Guangrong
2015-04-30 10:24 ` [PATCH 2/9] KVM: MMU: introduce slot_handle_level() and its helper guangrong.xiao
2015-04-30 10:24 ` [PATCH 3/9] KVM: MMU: use slot_handle_level and its helper to clean up the code guangrong.xiao
2015-04-30 10:24 ` [PATCH 4/9] KVM: MMU: introduce for_each_rmap_spte() guangrong.xiao
2015-04-30 10:24 ` [PATCH 5/9] KVM: MMU: KVM: introduce for_each_slot_rmap guangrong.xiao
2015-04-30 10:24 ` [PATCH 6/9] KVM: MMU: introduce kvm_zap_rmapp guangrong.xiao
2015-04-30 10:24 ` [PATCH 7/9] KVM: MMU: introduce kvm_zap_gfn_range() guangrong.xiao
2015-04-30 10:24 ` [PATCH 8/9] KVM: MMU: fix MTRR update guangrong.xiao
2015-04-30 10:24 ` [PATCH 9/9] KVM: x86: do not reset mmu if CR0.CD and CR0.NW are changed guangrong.xiao
2015-05-07 16:53 ` [PATCH 0/9] KVM: MTRR fixes and some cleanups 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=5550A86D.6000601@linux.intel.com \
--to=guangrong.xiao@linux.intel.com \
--cc=gleb@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.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