Skip to content

Commit 6dc98b8

Browse files
Xiao Guangrongbonzini
authored andcommitted
KVM: MMU: split reset_rsvds_bits_mask
Since softmmu & AMD nested shadow page tables and guest page tables have the same format, split reset_rsvds_bits_mask so that the logic can be reused by later patches which check zero bits on sptes Signed-off-by: Xiao Guangrong <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent a0a64f5 commit 6dc98b8

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

arch/x86/kvm/mmu.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3568,20 +3568,21 @@ static bool is_rsvd_bits_set(struct kvm_mmu *mmu, u64 gpte, int level)
35683568
#include "paging_tmpl.h"
35693569
#undef PTTYPE
35703570

3571-
static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu,
3572-
struct kvm_mmu *context)
3571+
static void
3572+
__reset_rsvds_bits_mask(struct kvm_vcpu *vcpu,
3573+
struct rsvd_bits_validate *rsvd_check,
3574+
int maxphyaddr, int level, bool nx, bool gbpages,
3575+
bool pse)
35733576
{
3574-
struct rsvd_bits_validate *rsvd_check = &context->guest_rsvd_check;
3575-
int maxphyaddr = cpuid_maxphyaddr(vcpu);
35763577
u64 exb_bit_rsvd = 0;
35773578
u64 gbpages_bit_rsvd = 0;
35783579
u64 nonleaf_bit8_rsvd = 0;
35793580

35803581
rsvd_check->bad_mt_xwr = 0;
35813582

3582-
if (!context->nx)
3583+
if (!nx)
35833584
exb_bit_rsvd = rsvd_bits(63, 63);
3584-
if (!guest_cpuid_has_gbpages(vcpu))
3585+
if (!gbpages)
35853586
gbpages_bit_rsvd = rsvd_bits(7, 7);
35863587

35873588
/*
@@ -3591,15 +3592,15 @@ static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu,
35913592
if (guest_cpuid_is_amd(vcpu))
35923593
nonleaf_bit8_rsvd = rsvd_bits(8, 8);
35933594

3594-
switch (context->root_level) {
3595+
switch (level) {
35953596
case PT32_ROOT_LEVEL:
35963597
/* no rsvd bits for 2 level 4K page table entries */
35973598
rsvd_check->rsvd_bits_mask[0][1] = 0;
35983599
rsvd_check->rsvd_bits_mask[0][0] = 0;
35993600
rsvd_check->rsvd_bits_mask[1][0] =
36003601
rsvd_check->rsvd_bits_mask[0][0];
36013602

3602-
if (!is_pse(vcpu)) {
3603+
if (!pse) {
36033604
rsvd_check->rsvd_bits_mask[1][1] = 0;
36043605
break;
36053606
}
@@ -3650,6 +3651,15 @@ static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu,
36503651
}
36513652
}
36523653

3654+
static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu,
3655+
struct kvm_mmu *context)
3656+
{
3657+
__reset_rsvds_bits_mask(vcpu, &context->guest_rsvd_check,
3658+
cpuid_maxphyaddr(vcpu), context->root_level,
3659+
context->nx, guest_cpuid_has_gbpages(vcpu),
3660+
is_pse(vcpu));
3661+
}
3662+
36533663
static void reset_rsvds_bits_mask_ept(struct kvm_vcpu *vcpu,
36543664
struct kvm_mmu *context, bool execonly)
36553665
{

0 commit comments

Comments
 (0)