From patchwork Tue Jul 30 04:43:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Araneda X-Patchwork-Id: 11064863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 940E21399 for ; Tue, 30 Jul 2019 04:44:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7737C2870F for ; Tue, 30 Jul 2019 04:44:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6851E2873D; Tue, 30 Jul 2019 04:44:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0D8112870F for ; Tue, 30 Jul 2019 04:44:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=1mDXbEwBa0xcTZcVUrbJUVnH2UAqCfqbxLFddf+LToA=; b=k15coMx/42qy1L pGZgj7jvvQsWO3XsxbXOQRvF2t7p8R3/QWOe/VXuclE3syuBQmgxx0+hH2JBVrADFPoQmRT8XUwep K/01j8C8CAYCgLVSQSqMpYV/TKg0DqZj9ugyW+Il5m/KHPhN3yknOevN5rkQM9HrQo0LlQ+G6Ec+Z ycLjYnej9eF+mbSlrsUPeYCqhEl2bWuDV1IzVTBQeZnQPjenstPONYxc6PBFqTE7Msg+umQ3ahCoz 5nwH9nDOe4X6MFS9xpOq/SgSvuYaurs3fWF/laXUOE6PGNejdlFmDZ6Qg+HRDw5Q48jv+JAj/zsTc wlsaG0gETefY93dluuQQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hsJzq-0001A8-6r; Tue, 30 Jul 2019 04:44:22 +0000 Received: from mail-vk1-xa41.google.com ([2607:f8b0:4864:20::a41]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hsJzn-00019n-PZ for linux-arm-kernel@lists.infradead.org; Tue, 30 Jul 2019 04:44:21 +0000 Received: by mail-vk1-xa41.google.com with SMTP id w186so4116573vkd.11 for ; Mon, 29 Jul 2019 21:44:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=d6rjIgo3Vi+suTjkC1h224KoPvKAJrv1+GATOVWvv+c=; b=b9qU2szS1N5oiCMNf2LCtIshtSE43S8VHtG1ncGc0M5oww14K731lyVUtLVpBmQKWE hzbAPThCAFOy0EWBlWYsxB8rNpS0UPOhot+SYXXr5yqT1tCbtjcCuYOjBcePHbC9rdQS G4XhGJ5oZaiuPcfNZQTuzyCoyVv3V0MMQHZyJAow31HnMCT+5DyNh+AktECRT8pGoXSW EI8PYmO1Jsz2dlefa61JtUdVZhmbVBdXeC5EhFeXu6PeyH2ZWWKWtjQXvIPRPju9Qgxk w/5klbqYApugKd6ZRbqLq14j0az9UW5FL3b7zzQEuE25wLjKSW+7zuMGu2M9HEPz3PAv QBoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=d6rjIgo3Vi+suTjkC1h224KoPvKAJrv1+GATOVWvv+c=; b=INsADkKz+y0h+VJeeBfHT0dPhORiWz5XLfYnh8TCIN/MtvgGMKo4b5TOKMzFIWp6VB 5fg3EYQiSGlaqhrQPhbxjq+DIx9hTNSqCN3mTiFyPSl8+YhcSq8S+EUZFBH3JYCYxsEd bkevdPE5NqQGV9COG7cLLooC4hDwX5jT0wcA72ivMlOggm51seRtwAUrNdbcKxhkWJ/6 5CLv59gilQDenS1uPouTKBy9QdEEKuCb2o9s3EEwxBXcskpGMWpJIDMPPynX8MRVlBKx pl9I1wJRzoAOgQ4u3ZIS93Qwl8Miu7MD0l1Mvz2ZScgvlrAyL01kdEwQGgLIM9uIX1tz Bw4A== X-Gm-Message-State: APjAAAX1+HRpl/jiCkey14mkfq9ka6bHsxNbz51whOYZZbRXQQh/xfIZ lR5BSU8KGUpEcdGCXgIJCws= X-Google-Smtp-Source: APXvYqw7o5XOlRVC1x5vjuCDZSNhKzcBq5UM33yBZVByZLEjGcAj/apcYqtE+eWCzuD/LcmWXaauYA== X-Received: by 2002:a1f:2b07:: with SMTP id r7mr44503723vkr.65.1564461857826; Mon, 29 Jul 2019 21:44:17 -0700 (PDT) Received: from asus-S451LA.lan ([190.22.43.156]) by smtp.gmail.com with ESMTPSA id f14sm15103387vsk.10.2019.07.29.21.44.15 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 29 Jul 2019 21:44:17 -0700 (PDT) From: Luis Araneda To: linux@armlinux.org.uk, michal.simek@xilinx.com Subject: [RFC PATCH] ARM: zynq: Use memcpy_toio instead of memcpy on smp bring-up Date: Tue, 30 Jul 2019 00:43:26 -0400 Message-Id: <20190730044326.1805-1-luaraneda@gmail.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190729_214419_857228_4C3D7706 X-CRM114-Status: GOOD ( 14.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Luis Araneda Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This fixes a kernel panic (read overflow) on memcpy when FORTIFY_SOURCE is enabled. The computed size of memcpy args are: - p_size (dst): 4294967295 = (size_t) -1 - q_size (src): 1 - size (len): 8 Additionally, the memory is marked as __iomem, so one of the memcpy_* functions should be used for read/write Signed-off-by: Luis Araneda --- For anyone trying to reproduce / debug this, it panics before the console has any output. I used JTAG to find the panic, but I had to comment-out the call to "zynq_slcr_cpu_stop" as it stops the JTAG interface and the connection is dropped, at least with OpenOCD. I run-tested this on a Digilent Zybo Z7 board --- arch/arm/mach-zynq/platsmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-zynq/platsmp.c b/arch/arm/mach-zynq/platsmp.c index a7cfe07156f4..407abade7336 100644 --- a/arch/arm/mach-zynq/platsmp.c +++ b/arch/arm/mach-zynq/platsmp.c @@ -57,7 +57,7 @@ int zynq_cpun_start(u32 address, int cpu) * 0x4: Jump by mov instruction * 0x8: Jumping address */ - memcpy((__force void *)zero, &zynq_secondary_trampoline, + memcpy_toio(zero, &zynq_secondary_trampoline, trampoline_size); writel(address, zero + trampoline_size);