diff --git a/manual/crypt.texi b/manual/crypt.texi
index 4882ee34e5..ce68f2853a 100644
--- a/manual/crypt.texi
+++ b/manual/crypt.texi
@@ -73,7 +73,7 @@ used by this function was added to the Linux kernel in version 3.17.)
 The combination of @var{buffer} and @var{length} arguments specifies
 an invalid memory range.
 
-@item EIO
+@item EINVAL
 @var{length} is larger than 256, or the kernel entropy pool has
 suffered a catastrophic failure.
 @end table
diff --git a/stdlib/getentropy.c b/stdlib/getentropy.c
index 5149fbdde0..aa42341291 100644
--- a/stdlib/getentropy.c
+++ b/stdlib/getentropy.c
@@ -16,16 +16,55 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <sys/random.h>
+#include <stdio.h>
 #include <errno.h>
+#include <not-cancel.h>
+#include <sys/random.h>
+
+static void
+getentropy_fatal (void)
+{
+  __libc_fatal ("Fatal glibc error: cannot get entropy for getentropy\n");
+}
 
 /* Write LENGTH bytes of randomness starting at BUFFER.  Return 0 on
    success and -1 on failure.  */
 int
 getentropy (void *buffer, size_t length)
 {
-  __set_errno (ENOSYS);
-  return -1;
-}
+  if (length > 256)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
 
-stub_warning (getentropy)
+  /* Try to fill the buffer completely.  Even with the 256 byte limit
+     above, we might still receive an EINTR error (when blocking
+     during boot).  */
+  void *end = buffer + length;
+  while (buffer < end)
+    {
+      /* NB: No cancellation point.  */
+      ssize_t bytes = __getrandom_nocancel (buffer, end - buffer, 0);
+      if (bytes < 0)
+        {
+	  switch (errno)
+	    {
+	    case EINTR:
+	      continue;
+	    case ENOSYS:
+	      return -1;
+	    default:
+	      getentropy_fatal ();
+	    }
+        }
+      else if (bytes == 0)
+        /* No more bytes available.  This should not happen under normal
+	   circumstances.  */
+	getentropy_fatal ();
+
+      /* Try again in case of a short read.  */
+      buffer += bytes;
+    }
+  return 0;
+}
diff --git a/stdlib/tst-getrandom.c b/stdlib/tst-getrandom.c
index 3b2153376b..9fff7a8309 100644
--- a/stdlib/tst-getrandom.c
+++ b/stdlib/tst-getrandom.c
@@ -211,7 +211,7 @@ test_getentropy (void)
       errors = true;
       return;
     }
-  if (errno != EIO)
+  if (errno != EINVAL)
     {
       printf ("error: getentropy wrong error for 257 byte buffer: %m\n");
       errors = true;
diff --git a/sysdeps/mach/hurd/getentropy.c b/sysdeps/mach/hurd/getentropy.c
deleted file mode 100644
index 6ad8acc773..0000000000
--- a/sysdeps/mach/hurd/getentropy.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Implementation of getentropy based on getrandom.
-   Copyright (C) 2016-2025 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <sys/random.h>
-#include <assert.h>
-#include <errno.h>
-#include <unistd.h>
-#include <hurd.h>
-
-/* Write LENGTH bytes of randomness starting at BUFFER.  Return 0 on
-   success and -1 on failure.  */
-int
-getentropy (void *buffer, size_t length)
-{
-  /* The interface is documented to return EIO for buffer lengths
-     longer than 256 bytes.  */
-  if (length > 256)
-    return __hurd_fail (EIO);
-
-  /* Try to fill the buffer completely.  Even with the 256 byte limit
-     above, we might still receive an EINTR error (when blocking
-     during boot).  */
-  void *end = buffer + length;
-  while (buffer < end)
-    {
-      /* NB: No cancellation point.  */
-      ssize_t bytes = __getrandom (buffer, end - buffer, 0);
-      if (bytes < 0)
-        {
-          if (errno == EINTR)
-            /* Try again if interrupted by a signal.  */
-            continue;
-          else
-            return -1;
-        }
-      if (bytes == 0)
-        /* No more bytes available.  This should not happen under
-           normal circumstances.  */
-        return __hurd_fail (EIO);
-      /* Try again in case of a short read.  */
-      buffer += bytes;
-    }
-  return 0;
-}
diff --git a/sysdeps/unix/sysv/linux/getentropy.c b/sysdeps/unix/sysv/linux/getentropy.c
deleted file mode 100644
index a62c9fb099..0000000000
--- a/sysdeps/unix/sysv/linux/getentropy.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Implementation of getentropy based on the getrandom system call.
-   Copyright (C) 2016-2025 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <sys/random.h>
-#include <assert.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sysdep.h>
-
-/* Write LENGTH bytes of randomness starting at BUFFER.  Return 0 on
-   success and -1 on failure.  */
-int
-getentropy (void *buffer, size_t length)
-{
-  /* The interface is documented to return EIO for buffer lengths
-     longer than 256 bytes.  */
-  if (length > 256)
-    {
-      __set_errno (EIO);
-      return -1;
-    }
-
-  /* Try to fill the buffer completely.  Even with the 256 byte limit
-     above, we might still receive an EINTR error (when blocking
-     during boot).  */
-  void *end = buffer + length;
-  while (buffer < end)
-    {
-      /* NB: No cancellation point.  */
-      ssize_t bytes = INLINE_SYSCALL_CALL (getrandom, buffer, end - buffer, 0);
-      if (bytes < 0)
-        {
-          if (errno == EINTR)
-            /* Try again if interrupted by a signal.  */
-            continue;
-          else
-            return -1;
-        }
-      if (bytes == 0)
-        {
-          /* No more bytes available.  This should not happen under
-             normal circumstances.  */
-          __set_errno (EIO);
-          return -1;
-        }
-      /* Try again in case of a short read.  */
-      buffer += bytes;
-    }
-  return 0;
-}
