[0/3] KVM: x86/mmu: Use kernel's PG_LEVEL_* enums
mbox series

Message ID 20200428005422.4235-1-sean.j.christopherson@intel.com
Headers show
Series
  • KVM: x86/mmu: Use kernel's PG_LEVEL_* enums
Related show

Message

Sean Christopherson April 28, 2020, 12:54 a.m. UTC
Drop KVM's PT_{PAGE_TABLE,DIRECTORY,PDPE}_LEVEL KVM enums in favor of the
kernel's PG_LEVEL_{4K,2M,1G} enums, which have far more user friendly
names.

The KVM names were presumably intended to abstract away the page size.  In
practice, the abstraction is only useful for a single line of code, a PSE
paging related large page check.  For everything else, the abstract names
do nothing but obfuscate the code.

Boot tested a PSE kernel under 32-bit KVM and 64-bit KVM, with and without
EPT enabled.  Patches 2 and 3 generate no binary difference relative to
patch 1 when compared via "objdump -d".

Sean Christopherson (3):
  KVM: x86/mmu: Tweak PSE hugepage handling to avoid 2M vs 4M conundrum
  KVM: x86/mmu: Move max hugepage level to a separate #define
  KVM: x86/mmu: Drop KVM's hugepage enums in favor of the kernel's enums

 arch/x86/include/asm/kvm_host.h |  13 +---
 arch/x86/kvm/mmu/mmu.c          | 118 +++++++++++++++-----------------
 arch/x86/kvm/mmu/page_track.c   |   4 +-
 arch/x86/kvm/mmu/paging_tmpl.h  |  18 ++---
 arch/x86/kvm/mmu_audit.c        |   6 +-
 arch/x86/kvm/svm/svm.c          |   2 +-
 arch/x86/kvm/vmx/vmx.c          |   6 +-
 arch/x86/kvm/x86.c              |   4 +-
 8 files changed, 79 insertions(+), 92 deletions(-)

Comments

Barret Rhoden April 28, 2020, 2:14 p.m. UTC | #1
On 4/27/20 8:54 PM, Sean Christopherson wrote:
> Drop KVM's PT_{PAGE_TABLE,DIRECTORY,PDPE}_LEVEL KVM enums in favor of the
> kernel's PG_LEVEL_{4K,2M,1G} enums, which have far more user friendly
> names.

thanks for doing this - it fell off my radar.

all 3:

Reviewed-by: Barret Rhoden <brho@google.com>

> 
> The KVM names were presumably intended to abstract away the page size.  In
> practice, the abstraction is only useful for a single line of code, a PSE
> paging related large page check.  For everything else, the abstract names
> do nothing but obfuscate the code.
> 
> Boot tested a PSE kernel under 32-bit KVM and 64-bit KVM, with and without
> EPT enabled.  Patches 2 and 3 generate no binary difference relative to
> patch 1 when compared via "objdump -d".
> 
> Sean Christopherson (3):
>    KVM: x86/mmu: Tweak PSE hugepage handling to avoid 2M vs 4M conundrum
>    KVM: x86/mmu: Move max hugepage level to a separate #define
>    KVM: x86/mmu: Drop KVM's hugepage enums in favor of the kernel's enums
> 
>   arch/x86/include/asm/kvm_host.h |  13 +---
>   arch/x86/kvm/mmu/mmu.c          | 118 +++++++++++++++-----------------
>   arch/x86/kvm/mmu/page_track.c   |   4 +-
>   arch/x86/kvm/mmu/paging_tmpl.h  |  18 ++---
>   arch/x86/kvm/mmu_audit.c        |   6 +-
>   arch/x86/kvm/svm/svm.c          |   2 +-
>   arch/x86/kvm/vmx/vmx.c          |   6 +-
>   arch/x86/kvm/x86.c              |   4 +-
>   8 files changed, 79 insertions(+), 92 deletions(-)
>
Paolo Bonzini May 4, 2020, 4:49 p.m. UTC | #2
On 28/04/20 02:54, Sean Christopherson wrote:
> Drop KVM's PT_{PAGE_TABLE,DIRECTORY,PDPE}_LEVEL KVM enums in favor of the
> kernel's PG_LEVEL_{4K,2M,1G} enums, which have far more user friendly
> names.
> 
> The KVM names were presumably intended to abstract away the page size.  In
> practice, the abstraction is only useful for a single line of code, a PSE
> paging related large page check.  For everything else, the abstract names
> do nothing but obfuscate the code.
> 
> Boot tested a PSE kernel under 32-bit KVM and 64-bit KVM, with and without
> EPT enabled.  Patches 2 and 3 generate no binary difference relative to
> patch 1 when compared via "objdump -d".
> 
> Sean Christopherson (3):
>   KVM: x86/mmu: Tweak PSE hugepage handling to avoid 2M vs 4M conundrum
>   KVM: x86/mmu: Move max hugepage level to a separate #define
>   KVM: x86/mmu: Drop KVM's hugepage enums in favor of the kernel's enums
> 
>  arch/x86/include/asm/kvm_host.h |  13 +---
>  arch/x86/kvm/mmu/mmu.c          | 118 +++++++++++++++-----------------
>  arch/x86/kvm/mmu/page_track.c   |   4 +-
>  arch/x86/kvm/mmu/paging_tmpl.h  |  18 ++---
>  arch/x86/kvm/mmu_audit.c        |   6 +-
>  arch/x86/kvm/svm/svm.c          |   2 +-
>  arch/x86/kvm/vmx/vmx.c          |   6 +-
>  arch/x86/kvm/x86.c              |   4 +-
>  8 files changed, 79 insertions(+), 92 deletions(-)
> 

Queued, thanks.

Paolo