From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A12CC5321D for ; Mon, 26 Aug 2024 10:05:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KPJLHXallyg9KmHzG33pW2yrWWWdJCpgp6MlPwkxfIc=; b=w4Ib4yk5fTP0CRSooYOeb/stwy ExkLx9JAsfxm/Tr32H8mppCOznPgJ/FF5QaY5d8UNxoCdTvKI6AogsEEtYFfracnkLXmjHl9OfSFv Dcbh358R+OuUMMUlomvn/GezAYHh6GzctwZp6pYZ/DOoEjzOld2a3P8o0weyYYJDdE/ZS8v//NFaE FhUQstfBbtiK1yVP1ikAfiU6SDQ2TpGWNnYyJ2jV2YtMaM0dNVOKGAaNKv8qJMYPoUKhG8ID4m52W w369igaq1NZhJ91OYvwxvTSrIUYa/2dZ1DjUNXHBr1QN5cy5EnFVijRIkKX0Q5oTZbkogn1TeSap7 4rgc7Jjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siWbL-00000006qEk-1osN; Mon, 26 Aug 2024 10:05:31 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siWZv-00000006pt0-1j5u for linux-arm-kernel@bombadil.infradead.org; Mon, 26 Aug 2024 10:04:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=KPJLHXallyg9KmHzG33pW2yrWWWdJCpgp6MlPwkxfIc=; b=DXKzPxNGGY5tzzmj4rZT41Fjg8 EG4ZbY64txB4MXjB0vridF8NxwDLjxu/YSjWgOOxPvRchQitBi/JqDbj2/mn+/hNleb7C7sfKTDKx 48i8t+aUhpk3a9Clw6CwI4bq+ClqjRui3sIvj2sWNHqTMWjJE55qVCNSJz1avrGBU5DSsYJWx5418 U9oueQMosoqkapyJG/DeF+KxoNkJS5gVRwycTb0YHFCe0Nhp02USHKsYtfla/4m6+NW29Odty5z/4 sriA4H1rxysIijm/izGG6VUaCUHFhbGkQYkUwxOZN+xC0wN1j+3gL8c4hXZd2KUYPNLtboz0B+a5s p6xrs88Q==; Received: from sin.source.kernel.org ([145.40.73.55]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siWZr-0000000Ad1W-3ln3 for linux-arm-kernel@lists.infradead.org; Mon, 26 Aug 2024 10:04:02 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B9413CE0CDA; Mon, 26 Aug 2024 10:03:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67943C51407; Mon, 26 Aug 2024 10:03:48 +0000 (UTC) Date: Mon, 26 Aug 2024 13:03:56 +0300 From: Catalin Marinas To: Steven Price Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Gavin Shan , Shanker Donthineni , Alper Gun Subject: Re: [PATCH v5 05/19] arm64: Detect if in a realm and set RIPAS RAM Message-ID: References: <20240819131924.372366-1-steven.price@arm.com> <20240819131924.372366-6-steven.price@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240819131924.372366-6-steven.price@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240826_110400_462615_5F5539E5 X-CRM114-Status: GOOD ( 18.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Aug 19, 2024 at 02:19:10PM +0100, Steven Price wrote: > +static bool rsi_version_matches(void) > +{ > + unsigned long ver_lower, ver_higher; > + unsigned long ret = rsi_request_version(RSI_ABI_VERSION, > + &ver_lower, > + &ver_higher); > + > + if (ret == SMCCC_RET_NOT_SUPPORTED) > + return false; > + > + if (ret != RSI_SUCCESS) { > + pr_err("RME: RMM doesn't support RSI version %lu.%lu. Supported range: %lu.%lu-%lu.%lu\n", > + RSI_ABI_VERSION_MAJOR, RSI_ABI_VERSION_MINOR, > + RSI_ABI_VERSION_GET_MAJOR(ver_lower), > + RSI_ABI_VERSION_GET_MINOR(ver_lower), > + RSI_ABI_VERSION_GET_MAJOR(ver_higher), > + RSI_ABI_VERSION_GET_MINOR(ver_higher)); > + return false; > + } > + > + pr_info("RME: Using RSI version %lu.%lu\n", > + RSI_ABI_VERSION_GET_MAJOR(ver_lower), > + RSI_ABI_VERSION_GET_MINOR(ver_lower)); > + > + return true; > +} I don't have the spec at hand now (on a plane) but given the possibility of a 1.0 guest regressing on later RMM versions, I wonder whether we should simply bail out if it's not an exact version match. I forgot what the spec says about returned ranges (they were pretty confusing last time I checked). > + > +void __init arm64_rsi_setup_memory(void) > +{ > + u64 i; > + phys_addr_t start, end; > + > + if (!is_realm_world()) > + return; > + > + /* > + * Iterate over the available memory ranges and convert the state to > + * protected memory. We should take extra care to ensure that we DO NOT > + * permit any "DESTROYED" pages to be converted to "RAM". > + * > + * BUG_ON is used because if the attempt to switch the memory to > + * protected has failed here, then future accesses to the memory are > + * simply going to be reflected as a SEA (Synchronous External Abort) > + * which we can't handle. Bailing out early prevents the guest limping > + * on and dying later. > + */ > + for_each_mem_range(i, &start, &end) { > + BUG_ON(rsi_set_memory_range_protected_safe(start, end)); > + } Would it help debugging if we print the memory ranges as well rather than just a BUG_ON()? -- Catalin