From patchwork Tue Jun 4 20:30:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ali Saidi X-Patchwork-Id: 10976001 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3AA876 for ; Tue, 4 Jun 2019 20:31:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B28C5288BA for ; Tue, 4 Jun 2019 20:31:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D476288D9; Tue, 4 Jun 2019 20:31:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.4 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 514FB287ED for ; Tue, 4 Jun 2019 20:31:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HzvnGbDrLXG3HexYvGnX8RZfNHq/O7uUaiT+f6HiJPw=; b=ZQbgHeC0QbNsPr OoGy/gWzSh1jmUdmTsIZDc1fPMGMjKYKYrXdmqIWl6Q+V0fBEjO1BQ2cYiF1DjsxLKtvwkwFcyll+ x5DG7ozHZH/qbMjLcTO9fI5RE49gcuaujLSFAUBU8N0bC32AziIJh9cJ8yZ8fJPAXiZPe03VXoCsa PwPFjipfyYacXHDRlixyMu6kgZ+s7HzPkjmNqlkX8lTgv5ExrME4QT2Opj/9SmlZi4y9GRU4Am3qJ ze+mJv14FIL4CPJHefDXV0bRs5bMANSxyQS/5weaqeD0Bls5ThpNWWM7XVrT3fIRs7OwSF+Exov/f XDT7aU6MR82apHI/gDEg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hYG5o-0004hw-Is; Tue, 04 Jun 2019 20:31:36 +0000 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hYG5l-0004gI-81 for linux-arm-kernel@lists.infradead.org; Tue, 04 Jun 2019 20:31:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1559680293; x=1591216293; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=GcMoPRXMHB7SOwtcOdUWfd9ABsMHYh/l/vnzcxwmq0E=; b=FRrZM2J23GQUDfAlO+e7oFH5aBVXAlOfc94bje8vgU40cqc+rOme8Z7c 43GOow0cdQ5PQq1yHqZwsB8nrh9WJM0635wumL1owqJ5eon6QEeDGfflf Ed0gwNYjLoo0mVGb3+0JPc9rVMMuv841JmsKoupTjRNVjnZnr6fMA6bse o=; X-IronPort-AV: E=Sophos;i="5.60,550,1549929600"; d="scan'208";a="803552790" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-2a-119b4f96.us-west-2.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 04 Jun 2019 20:31:29 +0000 Received: from EX13MTAUEB001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-2a-119b4f96.us-west-2.amazon.com (Postfix) with ESMTPS id 554C11A0D0E; Tue, 4 Jun 2019 20:31:29 +0000 (UTC) Received: from EX13D08UEB003.ant.amazon.com (10.43.60.11) by EX13MTAUEB001.ant.amazon.com (10.43.60.129) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 4 Jun 2019 20:31:28 +0000 Received: from EX13MTAUEB001.ant.amazon.com (10.43.60.96) by EX13D08UEB003.ant.amazon.com (10.43.60.11) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 4 Jun 2019 20:31:28 +0000 Received: from dev-dsk-alisaidi-i31e-4ac69482.us-east-1.amazon.com (10.200.136.151) by mail-relay.amazon.com (10.43.60.129) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Tue, 4 Jun 2019 20:31:28 +0000 Received: by dev-dsk-alisaidi-i31e-4ac69482.us-east-1.amazon.com (Postfix, from userid 5131138) id 9D9CC47DE5; Tue, 4 Jun 2019 20:31:28 +0000 (UTC) From: Ali Saidi To: , , Subject: [PATCH 1/3] arm/arm64: Add smccc hypervisor service identifiers Date: Tue, 4 Jun 2019 20:30:58 +0000 Message-ID: <20190604203100.15050-2-alisaidi@amazon.com> X-Mailer: git-send-email 2.15.3.AMZN In-Reply-To: <20190604203100.15050-1-alisaidi@amazon.com> References: <20190604203100.15050-1-alisaidi@amazon.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190604_133133_357951_7E0B058B X-CRM114-Status: UNSURE ( 9.33 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Benjamin Herrenschmidt , Herbert Xu , Arnd Bergmann , Catalin Marinas , Matt Mackall , Will Deacon , Ron Rindjunsky , David Woodhouse , Greg Kroah-Hartman , Ali Saidi Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The SMC calling convention defines service identifiers for generic and vendor specific hypervisor services. This patch adds those services to the list of existing service identifiers. Signed-off-by: Ali Saidi --- include/linux/arm-smccc.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h index 18863d56273c..bcf796801e3b 100644 --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h @@ -54,6 +54,8 @@ #define ARM_SMCCC_OWNER_SIP 2 #define ARM_SMCCC_OWNER_OEM 3 #define ARM_SMCCC_OWNER_STANDARD 4 +#define ARM_SMCCC_OWNER_STANDARD_HV 5 +#define ARM_SMCCC_OWNER_VENDOR_HV 6 #define ARM_SMCCC_OWNER_TRUSTED_APP 48 #define ARM_SMCCC_OWNER_TRUSTED_APP_END 49 #define ARM_SMCCC_OWNER_TRUSTED_OS 50 From patchwork Tue Jun 4 20:30:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ali Saidi X-Patchwork-Id: 10976007 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 815DC76 for ; Tue, 4 Jun 2019 20:31:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70EE026255 for ; Tue, 4 Jun 2019 20:31:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 655BB288BA; Tue, 4 Jun 2019 20:31:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.4 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2620426255 for ; Tue, 4 Jun 2019 20:31:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Jw8bAuuaW+2SncNGfrlqhL6gHFTbbBk7tbIi2fMefkA=; b=YVmlRp+iPtW9Ng hXevxEut3kuxMaAfGyH7wxCcpAXZfLjCssKVPMbi2zq7gxtDDKOtJDq2kSdP1N1cumctqWIt4dgxd QvHIVfVk/a1Ys4tqBpvgVuiXrr+4/eHqGhlgnskYpuAnFL3/IBqlx+2GuV07Qcg+kuNb/qwHcRWDX EVWUD3DFBlbAFjXTJBB13Ym5b1FI6aAKzFomDaxrBbmUVDcApY+8mq2MleoeRQT2Wj3zFQxNBnUXy dmSicSlz/D+6RfMArQiggFualYY41/dpNrOv2nhQwAgVH30J5+e6OfxxfUykVSPGxjePzp7j3te8R 4dZed5x+ku9l0tr+hdzg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hYG63-00055F-IQ; Tue, 04 Jun 2019 20:31:51 +0000 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hYG5m-0004gI-IQ for linux-arm-kernel@lists.infradead.org; Tue, 04 Jun 2019 20:31:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1559680294; x=1591216294; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ppSMBj7M9LtRxxqAyTLnY4a7CzGJ8fmmTXh653jqMx0=; b=j03e4gicMk9ODEFoPw8LrK27tFu/cBw+PPBpux8fgAl11NOtNKh4hwat u1QLS6G/zOL2vwwXnYdDRPgV0ksXI1PBOvuROY3QZ/UxYE5BE1FOySLmk ilrWP3nShiAEB1BD1yqIkIUUh2NGiPxyOReL6/Z28J9fVCdYMhHUG4Aeo A=; X-IronPort-AV: E=Sophos;i="5.60,550,1549929600"; d="scan'208";a="803552791" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-2c-579b7f5b.us-west-2.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 04 Jun 2019 20:31:29 +0000 Received: from EX13MTAUWB001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-2c-579b7f5b.us-west-2.amazon.com (Postfix) with ESMTPS id 8F374A20A1; Tue, 4 Jun 2019 20:31:29 +0000 (UTC) Received: from EX13D02UWB003.ant.amazon.com (10.43.161.48) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 4 Jun 2019 20:31:29 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D02UWB003.ant.amazon.com (10.43.161.48) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 4 Jun 2019 20:31:28 +0000 Received: from dev-dsk-alisaidi-i31e-4ac69482.us-east-1.amazon.com (10.200.136.151) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Tue, 4 Jun 2019 20:31:29 +0000 Received: by dev-dsk-alisaidi-i31e-4ac69482.us-east-1.amazon.com (Postfix, from userid 5131138) id A0CA347DE6; Tue, 4 Jun 2019 20:31:28 +0000 (UTC) From: Ali Saidi To: , , Subject: [PATCH 2/3] arm64: export acpi_psci_use_hvc Date: Tue, 4 Jun 2019 20:30:59 +0000 Message-ID: <20190604203100.15050-3-alisaidi@amazon.com> X-Mailer: git-send-email 2.15.3.AMZN In-Reply-To: <20190604203100.15050-1-alisaidi@amazon.com> References: <20190604203100.15050-1-alisaidi@amazon.com> MIME-Version: 1.0 Precedence: Bulk X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190604_133134_658596_19FDE787 X-CRM114-Status: UNSURE ( 9.63 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Benjamin Herrenschmidt , Herbert Xu , Arnd Bergmann , Catalin Marinas , Matt Mackall , Will Deacon , Ron Rindjunsky , David Woodhouse , Greg Kroah-Hartman , Ali Saidi Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Allow a module that wants to make SMC calls to detect if it should be using smc or hvc. Signed-off-by: Ali Saidi --- arch/arm64/kernel/acpi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 803f0494dd3e..ea41c6541d3c 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -119,6 +119,7 @@ bool acpi_psci_use_hvc(void) { return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC; } +EXPORT_SYMBOL_GPL(acpi_psci_use_hvc); /* * acpi_fadt_sanity_check() - Check FADT presence and carry out sanity From patchwork Tue Jun 4 20:31:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ali Saidi X-Patchwork-Id: 10976011 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6664076 for ; Tue, 4 Jun 2019 20:32:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55A55283BF for ; Tue, 4 Jun 2019 20:32:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52A6F288BC; Tue, 4 Jun 2019 20:32:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.4 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 46044283BF for ; Tue, 4 Jun 2019 20:32:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8uPzGT4ZniksMEHMNDB6B4Ex5LJDb6u1PskIN89uMjk=; b=K4lYMwygvTWNzz EeO2X+we2jjfstRqeerBxONEjhAJo683JtmtaZDJ4A6GEIVt4kGjM3BtGCH/5FsiDSLaeC4AhqrmS 2KJ8WSeiua20ZXW8v3RK9S+ZK9z15pHPOaN3sKw6G2DNGkMsVPehr1O2+njtJEuWE3oZ9UhZZ5KkR E+QVXY+GkX3xx/41X+fna3pFPXTUm1nGHBrdb1HZ+2iiVzBhRGXmDVvcA6g+mHMz5imyT/9j0xsbF KTbaXTnTcMi5sS3KM649wdAkIHWUoaQT/DDQ4A7rZCwVXXcAY2L/iGNLjcz5TYtSl/XBBhhZeCcdp E8LgGqoDdMOjOrV6kvYw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hYG6F-0005Jy-DA; Tue, 04 Jun 2019 20:32:03 +0000 Received: from smtp-fw-4101.amazon.com ([72.21.198.25]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hYG5l-0004gN-ET for linux-arm-kernel@lists.infradead.org; Tue, 04 Jun 2019 20:31:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1559680293; x=1591216293; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=GzsSZ1ZIthsTf/ARuWnJotXGJcL1/H1KE/r2e1NtQfo=; b=qsvczd6XHKP0m6+zoWv4uY7qcYh6C446Oj0u55oHOVWPi3amUbljZNDq g4Qed+Vc2GFKfs/V3KCpBkPc4WoYkUVY1jMURvwGrg+Ykf+eO/iPrRz0Y NZqy4itNxWYzCkaFAIginyyKLWUa1J3Of2ZSzC8vCovVdlYvLJr/nc3rM c=; X-IronPort-AV: E=Sophos;i="5.60,550,1549929600"; d="scan'208";a="768961315" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2c-168cbb73.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 04 Jun 2019 20:31:30 +0000 Received: from EX13MTAUWB001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-2c-168cbb73.us-west-2.amazon.com (Postfix) with ESMTPS id 93C8CA2297; Tue, 4 Jun 2019 20:31:29 +0000 (UTC) Received: from EX13D02UWB004.ant.amazon.com (10.43.161.11) by EX13MTAUWB001.ant.amazon.com (10.43.161.207) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 4 Jun 2019 20:31:29 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D02UWB004.ant.amazon.com (10.43.161.11) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 4 Jun 2019 20:31:29 +0000 Received: from dev-dsk-alisaidi-i31e-4ac69482.us-east-1.amazon.com (10.200.136.151) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Tue, 4 Jun 2019 20:31:29 +0000 Received: by dev-dsk-alisaidi-i31e-4ac69482.us-east-1.amazon.com (Postfix, from userid 5131138) id A3E6847DE7; Tue, 4 Jun 2019 20:31:28 +0000 (UTC) From: Ali Saidi To: , , Subject: [PATCH 3/3] hwrng: Add support for AWS Graviton TRNG Date: Tue, 4 Jun 2019 20:31:00 +0000 Message-ID: <20190604203100.15050-4-alisaidi@amazon.com> X-Mailer: git-send-email 2.15.3.AMZN In-Reply-To: <20190604203100.15050-1-alisaidi@amazon.com> References: <20190604203100.15050-1-alisaidi@amazon.com> MIME-Version: 1.0 Precedence: Bulk X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190604_133133_678827_A068AF0C X-CRM114-Status: GOOD ( 19.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Benjamin Herrenschmidt , Herbert Xu , Arnd Bergmann , Catalin Marinas , Matt Mackall , Will Deacon , Ron Rindjunsky , David Woodhouse , Greg Kroah-Hartman , Ali Saidi Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP AWS Graviton based systems provide an Arm SMC call in the vendor defined hypervisor region to read random numbers from a TRNG and return them to the guest. Co-developed-by: Ron Rindjunsky Signed-off-by: Ali Saidi Signed-off-by: Ron Rindjunsky --- MAINTAINERS | 6 ++ drivers/char/hw_random/Kconfig | 13 ++++ drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/graviton-rng.c | 130 ++++++++++++++++++++++++++++++++++ 4 files changed, 150 insertions(+) create mode 100644 drivers/char/hw_random/graviton-rng.c diff --git a/MAINTAINERS b/MAINTAINERS index 005902ea1450..e9c490e3fd9d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2771,6 +2771,12 @@ S: Maintained F: Documentation/devicetree/bindings/iio/adc/avia-hx711.txt F: drivers/iio/adc/hx711.c +AWS GRAVITON TRNG DRIVER +M: Ali Saidi +L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) +S: Supported +F: drivers/char/hw_random/graviton-rng.c + AX.25 NETWORK LAYER M: Ralf Baechle L: linux-hams@vger.kernel.org diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index 25a7d8ffdb5d..7ca7386a1ac4 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig @@ -439,6 +439,19 @@ config HW_RANDOM_OPTEE If unsure, say Y. +config HW_RANDOM_GRAVITON + tristate "AWS Graviton Random Number Generator support" + depends on HW_RANDOM && ACPI && (ARM64 || COMPILE_TEST) + default HW_RANDOM + help + This driver provides kernel-side support for the Random Number + Generator SMC found on AWS Graviton systems. + + To compile this driver as a module, choose M here: the + module will be called graviton-rng. + + If unsure, say Y. + endif # HW_RANDOM config UML_RANDOM diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile index 7c9ef4a7667f..d1fa72670e98 100644 --- a/drivers/char/hw_random/Makefile +++ b/drivers/char/hw_random/Makefile @@ -39,3 +39,4 @@ obj-$(CONFIG_HW_RANDOM_MTK) += mtk-rng.o obj-$(CONFIG_HW_RANDOM_S390) += s390-trng.o obj-$(CONFIG_HW_RANDOM_KEYSTONE) += ks-sa-rng.o obj-$(CONFIG_HW_RANDOM_OPTEE) += optee-rng.o +obj-$(CONFIG_HW_RANDOM_GRAVITON) += graviton-rng.o diff --git a/drivers/char/hw_random/graviton-rng.c b/drivers/char/hw_random/graviton-rng.c new file mode 100644 index 000000000000..898c8bb98a20 --- /dev/null +++ b/drivers/char/hw_random/graviton-rng.c @@ -0,0 +1,130 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AWS Graviton TRNG driver + * + * Copyright (C) 2019 Amazon Corp. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define AWS_GRAVITON_UUID \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, \ + ARM_SMCCC_OWNER_VENDOR_HV, 0xFF01) +#define AWS_GRAVITON_GET_VER \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_32, \ + ARM_SMCCC_OWNER_VENDOR_HV, 0xFF03) +#define AWS_GRAVITON_GET_RND \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, ARM_SMCCC_SMC_64, \ + ARM_SMCCC_OWNER_VENDOR_HV, 0) + +/** + * UID of the Graviton TRNG API: 1b64036c-badc-483e-99d23e283f067bdd + */ +#define GRVTN_TRNG_UUID_0 0x6c03641b +#define GRVTN_TRNG_UUID_1 0x3e48dcba +#define GRVTN_TRNG_UUID_2 0x283ed299 +#define GRVTN_TRNG_UUID_3 0xdd7b063f + +static void grvtn_smccc_conduit(u64 call_id, struct arm_smccc_res *res) +{ + if (acpi_psci_use_hvc()) + arm_smccc_1_1_hvc(call_id, res); + else + arm_smccc_1_1_smc(call_id, res); +} + +static int grvtn_trng_read(struct hwrng *trng, void *buf, size_t max, bool wait) +{ + struct arm_smccc_res res; + int err = 0; + /* timeout after one waiting period */ + int iter_remain = 2; + size_t count = max > sizeof(ulong) * 2 ? sizeof(ulong) * 2 : max; + size_t total = count; + + do { + if (err && wait) + /* Nominal wait is 5us */ + udelay(err); + + grvtn_smccc_conduit(AWS_GRAVITON_GET_RND, &res); + err = (int) res.a0; + + if (err < 0) + return err; + + iter_remain--; + } while (iter_remain && err && wait); + + if (err) + return 0; + + if (count > sizeof(ulong)) { + memcpy(buf, &res.a1, sizeof(ulong)); + count -= sizeof(ulong); + buf += sizeof(ulong); + } + memcpy(buf, &res.a2, count); + return total; +} + +static int grvtn_trng_probe(struct platform_device *pdev) +{ + int err; + struct arm_smccc_res res; + static struct hwrng ops = { + .name = "graviton", + .read = grvtn_trng_read, + .quality = 1024, /* all bits are sourced from a HW TRNG */ + }; + + grvtn_smccc_conduit(AWS_GRAVITON_UUID, &res); + + if (res.a0 != GRVTN_TRNG_UUID_0 || res.a1 != GRVTN_TRNG_UUID_1 || + res.a2 != GRVTN_TRNG_UUID_2 || res.a3 != GRVTN_TRNG_UUID_3) { + dev_err(&pdev->dev, "failed to match UUID\n"); + return -ENXIO; + } + + grvtn_smccc_conduit(AWS_GRAVITON_GET_VER, &res); + dev_info(&pdev->dev, "Graviton TRNG, SMC version %d.%d\n", + (u32)res.a0, (u32)res.a1); + + platform_set_drvdata(pdev, &ops); + err = devm_hwrng_register(&pdev->dev, &ops); + if (err) + dev_err(&pdev->dev, "failed to register hwrng"); + return err; +} + +static const struct acpi_device_id grvtn_trng_acpi_match[] = { + { "AMZN0010", }, + {} +}; + +MODULE_DEVICE_TABLE(acpi, grvtn_trng_acpi_match); + +static struct platform_driver grvtn_trng_driver = { + .probe = grvtn_trng_probe, + .driver = { + .name = "graviton-rng", + .owner = THIS_MODULE, + .acpi_match_table = ACPI_PTR(grvtn_trng_acpi_match), + }, +}; + +module_platform_driver(grvtn_trng_driver); + +MODULE_AUTHOR("Amazon.com, Inc. or it's affiliates"); +MODULE_DESCRIPTION("Graviton TRNG driver"); +MODULE_LICENSE("GPL v2");