Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp359941lqp; Wed, 12 Jun 2024 04:01:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWsV9Zqw0VCvyId326/3W4MHiKMgn02QnkOVcuEnFiD84Fow2mMYtawomruI2dtY9Wv/p1z3F/yzcPQxTTLuOiUO8eY/sV2wcyZYBC42g== X-Google-Smtp-Source: AGHT+IHm6/lZndaTh/uMw/YPfyAIKZpzatfyWwAZ+0Vg7bdnlnvjO7KCltBugtiJAYGDbUQDumDM X-Received: by 2002:a17:902:c401:b0:1f3:2b46:47c9 with SMTP id d9443c01a7336-1f83b609b25mr14542375ad.28.1718190101760; Wed, 12 Jun 2024 04:01:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718190101; cv=pass; d=google.com; s=arc-20160816; b=BacugbH232jzD767gnt0c9PMKmG+6Adz0pD3G/ykrmDkD8uazUoVgIpN9SKuampoYF Yuc95ooodUgrlZchWKZouxLShEHeM7ipWbylRfrSl4PP7nOrkDNdfZtXmsLKLc5ZYSSc xXgwp6dEVsgdn9ErIMtiwhBrNSK641ty7Yvvb0nLn/jSN3+wxTtLJ0h3D9nrQpvXn+ta CMzSCArfxYDC0y6Ei3oOc5beAjxsGr3aRsQnlHHzqKYkDp5727pLmo6j6znKu+WfhXmz hqPDegHd2WdEhZ/YtFQZ4Cp5/mt/S7Bo4PAPqBL5vum880MdYj4T3K6RjJA1gxyOAiEF h1MA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=z2EQwKfLvpDulqiWZaKLpveeq9xBAija4J7nqwcd4Hc=; fh=N/htlZtG+6fgxXLUkgy+ZjczmFs1KkCEEYOWNcngZMA=; b=zwtwlKovXwO+Pxu7491c6owUHxZ3+Be0yWxmfoKWa4Y9UNdhZp+KdDmQWKxPF6o5j/ HLxN1n58ndHSfGZEdBVsepHgQNwPot4QIas0uiVCTjEzOjhBYvUPN5blRgBXkZJk4P00 gYQIU/E3xVvpz4ocJ/o4Rw4TYlYye3pQ5pA0f54oYCu6C7n6qr49OpXmDrgwxpXNT3qK a/iB3JeFqAM6huDF8L2VM37impVwlPuxxuF83nq+eqiR5LcDBinPR+s/vqWH4J9cBxH+ eD0zpk6v1BG/Yzf+G+Swt/ONiaIoz0zwJcN55ZhEH3NH4a3V1TE0wZPCcrkhQEe665gH i9Nw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-211388-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211388-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd7d5918si113832545ad.254.2024.06.12.04.01.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 04:01:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211388-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-211388-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211388-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 02CF8B21F88 for ; Wed, 12 Jun 2024 10:59:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD9FD16F0CF; Wed, 12 Jun 2024 10:59:29 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB6CD16EBFD; 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=1718189969; cv=none; b=KpPtC+uB9hurzP06Ipi0n7SPgfbDCSumqCzeD0QWNRvJ/Q+kuBtz2TQ898nWHdwulDRN61MaWSTMjSBoJxKw40ndYPipziqzm0QJ5/acanJ4kJ+hG/HvDR1MDC52kKOkHvHy3P4cGCuakvUoQ8NqKbFQ/nntGakbUfKMpaw0KMg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718189969; c=relaxed/simple; bh=llCwwnVAkDKupqy/WhpTunxBcdTwr9NCz6JQmlN1bNM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ODIZkUBANWVIk7oTmDag5IMkw/Jbp4bBYrwMRJEoYNVWmFWMyHcMYGw7XxudPJxVmruyXWmSOpPFgyapJcZsTUDIOX9C49QAtIxOJSYGg9RxgkRt7cFdSTn8hVr3PJVd1GrUoX33Ath0C0OM7yCiQw21ZSqDBMriLAOD6M36N40= 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-kernel@vger.kernel.org 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 >