All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] KVM:x86: Clean up ModR/M "reg" initialization in reg op decoding
@ 2022-09-08 14:12 Liam Ni
  2022-09-08 15:50 ` Sean Christopherson
  0 siblings, 1 reply; 4+ messages in thread
From: Liam Ni @ 2022-09-08 14:12 UTC (permalink / raw)
  To: linux-kernel, kvm, x86; +Cc: pbonzini, tglx, dave.hansen, seanjc, zhiguangni01

From: Liam Ni <zhiguangni01@gmail.com>

Refactor decode_register_operand() to get the ModR/M register if and
only if the instruction uses a ModR/M encoding to make it more obvious
how the register operand is retrieved.

Signed-off-by: Liam Ni <zhiguangni01@gmail.com>
---
 arch/x86/kvm/emulate.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index f092c54d1a2f..879b52af763a 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -1137,9 +1137,11 @@ static int em_fnstsw(struct x86_emulate_ctxt *ctxt)
 static void decode_register_operand(struct x86_emulate_ctxt *ctxt,
 				    struct operand *op)
 {
-	unsigned reg = ctxt->modrm_reg;
+	unsigned int reg;
 
-	if (!(ctxt->d & ModRM))
+	if ((ctxt->d & ModRM))
+		reg = ctxt->modrm_reg;
+	else
 		reg = (ctxt->b & 7) | ((ctxt->rex_prefix & 1) << 3);
 
 	if (ctxt->d & Sse) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] KVM:x86: Clean up ModR/M "reg" initialization in reg op decoding
  2022-09-08 14:12 [PATCH v2] KVM:x86: Clean up ModR/M "reg" initialization in reg op decoding Liam Ni
@ 2022-09-08 15:50 ` Sean Christopherson
  2022-09-09 13:47   ` Liam Ni
  0 siblings, 1 reply; 4+ messages in thread
From: Sean Christopherson @ 2022-09-08 15:50 UTC (permalink / raw)
  To: Liam Ni; +Cc: linux-kernel, kvm, x86, pbonzini, tglx, dave.hansen

On Thu, Sep 08, 2022, Liam Ni wrote:
> From: Liam Ni <zhiguangni01@gmail.com>
> 
> Refactor decode_register_operand() to get the ModR/M register if and
> only if the instruction uses a ModR/M encoding to make it more obvious
> how the register operand is retrieved.
> 
> Signed-off-by: Liam Ni <zhiguangni01@gmail.com>
> ---

Pushed to branch `for_paolo/6.1` at:

    https://github.com/sean-jc/linux.git

with the below nit sqaushed.  Unless you hear otherwise, it will make its way to
kvm/queue "soon".

Note, the commit IDs are not guaranteed to be stable.

>  arch/x86/kvm/emulate.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index f092c54d1a2f..879b52af763a 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -1137,9 +1137,11 @@ static int em_fnstsw(struct x86_emulate_ctxt *ctxt)
>  static void decode_register_operand(struct x86_emulate_ctxt *ctxt,
>  				    struct operand *op)
>  {
> -	unsigned reg = ctxt->modrm_reg;
> +	unsigned int reg;
>  
> -	if (!(ctxt->d & ModRM))
> +	if ((ctxt->d & ModRM))

Only need one set of parentheses.  

> +		reg = ctxt->modrm_reg;
> +	else
>  		reg = (ctxt->b & 7) | ((ctxt->rex_prefix & 1) << 3);
>  
>  	if (ctxt->d & Sse) {
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] KVM:x86: Clean up ModR/M "reg" initialization in reg op decoding
  2022-09-08 15:50 ` Sean Christopherson
@ 2022-09-09 13:47   ` Liam Ni
  2022-09-09 14:57     ` Sean Christopherson
  0 siblings, 1 reply; 4+ messages in thread
From: Liam Ni @ 2022-09-09 13:47 UTC (permalink / raw)
  To: Sean Christopherson; +Cc: linux-kernel, kvm, x86, pbonzini, tglx, dave.hansen

On Thu, 8 Sept 2022 at 23:50, Sean Christopherson <seanjc@google.com> wrote:
>
> On Thu, Sep 08, 2022, Liam Ni wrote:
> > From: Liam Ni <zhiguangni01@gmail.com>
> >
> > Refactor decode_register_operand() to get the ModR/M register if and
> > only if the instruction uses a ModR/M encoding to make it more obvious
> > how the register operand is retrieved.
> >
> > Signed-off-by: Liam Ni <zhiguangni01@gmail.com>
> > ---
>
> Pushed to branch `for_paolo/6.1` at:
>
>     https://github.com/sean-jc/linux.git
>
> with the below nit sqaushed.  Unless you hear otherwise, it will make its way to
> kvm/queue "soon".
>
> Note, the commit IDs are not guaranteed to be stable.
>
> >  arch/x86/kvm/emulate.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> > index f092c54d1a2f..879b52af763a 100644
> > --- a/arch/x86/kvm/emulate.c
> > +++ b/arch/x86/kvm/emulate.c
> > @@ -1137,9 +1137,11 @@ static int em_fnstsw(struct x86_emulate_ctxt *ctxt)
> >  static void decode_register_operand(struct x86_emulate_ctxt *ctxt,
> >                                   struct operand *op)
> >  {
> > -     unsigned reg = ctxt->modrm_reg;
> > +     unsigned int reg;
> >
> > -     if (!(ctxt->d & ModRM))
> > +     if ((ctxt->d & ModRM))
>
> Only need one set of parentheses.

Sorry,  Should I prepare a new patch?

>
> > +             reg = ctxt->modrm_reg;
> > +     else
> >               reg = (ctxt->b & 7) | ((ctxt->rex_prefix & 1) << 3);
> >
> >       if (ctxt->d & Sse) {
> > --
> > 2.34.1
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] KVM:x86: Clean up ModR/M "reg" initialization in reg op decoding
  2022-09-09 13:47   ` Liam Ni
@ 2022-09-09 14:57     ` Sean Christopherson
  0 siblings, 0 replies; 4+ messages in thread
From: Sean Christopherson @ 2022-09-09 14:57 UTC (permalink / raw)
  To: Liam Ni; +Cc: linux-kernel, kvm, x86, pbonzini, tglx, dave.hansen

On Fri, Sep 09, 2022, Liam Ni wrote:
> On Thu, 8 Sept 2022 at 23:50, Sean Christopherson <seanjc@google.com> wrote:
> >
> > On Thu, Sep 08, 2022, Liam Ni wrote:
> > > From: Liam Ni <zhiguangni01@gmail.com>
> > >
> > > Refactor decode_register_operand() to get the ModR/M register if and
> > > only if the instruction uses a ModR/M encoding to make it more obvious
> > > how the register operand is retrieved.
> > >
> > > Signed-off-by: Liam Ni <zhiguangni01@gmail.com>
> > > ---
> >
> > Pushed to branch `for_paolo/6.1` at:
> >
> >     https://github.com/sean-jc/linux.git
> >
> > with the below nit sqaushed.  Unless you hear otherwise, it will make its way to
> > kvm/queue "soon".
> >
> > Note, the commit IDs are not guaranteed to be stable.
> >
> > >  arch/x86/kvm/emulate.c | 6 ++++--
> > >  1 file changed, 4 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> > > index f092c54d1a2f..879b52af763a 100644
> > > --- a/arch/x86/kvm/emulate.c
> > > +++ b/arch/x86/kvm/emulate.c
> > > @@ -1137,9 +1137,11 @@ static int em_fnstsw(struct x86_emulate_ctxt *ctxt)
> > >  static void decode_register_operand(struct x86_emulate_ctxt *ctxt,
> > >                                   struct operand *op)
> > >  {
> > > -     unsigned reg = ctxt->modrm_reg;
> > > +     unsigned int reg;
> > >
> > > -     if (!(ctxt->d & ModRM))
> > > +     if ((ctxt->d & ModRM))
> >
> > Only need one set of parentheses.
> 
> Sorry,  Should I prepare a new patch?

Nope, all taken care of.  Thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-09 14:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-08 14:12 [PATCH v2] KVM:x86: Clean up ModR/M "reg" initialization in reg op decoding Liam Ni
2022-09-08 15:50 ` Sean Christopherson
2022-09-09 13:47   ` Liam Ni
2022-09-09 14:57     ` Sean Christopherson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.