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 1E0F1ECE58C for ; Tue, 10 Sep 2024 00:01:40 +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=5KDrfnw4h4KPFm9gkKjM5Pcm4Qn58KLQZ4qPPhdTka4=; b=JDLeou5cp9nmcaPCIGTalBTDGQ WNaM1HYJUUJ/wplvGIJTM+i2Ikwft/zNmVWMwenuz7TPNNpdedzUpmjaYYcOzCRdaDcnljSzGI7ht 4oW13q6l90P2udHtJuZBldRQTMs2XN1up1GnwJyFWkdlT+QKOBQg1+rlrQc6DaWkTcq3L0AZGBp8G quVxiJ2E2hGDCrkIoMIJGkJCzZdJuTYMXb50Xb+tMEG1zzF9vreG/hJ60kKqUeZyBjRaTZ16/Eam5 3ov+8laduD2RyPgtKm7hLews6PHNCzYrkQ+OPkYBZZf8NaC0K8IaymM/nqPXi53pUVmWZ8eNBifT3 ea862wcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1snoK0-00000003e6W-3un4; Tue, 10 Sep 2024 00:01:28 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1snoFm-00000003dLO-2aIR for linux-arm-kernel@lists.infradead.org; Mon, 09 Sep 2024 23:57:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725926223; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5KDrfnw4h4KPFm9gkKjM5Pcm4Qn58KLQZ4qPPhdTka4=; b=itQsml/54rxNNuresKAHUjR7n8sAgJLZs/FHDCmB3EXZKq5eURJhMugnMi6O9AbvkJWSGL uBo4TiDnbcYWhTlykOVt3OWuVslVVXx4x5kjV3rGJIZ1+7CxYEYwhggcrwxH+UjTb3Kg3z t8lwOwPqGB9zHEBu7ytn9FeSt/An7j8= Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-213-N9KqbC9sODSUp6abDcIdlw-1; Mon, 09 Sep 2024 19:57:01 -0400 X-MC-Unique: N9KqbC9sODSUp6abDcIdlw-1 Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-7179469744dso258236b3a.2 for ; Mon, 09 Sep 2024 16:57:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725926221; x=1726531021; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5KDrfnw4h4KPFm9gkKjM5Pcm4Qn58KLQZ4qPPhdTka4=; b=FjPh+oQoaaHzbBLahiGtAEAXnONWvF7M0rFSPbLk9QfSajleWFhd0vTC6s8R/xigF5 xw6jkOhITYGLao6gGMrqDUfkDrMfwJezTQOzz3GhoZ8fzhQUs+xk5SjqdrEJYPcP+TnA 4BO3XnX880UnE/CqY1TMAG/i+ZIk7gHruo0e7UxOzobBTmLuDPC5sfKmjpff2OM6zp1W fNkLg/X3O+7wOGvSuTM4XNjTbucfULBmGkUXv1dVQr5i7r7cbKLfp5PwECZJ0zjBgQvh X3oWaKzRpROiDF1e7wOJqdU5f/s2QZYHGqfFqtxffnkjH6BNUHY4hn3zj2VddJ6hRbtQ NOtA== X-Forwarded-Encrypted: i=1; AJvYcCVejSLICpin3W8XLy+BT9dkssYkLpdbxCzG20pRIEVnDXZU7EJuICBhNz1W12wYIuD9opBqzyeRBoyUOOZ9O+9o@lists.infradead.org X-Gm-Message-State: AOJu0Yw6cRUgZfxOwDSUCPMYi9OblHykX1eXT3bsyS35aRX9dqmXcVhg 7up4RvV541Fvv5/3t45Rl4YwZcJmUbXOwwNOSK73LnisFq1kYXKWYf23ndShyUis5wSf3W90yde 3rEVpSFwT2LU23li0ds1QKyFs0u5O93FBjAIcX1GF962mANUJ5q1JtRXpfg0IRwAOgWDvuRHK X-Received: by 2002:a05:6a00:3c85:b0:718:d740:b870 with SMTP id d2e1a72fcca58-718e3352956mr12735764b3a.2.1725926220675; Mon, 09 Sep 2024 16:57:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsgj8V1pojC58pqDKayl2QgqKFvt9FHbNtmUL06MwiNOepfTXdxL0EwUPYChJ+RhkrUXN3AQ== X-Received: by 2002:a05:6a00:3c85:b0:718:d740:b870 with SMTP id d2e1a72fcca58-718e3352956mr12735733b3a.2.1725926220087; Mon, 09 Sep 2024 16:57:00 -0700 (PDT) Received: from [192.168.68.54] ([103.210.27.31]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71909092258sm269939b3a.127.2024.09.09.16.56.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Sep 2024 16:56:59 -0700 (PDT) Message-ID: <41d7c549-072c-4e55-beab-cf339f441ec5@redhat.com> Date: Tue, 10 Sep 2024 09:56:49 +1000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 04/19] firmware/psci: Add psci_early_test_conduit() To: Steven Price , kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Catalin Marinas , 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 , Shanker Donthineni , Alper Gun , Jean-Philippe Brucker References: <20240819131924.372366-1-steven.price@arm.com> <20240819131924.372366-5-steven.price@arm.com> From: Gavin Shan In-Reply-To: <20240819131924.372366-5-steven.price@arm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US 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-20240909_165706_771218_39D8D976 X-CRM114-Status: GOOD ( 23.87 ) 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 8/19/24 11:19 PM, Steven Price wrote: > From: Jean-Philippe Brucker > > Add a function to test early if PSCI is present and what conduit it > uses. Because the PSCI conduit corresponds to the SMCCC one, this will > let the kernel know whether it can use SMC instructions to discuss with > the Realm Management Monitor (RMM), early enough to enable RAM and > serial access when running in a Realm. > > Signed-off-by: Jean-Philippe Brucker > Signed-off-by: Steven Price > --- > v4: New patch > --- > drivers/firmware/psci/psci.c | 25 +++++++++++++++++++++++++ > include/linux/psci.h | 5 +++++ > 2 files changed, 30 insertions(+) > Question: Do we need same check for ACPI based system? > diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c > index 2328ca58bba6..2b308f97ef2c 100644 > --- a/drivers/firmware/psci/psci.c > +++ b/drivers/firmware/psci/psci.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -769,6 +770,30 @@ int __init psci_dt_init(void) > return ret; > } > > +/* > + * Test early if PSCI is supported, and if its conduit matches @conduit > + */ Nit: The comments needn't span into multiple lines. > +bool __init psci_early_test_conduit(enum arm_smccc_conduit conduit) > +{ > + int len; > + int psci_node; > + const char *method; > + unsigned long dt_root; > + > + /* DT hasn't been unflattened yet, we have to work with the flat blob */ > + dt_root = of_get_flat_dt_root(); > + psci_node = of_get_flat_dt_subnode_by_name(dt_root, "psci"); > + if (psci_node <= 0) > + return false; > + Nit: Strictly speaking, "psci_node == 0" isn't an error. So the check would be "if (psci_node < 0)" if I'm correct. > + method = of_get_flat_dt_prop(psci_node, "method", &len); > + if (!method) > + return false; > + > + return (conduit == SMCCC_CONDUIT_SMC && strncmp(method, "smc", len) == 0) || > + (conduit == SMCCC_CONDUIT_HVC && strncmp(method, "hvc", len) == 0); > +} > + > #ifdef CONFIG_ACPI > /* > * We use PSCI 0.2+ when ACPI is deployed on ARM64 and it's > diff --git a/include/linux/psci.h b/include/linux/psci.h > index 4ca0060a3fc4..a1fc1703ba20 100644 > --- a/include/linux/psci.h > +++ b/include/linux/psci.h > @@ -45,8 +45,13 @@ struct psci_0_1_function_ids get_psci_0_1_function_ids(void); > > #if defined(CONFIG_ARM_PSCI_FW) > int __init psci_dt_init(void); > +bool __init psci_early_test_conduit(enum arm_smccc_conduit conduit); > #else > static inline int psci_dt_init(void) { return 0; } > +static inline bool psci_early_test_conduit(enum arm_smccc_conduit conduit) > +{ > + return false; > +} > #endif > > #if defined(CONFIG_ARM_PSCI_FW) && defined(CONFIG_ACPI) Thanks, Gavin