From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2428B3769F4 for ; Wed, 8 Jul 2026 03:11:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783480312; cv=none; b=n8N10WsMnGfV/dI86INyps26a+sl3tWSb7lwT0kQfcDfHP4gN3hc/hVocjswshJnEg2ITtJ4ssZipsK+p1yId5x1l3lx5GzCz5JtVLN9yl/AqYlAM4VNprj1ijgt/i6FfaX4uq8IqTciIyWznmLA7TSwLvilibHLcueS0rYz81g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783480312; c=relaxed/simple; bh=R374UgAGAta5e+b/BGVX7ZxUm72sPia9iCwXdU6HvGU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=myF3BE9ruoG61+6lq+px/6JPTmmKeBG30QHrxqd7iVEGME1qNddvidiaBkWhOpPmRysC0n0OQQlOJDI9vWz710E0KuowZfXM9rtncvve2WD4RdPenxh9OLM+U7bBMSNIMD8Ieur57u6PhvrxAHS1LXaQZhkDwyH7V1/QED6SFvY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jthoughton.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=KqohPjPY; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jthoughton.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KqohPjPY" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-847ad67cc51so229789b3a.3 for ; Tue, 07 Jul 2026 20:11:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1783480309; x=1784085109; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=f2GJhcciwaP4fHjsRT6KM4zWTWsLGZ2JTjerBFR60HQ=; b=KqohPjPY0NpzFLMyYfRv9WwgTggQ5S2tEZseWLkujVupktg8+jUiFWnl6VkviXoBlJ k/pw8vwF4efDkUlmPEBSgdL/ergWc/1kurcsRw1DaAyHZx5anhGYEhjBzlrKkHMXNFOn wev8PqoQSBYCWLNLPwQZI8YiN8mkPlF2m7KZyxokvnw3nLd81KLQ1/GZihQrnBj0/Fjz ciiZapoZ2vPXq9p9+b3VzC8Ya7oNd8RxTP9mF1lIVm7kp5d5IxjbGr4RAQOWx/pH4xQ9 +pF0R9Fqiwm7VsZLP7hpcF1Q02tszN27Dq2Jur+s7spWAYb/bqnsoaO/nWvqIR+FA1sp J3vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783480309; x=1784085109; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=f2GJhcciwaP4fHjsRT6KM4zWTWsLGZ2JTjerBFR60HQ=; b=HCSmmaZr5vlU8BocU51yDeUOLLF/rz8d5w8kNkIBGwh51Y6hVGLloChLX6XfEZlZTL fID3G+XV40+BmszK72alz6UAIEzaBcdY3+YZHwAsU6LadhxS0nNR+v5lG2/5Vqow2z9t HFHY9z1gUuU2yFnAa3/Ot87oPlWvcLfZmre7pdQ5ZfTuFfWslMOnkf7px8gyZ+2CkNw2 SJIcMaZmOFwavJaAu6iqji9Ok2Dn8xMdOiCNZUZgTh/yp4030qfTk2jtGeBC72N6vOSy EAGKE0xAp9iTgOYA9Ocbd+wifP+ViC0CHUaortSf/6Z2L1S6TvvsNOfY3SAqpIXRMs2v KGUw== X-Forwarded-Encrypted: i=1; AHgh+RoEGCNISgqZmSnawMUWY9uCFDPyHUbB4CTVTH78kylkVqrVo4SEbqTl9YE0i/yPKFacvC/NJ3nFpZ65SVk=@vger.kernel.org X-Gm-Message-State: AOJu0YwERa74bt80VUkAxMtwTAc7sg935gIbFuou041FEzh/3kNaE+YQ H3wEDafHOOdlLLB/E1/HQZarfDTetICjnRO548aVYBCV61qom8q6b7nUkkqQQIYFkirqpYnCQDQ BFKe0RgOwhIm06aKIf1c/mw== X-Received: from pfbjf15.prod.google.com ([2002:a05:6a00:6e4f:b0:848:42e4:9622]) (user=jthoughton job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:178c:b0:847:70cd:395a with SMTP id d2e1a72fcca58-84842fce3a2mr805556b3a.59.1783480308390; Tue, 07 Jul 2026 20:11:48 -0700 (PDT) Date: Wed, 8 Jul 2026 03:11:27 +0000 In-Reply-To: <20260708031129.3503195-1-jthoughton@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260708031129.3503195-1-jthoughton@google.com> X-Mailer: git-send-email 2.55.0.795.g602f6c329a-goog Message-ID: <20260708031129.3503195-18-jthoughton@google.com> Subject: [PATCH 17/18] arm64: Permit onlining of HVO-incompatible late CPUs if HVO is not in use From: James Houghton To: Will Deacon , Catalin Marinas , Muchun Song , Oscar Salvador Cc: Nikos Nikoleris , Linu Cherian , Mark Rutland , David Hildenbrand , Andrew Morton , Ryan Roberts , Nanyong Sun , Yu Zhao , Frank van der Linden , David Rientjes , James Houghton , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" First, HVO must have ARM64_CPUCAP_OPTIONAL_FOR_LATE_CPU so that incompatible CPUs can be onlined if HVO is not in use. The late_cpu_enable() callback is used to check if HVO is truly in use. If the late CPU is incompatible with HVO and HVO is *not* in use, HVO becomes permanently disabled. If the late CPU is incompatible with HVO and HVO *is* in use, the CPU is not onlined. If the late CPU is compatible with HVO, there is no issue. Signed-off-by: James Houghton --- arch/arm64/kernel/cpufeature.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 7e2c134f3b55..65bb3c7c9595 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -76,6 +76,7 @@ #include #include #include +#include #include #include @@ -2181,6 +2182,22 @@ static bool hvo_compatible(const struct arm64_cpu_capabilities *caps, int scope) return supports_hw_af(scope); } +static bool late_cpu_enable_hvo(const struct arm64_cpu_capabilities *__unused) +{ +#ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP + if (cpu_has_hw_af()) + return true; + + /* + * If the CPU does not support HW AF, we cannot online it if HVO is + * currently in use. + */ + return hugetlb_vmemmap_optimization_try_disable(); +#else + return true; +#endif +} + static void cpu_enable_pan(const struct arm64_cpu_capabilities *__unused) { /* @@ -3079,8 +3096,11 @@ static const struct arm64_cpu_capabilities arm64_features[] = { { .desc = "HugeTLB Vmemmap Optimization Support", .capability = ARM64_HVO_COMPATIBLE, - .type = ARM64_CPUCAP_SYSTEM_FEATURE, + .type = ARM64_CPUCAP_SCOPE_SYSTEM | + ARM64_CPUCAP_OPTIONAL_FOR_LATE_CPU | + ARM64_CPUCAP_PERMITTED_FOR_LATE_CPU, .matches = hvo_compatible, + .late_cpu_enable = late_cpu_enable_hvo, }, { .desc = "52-bit Virtual Addressing for KVM (LPA2)", -- 2.55.0.795.g602f6c329a-goog