From patchwork Thu Sep 19 16:01:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyan Yang X-Patchwork-Id: 1987477 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=WzVTMacg; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=KzlBD5wK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X8gJx5FK8z1xrD for ; Fri, 20 Sep 2024 02:02:39 +1000 (AEST) 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: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:In-Reply-To:References: List-Owner; bh=vBXS/YOrZaqenDlWC3qOlhGpyJYJOIw8YvkR8sWme6o=; b=WzVTMacgAVtRWs HJkkK2ZM6JvNjPrJzCsQrJEAeEkkW97vQ0qoCM6hioJ77/VOFUtlwEC2qWZ6OqtBdCQrinN7jUgPl Pp2i8A9iC4fAVH9KeCIIBVxAqxXfVnS8kyYRJS4WpSEwvQTkS1HZfq/Q3pMB3GHW6OXiQWndJH7+Q XOwomeVXJPiFWES1Njq/xk6KR+uOXlotkAfgQDQk7/5d3EipB/NsXbBugdKgD+Q5EPlDS14WOR60T dfrXIxNJxnLYNV5mAqMfH8aLvlVG6DxuhcwDdXVTczDhKnY40Yy9LjOnfVLSco1X79tlg8B/wKJEA h98bRS/r6Ps3e/ZqyHMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1srJc4-0000000AbbP-27Hs; Thu, 19 Sep 2024 16:02:36 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1srJc1-0000000Abae-1TLQ for kvm-riscv@lists.infradead.org; Thu, 19 Sep 2024 16:02:34 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2059204f448so10377745ad.0 for ; Thu, 19 Sep 2024 09:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1726761751; x=1727366551; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=IY5B5QxXDNVGbG3vnBPyBqvWzO5uiDp/nIYu33vK85A=; b=KzlBD5wKt+0+qnWE3LPD3FlKUcrTDNyurjbiOFLuB2D6lh3EgIH8gLgVkt6AzYP2tU XrbJ4KJOM4tUWrwpVKz44m8LG+tbuU+jPk+o/Voaip2xeBK6vnCm02T0E7RkAgv8OHZ0 9+GaxrY8/S8rO8Rgl5EPMHE+EiNV0oQgiK0JPxetlubdL6a2erpb1BJtpl1NMHM+M+MT Q4KPBFVSRkKs/DXlE4RRNBQTdmAhNV2w3dktYesnNIUQJzUe7ORxw+k4u1tQ4oPZKMwe CI3249XAOy/zvFuIrBPJaYPE6V9X/YK98CAeqoXJ5XeeG5CvRRxj1gkPzqmyLy/LDzWx U+oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726761751; x=1727366551; 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=IY5B5QxXDNVGbG3vnBPyBqvWzO5uiDp/nIYu33vK85A=; b=IYEur+plUKfeqgFiAKOTGjZ1i0wOUf3GTznaRDB0ApQAd8y6BSAAy11/WTBVaTSYOj TOi8QYfp9WgbBF7rNfDCzsvJHHGgaVpTmU51JcCaq5Oxq/6WzwCJjswyYSJSM/oA0XLQ EyydShnVMacCbTkY/2USQzvH8l44JiZmpsc3ITigX1hkekRKBuLCUJ+yltT0XJoVCTvq /kDALxjf4OLG9ZNGnO/dAKdY3bYHzfpFmk/uv6LnS5447vuQ25yebTUJbMbVXpDYy4Oh QmvGaafDJb1DRBq6Y7vYIdlC9egynZ2JjQQafagbQoDjsuYSSwGpsSsrF40eab/zm+S4 DMMA== X-Forwarded-Encrypted: i=1; AJvYcCVEeTUzs/D65pkbcTBp8rbw2XvlDuyz+f/u69wWNXqQ1HxuGWwUglM5YPcW2ciN1yFmy1UggZjpMcY=@lists.infradead.org X-Gm-Message-State: AOJu0YwOFPuVuVSXdbOHXnDK+cCrfZH8QRBGIxKOWOJE1XFqD6JYyOXF UFZ+//llA9J0qrI0fJqHlbOHOI2i8y7bIJuu/kFvNqp6968SnIom2ivQi3NZ2d4= X-Google-Smtp-Source: AGHT+IHlrfEPPxfE7BBmxMTJoT8E08EE7/Q0AmzGFUzu6sN8uV/9Rnz5ZDYIemz+SMlLQ8t0Vj4kxg== X-Received: by 2002:a17:903:8c8:b0:205:40a6:115a with SMTP id d9443c01a7336-2076e4360f7mr350612825ad.48.1726761751137; Thu, 19 Sep 2024 09:02:31 -0700 (PDT) Received: from cyan-mbp.internal.sifive.com (114-32-147-116.hinet-ip.hinet.net. [114.32.147.116]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-207946d19e5sm81665645ad.140.2024.09.19.09.02.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Sep 2024 09:02:30 -0700 (PDT) From: Cyan Yang To: anup@brainfault.org Cc: atishp@atishpatra.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Cyan Yang , Yong-Xuan Wang Subject: [PATCH] RISCV: KVM: use raw_spinlock for critical section in imsic Date: Fri, 20 Sep 2024 00:01:26 +0800 Message-Id: <20240919160126.44487-1-cyan.yang@sifive.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240919_090233_421219_5B434E65 X-CRM114-Status: GOOD ( 10.35 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: For the external interrupt updating procedure in imsic, there was a spinlock to protect it already. But since it should not be preempted in any cases, we should turn to use raw_spinlock to prevent any [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:631 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org For the external interrupt updating procedure in imsic, there was a spinlock to protect it already. But since it should not be preempted in any cases, we should turn to use raw_spinlock to prevent any preemption in case PREEMPT_RT was enabled. Signed-off-by: Cyan Yang Reviewed-by: Yong-Xuan Wang Reviewed-by: Anup Patel --- arch/riscv/kvm/aia_imsic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/riscv/kvm/aia_imsic.c b/arch/riscv/kvm/aia_imsic.c index 0a1e85932..a8085cd82 100644 --- a/arch/riscv/kvm/aia_imsic.c +++ b/arch/riscv/kvm/aia_imsic.c @@ -55,7 +55,7 @@ struct imsic { /* IMSIC SW-file */ struct imsic_mrif *swfile; phys_addr_t swfile_pa; - spinlock_t swfile_extirq_lock; + raw_spinlock_t swfile_extirq_lock; }; #define imsic_vs_csr_read(__c) \ @@ -622,7 +622,7 @@ static void imsic_swfile_extirq_update(struct kvm_vcpu *vcpu) * interruptions between reading topei and updating pending status. */ - spin_lock_irqsave(&imsic->swfile_extirq_lock, flags); + raw_spin_lock_irqsave(&imsic->swfile_extirq_lock, flags); if (imsic_mrif_atomic_read(mrif, &mrif->eidelivery) && imsic_mrif_topei(mrif, imsic->nr_eix, imsic->nr_msis)) @@ -630,7 +630,7 @@ static void imsic_swfile_extirq_update(struct kvm_vcpu *vcpu) else kvm_riscv_vcpu_unset_interrupt(vcpu, IRQ_VS_EXT); - spin_unlock_irqrestore(&imsic->swfile_extirq_lock, flags); + raw_spin_unlock_irqrestore(&imsic->swfile_extirq_lock, flags); } static void imsic_swfile_read(struct kvm_vcpu *vcpu, bool clear, @@ -1051,7 +1051,7 @@ int kvm_riscv_vcpu_aia_imsic_init(struct kvm_vcpu *vcpu) } imsic->swfile = page_to_virt(swfile_page); imsic->swfile_pa = page_to_phys(swfile_page); - spin_lock_init(&imsic->swfile_extirq_lock); + raw_spin_lock_init(&imsic->swfile_extirq_lock); /* Setup IO device */ kvm_iodevice_init(&imsic->iodev, &imsic_iodoev_ops);