From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB68316E888; Wed, 12 Jun 2024 10:59:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718189968; cv=none; b=X+0PFSIU1n0UsflWr/eT1qGLnl+XU5YhPnv31ZM+sfjQ47TlzdrViW4PPXPgesba0FEwxtpdlOaAALOpkAykir6dZXCAtbCaaJQGowIeTJL1l+AiPWpsaRpB74JjdNA6yIrUbWqmeDfECC65yqYHR1I7xrLUP2c8AywMzq4p7UU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718189968; c=relaxed/simple; bh=llCwwnVAkDKupqy/WhpTunxBcdTwr9NCz6JQmlN1bNM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ea8n/QSiDO4p5BGuRkQWqisYRcDj8Onqk3jC93CKL5JCUzitDsg687yGK5NXKOEhHsHVGljT6AeHLHPPMepAGtCP3cJ5jVwf4dxXkrL94xMNgF6LGnk0MJAe6pyCKU/rvd/ov0oj2L7WdxItgozvg52pOf4+Sjs2qS7iJcA+1uo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 9FA281595; Wed, 12 Jun 2024 03:59:50 -0700 (PDT) Received: from [10.57.72.20] (unknown [10.57.72.20]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C2D073F73B; Wed, 12 Jun 2024 03:59:23 -0700 (PDT) Message-ID: <3301ddd8-f088-48e3-bfac-460891698eac@arm.com> Date: Wed, 12 Jun 2024 11:59:22 +0100 Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: 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-GB To: Jean-Philippe Brucker , Steven Price Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, 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: Suzuki K Poulose In-Reply-To: <20240612104023.GB4602@myrica> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/06/2024 11: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). Thanks for the report, Could we not check ID_AA64PFR0_EL1.EL3 >= 0 ? I think we do this for kvm-unit-tests, we need the same here. Suzuki > > 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 >