Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751360AbcDKCnq (ORCPT ); Sun, 10 Apr 2016 22:43:46 -0400 Received: from mail-pa0-f67.google.com ([209.85.220.67]:33122 "EHLO mail-pa0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750937AbcDKCni (ORCPT ); Sun, 10 Apr 2016 22:43:38 -0400 Subject: Re: [PATCH v2 10/30] Add x86-specific parity functions To: One Thousand Gnomes , Borislav Petkov References: <57031D9D.801@gmail.com> <1459934085-7152-1-git-send-email-zengzhaoxiu@163.com> <20160406101300.GA13719@pd.tnic> <20160406113737.0b73bb40@lxorguk.ukuu.org.uk> Cc: zengzhaoxiu@163.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, dvlasenk@redhat.com, akpm@linux-foundation.org, dvyukov@google.com, keescook@chromium.org, linux-kernel@vger.kernel.org From: Zeng Zhaoxiu Message-ID: <570B0F54.7060201@gmail.com> Date: Mon, 11 Apr 2016 10:43:32 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160406113737.0b73bb40@lxorguk.ukuu.org.uk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 931 Lines: 20 在 2016年04月06日 18:37, One Thousand Gnomes 写道: > Even that would still be wrong for the smaller parity values. The CPU > supports 8bit parity directly going back to the 8086 so the > implementation for 8bit and I think 16bit is still wrong. > > Alan I don't know where the errors. X86 is new to me. The definition of the parity flag on x86 from Wikipedia: In x86 processors, the parity flag reflects the parity only of the least significant byte of the result, and is set if the number of set bits of ones is even. According to 80386 Intel manual, the parity flag is changed in the x86 processor family by the following instructions: All arithmetic instructions; Compare instruction (equivalent to a subtract instruction without storing the result); Logical instructions - XOR, AND, OR; the TEST instruction (equivalent to the AND instruction without storing the result). the POPF instruction