Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3830508ybt; Tue, 30 Jun 2020 12:02:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4XAdkouPZm3QHdThAtIXfdDYwRofBho3BXJc1ng4N3suDjeYlAn2yVnLVBUcknEh1lCRY X-Received: by 2002:a50:a661:: with SMTP id d88mr24863377edc.34.1593543361554; Tue, 30 Jun 2020 11:56:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593543361; cv=none; d=google.com; s=arc-20160816; b=SgIoAAWhLtF3AxtF83pI7dReDPW9d97gHGsn/nmZHv0s/Y5ER3l0z7Q6ss0Os9z7/F Kcz5KEjdE6SjRhNG/Fg5OuuLX4/rqgNAxTMG20vcQWRtcQ63rEQs3bjxvORifl5tu+zt AL/3NU2Dq/OSxyomok9BDnADUsgU9YOlKpAXd9UXQVj+tBKK5jsXxvwa28N0QzvICU9X QcPQAYgUdWwoZ8vUP9jdhzXu/SqaZE8NISvPsm2Vn4zWPuvdleIDarxIBRi3dFdKoIig Qxc6Dayr6gplf8ONCiQHejVULU1b0GuG4L+vcQKHgm8ck35AQuPqCYgfEneVIWA+GV9A mtLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WsBqruUfg+VXeXRu9RemtwWzfGDUGVK0UFr+4/Xow2E=; b=Ymr70rL1axV40NSJv7WbNruwRAOWov0nDUWO20HIopNNptlbbBnrGkhS/aIbV66coA DC9+lxB+LDBQgo+n9bllQ1EsQdMlorTB3fc3DrrqPaUo5w3l/XGAVbOZZIIQvaHfZV6J E/qv8+6ALZH28Fwr2nQ3X1pRJRTCH/KRYxoY7oeBKfKfSSOHqqmksqZHan439EdOxcb4 H1vdi1lxM4MNUqooOXFXGFloVIaiMHXq8X4l95ZwTxOR8liUPNTGMrOURS7smxmdVHg0 PVb8ooBPifPVDNZDxLs1If/CYL2uP2tKlxao99oEtRRiDIYNTVYYurhrRWWAev4ueHXZ dkYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aHmhulfd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hh22si2283733ejb.85.2020.06.30.11.55.38; Tue, 30 Jun 2020 11:56:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aHmhulfd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2390484AbgF3RjA (ORCPT + 99 others); Tue, 30 Jun 2020 13:39:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:52170 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733290AbgF3Riv (ORCPT ); Tue, 30 Jun 2020 13:38:51 -0400 Received: from localhost.localdomain (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2513E208C7; Tue, 30 Jun 2020 17:38:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593538730; bh=2Mxxi9P5lRW+5g3NQeU4qRWtaohhR1GFugsFg71PpZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aHmhulfd7SvL45c44fC0qSgxIdAPN86DyrwnKNzGUg2Pq5OjOijA/yWJyAtsmEUma rPR64cLaZaBkm37b+Sa2giePD+devRt9g6SbU0ATC0mG6V+RLRb6k8iDZGKf1D8o3z k9YXXvWinl98EEh7HO58U2tPFIT6KD8BNSIG73q4= From: Will Deacon To: linux-kernel@vger.kernel.org Cc: Will Deacon , Sami Tolvanen , Nick Desaulniers , Kees Cook , Marco Elver , "Paul E. McKenney" , Josh Triplett , Matt Turner , Ivan Kokshaysky , Richard Henderson , Peter Zijlstra , Alan Stern , "Michael S. Tsirkin" , Jason Wang , Arnd Bergmann , Boqun Feng , Catalin Marinas , Mark Rutland , linux-arm-kernel@lists.infradead.org, linux-alpha@vger.kernel.org, virtualization@lists.linux-foundation.org, kernel-team@android.com Subject: [PATCH 16/18] arm64: cpufeatures: Add capability for LDAPR instruction Date: Tue, 30 Jun 2020 18:37:32 +0100 Message-Id: <20200630173734.14057-17-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200630173734.14057-1-will@kernel.org> References: <20200630173734.14057-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Armv8.3 introduced the LDAPR instruction, which provides weaker memory ordering semantics than LDARi (RCpc vs RCsc). Generally, we provide an RCsc implementation when implementing the Linux memory model, but LDAPR can be used as a useful alternative to dependency ordering, particularly when the compiler is capable of breaking the dependencies. Since LDAPR is not available on all CPUs, add a cpufeature to detect it at runtime and allow the instruction to be used with alternative code patching. Signed-off-by: Will Deacon --- arch/arm64/Kconfig | 3 +++ arch/arm64/include/asm/cpucaps.h | 3 ++- arch/arm64/kernel/cpufeature.c | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 66dc41fd49f2..e1073210e70b 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1409,6 +1409,9 @@ config ARM64_PAN The feature is detected at runtime, and will remain as a 'nop' instruction if the cpu does not implement the feature. +config AS_HAS_LDAPR + def_bool $(as-instr,.arch_extension rcpc) + config ARM64_LSE_ATOMICS bool default ARM64_USE_LSE_ATOMICS diff --git a/arch/arm64/include/asm/cpucaps.h b/arch/arm64/include/asm/cpucaps.h index d7b3bb0cb180..3ff0103d4dfd 100644 --- a/arch/arm64/include/asm/cpucaps.h +++ b/arch/arm64/include/asm/cpucaps.h @@ -62,7 +62,8 @@ #define ARM64_HAS_GENERIC_AUTH 52 #define ARM64_HAS_32BIT_EL1 53 #define ARM64_BTI 54 +#define ARM64_HAS_LDAPR 55 -#define ARM64_NCAPS 55 +#define ARM64_NCAPS 56 #endif /* __ASM_CPUCAPS_H */ diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 9f63053a63a9..a29256a782e9 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -2056,6 +2056,16 @@ static const struct arm64_cpu_capabilities arm64_features[] = { .sign = FTR_UNSIGNED, }, #endif + { + .desc = "RCpc load-acquire (LDAPR)", + .capability = ARM64_HAS_LDAPR, + .type = ARM64_CPUCAP_SYSTEM_FEATURE, + .sys_reg = SYS_ID_AA64ISAR1_EL1, + .sign = FTR_UNSIGNED, + .field_pos = ID_AA64ISAR1_LRCPC_SHIFT, + .matches = has_cpuid_feature, + .min_field_value = 1, + }, {}, }; -- 2.27.0.212.ge8ba1cc988-goog