From patchwork Fri Jan 21 08:06:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 1582472 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JgBnt6GG8z9s1l for ; Fri, 21 Jan 2022 19:08:02 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4JgBnt54V8z3cDY for ; Fri, 21 Jan 2022 19:08:02 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=csgroup.eu (client-ip=2a01:111:f400:7e19::604; helo=fra01-mr2-obe.outbound.protection.outlook.com; envelope-from=christophe.leroy@csgroup.eu; receiver=) Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-mr2fra01on0604.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e19::604]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4JgBmd3tlKz3bXd for ; Fri, 21 Jan 2022 19:06:57 +1100 (AEDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F+Eu7XgumGBGJYMG9OQuuJgSviT8MT6O1kmxJ4ycwEo0/i6KCC1q4pOA65NT3Ai5rqqPZTdkR1xAYUUkoRm4uQ5RknLxZCf8DUezFNWJmdlsCuZGGTSHgTnDRTSgZGXT9CU6mUAH6Eue30zoVhFVJedIZwlWellJqFxax1tpSRQczMJsEGp++9w1EK8ogIyFEnFha++Kq3r6CZooODpdGdL2IPdXdbRaFYOYPvVavCgtiyNzeuD+gFf5APzS/FDqlfxde1ydeTkXUCeryp+89mYeQnk5L54IWVA+4lpIswKL50H/LfjGtUHhwWu3B2w0hjZlDPK8mqxWfIRKT5RvNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Z3wjFFjEQNoPJejY4efQOtpANBEP8Aka2DcsdMne6ew=; b=PpuL+P7xKe4X0Vd/AKKF0kixHbiGi8y7H9HLdvLuzlzlm/nFMo/2qk3CcRKCIRZIcpmEp4bfTPkVqga8fHlUk8lVGBEYrEa+K6SeZ9pGmilcyUPs5ygg1aa7d3x0aaGY15eaWqtPqbyJ31ltVztHoqEGko1dVRufeFSmpHEnkVhlHS3zU+7/0rwe7htYQ2vXZbqiC94BdUQSqbjDpkZpGldrTmnCeBRjSCihxjTGjS44F3oYIU4J7I0d7KPdV7phWJRRj3Kzi9hy8gR9OGzYujIQcbI+6Q8TpkwxjKmx4XdhKAIjUXFY1AVIsHf9ckokz+IplvsYuZGvxjmqVtblQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by MR1P264MB3475.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:20::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Fri, 21 Jan 2022 08:06:38 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::9d4f:1090:9b36:3fc5%5]) with mapi id 15.20.4909.008; Fri, 21 Jan 2022 08:06:38 +0000 From: Christophe Leroy To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Subject: [PATCH 3/3] powerpc/lib/sstep: use truncate_if_32bit() Thread-Topic: [PATCH 3/3] powerpc/lib/sstep: use truncate_if_32bit() Thread-Index: AQHYDp3Q3+1McVpc502dpiOkuseC5g== Date: Fri, 21 Jan 2022 08:06:38 +0000 Message-ID: <7e1c07123f13156d4a27991a2e2694fb584bc068.1642752375.git.christophe.leroy@csgroup.eu> References: <6c608fd4795e2d8ea1a0a449405a0087f76d8bb3.1642752375.git.christophe.leroy@csgroup.eu> In-Reply-To: <6c608fd4795e2d8ea1a0a449405a0087f76d8bb3.1642752375.git.christophe.leroy@csgroup.eu> Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=csgroup.eu; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: abd9737e-da2f-4cef-f6a8-08d9dcb4f337 x-ms-traffictypediagnostic: MR1P264MB3475:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2201; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: JOcieOOe3gH4y243gra0ka+S/lp0IJPBmTypyZ47bkyRcxN5CHNxCkQflt+Erebk7hp+7MXIUWXQTHxGaLbjwqN0cZ3bsah+w1pX1J4u83afmd6pCBRut/VNPLBQqcx+wOroMWgoLDI+IEv7Zq09EwL+x6gTD3lnRso3ZmFjQfGVNWzBLX9PFw263TT67zFYUCdTgASiaTF/xgW+G4FNY54Od4dMR4ZrOT2ESkzgUZdEQyiAUrq50yrIsAwdnrlNwP3KbXVCO30+xgzIDLwti8VO4yFmfKfaAh9R1kNCEuEFEP8dotFlAfDjog7vCOiR6Y2L5TnCY+KA9paI0k4FLlQ4uR4A/ItBTeKOG/isDtjtL9BFWCgwrBcRpFx/ZHWxUUIJctptjbAZcigYielVgXE4VzT//xVqXejSa5gqFSRa8CR7y3GZaoTBWANTn0bdwcwnKIQ4deM2hGEIyoG/ar3rfrEt0GoqBmWRxQigO2CYIVO3ttzlJ75e+cfUzBfCNaQd1P77jiJobToA2s6Pnf6LQtNpJmv1/Kuk5rQgbZxfrDG6pbSUyFsu8EUNTKo+Z/gNwF5IKKacz+GveuLmMX8eszbYIpqk0DIqE6yqcEXkLyiEB/CmdWHk+PYxRfVd6cgljvoNVP8QV7xXKT429hKd20Upn6Dm/SknQSzZSVNKIvuhIV5U31hyeA5pmpjYC6L7zvYS3yaMwCprJmcvzA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(4636009)(366004)(83380400001)(38100700002)(8936002)(38070700005)(186003)(4326008)(508600001)(36756003)(2906002)(8676002)(6486002)(86362001)(122000001)(316002)(2616005)(26005)(66446008)(66556008)(6512007)(5660300002)(110136005)(64756008)(91956017)(54906003)(6506007)(76116006)(66476007)(71200400001)(66946007)(44832011); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?tlVQjN3VblvdG2sIwzSLDVb?= =?iso-8859-1?q?6imyFapeTNC33EmwaQO+kUW0+GyB5GMoqJqq9yISLO7WKWfXZBnaBm5/i86P?= =?iso-8859-1?q?gT9YAv1vGcwunRcwpBmbOP6fwVEZ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= =?iso-8859-1?q?nl8n5p5fCYhgfuNkkYm8I/j02p59S1btSDOTXywmF+jjRJOpZmtyqBqDwmbu?= =?iso-8859-1?q?tao9hSytJ2yz8sSgZTU0lCVZjcoDC6kCAT3kBYhhLdqIDc4UXyOxniLnnkje?= =?iso-8859-1?q?yOUjzjgRJDglc722FhAd4lblytmwxaxxQQW4dYtSMojbRyMynYE4v4H0+uUx?= =?iso-8859-1?q?Q3EnIrjrj7qWZv3ShKTsVQUVf2WGSQKiX2ujk3iAp+6y8/TWtXJLEKLI3LpQ?= =?iso-8859-1?q?m7pkc/DEC2XNb2Clbae8Xn94iSvSfixeZ0uhpOOLGyupcIx+sKz0PeWP3ViW?= =?iso-8859-1?q?BWdQLUwtc4k87nJEsG78AKZ5H/FriVdr2sTFEK+ctgLXnAPvv8LeMtPE+n7v?= =?iso-8859-1?q?CIXBg7N6ZbnDpZghzmASkOKRQK06EHIH7mvtZuJBUOVd7k1IgAMmfKc3km8Y?= =?iso-8859-1?q?AOQbSpE3wPVOA753YLcyMQM4j751ogx6QyqM6B4K9CLTs/XYn/k1dtDuICLd?= =?iso-8859-1?q?KE8mea70fY58j8PTuKTIejVKlMtKC/eYcYWhJ+Xfyi2vYrTo1muN8PuqNA5h?= =?iso-8859-1?q?p2zMvBGb4RCZDlvq2um1wjlcGI84gfKxLTv+wemRQq+Vh5ljTlygeAM/zUt2?= =?iso-8859-1?q?eHjcZQ5UxPlyOsq8h9vDekuR2LlUmb3NObCGFxTQg786sl2iruCkYO4JEMK2?= =?iso-8859-1?q?JoOu/SeJA8a7Ml5IVdQ5jyaLIgM5bXge5geCpm/0yohu9o5gj2VRxXQWb4CI?= =?iso-8859-1?q?r/ls=3D?= MIME-Version: 1.0 X-OriginatorOrg: csgroup.eu X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: abd9737e-da2f-4cef-f6a8-08d9dcb4f337 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:06:38.1297 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9914def7-b676-4fda-8815-5d49fb3b45c8 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: iOMSFWAHqEtBcZeKgHPcfCl1PMYUmVG6HhG0+j/1Nu64i9aXGO5LcyzjuojY7AgcYBs3ve55Qn/sOUEsK+4ylgHmH4HPs7chMqUSwkNAqNs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MR1P264MB3475 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "linuxppc-dev@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Use truncate_if_32bit() when possible instead of open coding. truncate_if_32bit() returns an unsigned long, so don't use it when a signed value is expected. Signed-off-by: Christophe Leroy --- arch/powerpc/lib/sstep.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c index 4aabe3854484..ca38d026fd88 100644 --- a/arch/powerpc/lib/sstep.c +++ b/arch/powerpc/lib/sstep.c @@ -1065,8 +1065,7 @@ int emulate_dcbz(unsigned long ea, struct pt_regs *regs) int err; unsigned long size = l1_dcache_bytes(); - if (!(regs->msr & MSR_64BIT)) - ea &= 0xffffffffUL; + ea = truncate_if_32bit(regs->msr, ea); ea &= ~(size - 1); if (!address_ok(regs, ea, size)) return -EFAULT; @@ -1164,10 +1163,8 @@ static nokprobe_inline void add_with_carry(const struct pt_regs *regs, op->type = COMPUTE + SETREG + SETXER; op->reg = rd; op->val = val; - if (!(regs->msr & MSR_64BIT)) { - val = (unsigned int) val; - val1 = (unsigned int) val1; - } + val = truncate_if_32bit(regs->msr, val); + val1 = truncate_if_32bit(regs->msr, val1); op->xerval = regs->xer; if (val < val1 || (carry_in && val == val1)) op->xerval |= XER_CA;