[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1583376535-27255-1-git-send-email-linmiaohe@huawei.com>
Date: Thu, 5 Mar 2020 10:48:55 +0800
From: linmiaohe <linmiaohe@...wei.com>
To: <pbonzini@...hat.com>, <rkrcmar@...hat.com>,
<sean.j.christopherson@...el.com>, <vkuznets@...hat.com>,
<jmattson@...gle.com>, <joro@...tes.org>, <tglx@...utronix.de>,
<mingo@...hat.com>, <bp@...en8.de>, <hpa@...or.com>
CC: <linmiaohe@...wei.com>, <kvm@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <x86@...nel.org>
Subject: [PATCH] KVM: x86: small optimization for is_mtrr_mask calculation
From: Miaohe Lin <linmiaohe@...wei.com>
We can get is_mtrr_mask by calculating (msr - 0x200) % 2 directly.
Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
---
arch/x86/kvm/mtrr.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c
index 7f0059aa30e1..a98701d9f2bf 100644
--- a/arch/x86/kvm/mtrr.c
+++ b/arch/x86/kvm/mtrr.c
@@ -348,7 +348,7 @@ static void set_var_mtrr_msr(struct kvm_vcpu *vcpu, u32 msr, u64 data)
int index, is_mtrr_mask;
index = (msr - 0x200) / 2;
- is_mtrr_mask = msr - 0x200 - 2 * index;
+ is_mtrr_mask = (msr - 0x200) % 2;
cur = &mtrr_state->var_ranges[index];
/* remove the entry if it's in the list. */
@@ -424,7 +424,7 @@ int kvm_mtrr_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
int is_mtrr_mask;
index = (msr - 0x200) / 2;
- is_mtrr_mask = msr - 0x200 - 2 * index;
+ is_mtrr_mask = (msr - 0x200) % 2;
if (!is_mtrr_mask)
*pdata = vcpu->arch.mtrr_state.var_ranges[index].base;
else
--
2.19.1
Powered by blists - more mailing lists