From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC3742FB084 for ; Sun, 16 Aug 2026 07:53:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786866808; cv=none; b=jcXZA47a7Va9t5lx/CHdVr7evWl0crUiJO+V5RYMrEMRW4PAhOI44A88nR4vhhJtVcEsErzCezbu0yml1CL4Xd+i2eW0j6eitcOzBYmy4qd3CEutrQl3WgmsNQlpSnKQfw7lg5d6u6OtmY3DjeHQShLvoWuWNBUQ4QSDNbTzzXg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786866808; c=relaxed/simple; bh=iJws9cMU3JxPn+6thXAIZwVSZOHadQXF+fFjSWfuO/c=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DiPRDyvWbOd1sgMz54AXoVySvk2WRo2p+j2WydIoUL/ysD/8xLGR/rLOIyKeSdOK6kdp97VmlxUbLnWpNPySKVMAaemWDcYSlLBaiLh68sXmjNMyDgEwz2eerRh6yFabU4e9TiccrNfjIRqawxecKjgT05OnMbbbkfKBQ3Sus9M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=j+HxHZTn; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j+HxHZTn" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-5b3119957f0so2159080e87.1 for ; Sun, 16 Aug 2026 00:53:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786866805; x=1787471605; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=sdpGdtIJTgPziDsxDwqeF79PiinqDS6T265fdArr+gw=; b=j+HxHZTn5IINqh9/k3aPF/8b0SLYyvaIBmnM9bswkfaHKug1mu3lK47uP3AKU2Fe1n uQF2jdPfwZZg8uva4PAf2uv553sYI3PUAR0KS2SmywP30p48/TAAUEer01MEvrHQAnH1 7O30SPvqrrI/Jf7w8Od8ILcjBz+PXnq2BU4ecCAAiNyxkAUE/02fNKWsfJHfkvJ3PHXS tiSqfmAfHgrpnZVfBhw8AAGm0qB++LWwvsW8Lr8rW8/upyKRR1aolEaihfMPnmqq6o9o pbckWhPphwh/JZctJzw8VaurTNBc6F42Z9jp86xf+REs6beq58s8WES+NeCY9aSoX8Sj 5pmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786866805; x=1787471605; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=sdpGdtIJTgPziDsxDwqeF79PiinqDS6T265fdArr+gw=; b=TPUEh8Bu7WJYbW0ZId7D+E5ka18r/8miecM+d6Oic9IUdjFZVj9+XmZcPIY/kr4CXO q6H8VYbdi49+VCVU05ADzHS5WbuKbQZ65c7Hy7V1R1aSvnZUkOX9MofYpd+bQ/ygLulY vO1snxxgXftmVniXEBFE39aF08qct2SwNymPiKmFir1AxzGo5zo6gOF1SxhnseAjqj0q sFqDkcj2ZYKWK815DatRM0/+zZPSKh7JiAOfA1xL5dyJeSRAhOmbFjVYJisPkyNPzgcH jnP0rJjh4vGfHfouxQnCVtyCkO2MgcQMA6caUi7+PwQuTxlwbvToSUxgcjrL/VeHkddp b8gg== X-Forwarded-Encrypted: i=1; AHgh+RoMSJLlxtZz5lpr2D4jdNJGTMGcCkGUU/CVx7fM59dy6M2RBxFQKd/ObwZ1nxOKZzgLuE3GLK1uTIiyHBI=@vger.kernel.org X-Gm-Message-State: AOJu0YyjiAlP+6JlORaFETG88F4M7FAXbk/9VRQiBQ5exBEdsAoaboJp TMvFHctOV6lJiahkyvlG91qz3zVlSp+v+Izr0Qhim4JiV72u6KpDj3Zg X-Gm-Gg: AR+sD10aQtcLtKN52wSJpW/QYRhghz+5UPgADNFXVCwxWQk4NGQMRzMr+fAZJ9Fdyz7 9rTjwhEuqrGtG0SQWPFSwpD2hVK4LvUbG1YAD3mVBkW0T5+EMFBwjuhslxpGs2FRgN8BApMZtV0 35gtRDZwdtkkra5Dn0YmKae2BXO97agJa00iFdprCZ+QhpdJXxsf66wqd/rdIS6mSeYhtyvQ+GN M7vGLGqu78855mBKpbd3J5a/BWQ60TkRfWhz80VdgudfueM0yt595q1qnd3e6cr9yoyGYiz+AP7 pLfXSTyeO/fa8D6z8/YaNyiQmZhyDPTiriwpsoxmoSMaWeYWeOcs53FQijgRcjcB4ZdY0GDyhFP sBn77/qEQVJGz6RtFRVhnN5AkC6pTFlKf9z+r3/KzRssMKzEDtzh78mX70weYRUFbFSvIL4hsbs WslmP+LiOUZXX3awuQYuECX048btgQVxEZjNqUYObtlSmQvQMxjJJiyApCvCvnfRtGif8jahfw0 QLHItJQVRL2PEb6AuyfVdTibBKeGCqf X-Received: by 2002:a05:6512:10ce:b0:5b2:1de0:5ea2 with SMTP id 2adb3069b0e04-5b459140f73mr2365592e87.16.1786866804662; Sun, 16 Aug 2026 00:53:24 -0700 (PDT) Received: from buildhost.darklands.se ([2001:9b1:ff:d701:51eb:176f:63d9:53f8]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b458b9a8d4sm1631136e87.15.2026.08.16.00.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Aug 2026 00:53:23 -0700 (PDT) From: Magnus Lindholm To: davem@davemloft.net, andreas@gaisler.com Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, Magnus Lindholm Subject: [PATCH v2 0/3] sparc32: allow a kernel loaded away from the start of RAM Date: Sun, 16 Aug 2026 09:50:14 +0200 Message-ID: <20260816075141.3489194-1-linmag7@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Many years ago I ran Linux on my SPARCstation hardware and tried to keep up with new releases, but somewhere around 3.x I hit a wall, sooner for SMP builds since they are larger. As the kernel grew it simply became too big for SILO to load. On this machine the last one that fit was 2.6.32, at 2598956 bytes against a 2605056 byte window: six kilobytes to spare. 3.12 was 184KB over. Fixing it turned out to need more than SILO changes, the kernel side needed work too, and I never got around to giving it serious thought. I recently dusted off my old SPARCs and picked the journey back up. A current sparc32 kernel no longer fits in the window SILO loads into: 0x4000 up to SILO's own text at 0x280000, about 2.5MB. Loading it higher instead exposes two places that assume the kernel sits at the start of RAM. Patch 1 is an independent pre-existing bug. viking_flush_page() and viking_mxcc_flush_page() compute a physical address as vaddr - PAGE_OFFSET, which is __pa() without phys_base. It is wrong regardless of the rest of this series; it simply cannot be observed while phys_base is zero. When it is not, iommu_flush_iotlb() flushes the wrong page, the IOMMU walks stale IOPTEs and every DMA transfer fails. It comes first so that no commit in the series leaves Viking DMA broken. Patch 2 makes setup_arch() discover a non-zero phys_base. It takes it from the lowest sp_banks[] entry today, and phys_base is the offset __pa() and __va() are defined in terms of, so once the kernel is loaded elsewhere every early translation is wrong by the difference, including the physical addresses written into page table descriptors. The tablewalker then follows pointers into pages holding nothing, while the same tables read back correctly through the nocache view, and the machine stops right after the context table pointer is installed with no console left to say why. The probe is the architecture's existing __get_phys(), which already implements it for sun4m and sun4d and returns zero elsewhere. Patch 3 sets HdrS to 0x0300, the protocol level that tells a boot loader the kernel supports being located somewhere other than physical 0x4000. No change in behaviour when phys_base is zero. Changes since v1: - drop the (unsigned int) casts and print with %lx (Sam Ravnborg) - always report RAM start and kernel start, not only when they differ (Sam Ravnborg). Note this means one line at every sparc32 boot; on platforms where __get_phys() is not implemented it reads as "kernel is at 0x0". - collect Reviewed-by from Sam Ravnborg on patches 1 and 3 Patches 1 and 3 are unchanged from v1 apart from the collected tag. Tested on a SPARCstation 20 booting from SCSI to a full userspace, with and without an initramfs, using a SILO carrying the matching loader changes. Also boot tested under qemu-system-sparc -M SS-5, and build tested for LEON and plain sparc32_defconfig. Each commit builds on its own. Emulation cannot exercise patch 1: microSPARC-II takes a different cache flush path, and qemu models no write-back cache, so a missed flush has no consequence there. The cost is the RAM below the load address, which the loader chooses. Magnus Lindholm (3): sparc32: honour phys_base in the viking cache flush routines sparc32: derive phys_base from the PAGE_OFFSET mapping sparc32: advertise relocatable kernel with HdrS 0x0300 arch/sparc/kernel/head_32.S | 2 +- arch/sparc/kernel/setup_32.c | 40 ++++++++++++++++++++++++++++++++++++ arch/sparc/mm/viking.S | 6 ++++++ 3 files changed, 47 insertions(+), 1 deletion(-) -- 2.43.0