From nobody Sun Feb 8 15:53:35 2026 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 DA40714D2BD for ; Tue, 24 Dec 2024 12:39:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735043997; cv=none; b=Ru3A/a7K7vlwwwa5dVBRbbFVfYfDOTHKpAiBSaV2oBG/npw9X4MGmr1ZCSotXtjeDCVD4zz8vVnjCn7Su5L5dpOKugYr8i/xChEUK++U4ssKzNrDhuHGRULIMKIw71A5r3mJ52uukuVUy8/szDo+oIdMJLoEdaMYHjZlE9d7vMQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735043997; c=relaxed/simple; bh=gG9TVunLeMccZCBEwSceO0+YEbqxI9AbCT1BvBoJN1Y=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=SWW/HY08o50tc/5xPHwqDc14B1mXO2caIXJpjFADACEcHfDagYhtT6IX3W3l3XNoIw+ozywj+0qNOF2mtoMDp2L3LTP/5KjDHTiGYmLPKlA+9gTj2JxVGbu6xx2hdfkEROT0pGq/CqdxrbDqBNHBpTKYpXrOc0xtr/hD3QK74Y4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=iEEyEMI3; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="iEEyEMI3" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2166f1e589cso61094445ad.3 for ; Tue, 24 Dec 2024 04:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1735043995; x=1735648795; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=h63UEgBoo3OlBZkGqbA1hPszqb23xAlCHsMCBjLn16g=; b=iEEyEMI3dbq3TTqtSO5fq/wXzvuL7Px/70jqFuYGK6mB6BHqVAPM/5lkIWh4b8ZGmP Kau0zPrsxdZIORmAERqHt4fkDwA1EibtqQZJos1hDBS5Yj//IA7Mvsd3a34AphUrwyIw By56WKLtsZrGDv4BFssHbWo8Rm2tQbk75k3iuHdSWfsRFKwFPATeUYhxdDUWJA8x79Bp u4wqfLH5nZ4cq1QUHNxmeQk4U9/1u7Q73bEJLzY2cezVcOu2DBTU4Ca0++lVfEf1LVfZ iaTqCdlNU/pSEn7NUuHOlsISDDJueKWk85Rz9j3z/5bIo9d10ySer+fxoafLPLEetvLp SwGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735043995; x=1735648795; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=h63UEgBoo3OlBZkGqbA1hPszqb23xAlCHsMCBjLn16g=; b=cGNH3iy/rJr3n/3sKhstoqpTJ2T2V/lFEJMfg7TxU8c6wZMHW3Pi3FTdqArO9JBzqL pdqA8q35U4coE+g+nfCp3fJqNhlrNTGaNSRNcflco3nqNXaQOOst3fmg6bzCFlSmzumk 4ac/tKU9QNiY/HQYeXu2Z9oWFXLAOFCShXvjsnMlWlqFgcvon3yvn9SaKx3rQ0JJf7Yt rczDZL3KODFXXQNCunN9k7fK91aZ1se8FIsMKgXdo/o4VKtdJOV6XHCFv1tshDwbU8gE pJJKXb9cJlNbMjA+YIP3NteGgpJgQW7CBiKLpEMuh8EbFM6VC5GW514/qo/EVm04ua+Y NVaA== X-Forwarded-Encrypted: i=1; AJvYcCWBAXMiCfm02GP9CGcQxs62SmoSexbFhO54Pfj5HvLYVVp+7LPhWrhERJy2pLT3H0otT+1M4Q5SV90riT4=@vger.kernel.org X-Gm-Message-State: AOJu0Yyc+KBTL9Yt5Lqi43Jz1Q3dpYoSJ71w5vyvZmvFVjxq0x5UdUOp 9TLmX9RNh5LESSxBea/iiP9XpEPhwijq5w7SQxnJ/OR3cu5+rWxVNxDjFc3yFEs= X-Gm-Gg: ASbGncs+bruR0VnEcZxL+W3nSrUlXHLFSFYL1LYAIHHXofyhQ2nlh6MngQemRL/JpCX CQYG6bEzqjWIUJ3oobthziFjmgN1qG/rxs8vL1vzcEDU/WCFtDNpu5BgVWK40Zh6Mmh6L7V0zbg vh6BQITgMHr2D7i9I6qvpCmiD7C1G3LRSBIjySTYFx0er8StGFoudwiZd1SOAjKQHZ77U+qLJvR dHUBRy1FWajhQJOwPDcAyeWFVBPk0PgqXlTLL0nZ4q9h90ACoALKnz+9SPMlBW+TfvPr64plCla mRE9C89sJUSblyE= X-Google-Smtp-Source: AGHT+IF0C8CqYoZCzd8tMQZmn/flQq7GafbIBzpAHhC+CWRw4cNqcwZFoAgrjOQIxh72JMmXwYgyzw== X-Received: by 2002:a05:6a20:d81b:b0:1e0:c30a:6f22 with SMTP id adf61e73a8af0-1e5e080cba4mr29952751637.40.1735043995218; Tue, 24 Dec 2024 04:39:55 -0800 (PST) Received: from L6YN4KR4K9.bytedance.net ([139.177.225.228]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842e4057b77sm7386550a12.83.2024.12.24.04.39.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 24 Dec 2024 04:39:54 -0800 (PST) From: Yunhui Cui To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, conor@kernel.org, charlie@rivosinc.com, ajones@ventanamicro.com, samuel.holland@sifive.com, cleger@rivosinc.com, andybnac@gmail.com, alexghiti@rivosinc.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Yunhui Cui Subject: [PATCH v2] RISC-V: Enable cbo.clean/flush in usermode Date: Tue, 24 Dec 2024 20:39:46 +0800 Message-Id: <20241224123946.97486-1-cuiyunhui@bytedance.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Enabling cbo.clean and cbo.flush in user mode makes it more convenient to manage the cache state and achieve better performance. Signed-off-by: Yunhui Cui Reviewed-by: Andrew Jones --- arch/riscv/kernel/cpufeature.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index c0916ed318c2..60d180b98f52 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -30,6 +30,7 @@ #define NUM_ALPHA_EXTS ('z' - 'a' + 1) =20 static bool any_cpu_has_zicboz; +static bool any_cpu_has_zicbom; =20 unsigned long elf_hwcap __read_mostly; =20 @@ -87,6 +88,8 @@ static int riscv_ext_zicbom_validate(const struct riscv_i= sa_ext_data *data, pr_err("Zicbom disabled as cbom-block-size present, but is not a power-o= f-2\n"); return -EINVAL; } + + any_cpu_has_zicbom =3D true; return 0; } =20 @@ -944,6 +947,11 @@ void __init riscv_user_isa_enable(void) current->thread.envcfg |=3D ENVCFG_CBZE; else if (any_cpu_has_zicboz) pr_warn("Zicboz disabled as it is unavailable on some harts\n"); + + if (riscv_has_extension_unlikely(RISCV_ISA_EXT_ZICBOM)) + current->thread.envcfg |=3D ENVCFG_CBCFE; + else if (any_cpu_has_zicbom) + pr_warn("Zicbom disabled as it is unavailable on some harts\n"); } =20 #ifdef CONFIG_RISCV_ALTERNATIVE --=20 2.39.2