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 E8D2BC2BBCA for ; Wed, 26 Jun 2024 00:12:55 +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:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TE5CpjMbO52gZWrRw/B2eqkwZSprVWCadGcmEMqw6yI=; b=tz23h12YHsTXSePhGqXvTd1roh /jcNXwT4YEvlQj9lvs25jgsvM0gNbq2KnhfkXZRMTgck/+mOrRCxK67HthuA6nU1C4pYLPOgRrJHS RuU44Pijfh9reHt6+OorNHPYVphbNfUtFmeNSqAj70GeMyy8RCC47guItbhIlW3VY0g2r2maIw+2n JoH3xwgoCFx7FryC7seI27RlYG+mtBghDuBdBdacv1H6vm9eN/qBUD+usN8EZnJ3TxIDdIf0mUpF9 OD3wLoOibU6WZ/vmPee8iR0g8bcDIg7kPG0pJ1wL5eN6rxVYyxjas24c/aTmlnhTGTmv/rePTJuHE Scm7pxoQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMGHE-00000004sWB-0DlF; Wed, 26 Jun 2024 00:12:44 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMGH7-00000004sUw-0F1y for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 00:12:38 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8DADD339; Tue, 25 Jun 2024 17:12:58 -0700 (PDT) Received: from [192.168.20.22] (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F00693F766; Tue, 25 Jun 2024 17:12:29 -0700 (PDT) Message-ID: Date: Tue, 25 Jun 2024 19:12:28 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 02/14] arm64: Detect if in a realm and set RIPAS RAM Content-Language: en-US To: Jean-Philippe Brucker , Steven Price Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, Suzuki K Poulose , Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , 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 References: <20240605093006.145492-1-steven.price@arm.com> <20240605093006.145492-3-steven.price@arm.com> <20240612104023.GB4602@myrica> From: Jeremy Linton In-Reply-To: <20240612104023.GB4602@myrica> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240625_171237_188750_3D588B50 X-CRM114-Status: GOOD ( 21.96 ) 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 Hi, On 6/12/24 05:40, Jean-Philippe Brucker wrote: > On Wed, Jun 05, 2024 at 10:29:54AM +0100, Steven Price wrote: >> From: Suzuki K Poulose >> >> Detect that the VM is a realm guest by the presence of the RSI >> interface. >> >> If in a realm then all memory needs to be marked as RIPAS RAM initially, >> the loader may or may not have done this for us. To be sure iterate over >> all RAM and mark it as such. Any failure is fatal as that implies the >> RAM regions passed to Linux are incorrect - which would mean failing >> later when attempting to access non-existent RAM. >> >> Signed-off-by: Suzuki K Poulose >> Co-developed-by: Steven Price >> Signed-off-by: Steven Price > >> +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); > > There is a regression on QEMU TCG (in emulation mode, not running under KVM): > > qemu-system-aarch64 -M virt -cpu max -kernel Image -nographic > > This doesn't implement EL3 or EL2, so SMC is UNDEFINED (DDI0487J.a R_HMXQS), > and we end up with an undef instruction exception. So this patch would > also break hardware that only implements EL1 (I don't know if it exists). To note: i've found out the hard way this set breaks a qemu+kvm+ACPI setup as well, for roughly the same reason. I imagine we want kernels which can boot in either a realm or a normal guest. I delayed the version check a bit and then, did enough that arm_smcccc_1_1_invoke() could replace arm_smccc_smc() in invoke_rsi_fn_smc_with_res(). Which naturally gets it booting again, the larger implications i've not considered yet. > > The easiest fix is to detect the SMC conduit through the PSCI node in DT. > SMCCC helpers already do this, but we can't use them this early in the > boot. I tested adding an early probe to the PSCI driver to check this, see > attached patches. > > Note that we do need to test the conduit after finding a PSCI node, > because even though it doesn't implement EL2 in this configuration, QEMU > still accepts PSCI HVCs in order to support SMP. > > Thanks, > Jean >