From: Alex Williamson Subject: Re: [PATCH v2 2/3] x86: kvm: Add MTRR support for kvm_get|put_msrs() Date: Thu, 14 Aug 2014 15:32:39 -0600 Message-ID: <1408051959.9800.286.camel@ul30vt.home> References: <20140814191147.13303.61655.stgit@gimli.home> <20140814192409.13303.58779.stgit@gimli.home> <53ED2802.4080403@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, qemu-stable@nongnu.org To: Laszlo Ersek Return-path: Received: from mx1.redhat.com ([209.132.183.28]:18866 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754656AbaHNVcl (ORCPT ); Thu, 14 Aug 2014 17:32:41 -0400 In-Reply-To: <53ED2802.4080403@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, 2014-08-14 at 23:20 +0200, Laszlo Ersek wrote: > You're going to use my name in contexts that I won't wish to be privy > to. :) I like everything about this patch except: > > > + case MSR_MTRRphysBase(0) ... MSR_MTRRphysMask(MSR_MTRRcap_VCNT): > > ... the off-by-one in this case range. Everything is cool and the range > conforms to > (ie. the > range is inclusive), but the *argument* of the MSR_MTRRphysMask() macro > is off-by-one. You should say > > case MSR_MTRRphysBase(0) ... MSR_MTRRphysMask(MSR_MTRRcap_VCNT - 1): > > Peek up to the for loops: the greatest argument you ever pass to > MSR_MTRRphysMask() is (MSR_MTRRcap_VCNT - 1). > > Of course this causes no visible bug, because we don't use those > register indices at all (and if we *did* use them, then we'd add new > case labels for them, and then gcc would be required by the standard to > complain about duplicated case labels [*]). Nope, legitimate bug. v3 on the way...