Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1253925lqp; Sun, 14 Apr 2024 23:49:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV5XlbemB4fAiobgPXBTrt0UbhBY/0XSdVF0nSlxUaOPZnnoWlZ0MQznHYg5SeMo7dODPNAHhZ6Frzf/gVtWPR2v3QEc3RalNlmzU41bw== X-Google-Smtp-Source: AGHT+IGqwBvgC6VLKovPmCWH7Qzh/YrBsuk+6g+3sJlRhk8KrrFZ6kN+BqOjZp+srbFP36ZhU5MN X-Received: by 2002:a05:622a:308:b0:434:bc33:a0fd with SMTP id q8-20020a05622a030800b00434bc33a0fdmr12169744qtw.13.1713163763596; Sun, 14 Apr 2024 23:49:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713163763; cv=pass; d=google.com; s=arc-20160816; b=DqYd2IvkdjZo/Olj8cBSyW+BOJKoTqf+eDuTzT6jtOqetHaF2fEeU7AgygCFMkhb69 neJ0XZx/G9JNkwvq/fApcNbMfC4tTyDOlWiFFEPm7KqqKmpG8m+vly89r3JhLDFuu4Sj 3ERTAALn/5V/agaDCWDvgTQM3iWYq4AzNdnyVwWiOPO5pisJnQSm2KhE8Mn4Bc4Bb86z 1kmOMVSCV4+Xxordeje6tJKbeDdVV6FAQAmIguiSJ6hrjGfRmFW9HkiS3D0ZwLbZFepQ vmhkAhU9KUvJNpPR2M3/H2RDXQjnmqewzpEghbBrgQmVtkp+xMoFg+LgRAaluI042LGo eDsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=DErZWi0JRkT/kr88yhBbwPniJ+j3I4IxiglXEXSEUgM=; fh=e1EGlh0sQtuTs1oHdudsV9/WmU9MGdFyUe8PIzozpXY=; b=wDIM/7zHM7bf4JT8vWZLg4TcgCvzQ2FdqZHLOqdRyg7sQJpJ7eQXBMof0/TGrm5ZGV mW5Y13OlSPPKcfC7Kz8000XZgXR8Zd+lViu9s6b66zKW0j0UhKuz72oevzQ1XUp40sB7 5/C9kmUV8NuCj3r+V5N16LijR1fcCMl+dBd6dMNwYfC0gmzNmGN6GznxBKy7aksrbheI JkRjqIw/Mo6UGA775FvMWZ+NZo3gWqN6P4O78yGhKoAOrRQ3/ZWU7OSYbP7AWiiFQkun obtaHp0t32PrGJIYYkA7pSa04um1Dg9PWHos50NG6szGBitnk7DQB5HTOW+VS/ALrkXd g60Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=GiyZ9NhV; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-144608-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144608-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id cb9-20020a05622a1f8900b00437234ee48asi163925qtb.686.2024.04.14.23.49.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Apr 2024 23:49:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144608-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=GiyZ9NhV; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-144608-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144608-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 56F8D1C21FDF for ; Mon, 15 Apr 2024 06:49:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 83533200BF; Mon, 15 Apr 2024 06:49:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="GiyZ9NhV" Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 204681D53F for ; Mon, 15 Apr 2024 06:49:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713163753; cv=none; b=kyeS/Cd+AGuJp/c0YNyqiv6IH/73YpFfdK/utL3kus4CTFpwLNWxr+iaknx3esjQx5hjrRIxx1ZfGEFcH7aNGoyE2+2Svnc/oAEk8m362gk6lcyCHwL4vc+33oXLnK5Lbd9kw8aZpgyDJPlSmFsVcqAXaRTVq848QLWgI1YWdeA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713163753; c=relaxed/simple; bh=5liYRdehCxf/qgC8OqFtGeudno/7H0JcP2nubfjgSn0=; h=From:To:Cc:Subject:Date:Message-Id; b=U7NbzgQH5t6gl9UzELWjnxg6unWb3kCwH20pzje1BAySk1my1LZqLkUXTVOS3YhJy+4agO4LlHQsNYo1OYtGObptgxuUPbeP1/KPoWViG7djWLJaee/pI4xQXBYAdbb5kLhZKlJ+z+IIKzaeviGVm9brBZb1ECavNROOYubVV34= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=GiyZ9NhV; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6ecf1bb7f38so2552076b3a.0 for ; Sun, 14 Apr 2024 23:49:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1713163750; x=1713768550; darn=vger.kernel.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DErZWi0JRkT/kr88yhBbwPniJ+j3I4IxiglXEXSEUgM=; b=GiyZ9NhVSKfgRFdZalM+OYGvYXOBpGhyw5eMnmk7ufdHa2HTeKs5Ay0w/guXrcuUzR zooenl1PuiQZpagpcgdrrE4JhLiIcr/RAHYvOLX/znoEY9EzPtlQA9Rr5geoShNKxEtJ dV4/6LGlZLvXvO+5k83+t/WMa2gdMmZVXPu6Q6QoTUHX2l+OMQoOZ+erYGXOcUI+fZfK qKgddMDcatYkJUJNiNQe/XcmYOLFijj+bsA6OknyDlX6lKZARphcdNwGiOsclmcSNnKl olNac8Wwi7SGaVK3yHbIwpqjIQwKz5u+eUo94q4iE+8zdR5Hd6g0PlD0clW43F6AB4Z8 sw+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713163750; x=1713768550; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DErZWi0JRkT/kr88yhBbwPniJ+j3I4IxiglXEXSEUgM=; b=I4rIVmCEuJVMo4cF1AcPAMHoP7lo074Pvzdb8R6UFaAOqUoCkAkXxhdceJLsX3ZlTy OMDsRw4iiGLwZggZu9WUPl3tH9XMO4J+Lt7x3yv7i8+XCY5IFJmt2VqWonRlar2qDLYg oN5hrRZxCQJEDzYNJaGA2MtDsqal0ZGxJ9e7B7LQEcwsm4qLfCswxX5jbG7naQpTI645 8omdqBnciyEbscBCH07lpLAY0UPB8LumB4AcFbmylL9OxKE7BTyAFn51cG7p4//f9ON/ 9HqMlP+RP1XsbX1k8ayLkAT+TFVpKF+qeUYVxeAbu1LwE+uneVXDY2wJ+ZhiDsWmeq8m Wbxw== X-Forwarded-Encrypted: i=1; AJvYcCUdKX7YMk7e7jl4GYWVEie19JHeJQ+Ky0tqrj1LQxbuRBa5q5tEb3Khg/LVkycu6LzTYaaKWU1jdQa0U8azmwZp0nnKXD+3QXvK5RPy X-Gm-Message-State: AOJu0YxR+daRK6wOOMQWr92OMvfo6BroPHGmq8ZtKyhRdSrdrQiCMQ6V Ts7aG+1I1q7AhQvdDJsBUQhtCFt46k8kuGsURbEj1ZvvJDA670JHtntmph7A1wQ= X-Received: by 2002:a05:6a21:6da2:b0:1a9:4055:6dca with SMTP id wl34-20020a056a216da200b001a940556dcamr9192611pzb.40.1713163750420; Sun, 14 Apr 2024 23:49:10 -0700 (PDT) Received: from hsinchu26.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id f18-20020a170902ce9200b001e421f98ebdsm7148962plg.280.2024.04.14.23.49.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Apr 2024 23:49:10 -0700 (PDT) From: Yong-Xuan Wang To: linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org Cc: greentime.hu@sifive.com, vincent.chen@sifive.com, Yong-Xuan Wang , Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/1] RISC-V: KVM: No need to use mask when hart-index-bit is 0 Date: Mon, 15 Apr 2024 14:49:04 +0800 Message-Id: <20240415064905.25184-1-yongxuan.wang@sifive.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: When the maximum hart number within groups is 1, hart-index-bit is set to 0. Consequently, there is no need to restore the hart ID from IMSIC addresses and hart-index-bit settings. Currently, QEMU and kvmtool do not pass correct hart-index-bit values when the maximum hart number is a power of 2, thereby avoiding this issue. Corresponding patches for QEMU and kvmtool will also be dispatched. Fixes: 89d01306e34d ("RISC-V: KVM: Implement device interface for AIA irqchip") Signed-off-by: Yong-Xuan Wang --- arch/riscv/kvm/aia_device.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/riscv/kvm/aia_device.c b/arch/riscv/kvm/aia_device.c index 0eb689351b7d..5cd407c6a8e4 100644 --- a/arch/riscv/kvm/aia_device.c +++ b/arch/riscv/kvm/aia_device.c @@ -237,10 +237,11 @@ static gpa_t aia_imsic_ppn(struct kvm_aia *aia, gpa_t addr) static u32 aia_imsic_hart_index(struct kvm_aia *aia, gpa_t addr) { - u32 hart, group = 0; + u32 hart = 0, group = 0; - hart = (addr >> (aia->nr_guest_bits + IMSIC_MMIO_PAGE_SHIFT)) & - GENMASK_ULL(aia->nr_hart_bits - 1, 0); + if (aia->nr_hart_bits) + hart = (addr >> (aia->nr_guest_bits + IMSIC_MMIO_PAGE_SHIFT)) & + GENMASK_ULL(aia->nr_hart_bits - 1, 0); if (aia->nr_group_bits) group = (addr >> aia->nr_group_shift) & GENMASK_ULL(aia->nr_group_bits - 1, 0); -- 2.17.1