From patchwork Mon Sep 2 16:15:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 13787481 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 3BF1ACD13CF for ; Mon, 2 Sep 2024 16:20:28 +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: MIME-Version:Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=vkyMDCLd9ysLyI5RLQZB8Ncj/M1dFlma3LBWXQip8L8=; b=lDm21LxLcCRA5QIXRfxErWjel4 YH4seRDCRlJ76rZ114Gj3lfycBFb0wDt8x9SbIxbWfL03j8+QHkmJPNrm++KIqPWFjnriM3vQC8yb ad2P2mUPTyjIBVs8OgT3DiJlwjw9xkVkhduQq71vlXJyKkbu3Z1mUxw+It9dSQ9bsKdX1ZKl8z52B g8eLmBfd4l8mCucF0/q6rLuPfJZsB4/EeZqYLexODRAYuROyYWZsYnYmNyfEB4qRvI4iyJKFdNdGz BXcFzMUERLq5/uMk2yp+pWs0/PRat0zhpwnGCJ6SWK0UkNvRTAw8BfrEmHCD7W6LbuMoLtX2x9Nm4 OTqRoOmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl9mq-0000000Ezd2-2F4B; Mon, 02 Sep 2024 16:20:16 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl9lt-0000000EzN6-3p8u for linux-arm-kernel@lists.infradead.org; Mon, 02 Sep 2024 16:19:19 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-374c180d123so1100561f8f.3 for ; Mon, 02 Sep 2024 09:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725293955; x=1725898755; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=vkyMDCLd9ysLyI5RLQZB8Ncj/M1dFlma3LBWXQip8L8=; b=zv+C8kMMXbv+ztNxQvqYYkVx8Q9LsMMScWpRzNEFbHLKjY8Y3BcvW9EavexGmXSba4 G56OLZrI4jMstZwF2ONkRkukwiSpxFdk4UNVu05fyT6t22Pe3u3EJSu2nr0LfMvtCoi9 G34j9rR2KxUaVihZO1f0Zkl22dUCE65h2SFZ2TR0bQPBwAJIMdn0NSsIv6MjxbW16JA3 0aEwZNluonQ8lse4J87Wv0HNxXeXEOmw5aWFenL63OXTrbcWDHg2rRmvMe3gM1RlFleY 7g/y2F85AxYTYWUXwP0iEC60Tjq6sSGZ2vnzdgUDIfnNYQY43mX/UtPBdbn35oluldWn UVWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725293955; x=1725898755; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vkyMDCLd9ysLyI5RLQZB8Ncj/M1dFlma3LBWXQip8L8=; b=E0f+Lak2PbA4uZyOWb4JjUiFhZURkuW8QXcTQ35s7xv0wTtLof8hELBA+ihs9/SBMz STvButMi/0DMTYlLdOhSZkIgCTywl74KhmkEMjUBJbWZHP0tmERNSryrRk38aYtr3oE8 AtMHm0lHUxpsTaMxrV2ga/bHX3XS6q7mQOq9Zzo5Sj1Tzetk/jIJYVEFAqOJoMeOUQ6v vxXskYeJVlCh/aqM7uzL78iR0hmUlPRo/LuzHw2cCgTwSeeDhirpFv4EX51p4R38Fnsc PoPQ6cwg8hTV5uyJmC5JhDo9rDIOo6+Du0MauoYCyR2TTTUED+bxQ0DcagMvu/c063WS EREA== X-Forwarded-Encrypted: i=1; AJvYcCVxLRUtaDr+Equ12FdmN3qmSAVFghpsPnjKon7PtacbLDHD7jIcfZR65Op8EWJESVH0PVzQFm1CPMdSar+G8FnH@lists.infradead.org X-Gm-Message-State: AOJu0YxruwsLUdrypDBVl5RqKSGGOoO3ZWo+C80uWe2pdCuW5ShTLv2D BTVSulxf89mDhaCys7jlCzsSHk+37VkfGwlj0L011YIsk2zqFhQs9TDWkQZh6YE= X-Google-Smtp-Source: AGHT+IHesPPhCPjvUcRq0H6NjoEXRkOvc8FVbv0aFUX8CIV5jvLI1kMhKeSNICFtv/lYiO8fmaQ/Fg== X-Received: by 2002:a05:6000:cf:b0:374:c101:32 with SMTP id ffacd0b85a97d-374c10100c3mr3726845f8f.46.1725293954927; Mon, 02 Sep 2024 09:19:14 -0700 (PDT) Received: from ubuntu-vm.. (51-148-40-55.dsl.zen.co.uk. [51.148.40.55]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42bb6deb239sm145970065e9.5.2024.09.02.09.19.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 09:19:14 -0700 (PDT) From: Adhemerval Zanella To: "Jason A . Donenfeld" , Theodore Ts'o , linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, Catalin Marinas , Will Deacon , Thomas Gleixner , Eric Biggers , Christophe Leroy Subject: [PATCH v4 0/2] arm64: Implement getrandom() in vDSO Date: Mon, 2 Sep 2024 16:15:45 +0000 Message-ID: <20240902161912.2751-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240902_091917_973780_1ED18C3A X-CRM114-Status: GOOD ( 12.15 ) 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 Implement stack-less ChaCha20 and wire it with the generic vDSO getrandom code. The first patch is Mark's fix to the alternatives system in the vDSO, while the the second is the actual vDSO work. Changes from v3: - Use alternative_has_cap_likely instead of ALTERNATIVE. Changes from v2: - Refactor Makefile to use same flags for vgettimeofday and vgetrandom. - Removed rodata usage and fixed BE on vgetrandom-chacha.S. Changes from v1: - Fixed style issues and typos. - Added fallback for systems without NEON support. - Avoid use of non-volatile vector registers in neon chacha20. - Use c-getrandom-y for vgetrandom.c. - Fixed TIMENS vdso_rnd_data access. Adhemerval Zanella (1): arm64: vdso: wire up getrandom() vDSO implementation Mark Rutland (1): arm64: alternative: make alternative_has_cap_likely() VDSO compatible arch/arm64/Kconfig | 1 + arch/arm64/include/asm/alternative-macros.h | 4 + arch/arm64/include/asm/mman.h | 6 +- arch/arm64/include/asm/vdso.h | 6 + arch/arm64/include/asm/vdso/getrandom.h | 50 ++++++ arch/arm64/include/asm/vdso/vsyscall.h | 10 ++ arch/arm64/kernel/vdso.c | 6 - arch/arm64/kernel/vdso/Makefile | 25 ++- arch/arm64/kernel/vdso/vdso | 1 + arch/arm64/kernel/vdso/vdso.lds.S | 4 + arch/arm64/kernel/vdso/vgetrandom-chacha.S | 178 ++++++++++++++++++++ arch/arm64/kernel/vdso/vgetrandom.c | 15 ++ tools/arch/arm64/vdso | 1 + tools/include/linux/compiler.h | 4 + tools/testing/selftests/vDSO/Makefile | 3 +- 15 files changed, 298 insertions(+), 16 deletions(-) create mode 100644 arch/arm64/include/asm/vdso/getrandom.h create mode 120000 arch/arm64/kernel/vdso/vdso create mode 100644 arch/arm64/kernel/vdso/vgetrandom-chacha.S create mode 100644 arch/arm64/kernel/vdso/vgetrandom.c create mode 120000 tools/arch/arm64/vdso