From patchwork Tue Sep 3 12:09:15 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: 13788600 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 DA816CD3420 for ; Tue, 3 Sep 2024 12:11:07 +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=JLYlLLGKbB0TvMjhCmijODtjVYZ8RqD6X4SH5pHru3k=; b=vgZdZu2hDB4a7IBqNVKPB3ZonY Ykg3K1RyYO0/WA7ngN0S0loRLMmL+v6vaf9qx+ZjNNNkWv6tSsqbHNRj/Q2w6YArl4F/dEBNV7hA6 YDTISeKrNd8zXw3j8uIhQP7K7Lr9heTpayGqdKDvUd3XzwX4NKH+l9HMsz0Y/CnYocDqiNfRpHE19 4LiA+JC+SKtqrqM9JvpUB1MM7lU37+WKNNdJWT9TM8q1vCRMLyGpiITd0vbqy0hjYazIBJ22yakIX Swd9WkOkQ73VZoXfr9Guo3r77jbrsVHClinhxJOwKzyz++jEGnXoSPCYkVkZg1tRKmukzugMpPoYq VETUEShA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slSN4-000000005Hi-0w5G; Tue, 03 Sep 2024 12:10:54 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1slSM7-000000004yK-1rGS for linux-arm-kernel@lists.infradead.org; Tue, 03 Sep 2024 12:09:56 +0000 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-374c8cef906so1556670f8f.2 for ; Tue, 03 Sep 2024 05:09:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725365393; x=1725970193; 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=JLYlLLGKbB0TvMjhCmijODtjVYZ8RqD6X4SH5pHru3k=; b=DBgrJz7SN45x22YzpkStg3VxvtPGMpzxaWxkbI2Yp2rFQLfqE2zf+TPxZaj5eZ67sV bxth8XOAI/auXEyTUp9Fb/XrEO5vTJCgjPykqq+fdEdnP9ZeAkEyItxjFdd2u/s7W8BK 0U9rcIFzzB1+XBo7ae93DtUiOW08p+OLa8w0n7M44QmzZfGgghZl9Ilfum+9CAlEPQdB 6i82xqS4KsJGG7+3QPEMyfglub3TH9PQnIkLvEq4VO58ujb2e2F2uPTrnENlq74ZUBEE Xhm8JBXpPzQzob0DBboqBnqsn/HwVsCtp6UypAnGbB87h44bfBLfjWN6UgtiR71vOkqz kLPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725365393; x=1725970193; 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=JLYlLLGKbB0TvMjhCmijODtjVYZ8RqD6X4SH5pHru3k=; b=c5v38BwQ+SrelfhH0Hz0zRCAxz6YB7kC3W4lcaSB8v61f7fXUd4PCWNo5TabRQO97J /4h5zOxqkXitD0braqykPZv+3WHzzsSxEXOPQrxR34LbtqTGC9WWeJvbP5ti1VZy8bUf Q/bhCTyKUhoqaPibgwsHt3W02E0w1+M0qILwCqcW5VOoOrXnmbcM1Y5G4D1kWEQxJUw1 O4tImFx3koPx4ohJgwxiSCCt3Qeg+Qcv4sxxe2IAJ9vJ0pNpakrTZS9s29v8K0GLnByU rhbVtfd1YGHx6gjayMpDyLrwmn7tbNMyx2upGUm7OcNbfHtWvoIs2ikfhljBIfeyQ2nc FbNg== X-Forwarded-Encrypted: i=1; AJvYcCVFIT45LkCOnffwMqx2eFYImtzE1F8LLmQcCiPX3g13fjcX+5Ug88+zJNXrw/PM8PeHMzvw5O6R69MoiFvtX1Kk@lists.infradead.org X-Gm-Message-State: AOJu0Yx6g/XgqVAuQO3EsiI5fMujedW3aRkGErUDhbnfqR6x41zmvi6u NwL+E7tJKqtnkwM30pbZKNpAZlIH1pN7c5m0a3zxlUeIpkHMymqGf3n0Bh6vzyU= X-Google-Smtp-Source: AGHT+IEyoZ4C1GIHdc4etZJ5y8/7i4ZOxLROM5omYazPOI3P6CpupmD7KGheFpP2J3CHj/uHt2FC5g== X-Received: by 2002:a5d:440b:0:b0:374:c847:852 with SMTP id ffacd0b85a97d-376dd71aa2bmr403119f8f.29.1725365393138; Tue, 03 Sep 2024 05:09:53 -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 ffacd0b85a97d-3749ee4a55fsm14069238f8f.10.2024.09.03.05.09.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 05:09:51 -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 v5 0/2] arm64: Implement getrandom() in vDSO Date: Tue, 3 Sep 2024 12:09:15 +0000 Message-ID: <20240903120948.13743-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-20240903_050955_501839_D6E4DE5C X-CRM114-Status: GOOD ( 12.34 ) 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 v4: - Improve BE handling. Changes from v3: - Use alternative_has_cap_likely instead of ALTERNATIVE. - Header/include and comment fixups. 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 | 172 ++++++++++++++++++++ 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, 292 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 Reviewed-by: Ard Biesheuvel Acked-by: Will Deacon