Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 27 Jun 2018 16:42:34 -0000 Received: from mx2.suse.de ([195.135.220.15]) by Galois.linutronix.de with esmtps (TLS1.0:DHE_RSA_CAMELLIA_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1fYDWb-0000Vs-KK for speck@linutronix.de; Wed, 27 Jun 2018 18:42:33 +0200 Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 5FEF0AD98 for ; Wed, 27 Jun 2018 16:42:28 +0000 (UTC) Date: Wed, 27 Jun 2018 18:42:26 +0200 From: Borislav Petkov Subject: [MODERATED] Re: [PATCH v4 5/8] [PATCH v4 5/8] Linux Patch #5 Message-ID: <20180627164226.GJ24227@zn.tnic> References: <20180623135445.789395832@localhost.localdomain> MIME-Version: 1.0 In-Reply-To: <20180623135445.789395832@localhost.localdomain> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable To: speck@linutronix.de List-ID: 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 >=20 > .. to help find the MSR on either the guest or host > MSR list. >=20 > Signed-off-by: Konrad Rzeszutek Wilk > --- > arch/x86/kvm/vmx.c | 31 ++++++++++++++++++------------- > 1 file changed, 18 insertions(+), 13 deletions(-) >=20 > 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 v= cpu_vmx *vmx, > vm_exit_controls_clearbit(vmx, exit); > } > =20 > +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 =3D 0; i < m->nr; ++i) { > + if (m->val[i].index =3D=3D 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 =3D &vmx->msr_autoload; > =20 > switch (msr) { > @@ -2399,11 +2410,8 @@ static void clear_atomic_switch_msr(struct vcpu_vmx = *vmx, unsigned msr) > } > break; > } > - for (i =3D 0; i < m->guest.nr; ++i) > - if (m->guest.val[i].index =3D=3D msr) > - break; > - > - if (i =3D=3D m->guest.nr) > + i =3D find_msr(&m->guest, msr); > + if (i < 0) > return; <---- newline here. > --m->guest.nr; > --m->host.nr; --=20 Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix Imend=C3=B6rffer, Jane Smithard, Graham Norton, HR= B 21284 (AG N=C3=BCrnberg) --=20