From nobody Sat Nov 23 21:01:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1730758996; cv=none; d=zohomail.com; s=zohoarc; b=YDN/DMhw/WuN8ewKzmTydzGgnkvL/otVLSko1OwK7vrEUITR/+LK3nUIzOLpNAh0sTJyzGRXDjYfYuNGy9gbkEQVWiCKP6h/njColB6/V/9cuXxoQqbMRxmzTvulZ5IFiyTphTc+0cf8WL3QSmirfoS2ik96K03MsiO8OEOpQPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730758996; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xOcpy6BRgMc6xnewM0r89Ss5p3pXoDrbvOahXHbomVw=; b=aWgkhJdChdpLY+Ko2J5N/qXytXePT/IowmwdfWopB0K+YS3x2XWHVU1IMWiyNnHRU162r4kxzw42MX90AoQam0Og81qKTJJexadNMYM1d7GLXd/nfIoymXrdYMeOt7qGxUSSKh1/YfR9cRHgNKuXMpBNJYmTBD0GoZ1wFYc6avY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730758996083852.463075928721; Mon, 4 Nov 2024 14:23:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t85T1-0005pi-0r; Mon, 04 Nov 2024 17:22:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t85Sy-0005m3-Qq for qemu-devel@nongnu.org; Mon, 04 Nov 2024 17:22:32 -0500 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t85Sx-0003pv-A7 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 17:22:32 -0500 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-723db2798caso1306085b3a.0 for ; Mon, 04 Nov 2024 14:22:30 -0800 (PST) Received: from linaro.. (216-180-64-156.dyn.novuscom.net. [216.180.64.156]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-720bc2eb76esm8146465b3a.154.2024.11.04.14.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 14:22:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730758950; x=1731363750; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xOcpy6BRgMc6xnewM0r89Ss5p3pXoDrbvOahXHbomVw=; b=TWyKs4EM8NagFJDajQJnqq+NeicVzn203yNvCWRNZYFkKCiysW1zIsIYFZqA+GvEA7 yaQsF6XKCbzcPIp5Qd+Zu+XeXhKpEtT/NKcXzEDgDfn+VFXWsWEFAaJxxhsBUpaq276K ApBPdE6oqv1DEe82A3PD91M9Ds4bUozvD6vo7fYV0IgWT/yQ0HeCitvOiBcFwF6A1Xjz E6S52DyAzcCzM/wNi8a3JcpqsRXeuY2Tr9KC8YRnmHa0N0V8ezJXn5XBDJGtoRSsXBj0 lDHgPCglfHmThlRBgew9nNgvJBvJQP83ea+3MnLAiSRoIZQkPnwh+B5WCZ7b6uFWFIf0 J90A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730758950; x=1731363750; 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=xOcpy6BRgMc6xnewM0r89Ss5p3pXoDrbvOahXHbomVw=; b=VNPF/jdPMKkyocMqkXBX0FgXzICvvQ9D3S2LbRGLLUpuJELrx9MwF4vFLi1JazK7SJ JhUNUdg9gvidMYblCT1xFaAMBDvnknfFzNiM+JY/LibcjkxOC4qqWVqtxV/5hjpaxFbb HNQTL7XLUfVdsruq8LtoRp3CnSPF8WxMBuSf/I/1v/lvdVNoyISQT61MdxVSEBjQ0ty+ 9NlDKMMPvUIbCJqB4BsJr1D5NZIbKona3t6dKLDf3yiDbvtVWNmNsgOKgc91FOyVmXK5 s4lREKKgjzPisKSPnnO9Q9rkIcxV470X16kfO6aV/XdBM5u92H6LtmCMzVUA8m14fmWH Ppog== X-Gm-Message-State: AOJu0YzbW0l/PVALCpDGjozDvt1qhPQmqBPBC3dEcn7qP5wkdaMdPeA0 FAf50zj7QVgSRV0fzAMvAxlQhDyhF0xHu9K/tJofpiXjPGkMDGaILvNNh113ff8ephK0Da/FF67 dvS3t2A== X-Google-Smtp-Source: AGHT+IGutZwsUsx+khBWnYbs4LvGgFdZDrJ51/t0mm32rYPT2fxykQvhIlqKCKH53gkiH8x49k86Vg== X-Received: by 2002:a05:6a00:2e93:b0:71e:41b3:a56b with SMTP id d2e1a72fcca58-720ab4c5d9bmr27670702b3a.24.1730758949707; Mon, 04 Nov 2024 14:22:29 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Bin Meng , tjeznach@rivosinc.com, qemu-riscv@nongnu.org, Alistair Francis , Palmer Dabbelt , pbonzini@redhat.com, Daniel Henrique Barboza , peter.maydell@linaro.org, Cameron Esfahani , Weiwei Li , Liu Zhiwei , Pierrick Bouvier Subject: [PATCH v2] hw/riscv: fix build error with clang Date: Mon, 4 Nov 2024 14:22:25 -0800 Message-Id: <20241104222225.1523751-1-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pf1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1730758997116116600 Content-Type: text/plain; charset="utf-8" Introduced in 0c54ac, "hw/riscv: add RISC-V IOMMU base emulation" ../hw/riscv/riscv-iommu.c:187:17: error: redefinition of '_pext_u64' 187 | static uint64_t _pext_u64(uint64_t val, uint64_t ext) | ^ D:/a/_temp/msys64/clang64/lib/clang/18/include/bmi2intrin.h:217:1: note: pr= evious definition is here 217 | _pext_u64(unsigned long long __X, unsigned long long __Y) | ^ After a conversation on the mailing list, it was decided to rename and add a comment for this function. Signed-off-by: Pierrick Bouvier Reviewed-by: Alistair Francis Reviewed-by: LIU Zhiwei --- hw/riscv/riscv-iommu.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/hw/riscv/riscv-iommu.c b/hw/riscv/riscv-iommu.c index feb650549ac..12f01a75f5d 100644 --- a/hw/riscv/riscv-iommu.c +++ b/hw/riscv/riscv-iommu.c @@ -183,8 +183,25 @@ static void riscv_iommu_pri(RISCVIOMMUState *s, } } =20 -/* Portable implementation of pext_u64, bit-mask extraction. */ -static uint64_t _pext_u64(uint64_t val, uint64_t ext) +/* + * Discards all bits from 'val' whose matching bits in the same + * positions in the mask 'ext' are zeros, and packs the remaining + * bits from 'val' contiguously at the least-significant end of the + * result, keeping the same bit order as 'val' and filling any + * other bits at the most-significant end of the result with zeros. + * + * For example, for the following 'val' and 'ext', the return 'ret' + * will be: + * + * val =3D a b c d e f g h + * ext =3D 1 0 1 0 0 1 1 0 + * ret =3D 0 0 0 0 a c f g + * + * This function, taken from the riscv-iommu 1.0 spec, section 2.3.3 + * "Process to translate addresses of MSIs", is similar to bit manip + * function PEXT (Parallel bits extract) from x86. + */ +static uint64_t riscv_iommu_pext_u64(uint64_t val, uint64_t ext) { uint64_t ret =3D 0; uint64_t rot =3D 1; @@ -528,7 +545,7 @@ static MemTxResult riscv_iommu_msi_write(RISCVIOMMUStat= e *s, int cause; =20 /* Interrupt File Number */ - intn =3D _pext_u64(PPN_DOWN(gpa), ctx->msi_addr_mask); + intn =3D riscv_iommu_pext_u64(PPN_DOWN(gpa), ctx->msi_addr_mask); if (intn >=3D 256) { /* Interrupt file number out of range */ res =3D MEMTX_ACCESS_ERROR; --=20 2.39.5