diff options
Diffstat (limited to 'arch/x86/kvm/svm/nested.c')
| -rw-r--r-- | arch/x86/kvm/svm/nested.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index cf148f7db887..13de4f63a9c2 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -197,6 +197,29 @@ void recalc_intercepts(struct vcpu_svm *svm) static int nested_svm_msrpm_merge_offsets[6] __ro_after_init; static int nested_svm_nr_msrpm_merge_offsets __ro_after_init; +static const u32 msrpm_ranges[] = {0, 0xc0000000, 0xc0010000}; + +static u32 svm_msrpm_offset(u32 msr) +{ + u32 offset; + int i; + + for (i = 0; i < ARRAY_SIZE(msrpm_ranges); i++) { + if (msr < msrpm_ranges[i] || + msr >= msrpm_ranges[i] + SVM_MSRS_PER_RANGE) + continue; + + offset = (msr - msrpm_ranges[i]) / SVM_MSRS_PER_BYTE; + offset += (i * SVM_MSRPM_BYTES_PER_RANGE); /* add range offset */ + + /* Now we have the u8 offset - but need the u32 offset */ + return offset / 4; + } + + /* MSR not in any range */ + return MSR_INVALID; +} + int __init nested_svm_init_msrpm_merge_offsets(void) { static const u32 merge_msrs[] __initconst = { |
