Historical speck list archives
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@suse.de>
To: speck@linutronix.de
Subject: [MODERATED] Re: [PATCH v4 5/8] [PATCH v4 5/8] Linux Patch #5
Date: Wed, 27 Jun 2018 18:42:26 +0200	[thread overview]
Message-ID: <20180627164226.GJ24227@zn.tnic> (raw)
In-Reply-To: <20180623135445.789395832@localhost.localdomain>

On Sat, Jun 23, 2018 at 09:54:19AM -0400, speck for konrad.wilk_at_oracle.com wrote:
> x86/KVM/VMX: Add find_msr helper function
> 
> .. to help find the MSR on either the guest or host
> MSR list.
> 
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
>  arch/x86/kvm/vmx.c | 31 ++++++++++++++++++-------------
>  1 file changed, 18 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 3649bf3b3b82..f9d70b3e9fcd 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -2376,9 +2376,20 @@ static void clear_atomic_switch_msr_special(struct vcpu_vmx *vmx,
>  	vm_exit_controls_clearbit(vmx, exit);
>  }
>  
> +static int find_msr(struct vmx_msrs *m, unsigned msr)

WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
#31: FILE: arch/x86/kvm/vmx.c:2379:
+static int find_msr(struct vmx_msrs *m, unsigned msr)

Please integrate scripts/checkpatch.pl into your patch creation
workflow. Some of the warnings/errors *actually* make sense.

> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < m->nr; ++i) {
> +		if (m->val[i].index == msr)
> +			return i;
> +	}
> +	return -ENOENT;
> +}
> +
>  static void clear_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr)
>  {
> -	unsigned i;
> +	int i;
>  	struct msr_autoload *m = &vmx->msr_autoload;
>  
>  	switch (msr) {
> @@ -2399,11 +2410,8 @@ static void clear_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr)
>  		}
>  		break;
>  	}
> -	for (i = 0; i < m->guest.nr; ++i)
> -		if (m->guest.val[i].index == msr)
> -			break;
> -
> -	if (i == m->guest.nr)
> +	i = find_msr(&m->guest, msr);
> +	if (i < 0)
>  		return;

<---- newline here.

>  	--m->guest.nr;
>  	--m->host.nr;

-- 
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 

      reply	other threads:[~2018-06-27 16:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-23 13:54 [MODERATED] [PATCH v4 5/8] [PATCH v4 5/8] Linux Patch #5 konrad.wilk
2018-06-27 16:42 ` Borislav Petkov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180627164226.GJ24227@zn.tnic \
    --to=bp@suse.de \
    --cc=speck@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).