From nobody Tue Jan 04 10:50:19 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 000CF1936DEE; Tue, 4 Jan 2022 10:50:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JSqBz5bWTz4RXT; Tue, 4 Jan 2022 10:50:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 93728176C1; Tue, 4 Jan 2022 10:50:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 204AoJmt044257; Tue, 4 Jan 2022 10:50:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 204AoJMW044253; Tue, 4 Jan 2022 10:50:19 GMT (envelope-from git) Date: Tue, 4 Jan 2022 10:50:19 GMT Message-Id: <202201041050.204AoJMW044253@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: d41cd6cce75b - stable/13 - Add an loader command on arm64 to sync the cache List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d41cd6cce75b751bda78424b0bf557894fd72763 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641293420; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=olfJnMle4DZx4Yuumf53swhOk7FOXlBtVv5C5pi0Usw=; b=dW4nHTXdFTvBOJ2iF9gkCaKFnVaLHJK8VFzDpBudmURA1iZaQRjujhZxwTjLBgy1m6gBwz lPqUUJPMK2YYuPw8LsNGEgTbiCJ4sNdrM0Oi0C9EAB75lpYx2r4euplxRphuLGZRXZS2Hb wBEVJVC2Nfd/NteD4xi7t0td4MHaOsXFvKwTedJF1ocgkSOftyLlFH67agwcll+Zzk/umO 1RpNzkJFnF76hYp3gjCWDtsMSGARccok7V+GXuO4DHSPK5dXOiUduaG25l1mwIN3fzeyDq eYcUHU9zXGyk8ByHvkhM1VygNgumAeDrT6F9dUAjvhcNsaVu9p6W81tlkdfAtQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641293420; a=rsa-sha256; cv=none; b=JK8czmIcH5cz1HQr/+zlT/mI691QqzI+lcQsm6fLz01SnFNRVxUSRJhmpIdGV6zxWwCrqe YE6D09Er15nUTe4ihKsGRPBQm5Srh/CzOIEcFts8+vQUvsMF314Ws/V4sOjMYrJQoVGKxO Ilapt0QBmkSV0aQNR4T2kJiTWnWW/VZzIDBwmZVzFjqM7Gok4oaGtvDmfhUPDqRF4DDxcd BYeimF5Iwpw9gv9aeCoBjJA/i+xPey4NLciJ+O0jf/akI5vtpxTyhYe70ZcdjtqrElgYzS TMdlkslerTB7uFXOHSczUTF920q5qQLNmzj+cqbGDcGqF37Uz5EGhyPo5sgk5A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=d41cd6cce75b751bda78424b0bf557894fd72763 commit d41cd6cce75b751bda78424b0bf557894fd72763 Author: Andrew Turner AuthorDate: 2021-12-20 13:42:15 +0000 Commit: Andrew Turner CommitDate: 2022-01-04 10:08:32 +0000 Add an loader command on arm64 to sync the cache On boot we don't need to perform any CPU cache management when the IDC and DIC fields in the ctr_el0 register are set. Add a command to tell loader to ignore these fields. This could be useful, for example, if the hardware is misreporting the values and we are missing a quirk to enable it. It is not expected this will be needed, but is only intended as a workaround to ensure the kernel can still boot. Sponsored by: The FreeBSD Foundation (cherry picked from commit c399283c71e310e1573e8d27f9cb9d27a4ea3376) --- stand/arm64/libarm64/cache.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/stand/arm64/libarm64/cache.c b/stand/arm64/libarm64/cache.c index ff52572399ac..105e08cb4257 100644 --- a/stand/arm64/libarm64/cache.c +++ b/stand/arm64/libarm64/cache.c @@ -37,17 +37,30 @@ __FBSDID("$FreeBSD$"); #include #include +#include "bootstrap.h" #include "cache.h" +static long cache_flags; +#define CACHE_FLAG_DIC_OFF (1<<0) +#define CACHE_FLAG_IDC_OFF (1<<1) + static bool get_cache_dic(uint64_t ctr) { + if ((cache_flags & CACHE_FLAG_DIC_OFF) != 0) { + return (false); + } + return (CTR_DIC_VAL(ctr) != 0); } static bool get_cache_idc(uint64_t ctr) { + if ((cache_flags & CACHE_FLAG_IDC_OFF) != 0) { + return (false); + } + return (CTR_IDC_VAL(ctr) != 0); } @@ -112,3 +125,28 @@ cpu_inval_icache(void) : : : "memory"); } } + +static int +command_cache_flags(int argc, char *argv[]) +{ + char *cp; + long new_flags; + + if (argc == 3) { + if (strcmp(argv[1], "set") == 0) { + new_flags = strtol(argv[2], &cp, 0); + if (cp[0] != '\0') { + printf("Invalid flags\n"); + } else { + printf("Setting cache flags to %#lx\n", + new_flags); + cache_flags = new_flags; + return (CMD_OK); + } + } + } + + printf("usage: cache_flags set \n"); + return (CMD_ERROR); +} +COMMAND_SET(cache_flags, "cache_flags", "Set cache flags", command_cache_flags);