From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 4/5] KVM: x86: Wrong register masking in 64-bit mode Date: Wed, 07 May 2014 17:24:00 +0200 Message-ID: <536A5010.6040206@redhat.com> References: <1399465972-4026-1-git-send-email-namit@cs.technion.ac.il> <1399465972-4026-5-git-send-email-namit@cs.technion.ac.il> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Cc: mtosatti@redhat.com, hpa@zytor.com, gleb@kernel.org, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org To: Bandan Das , Nadav Amit Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org Il 07/05/2014 16:50, Bandan Das ha scritto: >> > +static void assign_masked(ulong *dest, ulong src, int bytes) >> > { >> > - *dest = (*dest & ~mask) | (src & mask); >> > + switch (bytes) { >> > + case 2: >> > + *dest = (u16)src | (*dest & ~0xfffful); >> > + break; >> > + case 4: >> > + *dest = (u32)src; >> > + break; >> > + case 8: >> > + *dest = src; >> > + break; >> > + default: >> > + BUG(); > IIRC, Paolo mentioned that a WARN() is preferable. But I see > a lot other places where BUG() is called, maybe, he can confirm. > There is really no reason to crash the host for a misused API, so I do believe that a WARN() is preferable. Paolo