mbox series

[0/4] Add and use helpers to check bit set in CR0/CR4

Message ID 20230322045824.22970-1-binbin.wu@linux.intel.com (mailing list archive)
Headers show
Series Add and use helpers to check bit set in CR0/CR4 | expand

Message

Binbin Wu March 22, 2023, 4:58 a.m. UTC
Add two helpers
- kvm_is_cr0_bit_set()
- kvm_is_cr4_bit_set()
to do CR0/CR4 check on one specific bit and return the value in bool.
Replace kvm_read_{cr0,cr4}_bits() with kvm_is_{cr0,cr4}_bit_set() when applicable.

Also change return type of is_pae(), is_pse(), is_paging() and is_long_mode()
to bool.

No functional change intended.

The patch series is originated from cleanup code of KVM LAM enabling patchset by
Robert Hu
(https://lore.kernel.org/all/20230227084547.404871-3-robert.hu@linux.intel.com),
and suggested by Sean Christopherson during code review
(https://lore.kernel.org/all/ZAuRec2NkC3+4jvD@google.com).

Binbin Wu (4):
  KVM: x86: Add helpers to check bit set in CR0/CR4 and return in bool
  KVM: x86: Replace kvm_read_{cr0,cr4}_bits() with
    kvm_is_{cr0,cr4}_bit_set()
  KVM: SVM: Remove implicit cast from ulong to bool in
    svm_can_emulate_instruction()
  KVM: x86: Change return type of is_long_mode() to bool

 arch/x86/kvm/cpuid.c          |  4 ++--
 arch/x86/kvm/kvm_cache_regs.h | 16 ++++++++++++++++
 arch/x86/kvm/mmu.h            |  2 +-
 arch/x86/kvm/svm/svm.c        |  9 +++------
 arch/x86/kvm/vmx/nested.c     |  2 +-
 arch/x86/kvm/vmx/vmx.c        |  2 +-
 arch/x86/kvm/x86.c            | 20 ++++++++++----------
 arch/x86/kvm/x86.h            | 22 +++++++++++-----------
 8 files changed, 45 insertions(+), 32 deletions(-)

Comments

Sean Christopherson March 23, 2023, 10:47 p.m. UTC | #1
On Wed, 22 Mar 2023 12:58:20 +0800, Binbin Wu wrote:
> Add two helpers
> - kvm_is_cr0_bit_set()
> - kvm_is_cr4_bit_set()
> to do CR0/CR4 check on one specific bit and return the value in bool.
> Replace kvm_read_{cr0,cr4}_bits() with kvm_is_{cr0,cr4}_bit_set() when applicable.
> 
> Also change return type of is_pae(), is_pse(), is_paging() and is_long_mode()
> to bool.
> 
> [...]

Applied to kvm-x86 misc, with a fair bit of massaging to the changelogs.
Thanks much for putting this together!

[1/4] KVM: x86: Add helpers to check bit set in CR0/CR4 and return in bool
      https://github.com/kvm-x86/linux/commit/607475cfa0f7
[2/4] KVM: x86: Replace kvm_read_{cr0,cr4}_bits() with kvm_is_{cr0,cr4}_bit_set()
      https://github.com/kvm-x86/linux/commit/bede6eb4db19
[3/4] KVM: SVM: Remove implicit cast from ulong to bool in svm_can_emulate_instruction()
      https://github.com/kvm-x86/linux/commit/627778bfcfa1
[4/4] KVM: x86: Change return type of is_long_mode() to bool
      https://github.com/kvm-x86/linux/commit/68f7c82ab1b8

--
https://github.com/kvm-x86/linux/tree/next
https://github.com/kvm-x86/linux/tree/fixes