Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1092950pxu; Wed, 2 Dec 2020 10:49:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0sw+ZejsP2iXvWzJe6IXke6IX/Y2IAem8rmcwBFIX+Y5s2gPBFlsS2byVLPzWL/Rnvu0l X-Received: by 2002:a17:906:7f10:: with SMTP id d16mr1158053ejr.104.1606934973996; Wed, 02 Dec 2020 10:49:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606934973; cv=none; d=google.com; s=arc-20160816; b=EaCCdAmHFSryFqvKzY3vl7dSoN5cHDFoLhmupdDBa0DLuIpeN0DngAYuX680rnTLau /3zdYP9x2dDqpl1RS86eModONPC4Fh4oau48wqVyIag4v6JcGyrDZwa/d3gpqFbHxS03 SoITeicj0gPDJl5dHipy+nICN2J7hmX3oB3lWL1ULYt72fmcgvSrgZkkxynDaim/bUCd stM/qkt+q8/i8NELjW/Ogs7WGZkKTiAR3XRCLH77Yj4QqBkrIEMs4IX6KhIw7l031Ykq 3+NkJgBClnycDiiDkda5ZNw4gpZC+zq2DTZuOY6aPBtlFlXOcOBrVk/YlIzqsn7zPrym 1k/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=y2p8Ay2XnBVL3vmtVVdiQ6iCXfVcEKgd2S1Ri8Ky5yc=; b=PyoS6HwQAxSJ6eBCSuo2FZKyH9Sdf+OQ3NczL9uWecKQ093VEXd7+BF2dAIfezl2/+ r4y8c5BhZAu0hiai+KVSTrhThFQaNQfwQuu4ZerlsYDhkg0fB0tU2EysZ3163J0tm4Q/ 6iAvX7JxZRo1w4D7JqPO5gb3KFwBnq+Z7OEGwbjCNZr2qNpWaV0xdWLz7DMjoqZXFAGI OJsSGtPxM8561bYoT27l3J3fcd0tYYnvzZpMgadrgvE7e2EmPt7E3SpMVZlTgvQzTc46 E31OEXd03RhlOp5hQUlzWYeYtkyzycnVWuWPil7GP9wd65a20BRoFKbBFdmpix0N+l4r VyuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RVZK76j4; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j26si467714eds.457.2020.12.02.10.49.10; Wed, 02 Dec 2020 10:49:33 -0800 (PST) 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=@google.com header.s=20161025 header.b=RVZK76j4; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387910AbgLBSnF (ORCPT + 99 others); Wed, 2 Dec 2020 13:43:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387885AbgLBSnE (ORCPT ); Wed, 2 Dec 2020 13:43:04 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38F31C061A51 for ; Wed, 2 Dec 2020 10:41:44 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id z7so5174375wrn.3 for ; Wed, 02 Dec 2020 10:41:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y2p8Ay2XnBVL3vmtVVdiQ6iCXfVcEKgd2S1Ri8Ky5yc=; b=RVZK76j4k6bFwiXLgYuFF1wtJaBoX2V07k5mb0zz2XzuAWmLJ1i+F8W5NohjH00/sj gWlE7qrSAwcbIAEG3hSs7PAR248eOVkY6Xm3SGr2s7GCAbFd1nsA3SXKbGnzIxFSrkg8 irlXEGzEcD3yJ1mQ7deVRYJx/fqkEt/rYVXS4dv7nID08H9qJKazcokqFUOi0xPNWDmc wSiS1Rr8Nrm4KLg51r8BdgmhZJ5lT0++p3Ln9OxqEdQrrLW0MIdiVj2Hn7v3NIVuTRH5 LzsCZkvPa5kTdTcpPz8VJgGlrbBlyP+9VsdgTapGlKyPChgjeyjIeM7KiQROiHGleMKZ qLSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y2p8Ay2XnBVL3vmtVVdiQ6iCXfVcEKgd2S1Ri8Ky5yc=; b=H16LKfneoZC9FhDZXKV32s+R0P+JE/j0MeVA9sH4U1xFsaa1DHVJ4eK1p5sswU4bGl EHISXs1oSIRSGbH+lK8kf8EFKxxN5sKALKPn24piA8iJfkqoEAThm+R4lfRgUIUg474t EmIdOGsFe3yejoTd7CeVF5u3O07iIdfgoLjA7X7IcqgD8agyGKtA4kuxuEkr83URZgaE xDQoo2K1mIZNS9KnmCYhnrrSNOivHm/ZjAPrIW2D845vzYmsJvMb6tgyDQuKgugdTDwq v3JcI5gLb0eg7RnixzE9T6ESiXiDOMPaekKMNmtkS6S1yVDf4V0/3m52DR1D/vXeQ/FG fF/Q== X-Gm-Message-State: AOAM533a7fxTn6J+wUEP7Mif7XZByl4B8O2+JGwvJC4csm5jpGWpAUwO wkgmyHOGDtjZzOe5uYMXk1KyJQ== X-Received: by 2002:adf:c443:: with SMTP id a3mr5093368wrg.249.1606934502768; Wed, 02 Dec 2020 10:41:42 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:5ddd:b7c5:e3c9:e87a]) by smtp.gmail.com with ESMTPSA id v20sm2813264wmh.44.2020.12.02.10.41.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Dec 2020 10:41:41 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Cc: Jonathan Corbet , Catalin Marinas , Will Deacon , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Dennis Zhou , Tejun Heo , Christoph Lameter , Mark Rutland , Lorenzo Pieralisi , Sudeep Holla , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, David Brazdil Subject: [PATCH v4 07/26] arm64: Make cpu_logical_map() take unsigned int Date: Wed, 2 Dec 2020 18:41:03 +0000 Message-Id: <20201202184122.26046-8-dbrazdil@google.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201202184122.26046-1-dbrazdil@google.com> References: <20201202184122.26046-1-dbrazdil@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org CPU index should never be negative. Change the signature of (set_)cpu_logical_map to take an unsigned int. This still works even if the users treat the CPU index as an int, and will allow the hypervisor's implementation to check that the index is valid with a single upper-bound check. Signed-off-by: David Brazdil --- arch/arm64/include/asm/smp.h | 4 ++-- arch/arm64/kernel/setup.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h index 2e7f529ec5a6..bcb01ca15325 100644 --- a/arch/arm64/include/asm/smp.h +++ b/arch/arm64/include/asm/smp.h @@ -46,9 +46,9 @@ DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number); * Logical CPU mapping. */ extern u64 __cpu_logical_map[NR_CPUS]; -extern u64 cpu_logical_map(int cpu); +extern u64 cpu_logical_map(unsigned int cpu); -static inline void set_cpu_logical_map(int cpu, u64 hwid) +static inline void set_cpu_logical_map(unsigned int cpu, u64 hwid) { __cpu_logical_map[cpu] = hwid; } diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 133257ffd859..2f2973bc67c7 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -276,7 +276,7 @@ arch_initcall(reserve_memblock_reserved_regions); u64 __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HWID }; -u64 cpu_logical_map(int cpu) +u64 cpu_logical_map(unsigned int cpu) { return __cpu_logical_map[cpu]; } -- 2.29.2.454.gaff20da3a2-goog