From patchwork Fri Nov 14 14:40:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Frederic Sowa X-Patchwork-Id: 410856 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 672FD14009B for ; Sat, 15 Nov 2014 01:40:55 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965362AbaKNOkv (ORCPT ); Fri, 14 Nov 2014 09:40:51 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:35874 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964832AbaKNOku (ORCPT ); Fri, 14 Nov 2014 09:40:50 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 0AFB320BDF for ; Fri, 14 Nov 2014 09:40:50 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Fri, 14 Nov 2014 09:40:50 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= stressinduktion.org; h=x-sasl-enc:from:to:cc:subject:date :message-id:in-reply-to:references; s=mesmtp; bh=PLry7KnsriGrhf1 e3WGPL0I01pA=; b=lSk1VrxjvIF7REiR9B7HcoO2BKKCsmeE2rt59yvMJI1DH8F lOpRCx6pzx8smuC/xqOskn2f4Kv9RLmAfJupt1IeRXahKloN0jYOttkNZVbdWlJY lVZ1lSVOaBNvrfITv8wAbvYq7WT1/z8psYiKjqTT5hlZhZMBCLxOaZpQeMx8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:from:to:cc:subject:date :message-id:in-reply-to:references; s=smtpout; bh=PLry7KnsriGrhf 1e3WGPL0I01pA=; b=pUSin+xgQhjQXkiXYBVHu0+qcTLc73Y2M3k6dkevH+z9vJ LW1BjcRZlevYZIm39o0hXuxlVs0kb5eLUbD1nRY2tGIYJNK8LaTW55jX/no2nr5l +MTWaskLQ9qjfo8f5I1uCMeDXJ5SfZppESUrJ/exxpnmtDuKc0S3RaY+M3L3c= X-Sasl-enc: b5vVxOqre/Bzbdj/Qikw1W4bwHI4E9ag7uvEaoGKFxuz 1415976049 Received: from stressinduktion.org (unknown [217.192.177.17]) by mail.messagingengine.com (Postfix) with ESMTPA id BEBA9680087; Fri, 14 Nov 2014 09:40:48 -0500 (EST) From: Hannes Frederic Sowa To: netdev@vger.kernel.org Cc: ogerlitz@mellanox.com, pshelar@nicira.com, jesse@nicira.com, jay.vosburgh@canonical.com, discuss@openvswitch.org Subject: [PATCH net-next v2] fast_hash: clobber registers correctly for inline function use Date: Fri, 14 Nov 2014 15:40:43 +0100 Message-Id: <87f7d01be7175e1fc6dabbb2540e1de13fb293f6.1415975954.git.hannes@stressinduktion.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <4086c7bc9f7f9e8e2de9656c9e27ef1e71bb6423.1415973706.git.hannes@stressinduktion.org> References: <4086c7bc9f7f9e8e2de9656c9e27ef1e71bb6423.1415973706.git.hannes@stressinduktion.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In case the arch_fast_hash call gets inlined we need to tell gcc which registers are clobbered with. rhashtable was fine, because it used arch_fast_hash via function pointer and thus the compiler took care of that. In case of openvswitch the call got inlined and arch_fast_hash touched registeres which gcc didn't know about. Also don't use conditional compilation inside arguments, as this confuses sparse. Reported-by: Jay Vosburgh Cc: Pravin Shelar Cc: Jesse Gross Signed-off-by: Hannes Frederic Sowa --- v2) After studying gcc documentation again, it occured to me that I need to specificy all input operands in the clobber section, too. Otherwise gcc can expect that the inline assembler section won't modify the inputs, which is not true. Bye, Hannes arch/x86/include/asm/hash.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/hash.h b/arch/x86/include/asm/hash.h index a881d78..a25c45a 100644 --- a/arch/x86/include/asm/hash.h +++ b/arch/x86/include/asm/hash.h @@ -23,11 +23,15 @@ static inline u32 arch_fast_hash(const void *data, u32 len, u32 seed) { u32 hash; - alternative_call(__jhash, __intel_crc4_2_hash, X86_FEATURE_XMM4_2, #ifdef CONFIG_X86_64 - "=a" (hash), "D" (data), "S" (len), "d" (seed)); + alternative_call(__jhash, __intel_crc4_2_hash, X86_FEATURE_XMM4_2, + "=a" (hash), "D" (data), "S" (len), "d" (seed) + : "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r10", "r11", + "cc", "memory"); #else - "=a" (hash), "a" (data), "d" (len), "c" (seed)); + alternative_call(__jhash, __intel_crc4_2_hash, X86_FEATURE_XMM4_2, + "=a" (hash), "a" (data), "d" (len), "c" (seed) + : "edx", "ecx", "cc", "memory"); #endif return hash; } @@ -36,11 +40,15 @@ static inline u32 arch_fast_hash2(const u32 *data, u32 len, u32 seed) { u32 hash; - alternative_call(__jhash2, __intel_crc4_2_hash2, X86_FEATURE_XMM4_2, #ifdef CONFIG_X86_64 - "=a" (hash), "D" (data), "S" (len), "d" (seed)); + alternative_call(__jhash2, __intel_crc4_2_hash2, X86_FEATURE_XMM4_2, + "=a" (hash), "D" (data), "S" (len), "d" (seed) + : "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r10", "r11", + "cc", "memory"); #else - "=a" (hash), "a" (data), "d" (len), "c" (seed)); + alternative_call(__jhash2, __intel_crc4_2_hash2, X86_FEATURE_XMM4_2, + "=a" (hash), "a" (data), "d" (len), "c" (seed) + : "edx", "ecx", "cc", "memory"); #endif return hash; }