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 2B1B0C27C79 for ; Mon, 17 Jun 2024 10:28:01 +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-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version: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=uXp/Yz17OzdkV2gV0XI8xrmGqd5+ox1Pqhqcmx8WT9w=; b=0ePGqvovOtbLfIqTTw6YqmWruI nxWKllws+qYxjU3uqmwfAQnsZ7JlxVVm5Zc/hFnv7PwX/HtfjiU8XEAbZ7qwqAsy/Qpu+1NC/vtcn 8SQ2jhGjWKFtYxi9Jxt6CEJbtWee3OgUHz0TXcB/AGG9hVNKuZnypOUl3lAHMOoN/Z1dAWvKrHszk xX2No8g+r4W7GZFVLIk3tbdrT8PjGrK2XWgR0GBgjHUKwjBFvM5rPc8HNZRPRtj07xiSDmUL4bMsD fE/xsDhL43FzjhkFO6MiNivd6Cm0I75UxEI23i3tRngMfsp9PWzjavyMEJLLXtiANEEXdkEkQkt0I YfFIcAvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJ9aX-0000000AFj4-3rFh; Mon, 17 Jun 2024 10:27:49 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJ9aU-0000000AFi2-1ggw for linux-arm-kernel@lists.infradead.org; Mon, 17 Jun 2024 10:27:47 +0000 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-57c923e03caso4770837a12.3 for ; Mon, 17 Jun 2024 03:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718620062; x=1719224862; darn=lists.infradead.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=uXp/Yz17OzdkV2gV0XI8xrmGqd5+ox1Pqhqcmx8WT9w=; b=rK3f6RZpqUgsCxYH7+Yn6TZ/JVviQ/cXOgP2Vme5b3Ah1NvGmlXd3tDxpLGmslpAHn rQTNlx7CC3CWIlx2fcfIHFh/0MqX/H36s0x57bX+wD/kKjyfbknFrMyAtgRB7EyMo74i 1BkXiyw+Qblv0lLSGjSICfEBsfpZFbMMXknJFK30zrfTDDSnfMZuMc7rbbD5u1xDSrVk SjIi9W3cJl+57DPQ3MKVBzcg3IMGUWq/GOaxH7GQECt3mEWu3ItJsnW9f1SkwD5gTvEQ zfHkQUDoZxosUHxLB5a9CxAaQijHAFYAVu4hxLeXo1uKPWaN/FL2qQUfc43rKM5sVGWD HXLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718620062; x=1719224862; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uXp/Yz17OzdkV2gV0XI8xrmGqd5+ox1Pqhqcmx8WT9w=; b=HsP1Bf6QofSGmDDjTGtgWcIVuw5Krp1qzran+Fa01nFgF/dQIpmnveUEm5Zj2iBz6Z LR7z+f4d1P4UDwjodrj8uYiT7oXWHvokSBLkIhEGaK0tvtOuM9DDzG07A6YyJAMqRjRB LBD7M9nWFKYyGK5EW4d0e8k513DdeKb0c2GnX2NQgBvdIuLf8tzsUbo0Lw3/T65f9wp0 mFQ3njHK6BI01zv8lWCo1gjTI4OsmdbaG9oXIptnFDjkIW2ehApllXr6KUJw71MRbAB1 LI+UUynOrcXzrsOfbSUJfWQn/FfPA6yXvBPj+ebv5FZWGIaLj9x/1RrySGzHV80ydxTW Dwjg== X-Forwarded-Encrypted: i=1; AJvYcCV/XNi8O/1Y1DKO/7Uylg4RBzO/c45HWviVP8Q83XT5RtNucZr8qsRnt4ZpYKGjOIOuGfiLX06mcadDcba7weAyjRp0Xbcya3HIDyvipcn+PNLxS2M= X-Gm-Message-State: AOJu0YxEZFDSRDTKDrMXkgJqeODi/eL0iStITKlaCLDlIOIcXAGC9U3w dq2cjyJHnJ48mMM7M1TOLf1iIXvGGKGDnL0NtW7ukjsHOqzmKz6tbGB9j5KmMtmcD3oafwQd8vu RFYG1y2SGH6TfdPKmxoaYCLJFFyeeYyC7Kor0nA== X-Google-Smtp-Source: AGHT+IHa1KyYv1IKw590sCplWvhogQlO8OvOBxMlNOdOwgi5TbD9kl95KoZfAoxfCiWfEz/NonSQTv/NuyiSNK1pPCg= X-Received: by 2002:a50:a458:0:b0:57a:322c:b1a5 with SMTP id 4fb4d7f45d1cf-57cbd6a6d1dmr5332493a12.38.1718620062388; Mon, 17 Jun 2024 03:27:42 -0700 (PDT) MIME-Version: 1.0 References: <20240605093006.145492-1-steven.price@arm.com> <20240605093006.145492-3-steven.price@arm.com> <20240612104023.GB4602@myrica> <3301ddd8-f088-48e3-bfac-460891698eac@arm.com> <20240613105107.GC417776@myrica> In-Reply-To: <20240613105107.GC417776@myrica> From: Peter Maydell Date: Mon, 17 Jun 2024 11:27:31 +0100 Message-ID: Subject: Re: [PATCH v3 02/14] arm64: Detect if in a realm and set RIPAS RAM To: Jean-Philippe Brucker Cc: Suzuki K Poulose , Steven Price , 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 Content-Type: text/plain; charset="UTF-8" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240617_032746_469382_AEA9AC00 X-CRM114-Status: GOOD ( 29.78 ) 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 Thu, 13 Jun 2024 at 11:50, Jean-Philippe Brucker wrote: > > On Wed, Jun 12, 2024 at 11:59:22AM +0100, Suzuki K Poulose wrote: > > 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. > > Good point, it also fixes this case and is simpler. It assumes RMM doesn't > hide this field, but I can't think of a reason it would. > > This command won't work anymore: > > qemu-system-aarch64 -M virt,secure=on -cpu max -kernel Image -nographic > > implements EL3 and SMC still treated as undef. QEMU has a special case for > starting at EL2 in this case, but I couldn't find what this is for. That's a bit of an odd config, because it says "emulate EL3 but never use it". QEMU's boot loader starts the kernel at EL2 because the kernel boot protocol requires that (this is more relevant on boards other than virt where EL3 is not command-line disableable). I have a feeling we've occasionally found that somebody's had some corner case reason to use it, though. (eg https://gitlab.com/qemu-project/qemu/-/issues/1899 is from somebody who says they use this when booting Windows 11 because it asserts at boot time that EL3 is present and won't boot otherwise.) Your underlying problem here seems to be that you don't have a way for the firmware to say "hey, SMC works, you can use it" ? -- PMM