Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3319527imu; Sun, 11 Nov 2018 12:16:52 -0800 (PST) X-Google-Smtp-Source: AJdET5fCY/ZtouEokwJv6BUxnKYJEmiSDia9nIhEscGbsFNCWLKutT5PEEGgHcutcJxS5r75fPrj X-Received: by 2002:a63:f412:: with SMTP id g18mr15102880pgi.262.1541967411969; Sun, 11 Nov 2018 12:16:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541967411; cv=none; d=google.com; s=arc-20160816; b=hwhQbxYVhdyQ3FGt7c/GQH5XvMHEjDwlCmgUjU7Tzw1hmynMI8CQBrCZ5DChPGL+Sj 7bcrPS6nLHlC1Ho7xIY2wEGp03kEM4y5jWiXQjcIClnlPznH3MMxlsA3b2ceBAV05ih6 PjH3Ymc5rUG8eKPMXn3ZfzYgF2MbwtN0AhxSI7P8pApS5+g1mgl1Ts95xKxj2EJOx5zn /Y07g5NoEdYcS6ypPg+6QKLFBmdzEtcXaOpBgNzA4zdMMlhsG7hBTjGjq9AaPFo0hZ7O JcJvsfUyVYSBpCN7v/yg4dhwumwZLnrk5ykZGbt/rLf0mNnqFD6bLLcj9Yo3ZD+mIoXR a/OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=1Kl93KH2/IT5zRQffcNSLOd2n5psK+WsFZQM+AmUmqM=; b=M4jI41wKH+0xHUAuyOmNXjHp24MshbfFOA/Cnb7IKc6ehH8FKqvoncwh/xHTb7usEF KqCKvsSV5p7o3lkAqOntkzH1YAw9U9IyCDnYIYLlZqqoZoo+BhDjsdrdDA0mDmQux0l9 j3MR0ZPyilPjele8VyWM0tgiiDD2TBv8b0c/mYzzx4c13Al2PCUXyw5Mp2vPLqORXCAB 2fBZ5S0ZiGnkAVfVNTtLXBGyZo2l2ZSRNoZeJkE6oYUgPdNv0vfsSeWTy9V54wISDddo HtymgG1/5om0N4fL1/p6uuYeJLw/6ksZy+hPj/6we2F+jJXsXR2OgDncBbxiMPeKnGy7 GEzA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z126-v6si16380687pfb.280.2018.11.11.12.16.37; Sun, 11 Nov 2018 12:16:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731909AbeKLGFq (ORCPT + 99 others); Mon, 12 Nov 2018 01:05:46 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:53136 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731140AbeKLGFq (ORCPT ); Mon, 12 Nov 2018 01:05:46 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvtB-0000oM-RI; Sun, 11 Nov 2018 19:59:21 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsO-0001PQ-KX; Sun, 11 Nov 2018 19:58:32 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Michael Ellerman" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 042/366] powerpc/lib: Fix the feature fixup tests to actually work In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Michael Ellerman commit cad0e39023b43d94d5e38dfd55c103e15bdd093d upstream. The code patching code has always been a bit confused about whether it's best to use void *, unsigned int *, char *, etc. to point to instructions. In fact in the feature fixups tests we use both unsigned int[] and u8[] in different places. Unfortunately the tests that use unsigned int[] calculate the size of the code blocks using subtraction of those unsigned int pointers, and then pass the result to memcmp(). This means we're only comparing 1/4 of the bytes we need to, because we need to multiply by sizeof(unsigned int) to get the number of *bytes*. The result is that the tests do all the patching and then only compare some of the resulting code, so patching bugs that only effect that last 3/4 of the code could slip through undetected. It turns out that hasn't been happening, although one test had a bad expected case (see previous commit). Fix it for now by multiplying the size by 4 in the affected functions. Fixes: 362e7701fd18 ("powerpc: Add self-tests of the feature fixup code") Epic-brown-paper-bag-by: Michael Ellerman Signed-off-by: Michael Ellerman Signed-off-by: Ben Hutchings --- arch/powerpc/lib/feature-fixups.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/arch/powerpc/lib/feature-fixups.c +++ b/arch/powerpc/lib/feature-fixups.c @@ -170,7 +170,7 @@ void test_basic_patching(void) extern unsigned int end_ftr_fixup_test1[]; extern unsigned int ftr_fixup_test1_orig[]; extern unsigned int ftr_fixup_test1_expected[]; - int size = end_ftr_fixup_test1 - ftr_fixup_test1; + int size = 4 * (end_ftr_fixup_test1 - ftr_fixup_test1); fixup.value = fixup.mask = 8; fixup.start_off = calc_offset(&fixup, ftr_fixup_test1 + 1); @@ -202,7 +202,7 @@ static void test_alternative_patching(vo extern unsigned int ftr_fixup_test2_orig[]; extern unsigned int ftr_fixup_test2_alt[]; extern unsigned int ftr_fixup_test2_expected[]; - int size = end_ftr_fixup_test2 - ftr_fixup_test2; + int size = 4 * (end_ftr_fixup_test2 - ftr_fixup_test2); fixup.value = fixup.mask = 0xF; fixup.start_off = calc_offset(&fixup, ftr_fixup_test2 + 1); @@ -234,7 +234,7 @@ static void test_alternative_case_too_bi extern unsigned int end_ftr_fixup_test3[]; extern unsigned int ftr_fixup_test3_orig[]; extern unsigned int ftr_fixup_test3_alt[]; - int size = end_ftr_fixup_test3 - ftr_fixup_test3; + int size = 4 * (end_ftr_fixup_test3 - ftr_fixup_test3); fixup.value = fixup.mask = 0xC; fixup.start_off = calc_offset(&fixup, ftr_fixup_test3 + 1); @@ -261,7 +261,7 @@ static void test_alternative_case_too_sm extern unsigned int ftr_fixup_test4_orig[]; extern unsigned int ftr_fixup_test4_alt[]; extern unsigned int ftr_fixup_test4_expected[]; - int size = end_ftr_fixup_test4 - ftr_fixup_test4; + int size = 4 * (end_ftr_fixup_test4 - ftr_fixup_test4); unsigned long flag; /* Check a high-bit flag */ @@ -295,7 +295,7 @@ static void test_alternative_case_with_b extern unsigned int ftr_fixup_test5[]; extern unsigned int end_ftr_fixup_test5[]; extern unsigned int ftr_fixup_test5_expected[]; - int size = end_ftr_fixup_test5 - ftr_fixup_test5; + int size = 4 * (end_ftr_fixup_test5 - ftr_fixup_test5); check(memcmp(ftr_fixup_test5, ftr_fixup_test5_expected, size) == 0); } @@ -305,7 +305,7 @@ static void test_alternative_case_with_e extern unsigned int ftr_fixup_test6[]; extern unsigned int end_ftr_fixup_test6[]; extern unsigned int ftr_fixup_test6_expected[]; - int size = end_ftr_fixup_test6 - ftr_fixup_test6; + int size = 4 * (end_ftr_fixup_test6 - ftr_fixup_test6); check(memcmp(ftr_fixup_test6, ftr_fixup_test6_expected, size) == 0); }