From patchwork Mon Sep 2 16:15:46 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: 13787482 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 9AFAECD13CF for ; Mon, 2 Sep 2024 16:21:22 +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:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/DUDom//tRZnCzR0TPrW7dnmFkZZ6kQdXEFrODb12u4=; b=NwCcG2olKngNi42yZrBZDNQ6qy d5RCfKewnRmRjT9R+/mf/SIBIWuP1KmWvbd/jhDEatmb0PxrA9SI6Dq3c3eXoZSuVTyftXFUZebrY m1G28hG3xqVN+acxjwnXrvV2jZDNgJav/PtdlPc2Bwqa/df6bdNzbnixQu9G4ACFdeLenVSb/a84Z F5Q0NdJ8u+lOt+cZcCHbW6fgS5h6N4t+IziWTfwpuyCzFgklhOSAl2GOFRuPaQ+uD8MeTm/YAg/SB XgXLey7UEtLe0GQ9ZDcWGGCzfc1nVeo/8/iTkVuzS4++TmQoU41hvcLZ3iUYliKswf/7hwIaVSSsD DubKTVIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl9nl-0000000EzsY-2kkV; Mon, 02 Sep 2024 16:21:13 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sl9lz-0000000EzNo-2ZKY for linux-arm-kernel@lists.infradead.org; Mon, 02 Sep 2024 16:19:24 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-42bb6d3e260so37938555e9.1 for ; Mon, 02 Sep 2024 09:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725293962; x=1725898762; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/DUDom//tRZnCzR0TPrW7dnmFkZZ6kQdXEFrODb12u4=; b=gMSdzR7RVqEP1I2SIzSwFVsAawoFIA8dYGJYMqx+dwAigqTIBnZVYArnV6nro3T/+3 MlwNPZPkpjPF4BByFFyIiPp9uJdwkn17mtqj6YLoG+14t6INY5uddyTgKNcRtVp+LIau wnsXahwoU+pAwqtUWvf8TwOD+Lo5EhJZvqZQswwP1Q+DxJwCFFBwFjnA5vZQTnI2vMOd UOgmFQijwNhSpOi1jDb+WTpvKt8UNN18R8tbykaJFxg9YdBbxyIVcQoncRL5xB/5BRz2 9KNnd/k3aP2q7UCURYFEfOWJuM3kFqdokzFUNvxAWdChjLdL4r0hNMR+DIx1B27+vuld puhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725293962; x=1725898762; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/DUDom//tRZnCzR0TPrW7dnmFkZZ6kQdXEFrODb12u4=; b=Gp93+7ohaF0ampAXLhBO1Zlh8UtmYldqTy9p8bUcvxdgJj03c1oj7htMQ/bNPXLm/E 8pTF7GxtyhSIC3EN80fM19f+SO+aYviBgKq9FR81f5KHDmolqvSizqX67TM6+jRunUGN n/b4rVUwV6wYDVKdIoHp+RulRQXGH4wv1pxzzKlZQNFAB8Aj9bCSu/fcqNH92btlo7ki Jz3nWWDW4KPq797JvXAePQeU7XucMoA9+GZpsS9i6Oht4wIuBV5r21eMe5C6U+AsMgM8 9czcgTcnYdvmlY/OAu13ukz5v8HMxWWMmLST+qrmmvYLa4Mrm0J+88g1tRKJH1mqPEn+ klqQ== X-Forwarded-Encrypted: i=1; AJvYcCVaWN+KAen1yIk/jycCAoYyTk8wIc2RoJ77ukOzSbqnvAcz/kByJvfEka6QK9FCARTuRRJMPC0dOiu6xXEssoeA@lists.infradead.org X-Gm-Message-State: AOJu0YzdJUVwm10sffwJQgNpao7KqJSCmxjbJ3wxxrdGs5n2nOLw2UMK xRHXMM6NDz0rClvF2MBGyYcRvzdz9lrDJ2iHDKAKkH4NJj2nJ5yWMePlFKfuL90= X-Google-Smtp-Source: AGHT+IHxlg744kdhRp7ia5MEnyLycaQtMyvS6PmquQ558nqH6B/b8PrByKr+corJQzJhDTQ9+etDCA== X-Received: by 2002:a05:600c:3b87:b0:428:151b:e8e with SMTP id 5b1f17b1804b1-42bdc63348bmr46501825e9.10.1725293961685; Mon, 02 Sep 2024 09:19:21 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 09:19:21 -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 Cc: Mark Rutland Subject: [PATCH v4 1/2] arm64: alternative: make alternative_has_cap_likely() VDSO compatible Date: Mon, 2 Sep 2024 16:15:46 +0000 Message-ID: <20240902161912.2751-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240902161912.2751-1-adhemerval.zanella@linaro.org> References: <20240902161912.2751-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240902_091923_675305_A8505DE4 X-CRM114-Status: GOOD ( 13.07 ) 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 From: Mark Rutland Currently alternative_has_cap_unlikely() can be used in VDSO code, but alternative_has_cap_likely() cannot as it references alt_cb_patch_nops, which is not available when linking the VDSO. This is unfortunate as it would be useful to have alternative_has_cap_likely() available in VDSO code. The use of alt_cb_patch_nops was added in commit: d926079f17bf8aa4 ("arm64: alternatives: add shared NOP callback") ... as removing duplicate NOPs within the kernel Image saved areasonable amount of space. Given the VDSO code will have nowhere near as many alternative branches as the main kernel image, this isn't much of a concern, and a few extra nops isn't a massive problem. Change alternative_has_cap_likely() to only use alt_cb_patch_nops for the main kernel image, and allow duplicate NOPs in VDSO code. Signed-off-by: Mark Rutland Signed-off-by: Adhemerval Zanella --- arch/arm64/include/asm/alternative-macros.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/include/asm/alternative-macros.h b/arch/arm64/include/asm/alternative-macros.h index d328f549b1a6..c8c77f9e36d6 100644 --- a/arch/arm64/include/asm/alternative-macros.h +++ b/arch/arm64/include/asm/alternative-macros.h @@ -230,7 +230,11 @@ alternative_has_cap_likely(const unsigned long cpucap) return false; asm goto( +#ifdef BUILD_VDSO + ALTERNATIVE("b %l[l_no]", "nop", %[cpucap]) +#else ALTERNATIVE_CB("b %l[l_no]", %[cpucap], alt_cb_patch_nops) +#endif : : [cpucap] "i" (cpucap) :