Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1292863pxb; Fri, 6 Nov 2020 06:12:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqZ9x9PkjAKbXsp7ZSiPwkb4WUcQEhcw2x9OVIkQZd46POyyF6CAMUJmSukvrai6Vtwp3Q X-Received: by 2002:a19:384:: with SMTP id 126mr912869lfd.596.1604671950356; Fri, 06 Nov 2020 06:12:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1604671950; cv=pass; d=google.com; s=arc-20160816; b=MzpwYA2/FLPPxcwA9ZgAlcBnEcrxRozmvYkyf3JvTER9c7RUKMFTGGsMItawQjEXC2 W+6Aci6a+gpNPv4Xmn8PsvGBCLkbZD8HB3bYyVOqVG+AoTd1KXB0njQpATXkWqhNM4Su YLdr6nARekMFXpqYJajymdDrpp8vs26RYfiIH48qljCGzOil4c0XZ28hE6mVkM+4Hc2o pQq/mfpW24lAdGhrdHj7XXQqdKBGyK4Bxf/jvpOHHOUbfxCmr3w8e+S/Dkzkhr81dcoV zDp8k4u1xYiQJ7fdpeF1DTPF6me676LuDxFZyJKL/QWcqvxbOTE0t1L5pxqTWDoXvj9v ar4w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=F+iONw1HG+Y6aPFExtXa7UY0+8xU2+GL7T43OqG4v9U=; b=L/7XAxVPXUp9nB4GQCg5C6bsvVTKog0LQrjrxm+uX6ylB+aIYW4sx46bntnFwVp2/F VCfjAr8q6r4HdM3GIdJAHnJQ6A4fZbf34anQN19APP5narDHF2hHOEie/MNENNJDFYLu Zt7Q3NIr2f3BcX1W4hSKpLFwzzite2/KP/oSkSGouoEXrV8MoOVEtoBPQWbXLBxCwCb7 hcS6nauR6H4is+6i5kzT5Aas6iD3qf+XPj0fZCt5QkMce8sdEHXVYC5JYpDEXc6SrK6/ iEIROPxL671tO/qqKn5zx5AmjCC0xCqHCup6u7UfBdLFPZxNssb/CPWeT01WVTTkd1Bo JaIQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nokia.onmicrosoft.com header.s=selector1-nokia-onmicrosoft-com header.b=BkEq7gzM; arc=pass (i=1 spf=pass spfdomain=nokia.com dmarc=pass fromdomain=nokia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nokia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w3si912632ejo.13.2020.11.06.06.11.59; Fri, 06 Nov 2020 06:12:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nokia.onmicrosoft.com header.s=selector1-nokia-onmicrosoft-com header.b=BkEq7gzM; arc=pass (i=1 spf=pass spfdomain=nokia.com dmarc=pass fromdomain=nokia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nokia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727297AbgKFOK1 (ORCPT + 99 others); Fri, 6 Nov 2020 09:10:27 -0500 Received: from mail-eopbgr140139.outbound.protection.outlook.com ([40.107.14.139]:20485 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726812AbgKFOK1 (ORCPT ); Fri, 6 Nov 2020 09:10:27 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z6L1NPcBwh3YF36glbT4NEXD/xxXffRSPMdAeldgkQYiBNfVvKi2pCjQQX/DwnHcFFwS5/DQJFRMIvQoEZLsnSxCO1cmW/WiZD4XRVr20sE0GAviigz1+u44V9FXjepIde55ymN/5f85vsKIU3VDhBUtiUdxew0fUaTp4IXO5fK4OlVGuIWdNQkk/HIXUL9EX3VJhu+5m4Q25SbAAKZg616GylN2ddfxE2nFTQiS+HwLRqw5Y6epJ7zyFUFMKqJVh+fiX6GDrsnkDzlnX/9EjJo2oEXcJdfyHgURHGOLkMYeyeznHDbxPNpgrI7u3kq3eMNLGk48qau0UDVOt39ECQ== 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-SenderADCheck; bh=F+iONw1HG+Y6aPFExtXa7UY0+8xU2+GL7T43OqG4v9U=; b=IDu5U2hNGTcQUS0NDdh8tLrf4LJCVKaDGKDVFxrOP4ADXRJ9kNlTqaAT7fRyt0P/wUyQV5uvxEe1ZCb7DVc6WWEYlNIrzkIXIXb7ImnQPtmRGGWE38m1YdbRTCUEPOsuqVFqZhXutmA8AlD1okjOWmzN67fb1lTrjN3LU7h2joI4XjvQwE0aYDSrlqcYPRz0Bg8u9zAmKkJ5QQlGUaoYVYoEvYQBf7xR62Ot+HwbH1rKdWHKs5imM28uK6Jmg9QzLzUeG8d9WVCpRF6hdg7asdmvRY1VMlTTvZZWF7N4iAnCe/Pylq2nsbRpw0ku7jVi3sxC+G5gHsBIIlECcj5Z4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.2.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nokia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nokia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.onmicrosoft.com; s=selector1-nokia-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F+iONw1HG+Y6aPFExtXa7UY0+8xU2+GL7T43OqG4v9U=; b=BkEq7gzMG83AoW2SdaZr6GSTeYhu7CD8gHO95SUDnSud+zhFo5D6mZ5TE68g0q8GGjGR6fMJ/jMs2y2D+vfutWaUBnFrd8JYFOYyK6cSB1ATpaE3DZT3kFPo+mA57NY+5k89gjv8G3jCtKQGTfRXgubj1HhKxbuJwPzP0rUuOGI= Received: from AM4PR07CA0011.eurprd07.prod.outlook.com (2603:10a6:205:1::24) by DB6PR07MB3254.eurprd07.prod.outlook.com (2603:10a6:6:1d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3541.10; Fri, 6 Nov 2020 14:10:23 +0000 Received: from VE1EUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:205:1:cafe::a0) by AM4PR07CA0011.outlook.office365.com (2603:10a6:205:1::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.13 via Frontend Transport; Fri, 6 Nov 2020 14:10:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.2.17) smtp.mailfrom=nokia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nokia.com; Received-SPF: Pass (protection.outlook.com: domain of nokia.com designates 131.228.2.17 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.2.17; helo=fihe3nok0735.emea.nsn-net.net; Received: from fihe3nok0735.emea.nsn-net.net (131.228.2.17) by VE1EUR03FT011.mail.protection.outlook.com (10.152.18.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3541.17 via Frontend Transport; Fri, 6 Nov 2020 14:10:22 +0000 Received: from ulegcparamis.emea.nsn-net.net (ulegcparamis.emea.nsn-net.net [10.151.74.146]) by fihe3nok0735.emea.nsn-net.net (GMO) with ESMTP id 0A6EAGlV008549; Fri, 6 Nov 2020 14:10:17 GMT From: Alexander A Sverdlin To: Thomas Bogendoerfer , Jiaxun Yang , linux-mips@vger.kernel.org Cc: Alexander Sverdlin , Paul Burton , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] MIPS: reserve the memblock right after the kernel Date: Fri, 6 Nov 2020 15:10:01 +0100 Message-Id: <20201106141001.57637-1-alexander.sverdlin@nokia.com> X-Mailer: git-send-email 2.10.2 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: ebf90ad9-1dfc-4735-5a73-08d8825db381 X-MS-TrafficTypeDiagnostic: DB6PR07MB3254: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: itHud0jNV1wS3vzNRp3DCVz7Vsry0H76ECShRWS+vwOdWUIXpnN8nX2F3h8SB9rLq/hc5qWKfdNLTyd4twT3iVYsbWCoD2LJPQMBr1IhxIfDI8xU3wmJ7qe6ptNXS3odic+Xi+mL7OhQWBhp9c9l9114iSMX25XfDnEEtb90JDXirj24vx5rT453Wo76QTl20puczOLh20x93N2AmYZdAK0ZLMLfMrZH4xXj+6v5Y5V1Jvg7sO3Ukxm0Wpe93zGmsQ0NHVFs1O5j+c0sfEDYivBM73+5yPp0f5IKia5JmDTa2kCJMn+gffO+/OyrDstzztltu/BL5TIzIEFH3EgEM56mfx9z44Wzk1at9pegmtkCc3MNiUlbq1IasqFtbl8aUg/HQmRjUjIxM9oZ7EweLg== X-Forefront-Antispam-Report: CIP:131.228.2.17;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fihe3nok0735.emea.nsn-net.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(376002)(136003)(39860400002)(396003)(346002)(46966005)(81166007)(8936002)(356005)(4326008)(47076004)(2906002)(8676002)(82740400003)(6666004)(86362001)(83380400001)(5660300002)(36756003)(110136005)(70586007)(70206006)(336012)(2616005)(316002)(26005)(186003)(478600001)(54906003)(82310400003)(1076003);DIR:OUT;SFP:1102; X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2020 14:10:22.6644 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ebf90ad9-1dfc-4735-5a73-08d8825db381 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.2.17];Helo=[fihe3nok0735.emea.nsn-net.net] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR07MB3254 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Sverdlin Linux doesn't own the memory immediately after the kernel image. On Octeon bootloader places a shared structure right close after the kernel _end, refer to "struct cvmx_bootinfo *octeon_bootinfo" in cavium-octeon/setup.c. If check_kernel_sections_mem() rounds the PFNs up, first memblock_alloc() inside early_init_dt_alloc_memory_arch() <= device_tree_init() returns memory block overlapping with the above octeon_bootinfo structure, which is being overwritten afterwards. Cc: stable@vger.kernel.org Fixes: a94e4f24ec83 ("MIPS: init: Drop boot_mem_map") Signed-off-by: Alexander Sverdlin --- arch/mips/kernel/setup.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 0d42532..f6cf2f6 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -504,6 +504,12 @@ static void __init check_kernel_sections_mem(void) if (!memblock_is_region_memory(start, size)) { pr_info("Kernel sections are not in the memory maps\n"); memblock_add(start, size); + /* + * Octeon bootloader places shared data structure right after + * the kernel => make sure it will not be corrupted. + */ + memblock_reserve(__pa_symbol(&_end), + start + size - __pa_symbol(&_end)); } } -- 2.10.2