From nobody Tue Oct 7 05:40:50 2025 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6149220685 for ; Mon, 14 Jul 2025 06:10:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752473462; cv=none; b=ka9tHYkskxzRK3hEaMXH7SPHYVTt/p8mdeAkRMNQB8B5F0gBCzOzWAQcZ61qwpP0Ri4GV2tG9yWWlXReAlyWooEAgkjkhq5HnKcq2MRDGn3tEW0cWv3V0UlaGIDh0RiECMV/StcJ0P40+XDNXBJDqEQ8XACZqJOngi+MRCpcxzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752473462; c=relaxed/simple; bh=e/rH8SD+Tg5pje3Lq+JRo3ekvTZcKBI1NyNIj2hZ318=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=GNGow8EW14x6vLJakzyWI90yiB9RnaTOxk4jFl4JldpyKiYG88wyQH3U3zSuNlcGLd2U/W/HP9B8KdKTmZKnMRWLPTHoJNxhU1woW81bwnY8pGDyORYnHCfZ1UnAkfF7mYfwiO2IekBx4+YKZM57NOCtTrkIwUefc5KInZVN2JQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=rotWQsb+; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rotWQsb+" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-454dee17a91so29166225e9.3 for ; Sun, 13 Jul 2025 23:10:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1752473458; x=1753078258; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=dSes2g4E88oXBSFPDQ6neF7W89c9NwaUqwVhdR4xBqI=; b=rotWQsb+BzRaXaIF9EZasLzZPYnyLA4P5S1PT+5/VWN+Dhgdyo75t/Im2oc/puNMDM r4svFhAoVbTatc2Jeqfv8qnRYvFIWvGq20uJoCzlHiqN1B18XNUtilZ+1JTOEUzcsUsX upmsORqXRWevk6jm6eH4HGoM0UqqRwvU7Mc+JmeWBLssK4ATbh+xhplHXd9NbFHBlHjE StNxdm30CXJ+AI/WNkBSaezuJuaSieyu/t60RYUsKFFKdwC/6Q4oBlp9QVZZzVhHBL2H f/yC25oznPeMr/RKPnPDrWt0fMo95Wk5GN6CHASnkC5/kcCDzJRLK4YHCs3/i2ff/UcH qxQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752473458; x=1753078258; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dSes2g4E88oXBSFPDQ6neF7W89c9NwaUqwVhdR4xBqI=; b=MZ1uN00jmlBCJsNTt83fsTaIjq+2MxHsndesKN+x4xgOXPP4Ppi+DFgDmFaocAdKAL YNzaXvxoo/7nbNqoner/W2PgnjHC/8UvKGQyIShVLUys0O1d6IENJZq60EjVLAD5A7L7 EJi4PRpz6XjHItdLRjFCAsfsOec14VHCmKQFB70p8FudFUtONrLZ0JtmYDzTJcR8aZtD YulFEGC4IXCidSLOXuoWCD0sQa4Eg/FpBf5nsciZOnxVEWK7rwWFvxMHADeBl64mT/uv LxCK5pIvblIfiFLXRE0KUpskRoZn2BgozrKpAckEbgUee2laZT9hJ/LlTa+W6jHjzBoZ wacw== X-Gm-Message-State: AOJu0YyzKSz5PqQ8nLN5skrVlXSZm7BWMrYl0vOJP6KZC6KtO+ObBkFM PtyJ71uzPKt4HROInf4SXYxLy4D9D5+PMJZvMr240AfHhYX8d9sNv8mvrtBbb7MutBM38M1YZjb JzQes+Y1KMqkTRV8WHELDWxoAsJOSRZRd84JJXdO7DHDJxjALxoMnEMKdMWqNWK8BkZbhPxm8Od 3drADq6l32Pn9OeXW62Qn5imKoMqYJfj4GLw== X-Google-Smtp-Source: AGHT+IFULlVjyNemOnSbG4TdMozAA0zsJZsF8hZ5FwjjrDDzQ4zhxHet1bEj5zD9JLh9WJDb+7sgf2zL X-Received: from wmbel18.prod.google.com ([2002:a05:600c:3e12:b0:456:1194:a7e7]) (user=ardb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:358f:b0:456:7cf:527a with SMTP id 5b1f17b1804b1-45607cf57cbmr50279335e9.28.1752473458182; Sun, 13 Jul 2025 23:10:58 -0700 (PDT) Date: Mon, 14 Jul 2025 08:08:45 +0200 In-Reply-To: <20250714060843.4029171-5-ardb+git@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250714060843.4029171-5-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=4119; i=ardb@kernel.org; h=from:subject; bh=1185/TpkpWg9isRLFf5wyjQebHCYqV40b1OjCDnfhjU=; b=owGbwMvMwCVmkMcZplerG8N4Wi2JIaNk3pfgGfFHvMs1rzs+7g2Z3jR3vmPyZLljMXN3nZu4o j/3A2d6RykLgxgXg6yYIovA7L/vdp6eKFXrPEsWZg4rE8gQBi5OAZhI9XmGf+YT5LnE2xivqL3c nC3HM8NQY4PQY8/mbbM+RMQ4nbzY8JqRYeV6Hz0bozMrpnLtY7c4Y8N90k7s2BaRs7se9l/3u/z 3DAMA X-Mailer: git-send-email 2.50.0.727.gbf7dc18ff4-goog Message-ID: <20250714060843.4029171-6-ardb+git@google.com> Subject: [RFC PATCH 1/3] efi-rtc: Remove wakeup functionality From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Heinrich Schuchardt , Feng Tang , Alexandre Belloni , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Sunil V L , Bibo Mao , linux-rtc@vger.kernel.org, linux-efi@vger.kernel.org, xen-devel@lists.xenproject.org, x86@kernel.org, linux-riscv@lists.infradead.org, loongarch@lists.linux.dev Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ard Biesheuvel The EFI rtc driver is used by non-x86 architectures only, and exposes the get/set wakeup time functionality provided by the underlying platform. This is usually broken on most platforms, and not widely used to begin with [if at all], so let's just remove it. Signed-off-by: Ard Biesheuvel Tested-by: Feng Tang --- drivers/rtc/rtc-efi.c | 76 +------------------- 1 file changed, 2 insertions(+), 74 deletions(-) diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c index fa8bf82df948..b4f44999ef0f 100644 --- a/drivers/rtc/rtc-efi.c +++ b/drivers/rtc/rtc-efi.c @@ -112,48 +112,6 @@ convert_from_efi_time(efi_time_t *eft, struct rtc_time= *wtime) return true; } =20 -static int efi_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) -{ - efi_time_t eft; - efi_status_t status; - - /* - * As of EFI v1.10, this call always returns an unsupported status - */ - status =3D efi.get_wakeup_time((efi_bool_t *)&wkalrm->enabled, - (efi_bool_t *)&wkalrm->pending, &eft); - - if (status !=3D EFI_SUCCESS) - return -EINVAL; - - if (!convert_from_efi_time(&eft, &wkalrm->time)) - return -EIO; - - return rtc_valid_tm(&wkalrm->time); -} - -static int efi_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) -{ - efi_time_t eft; - efi_status_t status; - - convert_to_efi_time(&wkalrm->time, &eft); - - /* - * XXX Fixme: - * As of EFI 0.92 with the firmware I have on my - * machine this call does not seem to work quite - * right - * - * As of v1.10, this call always returns an unsupported status - */ - status =3D efi.set_wakeup_time((efi_bool_t)wkalrm->enabled, &eft); - - dev_warn(dev, "write status is %d\n", (int)status); - - return status =3D=3D EFI_SUCCESS ? 0 : -EINVAL; -} - static int efi_read_time(struct device *dev, struct rtc_time *tm) { efi_status_t status; @@ -188,17 +146,13 @@ static int efi_set_time(struct device *dev, struct rt= c_time *tm) =20 static int efi_procfs(struct device *dev, struct seq_file *seq) { - efi_time_t eft, alm; + efi_time_t eft; efi_time_cap_t cap; - efi_bool_t enabled, pending; - struct rtc_device *rtc =3D dev_get_drvdata(dev); =20 memset(&eft, 0, sizeof(eft)); - memset(&alm, 0, sizeof(alm)); memset(&cap, 0, sizeof(cap)); =20 efi.get_time(&eft, &cap); - efi.get_wakeup_time(&enabled, &pending, &alm); =20 seq_printf(seq, "Time\t\t: %u:%u:%u.%09u\n" @@ -214,26 +168,6 @@ static int efi_procfs(struct device *dev, struct seq_f= ile *seq) /* XXX fixme: convert to string? */ seq_printf(seq, "Timezone\t: %u\n", eft.timezone); =20 - if (test_bit(RTC_FEATURE_ALARM, rtc->features)) { - seq_printf(seq, - "Alarm Time\t: %u:%u:%u.%09u\n" - "Alarm Date\t: %u-%u-%u\n" - "Alarm Daylight\t: %u\n" - "Enabled\t\t: %s\n" - "Pending\t\t: %s\n", - alm.hour, alm.minute, alm.second, alm.nanosecond, - alm.year, alm.month, alm.day, - alm.daylight, - enabled =3D=3D 1 ? "yes" : "no", - pending =3D=3D 1 ? "yes" : "no"); - - if (alm.timezone =3D=3D EFI_UNSPECIFIED_TIMEZONE) - seq_puts(seq, "Timezone\t: unspecified\n"); - else - /* XXX fixme: convert to string? */ - seq_printf(seq, "Timezone\t: %u\n", alm.timezone); - } - /* * now prints the capabilities */ @@ -249,8 +183,6 @@ static int efi_procfs(struct device *dev, struct seq_fi= le *seq) static const struct rtc_class_ops efi_rtc_ops =3D { .read_time =3D efi_read_time, .set_time =3D efi_set_time, - .read_alarm =3D efi_read_alarm, - .set_alarm =3D efi_set_alarm, .proc =3D efi_procfs, }; =20 @@ -271,11 +203,7 @@ static int __init efi_rtc_probe(struct platform_device= *dev) platform_set_drvdata(dev, rtc); =20 rtc->ops =3D &efi_rtc_ops; - clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->features); - if (efi_rt_services_supported(EFI_RT_SUPPORTED_WAKEUP_SERVICES)) - set_bit(RTC_FEATURE_ALARM_WAKEUP_ONLY, rtc->features); - else - clear_bit(RTC_FEATURE_ALARM, rtc->features); + clear_bit(RTC_FEATURE_ALARM, rtc->features); =20 device_init_wakeup(&dev->dev, true); =20 --=20 2.50.0.727.gbf7dc18ff4-goog From nobody Tue Oct 7 05:40:50 2025 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 479A22222AF for ; Mon, 14 Jul 2025 06:11:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752473464; cv=none; b=LcxNwFj1ID01idA2BnmNrLdNKgPK7ulYF/vfEfJIzxQ60uPhZrVmKlVred9gS9tssXq3/9GmodAMRs6X3rfoyf+dLgY1fTC/7u6P9rp+ZtBm4oo4NI29XD9m9Iik/LGGgaCNedhFD8d4jSna5qfJwuMS0+OIJlcqPeiL2x881oc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752473464; c=relaxed/simple; bh=XDk/UZY05XJ4EiH/B3HsLcLcKWy6I2jZ9/dIhAfsBko=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=P98g5QN7OvMSFRL0ittOU/Gez42EI9fcHVwCQbnISd3HeXyX6y3w1CFl7OHEx+FeNfIjkng+FW6bs3BR5JLRuZ0N/iFoq46bhpqbqTHZrGShyXEJVIEa6GXf8GvhloLqZjtwsPNKYv/9sjTmZHdFk1TsWMDqco+TzpqAHXSAHwk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=bSp9aPs3; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bSp9aPs3" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-3af3c860ed7so1701719f8f.1 for ; Sun, 13 Jul 2025 23:11:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1752473460; x=1753078260; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=DAtRoMW47q6eWngfmkGzhbl2Om3dflePIieHts+FOBI=; b=bSp9aPs3KRtkvhLEe2L93iLZxWia/AnejfcfvLbVVauDo4EljAzb3XvQnXIyU6iEuj 8mwsnJfQxL8KLpdIzSrHRMUkIJ9VtXC4LSI7qbFnBd/q2S8mOdGmN9iiJsE9pxiMbnSo 0TX+sraR9cYPpBuQXsYrQFoF5M7vgWSVKHTX7WuCbzgNw7lhlZCJqAl9CBGRapN1Ba3D UjcaFkZ3uvk5fc7aYZBW6Fs2pPpufC7ZlnrIWC0BPVZLH9IwuhxBHabvi0FQUGFop9T7 S3lbwGGAbc51hia50dS5VEj619aJGTHsFep2DTlQJZZC9KNExMmZvdyzIcLplMbgDhfT AYiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752473460; x=1753078260; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DAtRoMW47q6eWngfmkGzhbl2Om3dflePIieHts+FOBI=; b=jNuerVReUuK+lJC7gzpEg4LEEA0zVCQ+fJvZu89sIpGT9oHWRSGK4/oev0URv4XycL G4M6qcS1dicyJ42SaO351fwxS9pknoxWbOjaoB2QMJqKIPmUgGWXSRIwhIBxh7XztqTH Yk5tjPQdmmiuU+o8eAVHG9VDNlUtZAionvG7Ayv6hFV+8OdXaquX/vasNgmmgnP235xn 771UJRORsIM44V5GNxvKfgEcFVgSb+dkZagQpR/w38DCa+0fwtzg9wWRX2wZt0M2q8CH UfnoN+3h/EwaBTOKMNmeBS+TxBtHiIGISk7ImYva1L/b41KLcsgNrVuO0H3ReGX9Th5S ANig== X-Gm-Message-State: AOJu0Yzk6KIHT3pVIefBlZTj9Z0FuhaXhCdAOx52eAZaYnkIPe4Y/jAk OmFj4jmXn02QRk1CE0X8dMqmagtt4eMlg9dObtAu6Gyiflx51Y5i8Y4WJsyBxB0l2zmJqz76Cum AyyW1C8E/+5tSOPnOfLvlyrLq7a2NYt62KiwyYQLy7Y6EoUOsxhjs8w7J6yOhwTDTstehJOfEUI iO9RbdZ+PGb/ArMF+2ouhBGRQ9Uh+XRAaVcw== X-Google-Smtp-Source: AGHT+IFsCLtHJL4bZduQByJdBWFSePt0ZVoqPC5acNqYECl/7QLB3y/VpTPIitmJ3C2pFikEet6/1z+u X-Received: from wmbay17.prod.google.com ([2002:a05:600c:1e11:b0:450:cd94:c302]) (user=ardb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:240a:b0:3a5:8a68:b839 with SMTP id ffacd0b85a97d-3b5f2e26c14mr9849725f8f.45.1752473460616; Sun, 13 Jul 2025 23:11:00 -0700 (PDT) Date: Mon, 14 Jul 2025 08:08:46 +0200 In-Reply-To: <20250714060843.4029171-5-ardb+git@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250714060843.4029171-5-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=5138; i=ardb@kernel.org; h=from:subject; bh=ntdr4EjVjZJfnyc3XZ20vyNdLzsBSSjtiozuNHpTjes=; b=owGbwMvMwCVmkMcZplerG8N4Wi2JIaNk3s+Lmbqczj0rvAVfRxbEdM6a85TrRHj8D0lpvTzZ/ Fdaq652lLIwiHExyIopsgjM/vtu5+mJUrXOs2Rh5rAygQxh4OIUgIk4VjL8T33FvUb59jozdqnm q/uqv/H1Tplbn7TcdSZ/lf6yLc3mAgz/jPUOZcXfVexgUWyuFC302nb67J1Gr/K2qWeKJ0eZ/2j hBwA= X-Mailer: git-send-email 2.50.0.727.gbf7dc18ff4-goog Message-ID: <20250714060843.4029171-7-ardb+git@google.com> Subject: [RFC PATCH 2/3] efi/test: Don't bother pseudo-testing unused EFI services From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Heinrich Schuchardt , Feng Tang , Alexandre Belloni , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Sunil V L , Bibo Mao , linux-rtc@vger.kernel.org, linux-efi@vger.kernel.org, xen-devel@lists.xenproject.org, x86@kernel.org, linux-riscv@lists.infradead.org, loongarch@lists.linux.dev Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ard Biesheuvel The EFI test module covers the get/set wakeup time EFI runtime services, as well as GetNextHighMonoCount(). In both cases, though, it just mindlessly exercises the API, without any functional testing. In case of the get/set wakeup time services, this would involve setting the wakeup time, and subsequently checking whether the system actually wakes up at the configured time, which is difficult for obvious reasons. In case of GetNextHighMonoCount(), this would involve performing some kind of verification that the returned number increases monotonically across reboots. Given that these APIs are not used in Linux to begin with, let's not pretend that testing them in this manner has any value, and just drop these tests entirely, so that we can drop the APIs themselves from the Linux EFI runtime layer. Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/test/efi_test.c | 108 +------------------- 1 file changed, 2 insertions(+), 106 deletions(-) diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/te= st/efi_test.c index 77b5f7ac3e20..bb2ace902346 100644 --- a/drivers/firmware/efi/test/efi_test.c +++ b/drivers/firmware/efi/test/efi_test.c @@ -333,77 +333,6 @@ static long efi_runtime_set_time(unsigned long arg) return status =3D=3D EFI_SUCCESS ? 0 : -EINVAL; } =20 -static long efi_runtime_get_waketime(unsigned long arg) -{ - struct efi_getwakeuptime __user *getwakeuptime_user; - struct efi_getwakeuptime getwakeuptime; - efi_bool_t enabled, pending; - efi_status_t status; - efi_time_t efi_time; - - getwakeuptime_user =3D (struct efi_getwakeuptime __user *)arg; - if (copy_from_user(&getwakeuptime, getwakeuptime_user, - sizeof(getwakeuptime))) - return -EFAULT; - - status =3D efi.get_wakeup_time( - getwakeuptime.enabled ? (efi_bool_t *)&enabled : NULL, - getwakeuptime.pending ? (efi_bool_t *)&pending : NULL, - getwakeuptime.time ? &efi_time : NULL); - - if (put_user(status, getwakeuptime.status)) - return -EFAULT; - - if (status !=3D EFI_SUCCESS) - return -EINVAL; - - if (getwakeuptime.enabled && put_user(enabled, - getwakeuptime.enabled)) - return -EFAULT; - - if (getwakeuptime.pending && put_user(pending, - getwakeuptime.pending)) - return -EFAULT; - - if (getwakeuptime.time) { - if (copy_to_user(getwakeuptime.time, &efi_time, - sizeof(efi_time_t))) - return -EFAULT; - } - - return 0; -} - -static long efi_runtime_set_waketime(unsigned long arg) -{ - struct efi_setwakeuptime __user *setwakeuptime_user; - struct efi_setwakeuptime setwakeuptime; - efi_bool_t enabled; - efi_status_t status; - efi_time_t efi_time; - - setwakeuptime_user =3D (struct efi_setwakeuptime __user *)arg; - - if (copy_from_user(&setwakeuptime, setwakeuptime_user, - sizeof(setwakeuptime))) - return -EFAULT; - - enabled =3D setwakeuptime.enabled; - if (setwakeuptime.time) { - if (copy_from_user(&efi_time, setwakeuptime.time, - sizeof(efi_time_t))) - return -EFAULT; - - status =3D efi.set_wakeup_time(enabled, &efi_time); - } else - status =3D efi.set_wakeup_time(enabled, NULL); - - if (put_user(status, setwakeuptime.status)) - return -EFAULT; - - return status =3D=3D EFI_SUCCESS ? 0 : -EINVAL; -} - static long efi_runtime_get_nextvariablename(unsigned long arg) { struct efi_getnextvariablename __user *getnextvariablename_user; @@ -505,37 +434,6 @@ static long efi_runtime_get_nextvariablename(unsigned = long arg) return rv; } =20 -static long efi_runtime_get_nexthighmonocount(unsigned long arg) -{ - struct efi_getnexthighmonotoniccount __user *getnexthighmonocount_user; - struct efi_getnexthighmonotoniccount getnexthighmonocount; - efi_status_t status; - u32 count; - - getnexthighmonocount_user =3D (struct - efi_getnexthighmonotoniccount __user *)arg; - - if (copy_from_user(&getnexthighmonocount, - getnexthighmonocount_user, - sizeof(getnexthighmonocount))) - return -EFAULT; - - status =3D efi.get_next_high_mono_count( - getnexthighmonocount.high_count ? &count : NULL); - - if (put_user(status, getnexthighmonocount.status)) - return -EFAULT; - - if (status !=3D EFI_SUCCESS) - return -EINVAL; - - if (getnexthighmonocount.high_count && - put_user(count, getnexthighmonocount.high_count)) - return -EFAULT; - - return 0; -} - static long efi_runtime_reset_system(unsigned long arg) { struct efi_resetsystem __user *resetsystem_user; @@ -697,16 +595,14 @@ static long efi_test_ioctl(struct file *file, unsigne= d int cmd, return efi_runtime_set_time(arg); =20 case EFI_RUNTIME_GET_WAKETIME: - return efi_runtime_get_waketime(arg); - case EFI_RUNTIME_SET_WAKETIME: - return efi_runtime_set_waketime(arg); + return -EINVAL; =20 case EFI_RUNTIME_GET_NEXTVARIABLENAME: return efi_runtime_get_nextvariablename(arg); =20 case EFI_RUNTIME_GET_NEXTHIGHMONOTONICCOUNT: - return efi_runtime_get_nexthighmonocount(arg); + return -EINVAL; =20 case EFI_RUNTIME_QUERY_VARIABLEINFO: return efi_runtime_query_variableinfo(arg); --=20 2.50.0.727.gbf7dc18ff4-goog From nobody Tue Oct 7 05:40:50 2025 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7633223DDA for ; Mon, 14 Jul 2025 06:11:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752473467; cv=none; b=HVm53d1xzjfVvPOZ9Ki16b0WkZZt/s6D15G4Ka44JYj6FRrBMf9ka0vdh2bmC9qMOhf5YKGc2LZOmkrkoUVmnmiZp2TrPsP6ykF8dlWur63PL7QYy2MU1mm+9p9NQoBxRZL+gqXpsVDyQQdv4Trle8P9sLEhd87qn+pABMW+Xzc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752473467; c=relaxed/simple; bh=o0jlk4akGmainIxV5Q+BPyj1VBWudU2LL5NaL17Oc4E=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=R4fcTea3EfK5ZfWI7LMjSvNsssnO/HxCHd1i6TCr7123QPOTU3yqKhKEduywVFWyzRNvQpnkG84enuABd4bAbyMchoGWqRzRooq7125oPqY1Sn5VIhYXRQ7b3UFpPCNTZqs8DiqSFIOuqJdzElE22bP+wpfrucTgGIzqx0RnmjU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=BayMHYcG; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BayMHYcG" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-3a4f6ff23ccso2028671f8f.2 for ; Sun, 13 Jul 2025 23:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1752473463; x=1753078263; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=U+Y2ODvkU1M3Yop4Vbyu4J7zT/gX9/QfE7MMpELx/ao=; b=BayMHYcGBxJ5mdnTNBnKiOUDQzgGWX2hp4Zds/9GbPEVuOkysUjrMtqUSWpvLgvc7Q 736JqyDJFbwA3qJfE1eLTqFQmk9XbsNo5R0QUoQlMg/21lSwqVTClv3iXeotnbCtt6jN ljbT1CxlwQa2C5ahpr5QcLomn2eI5zQTgWB6xQb1pQ20eK6/Xyl/j2fMvnaR0XakOVHM DtoqZ9S9Tj60a9PNm2MbAjFtTJhjnSEUgfUmTStwtdbEbV5LDQN42gcLj7rJFbc5lSPt dGWoMyKfx3hvWKLLHhQzOJ00BU5dsSJBGiPln6OdgPaLlmqNpoWIOxEUDntfGSvf/T1z 8/7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752473463; x=1753078263; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=U+Y2ODvkU1M3Yop4Vbyu4J7zT/gX9/QfE7MMpELx/ao=; b=VAaW1+0hjFBn4DP+2MsTp5TxwVkrCPbZCRpq+p/eHt1FcuUDf5nXQJ7NUVxga8f8jX /ybF9OMBhw1NuhXicT2nwjdt+vf39PIEZp+rdHJ8b6SOEZz+Db9GoE9lIV5j6xT4fZvX iVe55UVY9pnp6G4vXLnCUGYaA0dy5cGZnP7cAZdLfw8Aa+7wbZTo08lAlruNzqIVVzje 7gPygXRHTCih9+7M+M2lFP+B8P+lx8X1uEqicdVugUBzdfss2YJNmjBhnQfcPeCIIa/c 4D+yVdY2yedZThPAylhihp6VkFCALC1eqEgMgjWOrdt4B+s7KtYP99OEG3FwalLgjB8y FqRg== X-Gm-Message-State: AOJu0YzmLibJhIKtRZ0az02JPABp/hIiDlFJyORt1MUG1ZYheps4MkcO pmueYVtO2XRu/USSh2QQqfGrSHcLDq41G5SjBm7BKM6TI7X3JqfW/vN3vp4H2VtSPtEq4pd8vXM gVvcdffNPp7bpeublC5l2wT5FUpwT+BQukl/kCUKOQ3YhEuWvBgzPXn2f8mQv5QvNHJ0urK+s5n 2+OggL/1yT/jXrhHN9lZaQmJ9il4U4cn9bnQ== X-Google-Smtp-Source: AGHT+IGX28n5QiyMHbS8lBZuZk7ytkYxLROV5L6i8XeWU2qCGkPvK5JXtsuwoSWms4DVodcgWH84OylK X-Received: from wrpd13.prod.google.com ([2002:adf:f2cd:0:b0:3a5:7de1:2a54]) (user=ardb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:2d03:b0:3b1:9259:3ead with SMTP id ffacd0b85a97d-3b5f188ea57mr7903902f8f.28.1752473463212; Sun, 13 Jul 2025 23:11:03 -0700 (PDT) Date: Mon, 14 Jul 2025 08:08:47 +0200 In-Reply-To: <20250714060843.4029171-5-ardb+git@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250714060843.4029171-5-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=10631; i=ardb@kernel.org; h=from:subject; bh=AM0I+cBVbRNRbkYjQz/D1G435xAIpZLDBEjL19MJg2w=; b=owGbwMvMwCVmkMcZplerG8N4Wi2JIaNk3r/ty443O28umjfLomTz8/SAuPdT3B3Omps26nft3 bZh76H7HaUsDGJcDLJiiiwCs/++23l6olSt8yxZmDmsTCBDGLg4BWAiK6oZGboeRfLG+Ldu+j6J WUg46/ZEw41PP6Yf5ZxVHXwxuP9BnyUjw6wCn6md1VrPOid8avq4xaWe957uwZsiURsf/WZuDzM QZwIA X-Mailer: git-send-email 2.50.0.727.gbf7dc18ff4-goog Message-ID: <20250714060843.4029171-8-ardb+git@google.com> Subject: [RFC PATCH 3/3] efi: Remove support for pointless, unused EFI services From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Heinrich Schuchardt , Feng Tang , Alexandre Belloni , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Sunil V L , Bibo Mao , linux-rtc@vger.kernel.org, linux-efi@vger.kernel.org, xen-devel@lists.xenproject.org, x86@kernel.org, linux-riscv@lists.infradead.org, loongarch@lists.linux.dev Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ard Biesheuvel The get/set wakeup time EFI runtime services are often broken, and rarely if ever used in practice. But the GetNextHighMonoCount() EFI runtime services really takes the cake for most pointless API in the history of computing. So let's stop exposing them in Linux, hopefully removing the urge some folks seem to feel to test these APIs, and send emails around when they don't work. Signed-off-by: Ard Biesheuvel Acked-by: Stefano Stabellini --- arch/x86/platform/efi/efi_64.c | 22 ------- drivers/firmware/efi/runtime-wrappers.c | 68 -------------------- drivers/xen/efi.c | 56 ---------------- include/linux/efi.h | 6 -- 4 files changed, 152 deletions(-) diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index e7e8f77f77f8..0207937ab39d 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -540,19 +540,6 @@ static efi_status_t efi_thunk_set_time(efi_time_t *tm) return EFI_UNSUPPORTED; } =20 -static efi_status_t -efi_thunk_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending, - efi_time_t *tm) -{ - return EFI_UNSUPPORTED; -} - -static efi_status_t -efi_thunk_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm) -{ - return EFI_UNSUPPORTED; -} - static unsigned long efi_name_size(efi_char16_t *name) { return ucs2_strsize(name, EFI_VAR_NAME_LEN) + 1; @@ -681,12 +668,6 @@ efi_thunk_get_next_variable(unsigned long *name_size, return status; } =20 -static efi_status_t -efi_thunk_get_next_high_mono_count(u32 *count) -{ - return EFI_UNSUPPORTED; -} - static void efi_thunk_reset_system(int reset_type, efi_status_t status, unsigned long data_size, efi_char16_t *data) @@ -788,13 +769,10 @@ void __init efi_thunk_runtime_setup(void) =20 efi.get_time =3D efi_thunk_get_time; efi.set_time =3D efi_thunk_set_time; - efi.get_wakeup_time =3D efi_thunk_get_wakeup_time; - efi.set_wakeup_time =3D efi_thunk_set_wakeup_time; efi.get_variable =3D efi_thunk_get_variable; efi.get_next_variable =3D efi_thunk_get_next_variable; efi.set_variable =3D efi_thunk_set_variable; efi.set_variable_nonblocking =3D efi_thunk_set_variable_nonblocking; - efi.get_next_high_mono_count =3D efi_thunk_get_next_high_mono_count; efi.reset_system =3D efi_thunk_reset_system; efi.query_variable_info =3D efi_thunk_query_variable_info; efi.query_variable_info_nonblocking =3D efi_thunk_query_variable_info_non= blocking; diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi= /runtime-wrappers.c index 708b777857d3..2b66efb5ffef 100644 --- a/drivers/firmware/efi/runtime-wrappers.c +++ b/drivers/firmware/efi/runtime-wrappers.c @@ -52,17 +52,6 @@ union efi_rts_args { efi_time_t *time; } SET_TIME; =20 - struct { - efi_bool_t *enabled; - efi_bool_t *pending; - efi_time_t *time; - } GET_WAKEUP_TIME; - - struct { - efi_bool_t enable; - efi_time_t *time; - } SET_WAKEUP_TIME; - struct { efi_char16_t *name; efi_guid_t *vendor; @@ -92,10 +81,6 @@ union efi_rts_args { u64 *max_variable_size; } QUERY_VARIABLE_INFO; =20 - struct { - u32 *high_count; - } GET_NEXT_HIGH_MONO_COUNT; - struct { efi_capsule_header_t **capsules; unsigned long count; @@ -232,17 +217,6 @@ static void __nocfi efi_call_rts(struct work_struct *w= ork) status =3D efi_call_virt(set_time, args->SET_TIME.time); break; - case EFI_GET_WAKEUP_TIME: - status =3D efi_call_virt(get_wakeup_time, - args->GET_WAKEUP_TIME.enabled, - args->GET_WAKEUP_TIME.pending, - args->GET_WAKEUP_TIME.time); - break; - case EFI_SET_WAKEUP_TIME: - status =3D efi_call_virt(set_wakeup_time, - args->SET_WAKEUP_TIME.enable, - args->SET_WAKEUP_TIME.time); - break; case EFI_GET_VARIABLE: status =3D efi_call_virt(get_variable, args->GET_VARIABLE.name, @@ -272,10 +246,6 @@ static void __nocfi efi_call_rts(struct work_struct *w= ork) args->QUERY_VARIABLE_INFO.remaining_space, args->QUERY_VARIABLE_INFO.max_variable_size); break; - case EFI_GET_NEXT_HIGH_MONO_COUNT: - status =3D efi_call_virt(get_next_high_mono_count, - args->GET_NEXT_HIGH_MONO_COUNT.high_count); - break; case EFI_UPDATE_CAPSULE: status =3D efi_call_virt(update_capsule, args->UPDATE_CAPSULE.capsules, @@ -366,30 +336,6 @@ static efi_status_t virt_efi_set_time(efi_time_t *tm) return status; } =20 -static efi_status_t virt_efi_get_wakeup_time(efi_bool_t *enabled, - efi_bool_t *pending, - efi_time_t *tm) -{ - efi_status_t status; - - if (down_interruptible(&efi_runtime_lock)) - return EFI_ABORTED; - status =3D efi_queue_work(GET_WAKEUP_TIME, enabled, pending, tm); - up(&efi_runtime_lock); - return status; -} - -static efi_status_t virt_efi_set_wakeup_time(efi_bool_t enabled, efi_time_= t *tm) -{ - efi_status_t status; - - if (down_interruptible(&efi_runtime_lock)) - return EFI_ABORTED; - status =3D efi_queue_work(SET_WAKEUP_TIME, enabled, tm); - up(&efi_runtime_lock); - return status; -} - static efi_status_t virt_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor, u32 *attr, @@ -488,17 +434,6 @@ virt_efi_query_variable_info_nb(u32 attr, u64 *storage= _space, return status; } =20 -static efi_status_t virt_efi_get_next_high_mono_count(u32 *count) -{ - efi_status_t status; - - if (down_interruptible(&efi_runtime_lock)) - return EFI_ABORTED; - status =3D efi_queue_work(GET_NEXT_HIGH_MONO_COUNT, count); - up(&efi_runtime_lock); - return status; -} - static void __nocfi virt_efi_reset_system(int reset_type, efi_status_t status, unsigned long data_size, efi_char16_t *data) @@ -556,13 +491,10 @@ void __init efi_native_runtime_setup(void) { efi.get_time =3D virt_efi_get_time; efi.set_time =3D virt_efi_set_time; - efi.get_wakeup_time =3D virt_efi_get_wakeup_time; - efi.set_wakeup_time =3D virt_efi_set_wakeup_time; efi.get_variable =3D virt_efi_get_variable; efi.get_next_variable =3D virt_efi_get_next_variable; efi.set_variable =3D virt_efi_set_variable; efi.set_variable_nonblocking =3D virt_efi_set_variable_nb; - efi.get_next_high_mono_count =3D virt_efi_get_next_high_mono_count; efi.reset_system =3D virt_efi_reset_system; efi.query_variable_info =3D virt_efi_query_variable_info; efi.query_variable_info_nonblocking =3D virt_efi_query_variable_info_nb; diff --git a/drivers/xen/efi.c b/drivers/xen/efi.c index fb321cd6415a..baccf2d90af0 100644 --- a/drivers/xen/efi.c +++ b/drivers/xen/efi.c @@ -76,47 +76,6 @@ static efi_status_t xen_efi_set_time(efi_time_t *tm) return efi_data(op).status; } =20 -static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, - efi_bool_t *pending, - efi_time_t *tm) -{ - struct xen_platform_op op =3D INIT_EFI_OP(get_wakeup_time); - - if (HYPERVISOR_platform_op(&op) < 0) - return EFI_UNSUPPORTED; - - if (tm) { - BUILD_BUG_ON(sizeof(*tm) !=3D sizeof(efi_data(op).u.get_wakeup_time)); - memcpy(tm, &efi_data(op).u.get_wakeup_time, sizeof(*tm)); - } - - if (enabled) - *enabled =3D !!(efi_data(op).misc & XEN_EFI_GET_WAKEUP_TIME_ENABLED); - - if (pending) - *pending =3D !!(efi_data(op).misc & XEN_EFI_GET_WAKEUP_TIME_PENDING); - - return efi_data(op).status; -} - -static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t= *tm) -{ - struct xen_platform_op op =3D INIT_EFI_OP(set_wakeup_time); - - BUILD_BUG_ON(sizeof(*tm) !=3D sizeof(efi_data(op).u.set_wakeup_time)); - if (enabled) - efi_data(op).misc =3D XEN_EFI_SET_WAKEUP_TIME_ENABLE; - if (tm) - memcpy(&efi_data(op).u.set_wakeup_time, tm, sizeof(*tm)); - else - efi_data(op).misc |=3D XEN_EFI_SET_WAKEUP_TIME_ENABLE_ONLY; - - if (HYPERVISOR_platform_op(&op) < 0) - return EFI_UNSUPPORTED; - - return efi_data(op).status; -} - static efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *v= endor, u32 *attr, unsigned long *data_size, void *data) @@ -204,18 +163,6 @@ static efi_status_t xen_efi_query_variable_info(u32 at= tr, u64 *storage_space, return efi_data(op).status; } =20 -static efi_status_t xen_efi_get_next_high_mono_count(u32 *count) -{ - struct xen_platform_op op =3D INIT_EFI_OP(get_next_high_monotonic_count); - - if (HYPERVISOR_platform_op(&op) < 0) - return EFI_UNSUPPORTED; - - *count =3D efi_data(op).misc; - - return efi_data(op).status; -} - static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules, unsigned long count, unsigned long sg_list) { @@ -280,8 +227,6 @@ void __init xen_efi_runtime_setup(void) { efi.get_time =3D xen_efi_get_time; efi.set_time =3D xen_efi_set_time; - efi.get_wakeup_time =3D xen_efi_get_wakeup_time; - efi.set_wakeup_time =3D xen_efi_set_wakeup_time; efi.get_variable =3D xen_efi_get_variable; efi.get_next_variable =3D xen_efi_get_next_variable; efi.set_variable =3D xen_efi_set_variable; @@ -290,7 +235,6 @@ void __init xen_efi_runtime_setup(void) efi.query_variable_info_nonblocking =3D xen_efi_query_variable_info; efi.update_capsule =3D xen_efi_update_capsule; efi.query_capsule_caps =3D xen_efi_query_capsule_caps; - efi.get_next_high_mono_count =3D xen_efi_get_next_high_mono_count; efi.reset_system =3D xen_efi_reset_system; } =20 diff --git a/include/linux/efi.h b/include/linux/efi.h index 50db7df0efab..516afdc8a49d 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -650,8 +650,6 @@ extern struct efi { =20 efi_get_time_t *get_time; efi_set_time_t *set_time; - efi_get_wakeup_time_t *get_wakeup_time; - efi_set_wakeup_time_t *set_wakeup_time; efi_get_variable_t *get_variable; efi_get_next_variable_t *get_next_variable; efi_set_variable_t *set_variable; @@ -660,7 +658,6 @@ extern struct efi { efi_query_variable_info_t *query_variable_info_nonblocking; efi_update_capsule_t *update_capsule; efi_query_capsule_caps_t *query_capsule_caps; - efi_get_next_high_mono_count_t *get_next_high_mono_count; efi_reset_system_t *reset_system; =20 struct efi_memory_map memmap; @@ -1235,13 +1232,10 @@ enum efi_rts_ids { EFI_NONE, EFI_GET_TIME, EFI_SET_TIME, - EFI_GET_WAKEUP_TIME, - EFI_SET_WAKEUP_TIME, EFI_GET_VARIABLE, EFI_GET_NEXT_VARIABLE, EFI_SET_VARIABLE, EFI_QUERY_VARIABLE_INFO, - EFI_GET_NEXT_HIGH_MONO_COUNT, EFI_RESET_SYSTEM, EFI_UPDATE_CAPSULE, EFI_QUERY_CAPSULE_CAPS, --=20 2.50.0.727.gbf7dc18ff4-goog