KVM: mmio: cleanup kvm_set_mmio_spte_mask
PATCH 1/1 KVM: mmio: cleanup kvm_set_mmio_spte_mask
Just reuse rsvd_bits() inside kvm_set_mmio_spte_mask() for slightly better code.
Signed-off-by Tiejun Chen <[email protected]>
--- arch/x86/kvm/mmu.c | 5 ----- arch/x86/kvm/mmu.h | 5 +++++ arch/x86/kvm/x86.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
arch/x86/kvm/mmu.c +0 -5
@@ -296,11 +296,6 @@ static bool check_mmio_spte(struct kvm *kvm, u64 spte)return likely (kvm_gen == spte_gen); } -static inline u64 rsvd_bits (int s,int e) -{ -return ((1ULL << (e - s +1 )) -1 ) << s; -} -void kvm_mmu_set_mask_ptes (u64 user_mask,u64 accessed_mask,u64 dirty_mask,u64 nx_mask,u64 x_mask) {
arch/x86/kvm/mmu.h +5 -0
@@ -56,6 +56,11 @@#define PFERR_RSVD_MASK (1U << PFERR_RSVD_BIT)#define PFERR_FETCH_MASK (1U << PFERR_FETCH_BIT) +static inline u64 rsvd_bits (int s,int e) +{ +return ((1ULL << (e - s +1 )) -1 ) << s; +} +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);
arch/x86/kvm/x86.c +1 -1
@@ -5545,7 +5545,7 @@ static void kvm_set_mmio_spte_mask(void)* entry to generate page fault with PFER.RSV = 1. */ /* Mask the reserved physical address bits. */ - mask = ((1ull << (51 - maxphyaddr +1 )) -1 ) << maxphyaddr; + mask =rsvd_bits (maxphyaddr,51 );/* Bit 62 is always reserved for 32bit host. */ mask |=0x3ull <<62 ;
Signature · 1 line
1.9.1
Paolo Bonzini
maintainerIl 01/09/2014 12:44, Tiejun Chen ha scritto:
Quoted 48 lines
Just reuse
rsvd_bits()insidekvm_set_mmio_spte_mask()for slightly better code.Signed-off-by Tiejun Chen <[email protected]>--- arch/x86/kvm/mmu.c | 5 ----- arch/x86/kvm/mmu.h | 5 +++++ arch/x86/kvm/x86.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)arch/x86/kvm/mmu.c +0
-5@@ -296,11 +296,6 @@ static bool check_mmio_spte(struct kvm *kvm, u64 spte)return likely (kvm_gen == spte_gen); } -static inline u64 rsvd_bits (int s,int e) -{ -return ((1ULL << (e - s +1 )) -1 ) << s; -} -void kvm_mmu_set_mask_ptes (u64 user_mask,u64 accessed_mask,u64 dirty_mask,u64 nx_mask,u64 x_mask) {arch/x86/kvm/mmu.h +5
-0@@ -56,6 +56,11 @@#define PFERR_RSVD_MASK (1U << PFERR_RSVD_BIT)#define PFERR_FETCH_MASK (1U << PFERR_FETCH_BIT) +static inline u64 rsvd_bits (int s,int e) +{ +return ((1ULL << (e - s +1 )) -1 ) << s; +} +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);arch/x86/kvm/x86.c +0
-0
arch/x86/kvm/x86.c static void kvm_set_mmio_spte_mask(void) · line 5551
Quoted 8 lines
arch/x86/kvm/x86.c +1
-1@@ -5545,7 +5545,7 @@ static void kvm_set_mmio_spte_mask(void)* entry to generate page fault with PFER.RSV = 1. */ /* Mask the reserved physical address bits. */ - mask = ((1ull << (51 - maxphyaddr +1 )) -1 ) << maxphyaddr; + mask =rsvd_bits (maxphyaddr,51 );/* Bit 62 is always reserved for 32bit host. */ mask |=0x3ull <<62 ;
Nice, thanks.
Paolo