mbox series

[v4,0/2] Add a helper to read GPR index and move INVPCID validation to a common place

Message ID 20211109174426.2350547-1-vipinsh@google.com (mailing list archive)
Headers show
Series Add a helper to read GPR index and move INVPCID validation to a common place | expand

Message

Vipin Sharma Nov. 9, 2021, 5:44 p.m. UTC
INVPCID, INVVPID, and INVEPT instructions retrieve the GPR index
similarly to find the invalidation type. Patch 1 moves the shift and
mask magic to a single place.

INVPCID invalidation type check is same for both VMX and SVM. This
instruction is not documented to verify the type before reading the
operand from memory. So, moving the check to a common place in patch 2.

v4:
- Changed commit message of the patch 1

v3:
- https://lore.kernel.org/lkml/20211103205911.1253463-1-vipinsh@google.com/
- Patch 2's commit message is more detailed now.

v2:
- https://lore.kernel.org/lkml/20211103183232.1213761-1-vipinsh@google.com/
- Keeping the register read visible in the functions.
- Removed INVPCID type check hardcoding and moved error condition to common 
  function.

v1: https://lore.kernel.org/lkml/20211011194615.2955791-1-vipinsh@google.com/

Vipin Sharma (2):
  KVM: VMX: Add a helper function to retrieve the GPR index for INVPCID,
    INVVPID, and INVEPT
  KVM: Move INVPCID type check from vmx and svm to the common
    kvm_handle_invpcid()

 arch/x86/kvm/svm/svm.c    |  5 -----
 arch/x86/kvm/vmx/nested.c | 10 ++++++----
 arch/x86/kvm/vmx/vmx.c    |  9 +++------
 arch/x86/kvm/vmx/vmx.h    |  5 +++++
 arch/x86/kvm/x86.c        |  3 ++-
 5 files changed, 16 insertions(+), 16 deletions(-)

Comments

Paolo Bonzini Nov. 11, 2021, 2:06 p.m. UTC | #1
On 11/9/21 18:44, Vipin Sharma wrote:
> INVPCID, INVVPID, and INVEPT instructions retrieve the GPR index
> similarly to find the invalidation type. Patch 1 moves the shift and
> mask magic to a single place.
> 
> INVPCID invalidation type check is same for both VMX and SVM. This
> instruction is not documented to verify the type before reading the
> operand from memory. So, moving the check to a common place in patch 2.
> 
> v4:
> - Changed commit message of the patch 1
> 
> v3:
> - https://lore.kernel.org/lkml/20211103205911.1253463-1-vipinsh@google.com/
> - Patch 2's commit message is more detailed now.
> 
> v2:
> - https://lore.kernel.org/lkml/20211103183232.1213761-1-vipinsh@google.com/
> - Keeping the register read visible in the functions.
> - Removed INVPCID type check hardcoding and moved error condition to common
>    function.
> 
> v1: https://lore.kernel.org/lkml/20211011194615.2955791-1-vipinsh@google.com/
> 
> Vipin Sharma (2):
>    KVM: VMX: Add a helper function to retrieve the GPR index for INVPCID,
>      INVVPID, and INVEPT
>    KVM: Move INVPCID type check from vmx and svm to the common
>      kvm_handle_invpcid()
> 
>   arch/x86/kvm/svm/svm.c    |  5 -----
>   arch/x86/kvm/vmx/nested.c | 10 ++++++----
>   arch/x86/kvm/vmx/vmx.c    |  9 +++------
>   arch/x86/kvm/vmx/vmx.h    |  5 +++++
>   arch/x86/kvm/x86.c        |  3 ++-
>   5 files changed, 16 insertions(+), 16 deletions(-)
> 

Queued, thanks.

Paolo