Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp1122065rwl; Fri, 4 Nov 2022 10:01:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6HY3TU9dbqzyzvcJusQro+Hh8Jb7FULtWMVVu0ikXDr5jYEHJWO2XPFW+DkCT15g1Q/BqH X-Received: by 2002:a05:6a00:b89:b0:56d:2a21:a6b3 with SMTP id g9-20020a056a000b8900b0056d2a21a6b3mr32760924pfj.56.1667581317023; Fri, 04 Nov 2022 10:01:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667581317; cv=none; d=google.com; s=arc-20160816; b=XJe4I/VHlf1mD8bEQxvZubCeLp2x4yJnWNrMrcbOQF8fZMgKW/bRlOAGYjh7ROWfY9 AlvwqWlCijhKyKYiOv5tY3J+7FmduD/EtWcC107gV42EE0Gm0rZrXn0FZeDk6PWxAeED AmuC+dynrDOl2m0PT12Cjm1PhpD7DU+DP1TJA3/lcFsgOR+jbEPGJf7vV9jO7K0kXREm GKGqBgo53FSKfZz383zI7/tOrYTtUmpriIE+pJRle9yOWIJr5/0sHwOR7SGcl+8axP2O qxMeloMrmpYdT9Io/5oNnZk0TseEb0sV23VtaVs7jPFVfkLHWeqd4so3kmB8zmnI+XNQ bpIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=FMbGjTseZNdRY2rEGTGFhAHhWKID0sPI5rxJqiulQ54=; b=Kry2o6aGjblnfIM13F6co2E7y3qknyTm+ZUuS0Zv6FlC2B4HnTzyU4EzRVGOVTZpf3 im+Je5tNGQqqKkWV5/Gq22VWYT2CCLnEte6fDx5NPQnuW3Gnnl3Hpn/mrKrN85npM8xA X6ITEY9v5P2FrgEPt/UZeNpe8shGyjPam91Ul06y6CHjdRDrhzdyICQbB+0i9HIWepN5 rZwCtEyKqxTCFajYlwgmVig0x5BajNkwsankWHINfvrrwyTmCbxaNUp/jfR2j0kBbUKa hOheKTYDKbiK2Lm9C/5vfxC7MULaGP/MqFM65jvdCqjw4Nfl1csg4aZkUVlff2RF0LJt iumw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ir+ZohAh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j11-20020a056a00174b00b0056b86567ce9si5227767pfc.347.2022.11.04.10.01.27; Fri, 04 Nov 2022 10:01:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ir+ZohAh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229748AbiKDQl5 (ORCPT + 96 others); Fri, 4 Nov 2022 12:41:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232001AbiKDQlE (ORCPT ); Fri, 4 Nov 2022 12:41:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 394AC3F064 for ; Fri, 4 Nov 2022 09:40:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B38E4B82ED8 for ; Fri, 4 Nov 2022 16:40:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DC87C43143 for ; Fri, 4 Nov 2022 16:40:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667580043; bh=ntRAKbBYNWlX+LKMjOPFMzVDA2vJlFmB4vJ1n9WugN8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ir+ZohAhM2+/xuVD4BoGesVI38EMwbKMBOhUq5lLk5D4L3Hmhb++aZ+abXWPYsEbn +Tx7R0Z3ACe94HWLThGPvDwUfGTj8ov5MwPQtc805MRNHkjWbwf2NowXMZaQX9T12j 8iVIQ0N6pUN1TFLfl992pfiyT0JQMDoIUxHZFWW56mQSHUKbCtbzEGbm9y6S/mm+MU 8im7jUgBT6qI2uYhenvXICZqG0RQjXtwRF8ERIj3dXprq2+J65sIt0cO7DKk/kvkNR XruK2X644tqRnT5lsF9+1bHix3LMDX1bigiLXb15MZwNOx/IX2r28vTr1n5FZied61 qJ2XjU+wBt9WA== Received: by mail-lf1-f41.google.com with SMTP id d6so8126973lfs.10 for ; Fri, 04 Nov 2022 09:40:43 -0700 (PDT) X-Gm-Message-State: ACrzQf2doZCfJnfvZvtX9yDqCffr33QJt9hB2P5B+8vIqX7IezzJx99m p9Rb5SevdQDJYGZa0y93GKXKMeD3YNdQ4WX8d3Q= X-Received: by 2002:a19:4f53:0:b0:4b1:1f35:279b with SMTP id a19-20020a194f53000000b004b11f35279bmr7248289lfk.637.1667580041308; Fri, 04 Nov 2022 09:40:41 -0700 (PDT) MIME-Version: 1.0 References: <20221027112741.1678057-1-ardb@kernel.org> In-Reply-To: From: Ard Biesheuvel Date: Fri, 4 Nov 2022 17:40:29 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH] arm64: Enable data independent timing (DIT) in the kernel To: Catalin Marinas Cc: Eric Biggers , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Will Deacon , Mark Rutland , Marc Zyngier , "Jason A . Donenfeld" , Kees Cook , Suzuki K Poulose , Adam Langley Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 4 Nov 2022 at 17:19, Catalin Marinas wrote: > > On Fri, Nov 04, 2022 at 10:29:10AM +0100, Ard Biesheuvel wrote: > > On Fri, 4 Nov 2022 at 09:09, Eric Biggers wrote: > > > On Thu, Oct 27, 2022 at 01:27:41PM +0200, Ard Biesheuvel wrote: > > > > Given that running privileged code with DIT disabled on a CPU that > > > > implements support for it may result in a side channel that exposes > > > > privileged data to unprivileged user space processes, let's enable DIT > > > > while running in the kernel if supported by all CPUs. > > > > > > This patch looks good to me, though I'm not an expert in low-level arm64 stuff. > > > It's a bit unfortunate that we have to manually create the .inst to enable DIT > > > instead of just using the assembler. But it looks like there's a reason for it > > > (it's done for PAN et al. too), and based on the manual it looks correct. > > > > Yes. The reason is that the assembler requires -march=armv8.2-a to be > > passed when using the DIT register (and similar requirements apply to > > the other registers). However, doing so may result in object code that > > can no longer run on pre-v8.2 cores, whereas the DIT accesses > > themselves are only emitted in a carefully controlled manner anyway, > > so keeping the arch baseline to v8.0 and using .inst is the cleanest > > way around this. > > We worked around this already by defining asm-arch in > arch/arm64/Makefile to the latest that the assembler supports while > keeping the C compiler on armv8.0. Unlike the C compiler, the assembler > shouldn't generate new instructions unless specifically asked through > inline asm or .S files. We use this trick for MTE already (and LSE > atomics), though we needed another __MTE_PREAMBLE as armv8.5-a wasn't > sufficient for these instructions. > > I think we ended up with .inst initially as binutils did not support > some of those instructions. We could try to clean them up but it's a bit > of a hassle to check which versions your binutils supports. > OK, good to know. However, I double checked, and DIT needs v8.4-a (not v8.2 as i mentioned above), and my ubuntu 16.04 toolchain, which has GCC 5.3, only goes up to v8.2 So I guess we should be able to fix this at /some/ point, but for now, I'll need to stick with the __inst()