From nobody Wed Feb 11 04:19:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1770741433; cv=none; d=zohomail.com; s=zohoarc; b=VqpYS0j1KugCty1osvEz7d7qwp447rMIgZohP7DMv3wnNWzbPGJoetzI4vyIgr2Lpvg2fuckQMIEZoYv4DUHxFF/oRmxIGytr0xp5+Q35Nn+W93MUnRmhYbrPUT5Axz/tibQLn2YZJ0AxWPhf5afnQE31ofc9xrStcMwfG63b0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770741433; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=i83rk6CF00DSCAs1v5+Cc7fqBYd21dNjMT+muRCPfCk=; b=g5GuoUE86gfZ1NLwqY6VDiyW15tOtxqSlgBpfJ1UqvW1Law5VWkoxpNtFZqxursY4A8RA2FAM8ek69ilz5hLtJsNMMXHu4KaWnkSL68v0z0aLcEuuLY8bc9XSXAH34w/OEoEL2Kfjqgf4J0YQPPG45Hfie40hYprFjbq1A8oo4M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1770741433541953.2041776061648; Tue, 10 Feb 2026 08:37:13 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1226685.1533199 (Exim 4.92) (envelope-from ) id 1vpqjR-0001GX-2v; Tue, 10 Feb 2026 16:36:57 +0000 Received: by outflank-mailman (output) from mailman id 1226685.1533199; Tue, 10 Feb 2026 16:36:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vpqjQ-0001GH-UO; Tue, 10 Feb 2026 16:36:56 +0000 Received: by outflank-mailman (input) for mailman id 1226685; Tue, 10 Feb 2026 16:36:55 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vpqjP-00012i-HU for xen-devel@lists.xenproject.org; Tue, 10 Feb 2026 16:36:55 +0000 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [2a00:1450:4864:20::32e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b501d82f-069e-11f1-9ccf-f158ae23cfc8; Tue, 10 Feb 2026 17:36:53 +0100 (CET) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4806ce0f97bso8989705e9.0 for ; Tue, 10 Feb 2026 08:36:53 -0800 (PST) Received: from fedora (user-109-243-67-101.play-internet.pl. [109.243.67.101]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4834d5e11f5sm64803255e9.4.2026.02.10.08.36.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Feb 2026 08:36:52 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b501d82f-069e-11f1-9ccf-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770741413; x=1771346213; darn=lists.xenproject.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=i83rk6CF00DSCAs1v5+Cc7fqBYd21dNjMT+muRCPfCk=; b=by6uynguHIjGrWENp+I/1R6DpXqVCTlnN/CV3KRFqo3if36VMHFJBb2hZ0e2mvIW4M q6ScIe3mWSW8HpLX9qSslzHUU4h9yIAMfSh6AjpKQhjGr4AgR/WP4VrEPtlLAObwIu1m yMRdBm1vVv3IceZvwj25ZcNVb3rBm8oF0b4lN6tBFRSbWc2PSRpo65msu5uDCq2tUsw6 pR/ZDshu7gpQW1gPjvvGWYpSosjIOm3K9AnLKa8LXwoZndyOU/ta1Z25PTjgmuS0QICg nbz/FgYEFEsCSQsuoqEj5w7Tzk5hPUfyrZaOIIbuWBGpCYP5Q7LEvRoxTawlnCkCDx9e +xTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770741413; x=1771346213; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=i83rk6CF00DSCAs1v5+Cc7fqBYd21dNjMT+muRCPfCk=; b=AQtPYQLZFjraQU1ZfdLnNeDZB8G09/8rFuH4BPZtVXts4/YqJUyiM5TZur49CctuQs B6iEmNDrzpP3C1fb63U1QYhf03pL2XZ4TBOY6uwMNTCy/oXkaSKA+IYpzOwrMrFURUAz /o6Z1nGYPt8+xtXxQKWvOasmR8KHcU3hdh+5t2Pc7oXFZE8tl82xXaAQHUTHDe6BtGif y+2J4M9tIFhhyPpkd6GYlbXiuFFc1UcnyCiAgdmhjwhqqmNnHOg87sJ1D1jcw8mSZgPu vjoVD0EH4pxN0cEQQyt1Hpk4KLgMlwldQx21SvYOkxnmCUqlF0lRUjk/PhSZF+zIpnh6 U9EQ== X-Gm-Message-State: AOJu0YxHCLQJd4ydzmoXyJmVbJVH2ml8EVGextLhmU6TmFCRzJ3Ib0XK 3JUGP+czKPC3gZvDeVtrlsDFlOWzyIjk1Ca4JLePpzwCjWd1EMqLM+TsoJXY6ifk X-Gm-Gg: AZuq6aJhjsrKNTw2Vkwa7ymnp+Ua4MwmMCBz+hltag6iEslEEW2WGafnYSKDjIKn+u5 u6SQXZyplKfARFVIZlAQ/W585NNEfM5DnJhMrTTVFX9XFpIgQOfGa1LjL4JLiItXPJdvjALHw7T 7/w6hFc2cSinD4dZun/wbrhAzSCaCF/TZYkvS5mCk3ypmcAN8ZxoBymYOv5nEu6PoT5ywqUWK8l JuFU7DQJPcS9PHnjB4L8YBAQwf6McROJNR9hk7SXabvhmePZqRaVqLS8L2Z3JbkLyXofIxavCxt MoxXn4UXMrmgOFvC2WPQJQfQ1Tw4J68BECORLHv7tWlJ8Hb2wRXf0/S8A4QZ1EWtG8U5N9reA/Q +NNrxMzvxtSj7pfqQCYOGR7uS/gHGIrr5GouGkbKzq98qLOVlz2mHk/7yUHfAzhMLMzznwGgoaz 4ZMBdsRa+hBxoTC2RThkB0bnBDdeL5KH+xprR+dHIMdhrMV/5H2Pi3tEiX5cTPSIXlHFHufofBJ V8b X-Received: by 2002:a05:600c:154b:b0:477:7925:f7fb with SMTP id 5b1f17b1804b1-483201e3e8amr206281615e9.10.1770741412614; Tue, 10 Feb 2026 08:36:52 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v2 1/2] xen/riscv: add support for local guest TLB flush using HFENCE.VVMA Date: Tue, 10 Feb 2026 17:36:40 +0100 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1770741436020154100 Content-Type: text/plain; charset="utf-8" Introduce flush_tlb_guest_local() to perform a local TLB flush of the guest= 's address space for the current hart. This leverages the RISC-V HFENCE.VVMA instruction, which is used to invalidate translations in the VS-stage of address translation. As for RISC-V binutils >=3D 2.39 is choosen, we can use hfence.vvma mnemoni= cs instead of defining hfence.vvma using .insn. Although it would be possible to use sbi_remote_hfence_vvma() for this purp= ose, it is unnecessary in this context since the flush is required only on the local hart. Using the SBI call would introduce additional overhead without benefit, resulting in unnecessary performance loss. Signed-off-by: Oleksii Kurochko --- Changes in v2: - Add missed blanks in asm(). - Add operand modifier "z" and "J" constraint to be sure that zero register will be used when 0 is passed to HFENCE_VVMA(). --- xen/arch/riscv/include/asm/flushtlb.h | 7 +++++++ xen/arch/riscv/include/asm/insn-defs.h | 10 ++++++++++ 2 files changed, 17 insertions(+) create mode 100644 xen/arch/riscv/include/asm/insn-defs.h diff --git a/xen/arch/riscv/include/asm/flushtlb.h b/xen/arch/riscv/include= /asm/flushtlb.h index 4f64f9757058..b0112d416dbe 100644 --- a/xen/arch/riscv/include/asm/flushtlb.h +++ b/xen/arch/riscv/include/asm/flushtlb.h @@ -5,6 +5,7 @@ #include #include =20 +#include #include =20 struct page_info; @@ -14,6 +15,12 @@ static inline void local_hfence_gvma_all(void) asm volatile ( "hfence.gvma zero, zero" ::: "memory" ); } =20 +/* Flush VS-stage TLB for current hart. */ +static inline void flush_tlb_guest_local(void) +{ + HFENCE_VVMA(0, 0); +} + /* Flush TLB of local processor for address va. */ static inline void flush_tlb_one_local(vaddr_t va) { diff --git a/xen/arch/riscv/include/asm/insn-defs.h b/xen/arch/riscv/includ= e/asm/insn-defs.h new file mode 100644 index 000000000000..61aaa202fd13 --- /dev/null +++ b/xen/arch/riscv/include/asm/insn-defs.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef ASM_RISCV_INSN_DEFS_H +#define ASM_RISCV_INSN_DEFS_H + +#define HFENCE_VVMA(vaddr, asid) \ + asm volatile ( "hfence.vvma %z0, %z1" \ + :: "rJ" (vaddr), "rJ" (asid) : "memory" ) + +#endif /* ASM_RISCV_INSN_DEFS_H */ --=20 2.52.0