From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH] KVM: nVMX: consult PFEC_MASK and PFEC_MATCH when generating #PF VM-exit Date: Tue, 16 Dec 2014 10:21:43 +0100 Message-ID: <548FF9A7.7020308@redhat.com> References: <20141215205658.GA29239@gnote> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit To: Eugene Korenevsky , kvm@vger.kernel.org Return-path: Received: from mail-wi0-f173.google.com ([209.85.212.173]:55249 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750789AbaLPJVs (ORCPT ); Tue, 16 Dec 2014 04:21:48 -0500 Received: by mail-wi0-f173.google.com with SMTP id r20so11556563wiv.12 for ; Tue, 16 Dec 2014 01:21:47 -0800 (PST) In-Reply-To: <20141215205658.GA29239@gnote> Sender: kvm-owner@vger.kernel.org List-ID: On 15/12/2014 21:56, Eugene Korenevsky wrote: > + u32 inequality, bit; > + > + bit = (vmcs12->exception_bitmap & (1u << PF_VECTOR)) ? 1u : 0; > + inequality = > + (error_code & vmcs12->page_fault_error_code_mask) != > + vmcs12->page_fault_error_code_match ? 1u : 0; You should either remove "? 1u : 0" (which is redundant), or flip the bit in the exception bitmap, like inequality = ... ? (1u << PF_VECTOR) : 0; return ((vmcs12->exception_bitmap ^ inequality) & (1u << PF_VECTOR)) != 0; If you choose the former, please use "!= 0" in the assignment of "bit" instead of the ternary operator, and make the two variables bool. Then you can remove the "!= 0" in the "return" below. Paolo > + return (inequality ^ bit) != 0; > +}