From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755671AbeARSjL (ORCPT ); Thu, 18 Jan 2018 13:39:11 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:33853 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755321AbeARSjI (ORCPT ); Thu, 18 Jan 2018 13:39:08 -0500 X-Google-Smtp-Source: ACJfBosmcka5ZlE91vHODS9OMkBOMcU7hsIypRTyla/O0NmuNZSx1NThQvb18UiYSLbUyZC50Nccxw== Date: Thu, 18 Jan 2018 10:39:04 -0800 From: Eric Biggers To: Tianyu Lan Cc: Tianyu Lan , pbonzini@redhat.com, rkrcmar@redhat.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, jeremi.piotrowski@gmail.com Subject: Re: [Resend Patch] KVM/x86: Fix wrong macro references of X86_CR0_PG_BIT and X86_CR4_PAE_BIT in kvm_valid_sregs() Message-ID: <20180118183904.3fxeyfuyzlumgtrt@gmail.com> References: <1516095247-21414-1-git-send-email-Tianyu.Lan@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1516095247-21414-1-git-send-email-Tianyu.Lan@microsoft.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 16, 2018 at 05:34:07PM +0800, Tianyu Lan wrote: > kvm_valid_sregs() should use X86_CR0_PG and X86_CR4_PAE to check bit > status rather than X86_CR0_PG_BIT and X86_CR4_PAE_BIT. This patch is > to fix it. > > Fixes: f29810335965a(KVM/x86: Check input paging mode when cs.l is set) > Reported-by: Jeremi Piotrowski > Cc: Paolo Bonzini > Cc: Radim Krčmář > Signed-off-by: Tianyu Lan > --- > Sorry for noise. Missed kvm maillist. > > arch/x86/kvm/x86.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 1cec2c6..c53298d 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -7496,13 +7496,13 @@ EXPORT_SYMBOL_GPL(kvm_task_switch); > > int kvm_valid_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) > { > - if ((sregs->efer & EFER_LME) && (sregs->cr0 & X86_CR0_PG_BIT)) { > + if ((sregs->efer & EFER_LME) && (sregs->cr0 & X86_CR0_PG)) { > /* > * When EFER.LME and CR0.PG are set, the processor is in > * 64-bit mode (though maybe in a 32-bit code segment). > * CR4.PAE and EFER.LMA must be set. > */ > - if (!(sregs->cr4 & X86_CR4_PAE_BIT) > + if (!(sregs->cr4 & X86_CR4_PAE) > || !(sregs->efer & EFER_LMA)) > return -EINVAL; > } else { > -- > 2.7.4 > I came across this too and was just about to send the exact same patch. It looks good to me as long as the bits it's supposed to be checking were correct in the first place. Patch title could maybe be shortened a bit, e.g. "KVM/x86: Fix references to CR0.PG and CR4.PAE in kvm_valid_sregs()". The "Fixes:" line is also formatted incorrectly. Thanks, Eric