Message ID | 20230307140522.2311461-23-ardb@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> 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 B36EDC678D5 for <linux-arm-kernel@archiver.kernel.org>; Tue, 7 Mar 2023 14:30:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YV2FMo6SbOJv8xq+jHY+/YSqdCwYsZ8GE54kT+ssF0A=; b=EeaPDvIvqCk379 FoLXg7h02gbhXoz3EWsfoEdxiIgkkICcM1jAhYucFEwemRAQTJ32sPF3f16EhVS0zTZeJjj37ztDC +G2Go7IYzR/4rXxnX6YkyFLeGKX0w84p3OCYyLy/7bNy/9DjzBls1r4vTrIiSdfWUK9pw49qhCaTY S+S1MYJRb0EQQwsJaGry57tqbrjJeN8gbZQ8+ri/VoUqYcfTXj1RViQdom4UM+7DgePO5oVqcRfBZ cHgfKGowIk50NO3Cc+bV9gBdvRmIl1VBfG8NG1C9ZCBoI8bblaES1WugZzpXtTa8kp785pa0QOUKo ppiT/V29EMjnjITmWhFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZYJk-000ntQ-BN; Tue, 07 Mar 2023 14:29:29 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZXyW-000eIm-W1 for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 14:07:34 +0000 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 8221DB818F6; Tue, 7 Mar 2023 14:07:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BFA7C433A0; Tue, 7 Mar 2023 14:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678198051; bh=hxezYyQWYIw+0PPMhQw20oQnBobe/ik8sJQ0xwbtFKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PN/3C4zb71kHR2EC4VJjtXnKKx1XE1/0BQIwxpmI4Sxj9+qp1VKbeKRhbtc3YAbeS C8nfCAr7iCCKwFTrN4Oh04FXik3kVT7LDN9uTZw0+Lk1OXgla25XwYfRCUcwluEryz /L5oexRVHy0Z9i2k868BgOZpWj/b2H/a82nB9wrH7nQMv/s1XjFi2u1QLr5aSPnfnQ +MASJV4gL5qSvvoYDl3yX9YX2CIRFZ7bKraUQhipCfIyJRyIAY6xWfykKoC7KlvYfS Itdtg0RwutZeNXFZsjZOf1ERf3ap3TCr0axn8gYhejqt8n+W569S/elox04drH9bCk 4WDOl8gatJ64w== From: Ard Biesheuvel <ardb@kernel.org> To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel <ardb@kernel.org>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Ryan Roberts <ryan.roberts@arm.com>, Anshuman Khandual <anshuman.khandual@arm.com>, Kees Cook <keescook@chromium.org> Subject: [PATCH v3 22/60] arm64: idreg-override: Avoid kstrtou64() to parse a single hex digit Date: Tue, 7 Mar 2023 15:04:44 +0100 Message-Id: <20230307140522.2311461-23-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307140522.2311461-1-ardb@kernel.org> References: <20230307140522.2311461-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1644; i=ardb@kernel.org; h=from:subject; bh=hxezYyQWYIw+0PPMhQw20oQnBobe/ik8sJQ0xwbtFKk=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIYXdxXTJ4/+G+3m9lvhO8o42u3pI5v863Y/XyvXOtszzz 05/ukGio5SFQYyDQVZMkUVg9t93O09PlKp1niULM4eVCWQIAxenAEzknRvD/zxxTYk8/79ts88/ O2Muq6LueLq+zpBx629WkdAZvWJeYYwMbT/OVrn5yD+Ku7yh+e0MMb+Xx97qOCw7raRkftTqL4M tEwA= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_060733_224046_6CFC88C4 X-CRM114-Status: GOOD ( 16.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
arm64: Add support for LPA2 at stage1 and WXN
|
expand
|
diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c index 58c02fe20e1050b4..758f0e86e2bd2a34 100644 --- a/arch/arm64/kernel/idreg-override.c +++ b/arch/arm64/kernel/idreg-override.c @@ -195,6 +195,20 @@ static const struct { { "nokaslr", "arm64_sw.nokaslr=1" }, }; +static int __init parse_hexdigit(const char *p, u64 *v) +{ + // skip "0x" if it comes next + if (p[0] == '0' && tolower(p[1]) == 'x') + p += 2; + + // check whether the RHS is a single hex digit + if (!isxdigit(p[0]) || (p[1] && !isspace(p[1]))) + return -EINVAL; + + *v = tolower(*p) - (isdigit(*p) ? '0' : 'a' - 10); + return 0; +} + static int __init find_field(const char *cmdline, char *opt, int len, const struct ftr_set_desc *reg, int f, u64 *v) { @@ -208,7 +222,7 @@ static int __init find_field(const char *cmdline, char *opt, int len, if (memcmp(cmdline, opt, len)) return -1; - return kstrtou64(cmdline + len, 0, v); + return parse_hexdigit(cmdline + len, v); } static void __init match_options(const char *cmdline)
All ID register value overrides are =0 with the exception of the nokaslr pseudo feature which uses =1. In order to remove the dependency on kstrtou64(), which is part of the core kernel and no longer usable once we move idreg-override into the early mini C runtime, let's just parse a single hex digit (with optional leading 0x) and set the output value accordingly. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> --- arch/arm64/kernel/idreg-override.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)