From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jdBiR-0007V6-Ki for mharc-grub-devel@gnu.org; Mon, 25 May 2020 07:56:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jdBiQ-0007Uy-IS for grub-devel@gnu.org; Mon, 25 May 2020 07:56:22 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:35066) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jdBiP-0006iz-CJ for grub-devel@gnu.org; Mon, 25 May 2020 07:56:22 -0400 Received: by mail-wr1-x441.google.com with SMTP id x14so11464502wrp.2 for ; Mon, 25 May 2020 04:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=MhluTnYvR58PUErbTsvn+7S4o4+zLe3RO7veQyhSz50=; b=kMOgmF82u1ejDHbscGYWG4BgwIKNlhejFlFw8j//x5TjkTKR4w73SlzcdNZG1Z70hl nz+Pp55IrduPIQEjYrV+Conx5mWW1BtEuMAVsYqBTQL2FWxLnJ5+oAl3mmOZ2T2y7BOr AKP7GQuEMPO4iZLa0TSDM8IC+y9AkXU1yqGEI5LKV5Og83kT55mG8rIHZ47ml4ZTVSef krsfgphx3WcwR3aTvfxk5s8RtKlS9k2hx9YtY/4dWuk7ctc6Etj6TCLuxcH8sAvNcUEP WeyIKjRa1hLmPBwGFsTdPAOf/ShWMK6cOcAjPvAYrjwUKIPAt3ugB2TH3mL3cQAFYSzx HaLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=MhluTnYvR58PUErbTsvn+7S4o4+zLe3RO7veQyhSz50=; b=es6GXFgk59lEnwOX4GGVY0UJaQVKJEnLJyjvkmFHaJK0YUffinLZWuuSePNsNndKWq GnEFbO/wNsuPBvc/CuzPVHi0oFbTMY1HZleHHZ2cgABhLAIdkhdvwADPecFGGTXUAXBg 25wJIG1om75hnhf4RqegvZC1z29sf/wy7FvYfkGIfY5gIEeGxarj2smNzdieoprfgERV zyPx45FvYXzPUKsF5lV6jN2uzWY9POlr9pntZfUkB2sYywSBLoFxDq4fLrWaokHy+2nG cRIyXa6C1S2laDQ4scuAUSxoOPn0F7m3eOtv++uoW5ptbsRaq5Nxa9EsHL8L1VkpYOrw 3hpw== X-Gm-Message-State: AOAM531pl5tdyGmLvQFgLUREx/Bo06bOL1zdVq+zzPuNLVlMJC2pvHRH VfwjE94Hf/f0rMyahrwXXuoxIiZSA3WxaNtiom9+51L5N7YMp37M4uVsnWi89kq5jbYypU5gDYY 9T4coHcU5pZW71CfzFxWSEOqdXs7WQ7j+c9fV428B0FCO1YSRPmnv4zqqWR34RyM= X-Google-Smtp-Source: ABdhPJycoEiSRVAo8UehnJoRiknNjKDInGx6gsHC2RyPQrtX7GOzRrnLCR2iA68HYemFw+oiLjoVTQ== X-Received: by 2002:adf:814a:: with SMTP id 68mr15074085wrm.177.1590407778926; Mon, 25 May 2020 04:56:18 -0700 (PDT) Received: from vanye ([2001:470:1f09:12f0:b26e:bfff:fea9:f1b8]) by smtp.gmail.com with ESMTPSA id k14sm6250481wrq.97.2020.05.25.04.56.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2020 04:56:18 -0700 (PDT) Date: Mon, 25 May 2020 12:56:16 +0100 From: Leif Lindholm To: The development of GNU GRUB Cc: Marc Zyngier , Vladimir Serbinenko Subject: Re: [PATCH] Fix 32-bit ARM handling of the CTR register Message-ID: <20200525115616.GJ1923@vanye> References: <20200524113248.367082-1-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200524113248.367082-1-maz@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=leif@nuviainc.com; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 May 2020 11:56:22 -0000 On Sun, May 24, 2020 at 12:32:48 +0100, Marc Zyngier wrote: > When booting on an ARMv8 core that implements either CTR.IDC or CTR.DIC > (indicating that some of the cache maintenance operations can be > removed when dealing with I/D-cache coherency, GRUB dies with a > "Unsupported cache type 0x........" message. > > This is pretty likely to happen when running in a virtual machine > hosted on an arm64 machine (I've triggered it on a system built around > a bunch of Cortex-A55 cores, which implements CTR.IDC). > > It turns out that the way GRUB deals with the CTR register is a bit > harsh for anything from ARMv7 onwards. The layout of the register is > backward compatible, meaning that nothing that gets added is allowed to > break earlier behaviour. In this case, ignoring IDC is completely fine, > and only results in unnecessary cache maintenance. > > We can thus avoid being paranoid, and align the 32bit behaviour with > its 64bit equivalent. > > Signed-off-by: Marc Zyngier This patch has the added benfit that it gets rid of a (gnu-specific) case range. Reviewed-by: Leif Lindholm Thanks! > --- > grub-core/kern/arm/cache.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/grub-core/kern/arm/cache.c b/grub-core/kern/arm/cache.c > index af1c4bbf5..6c75193e4 100644 > --- a/grub-core/kern/arm/cache.c > +++ b/grub-core/kern/arm/cache.c > @@ -93,13 +93,16 @@ probe_caches (void) > grub_arch_cache_ilinesz = 8 << (cache_type & 3); > type = ARCH_ARMV6; > break; > - case 0x80 ... 0x8f: > + default: > + /* > + * The CTR register is pretty much unchanged from v7 onwards, > + * and is guaranteed to be backward compatible (the IDC/DIC bits > + * allow certain CMOs to be elided, but performing them is never > + * wrong), hence handling it like its AArch64 equivalent. > + */ > grub_arch_cache_dlinesz = 4 << ((cache_type >> 16) & 0xf); > grub_arch_cache_ilinesz = 4 << (cache_type & 0xf); > type = ARCH_ARMV7; > - break; > - default: > - grub_fatal ("Unsupported cache type 0x%x", cache_type); > } > if (grub_arch_cache_dlinesz > grub_arch_cache_ilinesz) > grub_arch_cache_max_linesz = grub_arch_cache_dlinesz; > -- > 2.26.2 > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel