From nobody Wed May 8 08:20:40 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633453951; cv=none; d=zohomail.com; s=zohoarc; b=gq4I+mkqfhF5v8lMxGq5qTr3QBXAgMZd5YA09Y3Xq8Y09ANiv4+QhixH/p0UlYwHqblteiDkoGWVj6JFFTzH1PnWHKKLaJ16pUaGiSsHhdH9uDnW88C6DtpSpz1JKuBnvQQOTAmsKWcBIeB4seMCqxvH9h+tUPRjFLF0JGhxU0w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633453951; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hoAsOcICaDiNobBhDkgg+vqDQALYK1r5xTzLqWDdXc8=; b=dZXeHGZFrFS90hRo0r7uUyAdAsoIHsx87CYR85lqDug0ffGZefHNyuvNBE4hgCIuLaan41E+Z4vbN03E1lVW/l50J+86VqQ1VVV7H5jdZq16SVzLAElnHjjK6qx072E8XYgo4ZAZzLQyShys9rreYC6/AtQXlE7Rvo+UNcHuviY= 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 163345395192548.718869590560644; Tue, 5 Oct 2021 10:12:31 -0700 (PDT) Received: from localhost ([::1]:59964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnzS-0007Bh-Hq for importer@patchew.org; Tue, 05 Oct 2021 13:12:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvH-00024y-Od for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25132) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvF-00071P-NU for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:07 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-417-F-PQp7nTPx2NO8L-WlC8hg-1; Tue, 05 Oct 2021 12:00:50 -0400 Received: by mail-wm1-f72.google.com with SMTP id f11-20020a7bcd0b000000b0030d72d5d0bcso1456566wmj.7 for ; Tue, 05 Oct 2021 09:00:50 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id b19sm299483wmb.1.2021.10.05.09.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hoAsOcICaDiNobBhDkgg+vqDQALYK1r5xTzLqWDdXc8=; b=fpCsK1K9P6JcKiwYHrL3vyNyQctv3aH3CGehscoJEQZqhNA4UarKVP39ngwvT2OWMSE9KV W5B+cNH8PSKrmKJP6wqgINAX7/DXlsG4l9ADu1gz4FqDG8r8W8lkAGsSLI/XrlqNisrqce pBYXnEvT5ktns9Bm4zaHFvhjSVjg1ow= X-MC-Unique: F-PQp7nTPx2NO8L-WlC8hg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=hoAsOcICaDiNobBhDkgg+vqDQALYK1r5xTzLqWDdXc8=; b=8ANKtxedP4ICn4sHkLcAVA7BvtxkFiigWiuJ3rkFJ7FU7ES+0khLjcApHY4toaBmos G1Oslif0ae8L8PkU+E33Uxa8kq7UkfXto8KslZRer8FbOu8/Cpu/z/aA61t3hDbIkh3q u7pH3roMDT4ETQVmYTf0LCyVqjc3wKLt789Jcb0EpvKz+zUqZHebj8R1/D36drf615Qn pPF2YgtSD764OYfpyT0FoNs9f9SE+g5Hz1O4izj6VKYbU1q8uUn+FD0I8Bw5S90E2UkH aGVZ70IL4md4z8hJV29c+fhVlWKhvq5R04OefWWfmgp/zM5sTMSpezMtLFTy7b1v/CJm E7rA== X-Gm-Message-State: AOAM530I3sWbozD0lMzsdl53fu7B7NYuzoCR9cEjS57/dSTgEb0PM0l3 WWoBckMCmnw7GzpLQXfxSiAGn0pHs72niUt/ekQgrijlqm/HUWt7knNYa/FHzXYpEg0sIdRv+Gl 0hJ4T6NNQezz0j1sbA9leV1hoOAOVFgjCubXWu2urQghQeEu4SIRlLfkl7Nln X-Received: by 2002:adf:bb88:: with SMTP id q8mr22588686wrg.390.1633449648660; Tue, 05 Oct 2021 09:00:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFG7i0LBhWZa/z8FAcj0xfdN1o7vTaWNSUy+TbtzAR44YMmhJVZ+hKI2U83zOosTh6Xvw3sA== X-Received: by 2002:adf:bb88:: with SMTP id q8mr22588639wrg.390.1633449648315; Tue, 05 Oct 2021 09:00:48 -0700 (PDT) Date: Tue, 5 Oct 2021 12:00:45 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 01/57] hw/virtio: Acquire RCU read lock in virtqueue_packed_drop_all() Message-ID: <20211005155946.513818-2-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633453953907100001 From: Philippe Mathieu-Daud=C3=A9 vring_get_region_caches() must be called with the RCU read lock acquired. virtqueue_packed_drop_all() does not, and uses the 'caches' pointer. Fix that by using the RCU_READ_LOCK_GUARD() macro. Reported-by: Stefano Garzarella Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210906104318.1569967-3-philmd@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefano Garzarella --- hw/virtio/virtio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 240759ff0b..dd0ab433b8 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1703,6 +1703,8 @@ static unsigned int virtqueue_packed_drop_all(VirtQue= ue *vq) VirtIODevice *vdev =3D vq->vdev; VRingPackedDesc desc; =20 + RCU_READ_LOCK_GUARD(); + caches =3D vring_get_region_caches(vq); if (!caches) { return 0; --=20 MST From nobody Wed May 8 08:20:40 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633450668; cv=none; d=zohomail.com; s=zohoarc; b=cPinC7kD5MuEBQ0fbscRLeN6u0zZbXvJsWVKY7HjXVRIfqSsUbNySS/1e1ITNXVm72u6chmH8/gv+Hk5IosK2rYx1jyy0t9M0xrmCv1CZNX0UeqXSQvOSNpuShgg96uMRnmRvK99sSZvanV7WF6JKNuphcnUaYTYfNFzbXxgXJA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633450668; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Q07SOpmoWMqQkr35xa7p8RNS09DTdrXyjxTlsEer860=; b=gNNKizIMS0hQvY8f+xzedMSnGylqivAyYZS++r5avQD5Qiah38hz72jr+syqJT0pfNJogJLKtvnwx+GJ4sWZzZLyBjplSijS1C/YI3BRSgeSLyqopxoBMMNvRuYFsteSfVWq+YChmj1yeeHLEt5hNsfvFBnXRuXyfCyenwniimk= 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 1633450668766825.2779386380652; Tue, 5 Oct 2021 09:17:48 -0700 (PDT) Received: from localhost ([::1]:52324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXn8V-0006yC-Pt for importer@patchew.org; Tue, 05 Oct 2021 12:17:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46708) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsK-0008Mx-3z for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25252) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsD-0004VP-TC for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:00:59 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-348-qGpp_669Mfm8DrRlw6lFxQ-1; Tue, 05 Oct 2021 12:00:54 -0400 Received: by mail-wm1-f71.google.com with SMTP id 10-20020a05600c240a00b0030d403f24e2so1481770wmp.9 for ; Tue, 05 Oct 2021 09:00:53 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id z17sm2279396wml.24.2021.10.05.09.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449655; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q07SOpmoWMqQkr35xa7p8RNS09DTdrXyjxTlsEer860=; b=Draewtqr08KKmN3TeWagnjXB3VVgf+e1e3+nT8KWgRPN8tkqAVzWdjU2b/LbFOTsTES7q2 WYh/ZWxNEetWyMapTUieaKU3CK4o32aUYBk2lhwJnwwSBY69nfGKodA+Oa+SvZVvMVoT96 pm5WStLZBrpJmuIS20bj6eVVZvPR3HI= X-MC-Unique: qGpp_669Mfm8DrRlw6lFxQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=Q07SOpmoWMqQkr35xa7p8RNS09DTdrXyjxTlsEer860=; b=6irRwOlFvKlPTY0oNqYDkbDZXrpFSakkLzn8FDGKLoxLOny2pneR6OTAYAfjvnwGR8 rBa/Ij4UUvt/HVKZlKRTlerE4SSxdSdXLyfSQ1IfCunnmYbx6KLU9DXw7dblvNoUWXBv nm6/B1uno45XhX1WwkCVv82eGbenRRjvGeTrMpbPeX4CquxSvMqUc//WG4uSvrDEcGad 1eyxaGFPpcpUr22CKTSCpHxslZyKuw88Y4gg0E0912evZM7mrEGTymlnTbB05CJuvHHP EqtmhAsr4ulQeNcvKAyr9tKC9+yYaO7mJk+/9/3LzoXO1jyGaytLgPKLSwFLOt3OPXIU a39Q== X-Gm-Message-State: AOAM531MEmVrpNsKoTbaA4x4cneZAqHGBz0vCCXU2xyjJk2TjPi/qdcK aSqbfSRNRXcwwmUdwvmS3wa04jDBqDhLYGo65yGQx6Y0YAFPBMTEayt84vPjx9lV2uV6vTkCDCT 2pmRVylFhyzXTxwJJMYmQgh2oMvT0Yo2lt756ImpZlywfhoI3bRruOjF7cdkH X-Received: by 2002:a7b:c048:: with SMTP id u8mr4250612wmc.113.1633449652345; Tue, 05 Oct 2021 09:00:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7+3CLrpx7AdXXsn8wIlHw9N4N81vuYyusbvLmwYiKFT9TTzDCoQiFrOBDtoKVchki5QGg7g== X-Received: by 2002:a7b:c048:: with SMTP id u8mr4250585wmc.113.1633449652059; Tue, 05 Oct 2021 09:00:52 -0700 (PDT) Date: Tue, 5 Oct 2021 12:00:48 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 02/57] hw/virtio: Have virtqueue_get_avail_bytes() pass caches arg to callees Message-ID: <20211005155946.513818-3-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633450669604100001 From: Philippe Mathieu-Daud=C3=A9 Both virtqueue_packed_get_avail_bytes() and virtqueue_split_get_avail_bytes() access the region cache, but their caller also does. Simplify by having virtqueue_get_avail_bytes calling both with RCU lock held, and passing the caches as argument. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210906104318.1569967-4-philmd@redhat.com> Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefano Garzarella --- hw/virtio/virtio.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index dd0ab433b8..cc69a9b881 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -984,28 +984,23 @@ static int virtqueue_split_read_next_desc(VirtIODevic= e *vdev, VRingDesc *desc, return VIRTQUEUE_READ_DESC_MORE; } =20 +/* Called within rcu_read_lock(). */ static void virtqueue_split_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes, unsigned int *out_byte= s, - unsigned max_in_bytes, unsigned max_out_bytes) + unsigned max_in_bytes, unsigned max_out_bytes, + VRingMemoryRegionCaches *caches) { VirtIODevice *vdev =3D vq->vdev; unsigned int max, idx; unsigned int total_bufs, in_total, out_total; - VRingMemoryRegionCaches *caches; MemoryRegionCache indirect_desc_cache =3D MEMORY_REGION_CACHE_INVALID; int64_t len =3D 0; int rc; =20 - RCU_READ_LOCK_GUARD(); - idx =3D vq->last_avail_idx; total_bufs =3D in_total =3D out_total =3D 0; =20 max =3D vq->vring.num; - caches =3D vring_get_region_caches(vq); - if (!caches) { - goto err; - } =20 while ((rc =3D virtqueue_num_heads(vq, idx)) > 0) { MemoryRegionCache *desc_cache =3D &caches->desc; @@ -1124,32 +1119,28 @@ static int virtqueue_packed_read_next_desc(VirtQueu= e *vq, return VIRTQUEUE_READ_DESC_MORE; } =20 +/* Called within rcu_read_lock(). */ static void virtqueue_packed_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes, unsigned int *out_bytes, unsigned max_in_bytes, - unsigned max_out_bytes) + unsigned max_out_bytes, + VRingMemoryRegionCaches *cach= es) { VirtIODevice *vdev =3D vq->vdev; unsigned int max, idx; unsigned int total_bufs, in_total, out_total; MemoryRegionCache *desc_cache; - VRingMemoryRegionCaches *caches; MemoryRegionCache indirect_desc_cache =3D MEMORY_REGION_CACHE_INVALID; int64_t len =3D 0; VRingPackedDesc desc; bool wrap_counter; =20 - RCU_READ_LOCK_GUARD(); idx =3D vq->last_avail_idx; wrap_counter =3D vq->last_avail_wrap_counter; total_bufs =3D in_total =3D out_total =3D 0; =20 max =3D vq->vring.num; - caches =3D vring_get_region_caches(vq); - if (!caches) { - goto err; - } =20 for (;;) { unsigned int num_bufs =3D total_bufs; @@ -1250,6 +1241,8 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigne= d int *in_bytes, uint16_t desc_size; VRingMemoryRegionCaches *caches; =20 + RCU_READ_LOCK_GUARD(); + if (unlikely(!vq->vring.desc)) { goto err; } @@ -1268,10 +1261,12 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsig= ned int *in_bytes, =20 if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED)) { virtqueue_packed_get_avail_bytes(vq, in_bytes, out_bytes, - max_in_bytes, max_out_bytes); + max_in_bytes, max_out_bytes, + caches); } else { virtqueue_split_get_avail_bytes(vq, in_bytes, out_bytes, - max_in_bytes, max_out_bytes); + max_in_bytes, max_out_bytes, + caches); } =20 return; --=20 MST From nobody Wed May 8 08:20:40 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633451280; cv=none; d=zohomail.com; s=zohoarc; b=mn9hZdn69xs1lr07498CCeQGHSWXmJ/3VSHEbe5rtb15KOH+v2pmm8+oi9GZzD2hrVaVjXyiaELBmLz4OW7SOh2E31U8a2rh6usd7HQDXyOt0xUo+9llIRvhatSSKyal15kXS4by6Hgf+86GJ8uFJQ69LGxrlDpmNKK0CHmmZAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633451280; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/2tyMA4ubaOTmCnsG3GSjYJgJRE9OF4GDfIrA22J2bo=; b=ZU/TuRfwnk21DVZaVZxLQ2YXa3ZOAcLaEPnVMNahXT/YaK9Ge1kin6Z0Zt06LTCQqt8zujlVDXbs+bBYBbJyG89SbV9tFsA4GelW1nEMgVaUmWYLpSOz9pvHIBOJ37C9ju9iqzTnYnTwvgcMu7CbghF72oi1GyXQwaBQOPA08bA= 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 1633451280816522.6401769467097; Tue, 5 Oct 2021 09:28:00 -0700 (PDT) Received: from localhost ([::1]:46030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnIN-0004zN-RG for importer@patchew.org; Tue, 05 Oct 2021 12:27:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsP-0008Po-Fu for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30014) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsJ-0004Yj-4l for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:08 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-235--BqDjZ0TP3uHTOQDoBPxzA-1; Tue, 05 Oct 2021 12:00:58 -0400 Received: by mail-wm1-f70.google.com with SMTP id h24-20020a7bc938000000b0030d400be5b5so6530237wml.0 for ; Tue, 05 Oct 2021 09:00:56 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id q3sm2192119wmc.25.2021.10.05.09.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:00:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449659; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/2tyMA4ubaOTmCnsG3GSjYJgJRE9OF4GDfIrA22J2bo=; b=Tc5CWlP3XSS/pAzFNH1Kmm7qMMMQCbhNX+qCpzvD8WreGU17/qxptc6dLLpCUNapB3V7I/ h51/vQ5Y8uqxuV/xPU1dVkHcLgA/IlxRMBeKRzOpWBONPryfRaVW3tjuar9Alf3aL3d8Iz 85E8bTeDFcV5ymWirbRTlJVk+4pKSnA= X-MC-Unique: -BqDjZ0TP3uHTOQDoBPxzA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/2tyMA4ubaOTmCnsG3GSjYJgJRE9OF4GDfIrA22J2bo=; b=q5aNbBpGMztbv9u1TJhHzt1qN7Xif2Pr7Elmq6/kJrdhKb8ea0jTutAVEvwyVfg4RR vm45R0M5I3BpOiH7hakT/eylvykTgn5Ll4ZDeTOP7mpFkz/6/3+ExBdOjzw+SyMv0Ecx K6XTXnveQ0KhBqqa5qSvsaDT/xdJyHcw4+cPoc1kZKiQO1Xd1zNW8vDw4K17pxdYQxEO Djt+wdQTH/7BtqIFVPoxsxnwaTadB/5JdcUJg7uYkKxhScvOyUjgy9H3BwDcc3aF1SMa a1kxi0lNfr7TPcZtFSYNnJABKp+gwMvnrHu0EF3ovBbbWiRdmD7L4pWRtsNiLboFEFQ1 v4dQ== X-Gm-Message-State: AOAM531LzL0QuKaxUKr04YchQe8zJpTuRbPE/zYp8/JTIHSG3/euJDHw LZNY6jfRDd+AK15VHaeiBL4xog4BRm0gDApwjeXc+if/3KY+ru9aOQOMZeQ7tuuDhERHiHdRdDo UY9qjtJz/QhOg97HKy31pGXJBoS2buiKRuEz+Prk/U088s5oy7EQYT/gERZ1B X-Received: by 2002:a05:6000:1866:: with SMTP id d6mr22016648wri.205.1633449655506; Tue, 05 Oct 2021 09:00:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJlyJqdWdEnIrLseRw3VwrK3XxkvGTm/ZgAyeTSTmji6PNQ4mf5+ykKko8wgq1lyr511TM+w== X-Received: by 2002:a05:6000:1866:: with SMTP id d6mr22016612wri.205.1633449655279; Tue, 05 Oct 2021 09:00:55 -0700 (PDT) Date: Tue, 5 Oct 2021 12:00:52 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 03/57] vhost-vdpa: open device fd in net_init_vhost_vdpa() Message-ID: <20211005155946.513818-4-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633451282191100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang This patch switches to open device fd in net_init_vhost_vpda(). This is used to prepare for the multiqueue support. Reviewed-by: Stefano Garzarella Signed-off-by: Jason Wang Message-Id: <20210907090322.1756-2-jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 912686457c..73d29a74ef 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -156,24 +156,19 @@ static NetClientInfo net_vhost_vdpa_info =3D { }; =20 static int net_vhost_vdpa_init(NetClientState *peer, const char *device, - const char *name, const char *vhostdev) + const char *name, int vdpa_device_fd) { NetClientState *nc =3D NULL; VhostVDPAState *s; - int vdpa_device_fd =3D -1; int ret =3D 0; assert(name); nc =3D qemu_new_net_client(&net_vhost_vdpa_info, peer, device, name); snprintf(nc->info_str, sizeof(nc->info_str), TYPE_VHOST_VDPA); s =3D DO_UPCAST(VhostVDPAState, nc, nc); - vdpa_device_fd =3D qemu_open_old(vhostdev, O_RDWR); - if (vdpa_device_fd =3D=3D -1) { - return -errno; - } + s->vhost_vdpa.device_fd =3D vdpa_device_fd; ret =3D vhost_vdpa_add(nc, (void *)&s->vhost_vdpa); if (ret) { - qemu_close(vdpa_device_fd); qemu_del_net_client(nc); } return ret; @@ -201,6 +196,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, NetClientState *peer, Error **errp) { const NetdevVhostVDPAOptions *opts; + int vdpa_device_fd, ret; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); opts =3D &netdev->u.vhost_vdpa; @@ -209,5 +205,16 @@ int net_init_vhost_vdpa(const Netdev *netdev, const ch= ar *name, (char *)name, errp)) { return -1; } - return net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, opts->vhostdev= ); + + vdpa_device_fd =3D qemu_open_old(opts->vhostdev, O_RDWR); + if (vdpa_device_fd =3D=3D -1) { + return -errno; + } + + ret =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_f= d); + if (ret) { + qemu_close(vdpa_device_fd); + } + + return ret; } --=20 MST From nobody Wed May 8 08:20:40 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633450824; cv=none; d=zohomail.com; s=zohoarc; b=THUb1Ixc7a2+LoNyytRTzeItlNLZVyJNexmBBhQ4kyJ//7JcrMovC7nFv29s5z6Jgn6gtpp09z4OV7GhemjVOrrEPNBt6ZYkZdIX02J+Gj0cUX023nhi7HhX9qlroqmz8VnrCEtT9V/AQfP82X0xJKREGxxQpbhUFui5kvqvBJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633450824; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fh2VpJXcxJxzBAVFO9OEfTC6q1W7DfmN4tRkON1Y0l0=; b=ENqMk1GaUTWa3iPF+hUUobFTOKt7Vk0TpuXf+5wC+dE+YAS+PBST92LTmhVc7OgmL3/J3+D8hOlUee3YT+MacF+pdy1NeZ+b+i0NmkflElFu3QgaitemV2AHBIyahURuKcuKMqdUWmiw3b2kZAJwTCap+TSUX6ZBaMlpRYrd4KU= 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 16334508242081003.7397616448327; Tue, 5 Oct 2021 09:20:24 -0700 (PDT) Received: from localhost ([::1]:57004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnB0-0001dn-Ou for importer@patchew.org; Tue, 05 Oct 2021 12:20:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsN-0008O2-GF for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44089) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsJ-0004bK-LA for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:07 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-507-XpsgrE3sP1-H_pTJyA4mXg-1; Tue, 05 Oct 2021 12:01:00 -0400 Received: by mail-wm1-f71.google.com with SMTP id 75-20020a1c004e000000b00307b9b32cc9so1118435wma.1 for ; Tue, 05 Oct 2021 09:01:00 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id y6sm7157068wro.63.2021.10.05.09.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449662; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fh2VpJXcxJxzBAVFO9OEfTC6q1W7DfmN4tRkON1Y0l0=; b=gWigkoRY88lRG9EY3+JM9eXNGNgVuARhbCgcsaUkbn8izrjqgFnJDZWtqI4zuSC1KCRjrz XtpViXfNXReyC1VTOC/H/k7VWweVKNNYIBJmzogAGc93/fmG9MdL9ibbAS89iBVnUpbpgj 8wQquBGGs7zHfuDUDCAd628QsyIbv+A= X-MC-Unique: XpsgrE3sP1-H_pTJyA4mXg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=fh2VpJXcxJxzBAVFO9OEfTC6q1W7DfmN4tRkON1Y0l0=; b=yE6m5pUIGzo4kezeLJsZCeLmJa0CaZmlEvdbqdwSj4ZsiP2yMP3w4XQXzxwiMrijYv EvDYNtRI1kZfYBDPQ6cFMiqz/ZTvPr/8kfws1i2bXhqjLU/ED9lFzwsZBsyYkCXPONEn Gv6Tmb4otyKKuWQ26ioYdwUd4FnGeTE275lNQ3mxnfGtCDjaJbkcKbveDQbE9AWA5cDl WJ2i5O22gITPKNPk89mdPs4ML9W7dWgbaclCXdNnHFi7lPgoe6enCup3aMW5EbwttsJA TtciOKBRhNATnulV2Xtgq7CJr0VQpwdwhhbElxZNfRRdZcyq1FT2j7xUi5nEEWgYXPXq CFeA== X-Gm-Message-State: AOAM533hrD+TM6B0U9dqNnPAboRqD7dx+j5apj1DyH7p9iGIF7w1hidX aPFQjeoG5m4QV3jlWwCQBEL+qDPN9L3xJl6v6EJqmmfuXSaQqwTnoVySGezoFc+0ADS1LGjvRpk CdkSITqfcwKxQKjPTf1IrOBxfe8TmYhzYWOhZBdLBnCb/yUE5tOMb0Wdkbc45 X-Received: by 2002:a05:600c:1553:: with SMTP id f19mr4364147wmg.66.1633449658826; Tue, 05 Oct 2021 09:00:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxl5yHJwhofQS9dq0CCX8L+VKJiWobW9rsU0NzAXMJmT6zS/EkcE7PDezTnrizjd6rF8uvfHQ== X-Received: by 2002:a05:600c:1553:: with SMTP id f19mr4364125wmg.66.1633449658626; Tue, 05 Oct 2021 09:00:58 -0700 (PDT) Date: Tue, 5 Oct 2021 12:00:55 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 04/57] vhost-vdpa: classify one time request Message-ID: <20211005155946.513818-5-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633450826287100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang Vhost-vdpa uses one device multiqueue queue (pairs) model. So we need to classify the one time request (e.g SET_OWNER) and make sure those request were only called once per device. This is used for multiqueue support. Signed-off-by: Jason Wang Message-Id: <20210907090322.1756-3-jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-vdpa.h | 1 + hw/virtio/vhost-vdpa.c | 52 ++++++++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index a8963da2d9..6b9288fef8 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -21,6 +21,7 @@ typedef struct VhostVDPAHostNotifier { =20 typedef struct vhost_vdpa { int device_fd; + int index; uint32_t msg_type; bool iotlb_batch_begin_sent; MemoryListener listener; diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 47d7a5a23d..edac4017da 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -279,6 +279,13 @@ static void vhost_vdpa_add_status(struct vhost_dev *de= v, uint8_t status) vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &s); } =20 +static bool vhost_vdpa_one_time_request(struct vhost_dev *dev) +{ + struct vhost_vdpa *v =3D dev->opaque; + + return v->index !=3D 0; +} + static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **er= rp) { struct vhost_vdpa *v; @@ -291,6 +298,10 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void= *opaque, Error **errp) v->listener =3D vhost_vdpa_memory_listener; v->msg_type =3D VHOST_IOTLB_MSG_V2; =20 + if (vhost_vdpa_one_time_request(dev)) { + return 0; + } + vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER); =20 @@ -401,6 +412,10 @@ static int vhost_vdpa_memslots_limit(struct vhost_dev = *dev) static int vhost_vdpa_set_mem_table(struct vhost_dev *dev, struct vhost_memory *mem) { + if (vhost_vdpa_one_time_request(dev)) { + return 0; + } + trace_vhost_vdpa_set_mem_table(dev, mem->nregions, mem->padding); if (trace_event_get_state_backends(TRACE_VHOST_VDPA_SET_MEM_TABLE) && trace_event_get_state_backends(TRACE_VHOST_VDPA_DUMP_REGIONS)) { @@ -424,6 +439,11 @@ static int vhost_vdpa_set_features(struct vhost_dev *d= ev, uint64_t features) { int ret; + + if (vhost_vdpa_one_time_request(dev)) { + return 0; + } + trace_vhost_vdpa_set_features(dev, features); ret =3D vhost_vdpa_call(dev, VHOST_SET_FEATURES, &features); uint8_t status =3D 0; @@ -448,9 +468,12 @@ static int vhost_vdpa_set_backend_cap(struct vhost_dev= *dev) } =20 features &=3D f; - r =3D vhost_vdpa_call(dev, VHOST_SET_BACKEND_FEATURES, &features); - if (r) { - return -EFAULT; + + if (vhost_vdpa_one_time_request(dev)) { + r =3D vhost_vdpa_call(dev, VHOST_SET_BACKEND_FEATURES, &features); + if (r) { + return -EFAULT; + } } =20 dev->backend_cap =3D features; @@ -559,11 +582,21 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev= , bool started) { struct vhost_vdpa *v =3D dev->opaque; trace_vhost_vdpa_dev_start(dev, started); + + if (started) { + vhost_vdpa_host_notifiers_init(dev); + vhost_vdpa_set_vring_ready(dev); + } else { + vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); + } + + if (vhost_vdpa_one_time_request(dev)) { + return 0; + } + if (started) { uint8_t status =3D 0; memory_listener_register(&v->listener, &address_space_memory); - vhost_vdpa_host_notifiers_init(dev); - vhost_vdpa_set_vring_ready(dev); vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &status); =20 @@ -572,7 +605,6 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, = bool started) vhost_vdpa_reset_device(dev); vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER); - vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); memory_listener_unregister(&v->listener); =20 return 0; @@ -582,6 +614,10 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev,= bool started) static int vhost_vdpa_set_log_base(struct vhost_dev *dev, uint64_t base, struct vhost_log *log) { + if (vhost_vdpa_one_time_request(dev)) { + return 0; + } + trace_vhost_vdpa_set_log_base(dev, base, log->size, log->refcnt, log->= fd, log->log); return vhost_vdpa_call(dev, VHOST_SET_LOG_BASE, &base); @@ -647,6 +683,10 @@ static int vhost_vdpa_get_features(struct vhost_dev *d= ev, =20 static int vhost_vdpa_set_owner(struct vhost_dev *dev) { + if (vhost_vdpa_one_time_request(dev)) { + return 0; + } + trace_vhost_vdpa_set_owner(dev); return vhost_vdpa_call(dev, VHOST_SET_OWNER, NULL); } --=20 MST From nobody Wed May 8 08:20:40 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633451047; cv=none; d=zohomail.com; s=zohoarc; b=dz5/oHzWAEeByyNtgSZDlPj4bAWC8v8VG6MKfiZDyrThHjvDHOAT+xD2fDD/4Pz/+XOckJWc5ezmKeUkWV1Fv8OrT2kp3jzLyaYJZc70cEM8Tum4R2wQ+4sdN2qa7DeGetwKckjNKxoacaNfm8+bVr5l0iujEVPIvllwh6DGk/k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633451047; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3fYa6vJLW2VmUzZYvrPmX+saUCEhMTSNzZACWsAw/4Q=; b=kVL69Yyyh2h7CPD9SkKqtdZg8E+ddos8+Dev7pPUvWJBsAx8A81HH+yveRj6hUGY6NUyM+0asQjFAZYvDFIjUS60Cqw+8H+gg676Ru4CopkBKTzrRV23bny4slkA9bs1oPhoHSpkQ2ngCLs2ALAh3LJCwmbPN0a19QenoTRht8U= 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 1633451047820441.2508082713679; Tue, 5 Oct 2021 09:24:07 -0700 (PDT) Received: from localhost ([::1]:37246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnEc-0007R8-OZ for importer@patchew.org; Tue, 05 Oct 2021 12:24:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsN-0008O1-DS for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23824) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsL-0004dv-OE for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:07 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-270-WvNToLLRO464PcI5AiX1sQ-1; Tue, 05 Oct 2021 12:01:03 -0400 Received: by mail-wm1-f69.google.com with SMTP id m9-20020a05600c4f4900b003057c761567so1500971wmq.1 for ; Tue, 05 Oct 2021 09:01:03 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id o12sm2995040wms.15.2021.10.05.09.01.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:01:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449664; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3fYa6vJLW2VmUzZYvrPmX+saUCEhMTSNzZACWsAw/4Q=; b=YF5iPDd/Xmwll4JfJTMO9teFDppC0HHB/jM9GWcyDT6m8Wr7Fn7UgxPCUwCv0MsY0R3jWm jY150vJFcRoNy+SIJEC4lkSlRBWow5qR7HUHP7vrgZ6GQS9qhsZkYKdDNvsxzs04KHdI+w q1AJLKMXdJLeZo2BAnITNrQ3lk21eig= X-MC-Unique: WvNToLLRO464PcI5AiX1sQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3fYa6vJLW2VmUzZYvrPmX+saUCEhMTSNzZACWsAw/4Q=; b=PhlEGoMqphysDKnqTRz8aSEVGNB9JBvbRR3bDG3hnwxEPAcECXdQXLGIfTi2u+j8WD +Ei2vyCp6A110O3z38jeKIL03fZkjjZ0x0xXiqLvCyLq7WAk1m6OuoTDsa0b5DugSzXX 5APDNnryG9jRU4w1radnbzsPyxPAoCJr61nzopPsXby0CAA5sRViji1FFwhmeJRVyK2U T92vQwjJulyQqyVEmXxkoCHCu8qUWELBIxsxgLUJRRQ6GwX9WoD9EwRM/R4i7D2031sa A/ZcHl6ujgNKhPNjAJZOfFlq4iQVQLFMJq5N1vVCDZgJ3Qh4PfEhFIzepFduOmmDyli2 sJUw== X-Gm-Message-State: AOAM533SRtJDrfTYbBVLxZK9bdwdbjWFkjtEa8EurDZM/pNd+3dhdT01 li+6yyLLsugkZS0INGDps1IFBxJCTfomVocQu7sW/a5CNolkyZsCXcQl1/0Cn19JvpC5QWEa5eh F0wP4K8dBmHAXz6Npyl6gzoD3w8/UiDgRzmeyyXdnjSAPlF7a2wWKvfFwh4Gi X-Received: by 2002:a7b:cd82:: with SMTP id y2mr4315894wmj.106.1633449662028; Tue, 05 Oct 2021 09:01:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbZcD03Hex8BrEAzzjN5PPcIhbuVC43tn2bYZQDLJC+5B2j2ThZH7UK9W8kD1ycHWxztPVDg== X-Received: by 2002:a7b:cd82:: with SMTP id y2mr4315859wmj.106.1633449661718; Tue, 05 Oct 2021 09:01:01 -0700 (PDT) Date: Tue, 5 Oct 2021 12:00:58 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 05/57] vhost-vdpa: prepare for the multiqueue support Message-ID: <20211005155946.513818-6-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633451048713100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang Unlike vhost-kernel, vhost-vdpa adapts a single device multiqueue model. So we need to simply use virtqueue index as the vhost virtqueue index. This is a must for multiqueue to work for vhost-vdpa. Signed-off-by: Jason Wang Message-Id: <20210907090322.1756-4-jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vdpa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index edac4017da..8587d30918 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -504,8 +504,8 @@ static int vhost_vdpa_get_vq_index(struct vhost_dev *de= v, int idx) { assert(idx >=3D dev->vq_index && idx < dev->vq_index + dev->nvqs); =20 - trace_vhost_vdpa_get_vq_index(dev, idx, idx - dev->vq_index); - return idx - dev->vq_index; + trace_vhost_vdpa_get_vq_index(dev, idx, idx); + return idx; } =20 static int vhost_vdpa_set_vring_ready(struct vhost_dev *dev) --=20 MST From nobody Wed May 8 08:20:40 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633454372; cv=none; d=zohomail.com; s=zohoarc; b=hBljJ6Wg9liNQsMkpBD8eEr56PzRM9YdogMVbEJkAb6hLZph4Vng7C38y+EzY9bnuB6rZbJj+aRUsy6PcU9Xs6UAfgmv6fG3n/3cNWe7hHWgILcOXhSe0s5R04KdNbsCMuSYqF7G1skBo/UdltvTIlZqv7PIzJQP3NpKBXLmYxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633454372; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g9Wr3YkTOKaztifTi4RRc4EZqPUFUqK9x43E/i+EsSw=; b=fScvNt2PLlvNpEIVF/B3zOPbGHsiZJSUC+dFLFaAUZPDn6dfySMVLXtnLbTOaNVAZvHc2OV7HBMHv4Al4Nd2OtWoPL0Io2PL3S4gYRd9aVmFCeAO6aVqYyXjVHt5kjs6ZdtaBnvgg3VSLGxCY6Sj5iLAGiivlxUYWkQCe03N+Gw= 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 1633454372816544.8843221255961; Tue, 5 Oct 2021 10:19:32 -0700 (PDT) Received: from localhost ([::1]:49064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXo6F-00028c-LM for importer@patchew.org; Tue, 05 Oct 2021 13:19:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvR-0002BL-MC for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56588) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvF-00070x-ML for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:17 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-PbKWSs5eNnO90ATZAp23sQ-1; Tue, 05 Oct 2021 12:01:07 -0400 Received: by mail-wr1-f71.google.com with SMTP id a10-20020a5d508a000000b00160723ce588so5866451wrt.23 for ; Tue, 05 Oct 2021 09:01:07 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id t16sm2657110wmi.33.2021.10.05.09.01.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:01:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=g9Wr3YkTOKaztifTi4RRc4EZqPUFUqK9x43E/i+EsSw=; b=DOA/da5XP/o1SgBhhfm+EHgCTIHJTQoU8sIqb/4fz4al+JX16PU9JJ8KyVnUKzGmYA01Qp eYt9gIzb9id/OokMwdSw1dyfIKVM4WOCBAdFLmT3WG3QxfDqP75ZwmuMgrw7GUGiaa2+Is l19H7DZQnvx0mCzPYJg4XNk4IT+s7Cg= X-MC-Unique: PbKWSs5eNnO90ATZAp23sQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=g9Wr3YkTOKaztifTi4RRc4EZqPUFUqK9x43E/i+EsSw=; b=KWv4jp8j6lTlQE1Icbc6BHo/eKhurA6bfI/muBOrn1OQFpLSjj42V3lCaS9IeKnBXz NVPFk+i17EBK1movnKdX1LZdu4VFb3ssqpKNsFLlIcag3uEW3XFpfKe4fo3b5O3u9zFJ wTIpwlLAsXzvjHd5regXFct0WC8Sd+/7Ng5OyvLT5qyjDVPsZ6/iXnD6RmOAudifkc3l M0PENnI0/vu0XljnrneAc2qs2l7tcz7tvArBERroBOJ5v7YzcscTDGSLae9yuKhTf5vH xk0tBHvklbJtvrj1kiBHB2Z3NMp+gykgt+94B8qCK6s6vNmJpN/99PfQqguqybsMKLyt 7Usw== X-Gm-Message-State: AOAM532rb2KTuZjUKBDW47mdvhRAxX+RDgjuIy1Ga6+4A0SW1AKBDsGE rBshMCY2rT7X7s5DSyKNbZDrJiKkt8PnZ4ZfnaCCWDRpfo6LqLn64Iy3KdDKm8VSnEm60Pgguqc TJdDagD2QpsTc/CxnZHjcidE7cWCMX+N4NDoxmt6OloWrJXNW9v4325JFZvsN X-Received: by 2002:a05:600c:19d3:: with SMTP id u19mr4202610wmq.164.1633449665635; Tue, 05 Oct 2021 09:01:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBGmkgwr07pvMzVheyee/dpOzvFMfIGwt1P1okzRWy9dOAfEG0C5okL1Kx/swBAiPCAHOFxQ== X-Received: by 2002:a05:600c:19d3:: with SMTP id u19mr4202577wmq.164.1633449665400; Tue, 05 Oct 2021 09:01:05 -0700 (PDT) Date: Tue, 5 Oct 2021 12:01:01 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 06/57] vhost-vdpa: let net_vhost_vdpa_init() returns NetClientState * Message-ID: <20211005155946.513818-7-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633454373346100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang This patch switches to let net_vhost_vdpa_init() to return NetClientState *. This is used for the callers to allocate multiqueue NetClientState for multiqueue support. Signed-off-by: Jason Wang Message-Id: <20210907090322.1756-5-jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 73d29a74ef..834dab28dd 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -155,8 +155,10 @@ static NetClientInfo net_vhost_vdpa_info =3D { .has_ufo =3D vhost_vdpa_has_ufo, }; =20 -static int net_vhost_vdpa_init(NetClientState *peer, const char *device, - const char *name, int vdpa_device_fd) +static NetClientState *net_vhost_vdpa_init(NetClientState *peer, + const char *device, + const char *name, + int vdpa_device_fd) { NetClientState *nc =3D NULL; VhostVDPAState *s; @@ -170,8 +172,9 @@ static int net_vhost_vdpa_init(NetClientState *peer, co= nst char *device, ret =3D vhost_vdpa_add(nc, (void *)&s->vhost_vdpa); if (ret) { qemu_del_net_client(nc); + return NULL; } - return ret; + return nc; } =20 static int net_vhost_check_net(void *opaque, QemuOpts *opts, Error **errp) @@ -196,7 +199,8 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, NetClientState *peer, Error **errp) { const NetdevVhostVDPAOptions *opts; - int vdpa_device_fd, ret; + int vdpa_device_fd; + NetClientState *nc; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); opts =3D &netdev->u.vhost_vdpa; @@ -211,10 +215,11 @@ int net_init_vhost_vdpa(const Netdev *netdev, const c= har *name, return -errno; } =20 - ret =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_f= d); - if (ret) { + nc =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd= ); + if (!nc) { qemu_close(vdpa_device_fd); + return -1; } =20 - return ret; + return 0; } --=20 MST From nobody Wed May 8 08:20:40 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633450946; cv=none; d=zohomail.com; s=zohoarc; b=Fhh8qeFp8iKIXdC5Ma3oXcoDH6HcQ6w68Y1hMbJNQ/Q8Fo5AtQk1RQ4qMVzSd7piixVY01UZRnQxkFcItGfctzPzn4V9nXJc3WRzE7+IdQ55ambBlakU/HiHt0Q/X4KfZqlTy8ccRx5e5ls4xEYtETSBIPC5vaCbK5dgxmw+04k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633450946; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Co6yxN/jFeQeLIIMJX0QvM5s16uKZLl6Gfzgn/2s9wE=; b=RMIV/EiR7xy2pBZZanTpGf1+LFtd9CAkugDy/QG0fxZyJQO2JtMvatrL5/vjXBpZvPV9aMsQ0qD4bxBv4YXzeEbVuZNcZNWNSD/TOUP2801IpQ9it1XuVK/o0TSnRcl9mt6M12EyXUXOGrAloLthsCUea5TIHd1c15fUcGkCyW0= 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 1633450946153745.206543945324; Tue, 5 Oct 2021 09:22:26 -0700 (PDT) Received: from localhost ([::1]:33108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnCz-0004e7-47 for importer@patchew.org; Tue, 05 Oct 2021 12:22:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsW-00005u-KO for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsU-0004jv-Tw for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:16 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-402-EJXGOjAYOF2LTISv1J69gw-1; Tue, 05 Oct 2021 12:01:11 -0400 Received: by mail-wr1-f71.google.com with SMTP id r25-20020adfab59000000b001609ddd5579so2866934wrc.21 for ; Tue, 05 Oct 2021 09:01:11 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id n68sm2351546wmn.13.2021.10.05.09.01.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:01:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449672; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Co6yxN/jFeQeLIIMJX0QvM5s16uKZLl6Gfzgn/2s9wE=; b=iBXi/FUikDIxBOc+RsRtelm7/b5i/PtHZJfJkD0V/hr/HVRdLraL3EzWK3YQsBn/UdRaBs JBBfctiR1ey/nz9dDorfO4WknYS37u1Qgjy831i7YsMEtXIcQReeVnjlsL0gOdq55WvOm/ eNHe8slLwQ8Aqx1+uq83Y68CkAcyKqc= X-MC-Unique: EJXGOjAYOF2LTISv1J69gw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Co6yxN/jFeQeLIIMJX0QvM5s16uKZLl6Gfzgn/2s9wE=; b=2WExjougsTVoBivbX2ujPYGyXZGBHcferuS0klzzW+6ziEekX9pBk4pPxxHecvL/eP x13MA8WOXwJWBwIPJnjRQlD5lS0MDgTIjI0Iq+tt9F1m8GHniAHpnsBQv74xD1TBCK1N HX0z5YDARsK/+Vud0kFa7TNh6LdUCpke+16pCgL1Yv2Y56VHZrE3f411g4O0YRUQnijI BnlFdo2zeZ1HjF44e1WZPmP4ky73Ky5LW28s7JPWbwjh+i3I4WIkCBO6g/KmX45F6RS+ al7PkAgATdS23webcdPg9Y9p9Ml48b7vKgpIpHhdjR9rdr1iq+XV2UTF7QjNdDbMLHKR +VMQ== X-Gm-Message-State: AOAM530ieAD9xdH5PjEGPSnq+fvQteGnmiJZjQBIe4XBOxj+UzIilUG9 hgjDLlDfcdIuJg+WmpgrGX8uuJdhuZSL0mKMXAEYJqW9MMSECj+y1e0tFCQjtHgeoGNFASS7jvS WkX+yBs2d3KLIErZDkHwVwMI61YBOQryQqupsY3y66DMzk4pA3IG17P5vLJ71 X-Received: by 2002:a1c:158:: with SMTP id 85mr4266333wmb.187.1633449669140; Tue, 05 Oct 2021 09:01:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAtqpoh20Aupv6Y3IoVcv9eeo24ldQgW6yUKKb5STwRD1WFwdt2SuI37yLh6KXnWBDU8aH/w== X-Received: by 2002:a1c:158:: with SMTP id 85mr4266299wmb.187.1633449668931; Tue, 05 Oct 2021 09:01:08 -0700 (PDT) Date: Tue, 5 Oct 2021 12:01:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 07/57] net: introduce control client Message-ID: <20211005155946.513818-8-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633450947905100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang This patch introduces a boolean for the device has control queue which can accepts control command via network queue. The first user would be the control virtqueue support for vhost. Signed-off-by: Jason Wang Message-Id: <20210907090322.1756-6-jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/net/net.h | 5 +++++ net/net.c | 24 +++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 5d1508081f..4f400b8a09 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -103,6 +103,7 @@ struct NetClientState { int vnet_hdr_len; bool is_netdev; bool do_not_pad; /* do not pad to the minimum ethernet frame length */ + bool is_datapath; QTAILQ_HEAD(, NetFilterState) filters; }; =20 @@ -134,6 +135,10 @@ NetClientState *qemu_new_net_client(NetClientInfo *inf= o, NetClientState *peer, const char *model, const char *name); +NetClientState *qemu_new_net_control_client(NetClientInfo *info, + NetClientState *peer, + const char *model, + const char *name); NICState *qemu_new_nic(NetClientInfo *info, NICConf *conf, const char *model, diff --git a/net/net.c b/net/net.c index 52c99196c6..f0d14dbfc1 100644 --- a/net/net.c +++ b/net/net.c @@ -239,7 +239,8 @@ static void qemu_net_client_setup(NetClientState *nc, NetClientState *peer, const char *model, const char *name, - NetClientDestructor *destructor) + NetClientDestructor *destructor, + bool is_datapath) { nc->info =3D info; nc->model =3D g_strdup(model); @@ -258,6 +259,7 @@ static void qemu_net_client_setup(NetClientState *nc, =20 nc->incoming_queue =3D qemu_new_net_queue(qemu_deliver_packet_iov, nc); nc->destructor =3D destructor; + nc->is_datapath =3D is_datapath; QTAILQ_INIT(&nc->filters); } =20 @@ -272,7 +274,23 @@ NetClientState *qemu_new_net_client(NetClientInfo *inf= o, =20 nc =3D g_malloc0(info->size); qemu_net_client_setup(nc, info, peer, model, name, - qemu_net_client_destructor); + qemu_net_client_destructor, true); + + return nc; +} + +NetClientState *qemu_new_net_control_client(NetClientInfo *info, + NetClientState *peer, + const char *model, + const char *name) +{ + NetClientState *nc; + + assert(info->size >=3D sizeof(NetClientState)); + + nc =3D g_malloc0(info->size); + qemu_net_client_setup(nc, info, peer, model, name, + qemu_net_client_destructor, false); =20 return nc; } @@ -297,7 +315,7 @@ NICState *qemu_new_nic(NetClientInfo *info, =20 for (i =3D 0; i < queues; i++) { qemu_net_client_setup(&nic->ncs[i], info, peers[i], model, name, - NULL); + NULL, true); nic->ncs[i].queue_index =3D i; } =20 --=20 MST From nobody Wed May 8 08:20:40 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633451120; cv=none; d=zohomail.com; s=zohoarc; b=MeI5VLwN4Jsf4BvEWYfksmj+mJg6Xsow15ODKsdR+Q4RzngeCvlRkZTY6QAhIp0o5BizCz6YegVvpNKUriEzWUgzNIvqeIj7p+JpcTrtPd/ttOIpMudvW6pht6OrBRrni/52XrWhbBC2nxFev5rvmMu7WBePfGlzqKYAdaVwhis= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633451120; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DSyVi0I4imdq55uSunyFJ+6UljUfdU64JGgCSA4aLIE=; b=bWbaBoFcoGFcAk55W0SZ6AasR6M5qZS4O0rF3HEs7vJ5amDjymXuowt2pou0HKBf0jenCXXDu8FiTI9X2sLKK5ErQVa3SAuvTueuzb8uNlkqWUQ+Z2NsYBbKEdToWhx7s/MV2Rn2L4rBl/piJtdjf8zS7whk4XRyuMrPZI1sGq4= 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 1633451120743558.7836098895436; Tue, 5 Oct 2021 09:25:20 -0700 (PDT) Received: from localhost ([::1]:41362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnFn-0001kb-II for importer@patchew.org; Tue, 05 Oct 2021 12:25:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsY-00007C-In for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20183) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsV-0004mJ-P9 for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:18 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-475-L8u39Q9KNRWy8vyoCHiH2Q-1; Tue, 05 Oct 2021 12:01:13 -0400 Received: by mail-wm1-f69.google.com with SMTP id u14-20020a7bcb0e0000b0290248831d46e4so1215162wmj.6 for ; Tue, 05 Oct 2021 09:01:13 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id k188sm2371494wme.44.2021.10.05.09.01.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:01:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DSyVi0I4imdq55uSunyFJ+6UljUfdU64JGgCSA4aLIE=; b=C/W5nxahu49Itmgrge2ue/12OmS1WA1/P6koIgOqHy2yy+5yaXCCsZAdKn8KyuiYFu4xgS 7LbAis+Q5Q5rWPhvI1ftTobGs3FyLWk3xV7a8v0XM3vpFQw6xdpHISHLQB8f+f6STEvfga kW9Xt/8RA2oM/z53QKVE1inQ0wvR+Xk= X-MC-Unique: L8u39Q9KNRWy8vyoCHiH2Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=DSyVi0I4imdq55uSunyFJ+6UljUfdU64JGgCSA4aLIE=; b=pdBV7ci6rg46h+sZgFmXTSp+fmMyBKEYWkV2yM0BIaY42f/oAY5uSsNnhXdRrTqVm3 i60l1YtLQLgkVDBjp+13IieG0ZSDhTrtyMSVrJO6aXrblMXwuEnv24lJH4VvhOpR9Z9p 0wNcPi5zgkQRW3/gwxNLxSC3iEYDb3VvAcTM5Zlq+A2NjW1ykniMDFZj+gwoFFDalHq1 wNBU1KczpCicDkwqOFxvhBdUVIirREWQWUTxPnqo9cgj8GO6lM0co8mYFuUSj0PI5GS2 ea5EuqrYaCiICn8ChTDoXJc59L+sYr4g5gkUSzGRUJVMvv58IdlffiZ2ShYA4GNDoqmr OiAg== X-Gm-Message-State: AOAM532uMEWl0KrrJF1fmaqv7lBI6axRVZRh5Ra7amIoMFMJBCixD2iT Xb1xAUtU0LAbOeXPyU4a38smOYDVmQC59xSWmpPU3mbp2ldpPaze8b2TEujFJSJTTPdegxScCpN JQSM0VpxpjvLH/iKrsJhf5bbApuHGjquXmu5/UU/4K9SL0h0l4wnLNaNqLmLy X-Received: by 2002:a5d:59a6:: with SMTP id p6mr22209899wrr.142.1633449672152; Tue, 05 Oct 2021 09:01:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3smtNMHVjaAAhzdQMLOnUNmw7HuBwe+35fjwpI7ymXhDfkZSN2N6JfuoiCaqH4kZ0qPT3jA== X-Received: by 2002:a5d:59a6:: with SMTP id p6mr22209843wrr.142.1633449671811; Tue, 05 Oct 2021 09:01:11 -0700 (PDT) Date: Tue, 5 Oct 2021 12:01:09 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 08/57] vhost-net: control virtqueue support Message-ID: <20211005155946.513818-9-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633451121611100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang We assume there's no cvq in the past, this is not true when we need control virtqueue support for vhost-user backends. So this patch implements the control virtqueue support for vhost-net. As datapath, the control virtqueue is also required to be coupled with the NetClientState. The vhost_net_start/stop() are tweaked to accept the number of datapath queue pairs plus the the number of control virtqueue for us to start and stop the vhost device. Signed-off-by: Jason Wang Message-Id: <20210907090322.1756-7-jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/net/vhost_net.h | 6 ++++-- hw/net/vhost_net.c | 43 ++++++++++++++++++++++++++++++----------- hw/net/virtio-net.c | 4 ++-- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index fba40cf695..387e913e4e 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -21,8 +21,10 @@ typedef struct VhostNetOptions { uint64_t vhost_net_get_max_queues(VHostNetState *net); struct vhost_net *vhost_net_init(VhostNetOptions *options); =20 -int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, int total_queu= es); -void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs, int total_queu= es); +int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, + int data_queue_pairs, int cvq); +void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs, + int data_queue_pairs, int cvq); =20 void vhost_net_cleanup(VHostNetState *net); =20 diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 386ec2eaa2..e1e9d1ec89 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -315,11 +315,14 @@ static void vhost_net_stop_one(struct vhost_net *net, } =20 int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, - int total_queues) + int data_queue_pairs, int cvq) { BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(dev))); VirtioBusState *vbus =3D VIRTIO_BUS(qbus); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(vbus); + int total_notifiers =3D data_queue_pairs * 2 + cvq; + VirtIONet *n =3D VIRTIO_NET(dev); + int nvhosts =3D data_queue_pairs + cvq; struct vhost_net *net; int r, e, i; NetClientState *peer; @@ -329,9 +332,14 @@ int vhost_net_start(VirtIODevice *dev, NetClientState = *ncs, return -ENOSYS; } =20 - for (i =3D 0; i < total_queues; i++) { + for (i =3D 0; i < nvhosts; i++) { + + if (i < data_queue_pairs) { + peer =3D qemu_get_peer(ncs, i); + } else { /* Control Virtqueue */ + peer =3D qemu_get_peer(ncs, n->max_queues); + } =20 - peer =3D qemu_get_peer(ncs, i); net =3D get_vhost_net(peer); vhost_net_set_vq_index(net, i * 2); =20 @@ -344,14 +352,18 @@ int vhost_net_start(VirtIODevice *dev, NetClientState= *ncs, } } =20 - r =3D k->set_guest_notifiers(qbus->parent, total_queues * 2, true); + r =3D k->set_guest_notifiers(qbus->parent, total_notifiers, true); if (r < 0) { error_report("Error binding guest notifier: %d", -r); goto err; } =20 - for (i =3D 0; i < total_queues; i++) { - peer =3D qemu_get_peer(ncs, i); + for (i =3D 0; i < nvhosts; i++) { + if (i < data_queue_pairs) { + peer =3D qemu_get_peer(ncs, i); + } else { + peer =3D qemu_get_peer(ncs, n->max_queues); + } r =3D vhost_net_start_one(get_vhost_net(peer), dev); =20 if (r < 0) { @@ -375,7 +387,7 @@ err_start: peer =3D qemu_get_peer(ncs , i); vhost_net_stop_one(get_vhost_net(peer), dev); } - e =3D k->set_guest_notifiers(qbus->parent, total_queues * 2, false); + e =3D k->set_guest_notifiers(qbus->parent, total_notifiers, false); if (e < 0) { fprintf(stderr, "vhost guest notifier cleanup failed: %d\n", e); fflush(stderr); @@ -385,18 +397,27 @@ err: } =20 void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs, - int total_queues) + int data_queue_pairs, int cvq) { BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(dev))); VirtioBusState *vbus =3D VIRTIO_BUS(qbus); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(vbus); + VirtIONet *n =3D VIRTIO_NET(dev); + NetClientState *peer; + int total_notifiers =3D data_queue_pairs * 2 + cvq; + int nvhosts =3D data_queue_pairs + cvq; int i, r; =20 - for (i =3D 0; i < total_queues; i++) { - vhost_net_stop_one(get_vhost_net(ncs[i].peer), dev); + for (i =3D 0; i < nvhosts; i++) { + if (i < data_queue_pairs) { + peer =3D qemu_get_peer(ncs, i); + } else { + peer =3D qemu_get_peer(ncs, n->max_queues); + } + vhost_net_stop_one(get_vhost_net(peer), dev); } =20 - r =3D k->set_guest_notifiers(qbus->parent, total_queues * 2, false); + r =3D k->set_guest_notifiers(qbus->parent, total_notifiers, false); if (r < 0) { fprintf(stderr, "vhost guest notifier cleanup failed: %d\n", r); fflush(stderr); diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index f205331dcf..f1119cf0ad 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -285,14 +285,14 @@ static void virtio_net_vhost_status(VirtIONet *n, uin= t8_t status) } =20 n->vhost_started =3D 1; - r =3D vhost_net_start(vdev, n->nic->ncs, queues); + r =3D vhost_net_start(vdev, n->nic->ncs, queues, 0); if (r < 0) { error_report("unable to start vhost net: %d: " "falling back on userspace virtio", -r); n->vhost_started =3D 0; } } else { - vhost_net_stop(vdev, n->nic->ncs, queues); + vhost_net_stop(vdev, n->nic->ncs, queues, 0); n->vhost_started =3D 0; } } --=20 MST From nobody Wed May 8 08:20:40 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633450483; cv=none; d=zohomail.com; s=zohoarc; b=kfl1RtdInpY9U/wziRHKjc+6bn18pBatGiaWyQIAJAxrmYzZ9ZWTZgvSFYruI3w9q+SYJgj1KgjD1x3j9juiThJQdAf6ZrFjw/q7r555ZW2KHPfkaw0U/3xo2/5yVJI+27ObKYXd/jpiwTD+uwh+7tQqpkfURY/GObGYZC/U2Bs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633450483; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lDEtzyUVlP2RnNqCpZsfRKPbJYMvaSIWPYWNyrinLf0=; b=AZkMekDLXSyJzMEM17IxYh1uoYc6qir0gSO39Rkg2lAnN6vDAlnbckXIS4dH6rbRoIpPQ4zW5KILgIzCv30Hjky6mO4SnGpznRaIMN1n5dI4Ni8ucIN47Ugoercn/Nd9bVrW3Bm3NCgiA2Ma8XHleHrUuiMFhTh6SmquniRBUDo= 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 1633450483796182.36559811878806; Tue, 5 Oct 2021 09:14:43 -0700 (PDT) Received: from localhost ([::1]:47882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXn5W-0003oQ-Nf for importer@patchew.org; Tue, 05 Oct 2021 12:14:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46892) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmse-00009E-Ii for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51008) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsb-0004pN-0s for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:24 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-525-1AgJj1hnNuaelatsBSV4uw-1; Tue, 05 Oct 2021 12:01:18 -0400 Received: by mail-wm1-f71.google.com with SMTP id 75-20020a1c004e000000b00307b9b32cc9so1118758wma.1 for ; Tue, 05 Oct 2021 09:01:17 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id 189sm2737360wmz.27.2021.10.05.09.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449680; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lDEtzyUVlP2RnNqCpZsfRKPbJYMvaSIWPYWNyrinLf0=; b=TZCHGwBCKQAMd7NqtS2Iiy/I8775mIRRte34M++TuDuMyKZ7P4vSPTgAjKlPbJdrl+fXZy 2v12pw+Xp9fqID3Xn3pW3F/I+rZbxa8iI6ChpnXUHTW+iC7nMXXaxhNGfZiCNYCG0HEL7o O0V+92+pliOx+pp9r/wjzpaZIYpx/qE= X-MC-Unique: 1AgJj1hnNuaelatsBSV4uw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=lDEtzyUVlP2RnNqCpZsfRKPbJYMvaSIWPYWNyrinLf0=; b=ZmXLU3nOTA7T5lX/do04LXlFxyrC4vhp1zrKAZ2SpjHBVj9mioMh+xxDI088yTyz6K anAd2onBdWTy98xusPIcIOobeNFl/60rEP06kPlQ5c2F1SlYMl+c/snI8qnTSrKZgvPV UWBJPlLe7793I/WPiQ5nLhGbv9yqM5uVXqYZLVTeL3MpLYOzDJoQbpkOCZvuJdRLfYlf DGAxXN/ZUHF63q0/lbhlsTeSoeoWz3akIpWQOMdQZCKVKRb9x+SoJ2mYjQuFtBkxXh2R Pp5WNCoV4/dwLxlTDJCkgdwx6yRezvgA7+oE7/OKZTuyfhauPmaimwnTgeydavx6lVc3 r/Cw== X-Gm-Message-State: AOAM532z2fsEdnB+aIw7OGitLZvlH8DjRmEh7nuWYchEi3WwuTuJqPCL Osa8h3dEdN+4nhaZJi2ASuduzMt4uqUXFstCCBb6Z98j6WhlgDVh/9lzxBcX8YTAUQv7vM7/dyM sLRTzM6sv5p5sT0NkvaExDWKUW35JCxxmGauFZsj76g6uqvB+6Iw5rVPY+qK2 X-Received: by 2002:adf:97cc:: with SMTP id t12mr20487306wrb.189.1633449676080; Tue, 05 Oct 2021 09:01:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKcCDOZgzgv/Kgp3WnvQJ8gZLcouExno+/ZG3a+ftaxIQjCn0GdR4VU9dodIV4/xJ/ZhwkFg== X-Received: by 2002:adf:97cc:: with SMTP id t12mr20487225wrb.189.1633449675509; Tue, 05 Oct 2021 09:01:15 -0700 (PDT) Date: Tue, 5 Oct 2021 12:01:12 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 09/57] virtio-net: use "queue_pairs" instead of "queues" when possible Message-ID: <20211005155946.513818-10-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633450484724100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang Most of the time, "queues" really means queue pairs. So this patch switch to use "queue_pairs" to avoid confusion. Signed-off-by: Jason Wang Message-Id: <20210907090322.1756-8-jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-net.h | 4 +- hw/net/vhost_net.c | 6 +- hw/net/virtio-net.c | 150 ++++++++++++++++----------------- 3 files changed, 80 insertions(+), 80 deletions(-) diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 824a69c23f..71cbdc26d7 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -194,8 +194,8 @@ struct VirtIONet { NICConf nic_conf; DeviceState *qdev; int multiqueue; - uint16_t max_queues; - uint16_t curr_queues; + uint16_t max_queue_pairs; + uint16_t curr_queue_pairs; size_t config_size; char *netclient_name; char *netclient_type; diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index e1e9d1ec89..2b594b4642 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -337,7 +337,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *= ncs, if (i < data_queue_pairs) { peer =3D qemu_get_peer(ncs, i); } else { /* Control Virtqueue */ - peer =3D qemu_get_peer(ncs, n->max_queues); + peer =3D qemu_get_peer(ncs, n->max_queue_pairs); } =20 net =3D get_vhost_net(peer); @@ -362,7 +362,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *= ncs, if (i < data_queue_pairs) { peer =3D qemu_get_peer(ncs, i); } else { - peer =3D qemu_get_peer(ncs, n->max_queues); + peer =3D qemu_get_peer(ncs, n->max_queue_pairs); } r =3D vhost_net_start_one(get_vhost_net(peer), dev); =20 @@ -412,7 +412,7 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState *= ncs, if (i < data_queue_pairs) { peer =3D qemu_get_peer(ncs, i); } else { - peer =3D qemu_get_peer(ncs, n->max_queues); + peer =3D qemu_get_peer(ncs, n->max_queue_pairs); } vhost_net_stop_one(get_vhost_net(peer), dev); } diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index f1119cf0ad..2ade019b22 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -54,7 +54,7 @@ #define VIRTIO_NET_RX_QUEUE_DEFAULT_SIZE 256 #define VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE 256 =20 -/* for now, only allow larger queues; with virtio-1, guest can downsize */ +/* for now, only allow larger queue_pairs; with virtio-1, guest can downsi= ze */ #define VIRTIO_NET_RX_QUEUE_MIN_SIZE VIRTIO_NET_RX_QUEUE_DEFAULT_SIZE #define VIRTIO_NET_TX_QUEUE_MIN_SIZE VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE =20 @@ -131,7 +131,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, u= int8_t *config) int ret =3D 0; memset(&netcfg, 0 , sizeof(struct virtio_net_config)); virtio_stw_p(vdev, &netcfg.status, n->status); - virtio_stw_p(vdev, &netcfg.max_virtqueue_pairs, n->max_queues); + virtio_stw_p(vdev, &netcfg.max_virtqueue_pairs, n->max_queue_pairs); virtio_stw_p(vdev, &netcfg.mtu, n->net_conf.mtu); memcpy(netcfg.mac, n->mac, ETH_ALEN); virtio_stl_p(vdev, &netcfg.speed, n->net_conf.speed); @@ -243,7 +243,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8= _t status) { VirtIODevice *vdev =3D VIRTIO_DEVICE(n); NetClientState *nc =3D qemu_get_queue(n->nic); - int queues =3D n->multiqueue ? n->max_queues : 1; + int queue_pairs =3D n->multiqueue ? n->max_queue_pairs : 1; =20 if (!get_vhost_net(nc->peer)) { return; @@ -266,7 +266,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8= _t status) /* Any packets outstanding? Purge them to avoid touching rings * when vhost is running. */ - for (i =3D 0; i < queues; i++) { + for (i =3D 0; i < queue_pairs; i++) { NetClientState *qnc =3D qemu_get_subqueue(n->nic, i); =20 /* Purge both directions: TX and RX. */ @@ -285,14 +285,14 @@ static void virtio_net_vhost_status(VirtIONet *n, uin= t8_t status) } =20 n->vhost_started =3D 1; - r =3D vhost_net_start(vdev, n->nic->ncs, queues, 0); + r =3D vhost_net_start(vdev, n->nic->ncs, queue_pairs, 0); if (r < 0) { error_report("unable to start vhost net: %d: " "falling back on userspace virtio", -r); n->vhost_started =3D 0; } } else { - vhost_net_stop(vdev, n->nic->ncs, queues, 0); + vhost_net_stop(vdev, n->nic->ncs, queue_pairs, 0); n->vhost_started =3D 0; } } @@ -309,11 +309,11 @@ static int virtio_net_set_vnet_endian_one(VirtIODevic= e *vdev, } =20 static bool virtio_net_set_vnet_endian(VirtIODevice *vdev, NetClientState = *ncs, - int queues, bool enable) + int queue_pairs, bool enable) { int i; =20 - for (i =3D 0; i < queues; i++) { + for (i =3D 0; i < queue_pairs; i++) { if (virtio_net_set_vnet_endian_one(vdev, ncs[i].peer, enable) < 0 = && enable) { while (--i >=3D 0) { @@ -330,7 +330,7 @@ static bool virtio_net_set_vnet_endian(VirtIODevice *vd= ev, NetClientState *ncs, static void virtio_net_vnet_endian_status(VirtIONet *n, uint8_t status) { VirtIODevice *vdev =3D VIRTIO_DEVICE(n); - int queues =3D n->multiqueue ? n->max_queues : 1; + int queue_pairs =3D n->multiqueue ? n->max_queue_pairs : 1; =20 if (virtio_net_started(n, status)) { /* Before using the device, we tell the network backend about the @@ -339,14 +339,14 @@ static void virtio_net_vnet_endian_status(VirtIONet *= n, uint8_t status) * virtio-net code. */ n->needs_vnet_hdr_swap =3D virtio_net_set_vnet_endian(vdev, n->nic= ->ncs, - queues, true); + queue_pairs, t= rue); } else if (virtio_net_started(n, vdev->status)) { /* After using the device, we need to reset the network backend to * the default (guest native endianness), otherwise the guest may * lose network connectivity if it is rebooted into a different * endianness. */ - virtio_net_set_vnet_endian(vdev, n->nic->ncs, queues, false); + virtio_net_set_vnet_endian(vdev, n->nic->ncs, queue_pairs, false); } } =20 @@ -368,12 +368,12 @@ static void virtio_net_set_status(struct VirtIODevice= *vdev, uint8_t status) virtio_net_vnet_endian_status(n, status); virtio_net_vhost_status(n, status); =20 - for (i =3D 0; i < n->max_queues; i++) { + for (i =3D 0; i < n->max_queue_pairs; i++) { NetClientState *ncs =3D qemu_get_subqueue(n->nic, i); bool queue_started; q =3D &n->vqs[i]; =20 - if ((!n->multiqueue && i !=3D 0) || i >=3D n->curr_queues) { + if ((!n->multiqueue && i !=3D 0) || i >=3D n->curr_queue_pairs) { queue_status =3D 0; } else { queue_status =3D status; @@ -540,7 +540,7 @@ static void virtio_net_reset(VirtIODevice *vdev) n->nouni =3D 0; n->nobcast =3D 0; /* multiqueue is disabled by default */ - n->curr_queues =3D 1; + n->curr_queue_pairs =3D 1; timer_del(n->announce_timer.tm); n->announce_timer.round =3D 0; n->status &=3D ~VIRTIO_NET_S_ANNOUNCE; @@ -556,7 +556,7 @@ static void virtio_net_reset(VirtIODevice *vdev) memset(n->vlans, 0, MAX_VLAN >> 3); =20 /* Flush any async TX */ - for (i =3D 0; i < n->max_queues; i++) { + for (i =3D 0; i < n->max_queue_pairs; i++) { NetClientState *nc =3D qemu_get_subqueue(n->nic, i); =20 if (nc->peer) { @@ -610,7 +610,7 @@ static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, in= t mergeable_rx_bufs, sizeof(struct virtio_net_hdr); } =20 - for (i =3D 0; i < n->max_queues; i++) { + for (i =3D 0; i < n->max_queue_pairs; i++) { nc =3D qemu_get_subqueue(n->nic, i); =20 if (peer_has_vnet_hdr(n) && @@ -655,7 +655,7 @@ static int peer_attach(VirtIONet *n, int index) return 0; } =20 - if (n->max_queues =3D=3D 1) { + if (n->max_queue_pairs =3D=3D 1) { return 0; } =20 @@ -681,7 +681,7 @@ static int peer_detach(VirtIONet *n, int index) return tap_disable(nc->peer); } =20 -static void virtio_net_set_queues(VirtIONet *n) +static void virtio_net_set_queue_pairs(VirtIONet *n) { int i; int r; @@ -690,8 +690,8 @@ static void virtio_net_set_queues(VirtIONet *n) return; } =20 - for (i =3D 0; i < n->max_queues; i++) { - if (i < n->curr_queues) { + for (i =3D 0; i < n->max_queue_pairs; i++) { + if (i < n->curr_queue_pairs) { r =3D peer_attach(n, i); assert(!r); } else { @@ -920,7 +920,7 @@ static void virtio_net_set_features(VirtIODevice *vdev,= uint64_t features) virtio_net_apply_guest_offloads(n); } =20 - for (i =3D 0; i < n->max_queues; i++) { + for (i =3D 0; i < n->max_queue_pairs; i++) { NetClientState *nc =3D qemu_get_subqueue(n->nic, i); =20 if (!get_vhost_net(nc->peer)) { @@ -1247,7 +1247,7 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, VirtIODevice *vdev =3D VIRTIO_DEVICE(n); struct virtio_net_rss_config cfg; size_t s, offset =3D 0, size_get; - uint16_t queues, i; + uint16_t queue_pairs, i; struct { uint16_t us; uint8_t b; @@ -1289,7 +1289,7 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, } n->rss_data.default_queue =3D do_rss ? virtio_lduw_p(vdev, &cfg.unclassified_queue) : 0; - if (n->rss_data.default_queue >=3D n->max_queues) { + if (n->rss_data.default_queue >=3D n->max_queue_pairs) { err_msg =3D "Invalid default queue"; err_value =3D n->rss_data.default_queue; goto error; @@ -1318,14 +1318,14 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, size_get =3D sizeof(temp); s =3D iov_to_buf(iov, iov_cnt, offset, &temp, size_get); if (s !=3D size_get) { - err_msg =3D "Can't get queues"; + err_msg =3D "Can't get queue_pairs"; err_value =3D (uint32_t)s; goto error; } - queues =3D do_rss ? virtio_lduw_p(vdev, &temp.us) : n->curr_queues; - if (queues =3D=3D 0 || queues > n->max_queues) { - err_msg =3D "Invalid number of queues"; - err_value =3D queues; + queue_pairs =3D do_rss ? virtio_lduw_p(vdev, &temp.us) : n->curr_queue= _pairs; + if (queue_pairs =3D=3D 0 || queue_pairs > n->max_queue_pairs) { + err_msg =3D "Invalid number of queue_pairs"; + err_value =3D queue_pairs; goto error; } if (temp.b > VIRTIO_NET_RSS_MAX_KEY_SIZE) { @@ -1340,7 +1340,7 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, } if (!temp.b && !n->rss_data.hash_types) { virtio_net_disable_rss(n); - return queues; + return queue_pairs; } offset +=3D size_get; size_get =3D temp.b; @@ -1373,7 +1373,7 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, trace_virtio_net_rss_enable(n->rss_data.hash_types, n->rss_data.indirections_len, temp.b); - return queues; + return queue_pairs; error: trace_virtio_net_rss_error(err_msg, err_value); virtio_net_disable_rss(n); @@ -1384,15 +1384,15 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8= _t cmd, struct iovec *iov, unsigned int iov_cnt) { VirtIODevice *vdev =3D VIRTIO_DEVICE(n); - uint16_t queues; + uint16_t queue_pairs; =20 virtio_net_disable_rss(n); if (cmd =3D=3D VIRTIO_NET_CTRL_MQ_HASH_CONFIG) { - queues =3D virtio_net_handle_rss(n, iov, iov_cnt, false); - return queues ? VIRTIO_NET_OK : VIRTIO_NET_ERR; + queue_pairs =3D virtio_net_handle_rss(n, iov, iov_cnt, false); + return queue_pairs ? VIRTIO_NET_OK : VIRTIO_NET_ERR; } if (cmd =3D=3D VIRTIO_NET_CTRL_MQ_RSS_CONFIG) { - queues =3D virtio_net_handle_rss(n, iov, iov_cnt, true); + queue_pairs =3D virtio_net_handle_rss(n, iov, iov_cnt, true); } else if (cmd =3D=3D VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) { struct virtio_net_ctrl_mq mq; size_t s; @@ -1403,24 +1403,24 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8= _t cmd, if (s !=3D sizeof(mq)) { return VIRTIO_NET_ERR; } - queues =3D virtio_lduw_p(vdev, &mq.virtqueue_pairs); + queue_pairs =3D virtio_lduw_p(vdev, &mq.virtqueue_pairs); =20 } else { return VIRTIO_NET_ERR; } =20 - if (queues < VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN || - queues > VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX || - queues > n->max_queues || + if (queue_pairs < VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN || + queue_pairs > VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX || + queue_pairs > n->max_queue_pairs || !n->multiqueue) { return VIRTIO_NET_ERR; } =20 - n->curr_queues =3D queues; - /* stop the backend before changing the number of queues to avoid hand= ling a + n->curr_queue_pairs =3D queue_pairs; + /* stop the backend before changing the number of queue_pairs to avoid= handling a * disabled queue */ virtio_net_set_status(vdev, vdev->status); - virtio_net_set_queues(n); + virtio_net_set_queue_pairs(n); =20 return VIRTIO_NET_OK; } @@ -1498,7 +1498,7 @@ static bool virtio_net_can_receive(NetClientState *nc) return false; } =20 - if (nc->queue_index >=3D n->curr_queues) { + if (nc->queue_index >=3D n->curr_queue_pairs) { return false; } =20 @@ -2778,11 +2778,11 @@ static void virtio_net_del_queue(VirtIONet *n, int = index) virtio_del_queue(vdev, index * 2 + 1); } =20 -static void virtio_net_change_num_queues(VirtIONet *n, int new_max_queues) +static void virtio_net_change_num_queue_pairs(VirtIONet *n, int new_max_qu= eue_pairs) { VirtIODevice *vdev =3D VIRTIO_DEVICE(n); int old_num_queues =3D virtio_get_num_queues(vdev); - int new_num_queues =3D new_max_queues * 2 + 1; + int new_num_queues =3D new_max_queue_pairs * 2 + 1; int i; =20 assert(old_num_queues >=3D 3); @@ -2815,12 +2815,12 @@ static void virtio_net_change_num_queues(VirtIONet = *n, int new_max_queues) =20 static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue) { - int max =3D multiqueue ? n->max_queues : 1; + int max =3D multiqueue ? n->max_queue_pairs : 1; =20 n->multiqueue =3D multiqueue; - virtio_net_change_num_queues(n, max); + virtio_net_change_num_queue_pairs(n, max); =20 - virtio_net_set_queues(n); + virtio_net_set_queue_pairs(n); } =20 static int virtio_net_post_load_device(void *opaque, int version_id) @@ -2853,7 +2853,7 @@ static int virtio_net_post_load_device(void *opaque, = int version_id) */ n->saved_guest_offloads =3D n->curr_guest_offloads; =20 - virtio_net_set_queues(n); + virtio_net_set_queue_pairs(n); =20 /* Find the first multicast entry in the saved MAC filter */ for (i =3D 0; i < n->mac_table.in_use; i++) { @@ -2866,7 +2866,7 @@ static int virtio_net_post_load_device(void *opaque, = int version_id) /* nc.link_down can't be migrated, so infer link_down according * to link status bit in n->status */ link_down =3D (n->status & VIRTIO_NET_S_LINK_UP) =3D=3D 0; - for (i =3D 0; i < n->max_queues; i++) { + for (i =3D 0; i < n->max_queue_pairs; i++) { qemu_get_subqueue(n->nic, i)->link_down =3D link_down; } =20 @@ -2931,9 +2931,9 @@ static const VMStateDescription vmstate_virtio_net_qu= eue_tx_waiting =3D { }, }; =20 -static bool max_queues_gt_1(void *opaque, int version_id) +static bool max_queue_pairs_gt_1(void *opaque, int version_id) { - return VIRTIO_NET(opaque)->max_queues > 1; + return VIRTIO_NET(opaque)->max_queue_pairs > 1; } =20 static bool has_ctrl_guest_offloads(void *opaque, int version_id) @@ -2958,13 +2958,13 @@ static bool mac_table_doesnt_fit(void *opaque, int = version_id) struct VirtIONetMigTmp { VirtIONet *parent; VirtIONetQueue *vqs_1; - uint16_t curr_queues_1; + uint16_t curr_queue_pairs_1; uint8_t has_ufo; uint32_t has_vnet_hdr; }; =20 /* The 2nd and subsequent tx_waiting flags are loaded later than - * the 1st entry in the queues and only if there's more than one + * the 1st entry in the queue_pairs and only if there's more than one * entry. We use the tmp mechanism to calculate a temporary * pointer and count and also validate the count. */ @@ -2974,9 +2974,9 @@ static int virtio_net_tx_waiting_pre_save(void *opaqu= e) struct VirtIONetMigTmp *tmp =3D opaque; =20 tmp->vqs_1 =3D tmp->parent->vqs + 1; - tmp->curr_queues_1 =3D tmp->parent->curr_queues - 1; - if (tmp->parent->curr_queues =3D=3D 0) { - tmp->curr_queues_1 =3D 0; + tmp->curr_queue_pairs_1 =3D tmp->parent->curr_queue_pairs - 1; + if (tmp->parent->curr_queue_pairs =3D=3D 0) { + tmp->curr_queue_pairs_1 =3D 0; } =20 return 0; @@ -2989,9 +2989,9 @@ static int virtio_net_tx_waiting_pre_load(void *opaqu= e) /* Reuse the pointer setup from save */ virtio_net_tx_waiting_pre_save(opaque); =20 - if (tmp->parent->curr_queues > tmp->parent->max_queues) { - error_report("virtio-net: curr_queues %x > max_queues %x", - tmp->parent->curr_queues, tmp->parent->max_queues); + if (tmp->parent->curr_queue_pairs > tmp->parent->max_queue_pairs) { + error_report("virtio-net: curr_queue_pairs %x > max_queue_pairs %x= ", + tmp->parent->curr_queue_pairs, tmp->parent->max_queue_pairs); =20 return -EINVAL; } @@ -3005,7 +3005,7 @@ static const VMStateDescription vmstate_virtio_net_tx= _waiting =3D { .pre_save =3D virtio_net_tx_waiting_pre_save, .fields =3D (VMStateField[]) { VMSTATE_STRUCT_VARRAY_POINTER_UINT16(vqs_1, struct VirtIONetMigTmp, - curr_queues_1, + curr_queue_pairs_1, vmstate_virtio_net_queue_tx_waiting, struct VirtIONetQueue), VMSTATE_END_OF_LIST() @@ -3147,9 +3147,9 @@ static const VMStateDescription vmstate_virtio_net_de= vice =3D { VMSTATE_UINT8(nobcast, VirtIONet), VMSTATE_WITH_TMP(VirtIONet, struct VirtIONetMigTmp, vmstate_virtio_net_has_ufo), - VMSTATE_SINGLE_TEST(max_queues, VirtIONet, max_queues_gt_1, 0, + VMSTATE_SINGLE_TEST(max_queue_pairs, VirtIONet, max_queue_pairs_gt= _1, 0, vmstate_info_uint16_equal, uint16_t), - VMSTATE_UINT16_TEST(curr_queues, VirtIONet, max_queues_gt_1), + VMSTATE_UINT16_TEST(curr_queue_pairs, VirtIONet, max_queue_pairs_g= t_1), VMSTATE_WITH_TMP(VirtIONet, struct VirtIONetMigTmp, vmstate_virtio_net_tx_waiting), VMSTATE_UINT64_TEST(curr_guest_offloads, VirtIONet, @@ -3393,16 +3393,16 @@ static void virtio_net_device_realize(DeviceState *= dev, Error **errp) return; } =20 - n->max_queues =3D MAX(n->nic_conf.peers.queues, 1); - if (n->max_queues * 2 + 1 > VIRTIO_QUEUE_MAX) { - error_setg(errp, "Invalid number of queues (=3D %" PRIu32 "), " + n->max_queue_pairs =3D MAX(n->nic_conf.peers.queues, 1); + if (n->max_queue_pairs * 2 + 1 > VIRTIO_QUEUE_MAX) { + error_setg(errp, "Invalid number of queue_pairs (=3D %" PRIu32 "),= " "must be a positive integer less than %d.", - n->max_queues, (VIRTIO_QUEUE_MAX - 1) / 2); + n->max_queue_pairs, (VIRTIO_QUEUE_MAX - 1) / 2); virtio_cleanup(vdev); return; } - n->vqs =3D g_malloc0(sizeof(VirtIONetQueue) * n->max_queues); - n->curr_queues =3D 1; + n->vqs =3D g_malloc0(sizeof(VirtIONetQueue) * n->max_queue_pairs); + n->curr_queue_pairs =3D 1; n->tx_timeout =3D n->net_conf.txtimer; =20 if (n->net_conf.tx && strcmp(n->net_conf.tx, "timer") @@ -3416,7 +3416,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) n->net_conf.tx_queue_size =3D MIN(virtio_net_max_tx_queue_size(n), n->net_conf.tx_queue_size); =20 - for (i =3D 0; i < n->max_queues; i++) { + for (i =3D 0; i < n->max_queue_pairs; i++) { virtio_net_add_queue(n, i); } =20 @@ -3440,13 +3440,13 @@ static void virtio_net_device_realize(DeviceState *= dev, Error **errp) object_get_typename(OBJECT(dev)), dev->id, n= ); } =20 - for (i =3D 0; i < n->max_queues; i++) { + for (i =3D 0; i < n->max_queue_pairs; i++) { n->nic->ncs[i].do_not_pad =3D true; } =20 peer_test_vnet_hdr(n); if (peer_has_vnet_hdr(n)) { - for (i =3D 0; i < n->max_queues; i++) { + for (i =3D 0; i < n->max_queue_pairs; i++) { qemu_using_vnet_hdr(qemu_get_subqueue(n->nic, i)->peer, true); } n->host_hdr_len =3D sizeof(struct virtio_net_hdr); @@ -3488,7 +3488,7 @@ static void virtio_net_device_unrealize(DeviceState *= dev) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIONet *n =3D VIRTIO_NET(dev); - int i, max_queues; + int i, max_queue_pairs; =20 if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) { virtio_net_unload_ebpf(n); @@ -3510,12 +3510,12 @@ static void virtio_net_device_unrealize(DeviceState= *dev) remove_migration_state_change_notifier(&n->migration_state); } =20 - max_queues =3D n->multiqueue ? n->max_queues : 1; - for (i =3D 0; i < max_queues; i++) { + max_queue_pairs =3D n->multiqueue ? n->max_queue_pairs : 1; + for (i =3D 0; i < max_queue_pairs; i++) { virtio_net_del_queue(n, i); } /* delete also control vq */ - virtio_del_queue(vdev, max_queues * 2); + virtio_del_queue(vdev, max_queue_pairs * 2); qemu_announce_timer_del(&n->announce_timer, false); g_free(n->vqs); qemu_del_nic(n->nic); --=20 MST From nobody Wed May 8 08:20:40 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633451650; cv=none; d=zohomail.com; s=zohoarc; b=D5O0P2Ej5iPLMwG2hJ7YPh8DqTFABMFw4q3bdQp9+sH2qw68kmBYqOfDQ3G+VLf+PeJucQJNiY6mQNh8Oejcqip28hutmVu9O7MJGUg79Vp4ItNjfxAhoLjkmGMPQvUQ3nONuUUD0oiAyuiUpxwAXfanlaNonkSDB3Q9Y6EfOfg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633451650; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=d/UhAX8qqzFfBbaE8CkU4RYO+sribXdFP+HxFT6ht6I=; b=Zimd+kphWvydkhCXllKzmZotCaFm3kXxzk3vOrP/WVmVj8yCs4knuRSy6Rlcw5g3CA364e+WKHzLG3mMiqvAyIpoAIQv133VWt2crzgxCClKlFnBE5FHdhdkizfkd6wRANyHTXHH7lE1+psBg00ZXw6jAI/dSQdZe19mTWg3yl0= 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 163345165022932.19581729709557; Tue, 5 Oct 2021 09:34:10 -0700 (PDT) Received: from localhost ([::1]:58904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnOH-0005FW-HI for importer@patchew.org; Tue, 05 Oct 2021 12:34:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsp-0000B4-EP for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41846) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsl-0004xe-Jf for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:33 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-494-BhFGMh-NMJyvX0ngxTh6YA-1; Tue, 05 Oct 2021 12:01:27 -0400 Received: by mail-wr1-f71.google.com with SMTP id d13-20020adfa34d000000b00160aa1cc5f1so2191510wrb.14 for ; Tue, 05 Oct 2021 09:01:26 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id r9sm18084430wru.2.2021.10.05.09.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:01:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449689; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=d/UhAX8qqzFfBbaE8CkU4RYO+sribXdFP+HxFT6ht6I=; b=IqqASnyorCUDzL7BmN1VZuAFdKMd7/8B8GwCFVcC6ad6R2cIgDW3Oj5JbW+hT5qk37lkGB fCLqhMzkA3XW4T+0QuSAAYsqPBHqosGzJSa4w9fzR2oob8OpBfoW5qfI46wXeRl6CDtEOL 4t42E917IKczIisc5DENGAW6pOwk9oA= X-MC-Unique: BhFGMh-NMJyvX0ngxTh6YA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=d/UhAX8qqzFfBbaE8CkU4RYO+sribXdFP+HxFT6ht6I=; b=o/on5erBez5GRyF/nT0oEchdXyTUXyO8niVF5rTYwXnPy8kkNkf0B3Ud5YaSv/j6/0 QgaGNy1mDDlyQuhxt4LtfrlwhIHAuvUfdlXEkQ4DfWd8JxfidKCnFZ2J7qZ0F9VhV42R fZ+FcngdGwM/6Aj7oQyo2noMPlKZrPdQJtRrw4+WfqpKMaYiEX3yCAgBdAq4lO+n1VJ0 2FFobOvo03KChVjyfe3IoZyQEdRg9YUHquOopd2ylPr7wDDN+hlNuse4pDlKL6mgcrI+ NznbAAqLzIlfMV+Xda8CzCalcg4So/QmNd9E6nWZG5gZQcTZttxXON5xLTlcS9vZfhGD UZVw== X-Gm-Message-State: AOAM533UnO7iQOVlWYVZ7Y9kWuqeDML+0LTXhPZi0NSvlT6V7PN5pK5Y 1fQOQfGDHc7y40JxSufvOPRHFmvBUA31L700lsOHihT5xEpEwQ+XI4PaEjW/Fy6DWZYV7Mvfyd+ VGwZH5o7+jTrPlySoK/YhTkOuBKvcIUex3sRGv4N4q3Ihsbq/yWjBrdolb6eR X-Received: by 2002:adf:9c02:: with SMTP id f2mr22811452wrc.329.1633449682669; Tue, 05 Oct 2021 09:01:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDzUe2ztA8MzCq8L1earx//op71m8Suoy8MFnQ+ITQ9GbWM4SGUVebmgi9Bxy7iAzb/vLX7A== X-Received: by 2002:adf:9c02:: with SMTP id f2mr22810906wrc.329.1633449678762; Tue, 05 Oct 2021 09:01:18 -0700 (PDT) Date: Tue, 5 Oct 2021 12:01:15 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 10/57] vhost: record the last virtqueue index for the virtio device Message-ID: <20211005155946.513818-11-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633451651840100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang This patch introduces a new field in the vhost_dev structure to record the last virtqueue index for the virtio device. This will be useful for the vhost backends with 1:N model to start or stop the device after all the vhost_dev structures were started or stopped. Signed-off-by: Jason Wang Message-Id: <20210907090322.1756-9-jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost.h | 2 ++ hw/net/vhost_net.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 1a9fc65089..3fa0b554ef 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -74,6 +74,8 @@ struct vhost_dev { unsigned int nvqs; /* the first virtqueue which would be used by this vhost dev */ int vq_index; + /* the last vq index for the virtio device (not vhost) */ + int last_index; /* if non-zero, minimum required value for max_queues */ int num_queues; uint64_t features; diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 2b594b4642..3aabab06ea 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -231,9 +231,11 @@ fail: return NULL; } =20 -static void vhost_net_set_vq_index(struct vhost_net *net, int vq_index) +static void vhost_net_set_vq_index(struct vhost_net *net, int vq_index, + int last_index) { net->dev.vq_index =3D vq_index; + net->dev.last_index =3D last_index; } =20 static int vhost_net_start_one(struct vhost_net *net, @@ -324,9 +326,13 @@ int vhost_net_start(VirtIODevice *dev, NetClientState = *ncs, VirtIONet *n =3D VIRTIO_NET(dev); int nvhosts =3D data_queue_pairs + cvq; struct vhost_net *net; - int r, e, i; + int r, e, i, last_index =3D data_qps * 2; NetClientState *peer; =20 + if (!cvq) { + last_index -=3D 1; + } + if (!k->set_guest_notifiers) { error_report("binding does not support guest notifiers"); return -ENOSYS; @@ -341,7 +347,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *= ncs, } =20 net =3D get_vhost_net(peer); - vhost_net_set_vq_index(net, i * 2); + vhost_net_set_vq_index(net, i * 2, last_index); =20 /* Suppress the masking guest notifiers on vhost user * because vhost user doesn't interrupt masking/unmasking --=20 MST From nobody Wed May 8 08:20:40 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633450384; cv=none; d=zohomail.com; s=zohoarc; b=hJLP7xF2uZ39jir5eRIDuX2hP5BbgEPRR2cBxit7wCCXBf8Cunuhy91uIhlHHr2eHIxWAc4gwFjHhhoAB9WZZ+IXFgCcXRQMxjaE49AU/FWMNBTSZYWG7jXWQc37k0PrTAmpd8LU93A5EoNyL444+s4Zm9rCheuAz14oK8YLT6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633450384; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=E/2AbBIxr8gJIB7YiiNV6HX7OyqnjUd6KvubBiO23Xo=; b=iaf7ktpSCF/RfrBTJ6kwJ4zQQ5BsrWvqPMD88bFaUUV5mwdehOdmuwbUO4gTSINzZ4igDnezc5DSOIT4ioih/9bd4GnFdIUP9GI2mQV7j4WamsmuptVl+tKN49vWB8mN1AHYRqw/vT05eq3TK65i5cRX8XO6PUEWgjcCBTTxK/U= 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 1633450384523559.956891557021; Tue, 5 Oct 2021 09:13:04 -0700 (PDT) Received: from localhost ([::1]:43780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXn3u-0000sQ-VP for importer@patchew.org; Tue, 05 Oct 2021 12:13:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsm-0000AE-Oc for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42155) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsi-0004us-R1 for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:31 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-482-jhwAf8ACP1SFFvXfJJtGmw-1; Tue, 05 Oct 2021 12:01:25 -0400 Received: by mail-wr1-f70.google.com with SMTP id f11-20020adfc98b000000b0015fedc2a8d4so5921795wrh.0 for ; Tue, 05 Oct 2021 09:01:25 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id d16sm2238699wmb.2.2021.10.05.09.01.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:01:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449686; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E/2AbBIxr8gJIB7YiiNV6HX7OyqnjUd6KvubBiO23Xo=; b=ZXbiViFg7PT5eWPcVFiS+5+0hOEH4H0PUDZDcTOhTDNbZaK6Ikneo2vn9I9j/Qfx47Gsqy O13SFyfP29ZyUiqLmuhb/Px66mdlSN7qm09JHMoLv4kRQDiXKTDA3qwQGcC7DVT2CYno7T a3lsXyGAXVi8Xo7q+CCS/NnH+tim08M= X-MC-Unique: jhwAf8ACP1SFFvXfJJtGmw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=E/2AbBIxr8gJIB7YiiNV6HX7OyqnjUd6KvubBiO23Xo=; b=qMmEsA1qePk+bvM/YMAudSjIrL1N0wvIFz08Xv/ZfXwYNyJaemiSk6HGqxaL6JZibj iIauzNKzct3sxR5AYkyDsswnQEzkJoRXH+3AQX/VMrl8KfkobGlw3MlPqU/GCwEz8Twr TTtOAXAxfY/Pf1pN35fUcCjQ5uvEPJnZ9dNjxGrD++HQTOCLIRRLbizJEX2bfVctEIl9 Gm5EhPBxzBLaC8p9K/r4Q0/0i000FpIubieQotqaUK3Ja75HuP91d+aKgHk0C0Sl7JHn safY0b9VtkErkfrI+WP3/KbYdpFo9v3Xgs2JV7aR/Q6qcGnAyGJ5/a3wVzUn/sKSgplP ybSg== X-Gm-Message-State: AOAM533jaidz2/kb2LEX2l8TJAm8Hr38RQqpObIe3ZEVjbhE2Km+B5o8 ObDHKPJfP9BHWlx0TU8mqoSLS8CoXhtgHTq28OfZTeuQdQHobmT1PsgNi5M0bO8FLwDD6W444SI SmeJFtW3S+/f5Il9vy4PBujCLQx3m5ljFYLQYgpqhcdGelwx02atCs8wQR/KK X-Received: by 2002:a1c:43c3:: with SMTP id q186mr4218967wma.143.1633449683519; Tue, 05 Oct 2021 09:01:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvDYisFhozDkxlqSWshcqezbP5c8oMJhq+JguusiNSjzMFVO4EAvdwTbzxTfL2iqn+p0muGw== X-Received: by 2002:a1c:43c3:: with SMTP id q186mr4218933wma.143.1633449683285; Tue, 05 Oct 2021 09:01:23 -0700 (PDT) Date: Tue, 5 Oct 2021 12:01:20 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 11/57] virtio-net: vhost control virtqueue support Message-ID: <20211005155946.513818-12-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633450386624100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang This patch implements the control virtqueue support for vhost. This requires virtio-net to figure out the datapath queue pairs and control virtqueue via is_datapath and pass the number of those two types of virtqueues to vhost_net_start()/vhost_net_stop(). Signed-off-by: Jason Wang Message-Id: <20210907090322.1756-10-jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-net.h | 1 + hw/net/vhost_net.c | 2 +- hw/net/virtio-net.c | 23 +++++++++++++++++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 71cbdc26d7..08ee6dea39 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -196,6 +196,7 @@ struct VirtIONet { int multiqueue; uint16_t max_queue_pairs; uint16_t curr_queue_pairs; + uint16_t max_ncs; size_t config_size; char *netclient_name; char *netclient_type; diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 3aabab06ea..0d888f29a6 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -326,7 +326,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *= ncs, VirtIONet *n =3D VIRTIO_NET(dev); int nvhosts =3D data_queue_pairs + cvq; struct vhost_net *net; - int r, e, i, last_index =3D data_qps * 2; + int r, e, i, last_index =3D data_queue_pairs * 2; NetClientState *peer; =20 if (!cvq) { diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 2ade019b22..57a0cbc6cd 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -244,6 +244,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8= _t status) VirtIODevice *vdev =3D VIRTIO_DEVICE(n); NetClientState *nc =3D qemu_get_queue(n->nic); int queue_pairs =3D n->multiqueue ? n->max_queue_pairs : 1; + int cvq =3D n->max_ncs - n->max_queue_pairs; =20 if (!get_vhost_net(nc->peer)) { return; @@ -285,14 +286,14 @@ static void virtio_net_vhost_status(VirtIONet *n, uin= t8_t status) } =20 n->vhost_started =3D 1; - r =3D vhost_net_start(vdev, n->nic->ncs, queue_pairs, 0); + r =3D vhost_net_start(vdev, n->nic->ncs, queue_pairs, cvq); if (r < 0) { error_report("unable to start vhost net: %d: " "falling back on userspace virtio", -r); n->vhost_started =3D 0; } } else { - vhost_net_stop(vdev, n->nic->ncs, queue_pairs, 0); + vhost_net_stop(vdev, n->nic->ncs, queue_pairs, cvq); n->vhost_started =3D 0; } } @@ -3393,9 +3394,23 @@ static void virtio_net_device_realize(DeviceState *d= ev, Error **errp) return; } =20 - n->max_queue_pairs =3D MAX(n->nic_conf.peers.queues, 1); + n->max_ncs =3D MAX(n->nic_conf.peers.queues, 1); + + /* + * Figure out the datapath queue pairs since the backend could + * provide control queue via peers as well. + */ + if (n->nic_conf.peers.queues) { + for (i =3D 0; i < n->max_ncs; i++) { + if (n->nic_conf.peers.ncs[i]->is_datapath) { + ++n->max_queue_pairs; + } + } + } + n->max_queue_pairs =3D MAX(n->max_queue_pairs, 1); + if (n->max_queue_pairs * 2 + 1 > VIRTIO_QUEUE_MAX) { - error_setg(errp, "Invalid number of queue_pairs (=3D %" PRIu32 "),= " + error_setg(errp, "Invalid number of queue pairs (=3D %" PRIu32 "),= " "must be a positive integer less than %d.", n->max_queue_pairs, (VIRTIO_QUEUE_MAX - 1) / 2); virtio_cleanup(vdev); --=20 MST From nobody Wed May 8 08:20:40 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633450664; cv=none; d=zohomail.com; s=zohoarc; b=M1LLnPWv66mxm9YDIhu2ms4qPPyP0SD1rHwslkQsZuXZWfiU40AaLZy35Ud/g+VrAGZrGP43IhCp3U7CjaTjVDHgNVsrQ2h9K+h5cUgDIcImbJ/aDnkfeyYXrB5Kv3vxXfja6Oqbwa6+HCoq+0gcjjwZdlAsP+jnb+MHeUcZZr8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633450664; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hX3b5CaKP1VVugxs36uHglvddVRMuC85IYkRRxHHhEk=; b=OMR04lQ86mq0FM54uCW6njjTPIFoP0ovoiNs6z5tpV0IxvjlSiAj+41dKgefCYrZ2Z4rhjdkkOzM85iQyxE0IQQSl/cpVCWpX2haz8UaYUFYVbJmCSsSIL/TGLMPui4Ig2Shtjx0+RMgJINNWUBkDuVwR9bEGdSTIR+axCNPoW8= 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 163345066461529.83160006415801; Tue, 5 Oct 2021 09:17:44 -0700 (PDT) Received: from localhost ([::1]:52088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXn8R-0006pD-IL for importer@patchew.org; Tue, 05 Oct 2021 12:17:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsp-0000B3-Eb for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsl-0004ye-Jp for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:34 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-365-qUOJN0hwNfmzMETjGnYdkg-1; Tue, 05 Oct 2021 12:01:29 -0400 Received: by mail-wm1-f69.google.com with SMTP id z22-20020a7bc7d6000000b0030d5c26120fso1221368wmk.1 for ; Tue, 05 Oct 2021 09:01:28 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id f3sm2305698wmb.12.2021.10.05.09.01.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:01:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hX3b5CaKP1VVugxs36uHglvddVRMuC85IYkRRxHHhEk=; b=Ar7OJwddF+vRiMBm5zAOJkiagVa6Xn3zq5oue20pMsMjKesFHJufAjvT7V+bbCUBH+M0fk xsr3cTi9hSBiP+DdxRku7DnJ6dwWRgKuH9MPx0JheE/Tgcqdl0TuUmcPJZpK9ULsBCQuli sXGNk9D8s50IQe1nrfFnKHZ0GV0f9e8= X-MC-Unique: qUOJN0hwNfmzMETjGnYdkg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=hX3b5CaKP1VVugxs36uHglvddVRMuC85IYkRRxHHhEk=; b=GwRzK4wDq/wHOUDQaxAO57AbD1yABmRV72tnzP2A2pZDQLzlnvw40FurPLas9mIMv4 KSk05vXK2CU5KNysjE1qHCFr6y95MeURdduLisGI7Il1XOkvHPrLNFL+wWtcrGCZGSAr hiJ+sFA6fyQF1eLOvjMrPfxST3Y+ijo1cm6xB65HliO3BzAs2/5M30rWCQZq/szXm29m 1VywkrloRZWCFFf8xr+KtAGeN0VZot8SLxxVy3EFqCtvhdlRRIDk+KL2vWVITHGbxBno u3a5AltO3n7FxwP0X3OmW1frrfW8rOqGAZCEkcjOd3xwIPORU0Zpt8nCPWVLbdIRDDhV GqrA== X-Gm-Message-State: AOAM532l6oiCkZm9HcPKtRD867U1LS3qYkugDohTaUZm1jDcsE/NMT7B thiV0EaEo+xMe0h4enenefvx8m6J4vzaomfqozvyBljPb/MBTXWL1Fh4A72weXfUKIpPk5rChNO u4QeJ/WzdIjPf5jBt/dbYivKpUqQpNdu45ql218dmtX8Su7HEsIxZD1vxdMrH X-Received: by 2002:a05:600c:4fc3:: with SMTP id o3mr203653wmq.158.1633449687131; Tue, 05 Oct 2021 09:01:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZy5hHeKlvleZe78zO8dW2PSCwXhbF3xk+juPEz+6RDCarvJfFCCwoF7Cv8vGZEffoLjmH+Q== X-Received: by 2002:a05:600c:4fc3:: with SMTP id o3mr203618wmq.158.1633449686801; Tue, 05 Oct 2021 09:01:26 -0700 (PDT) Date: Tue, 5 Oct 2021 12:01:23 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 12/57] vhost-vdpa: multiqueue support Message-ID: <20211005155946.513818-13-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633450665275100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang This patch implements the multiqueue support for vhost-vdpa. This is done simply by reading the number of queue pairs from the config space and initialize the datapath and control path net client. Signed-off-by: Jason Wang Message-Id: <20210907090322.1756-11-jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vdpa.c | 2 +- net/vhost-vdpa.c | 105 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 97 insertions(+), 10 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 8587d30918..f9acfe9bdb 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -590,7 +590,7 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, = bool started) vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); } =20 - if (vhost_vdpa_one_time_request(dev)) { + if (dev->vq_index + dev->nvqs !=3D dev->last_index) { return 0; } =20 diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 834dab28dd..533b15ae8c 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -18,6 +18,7 @@ #include "qemu/error-report.h" #include "qemu/option.h" #include "qapi/error.h" +#include #include #include #include "standard-headers/linux/virtio_net.h" @@ -51,6 +52,14 @@ const int vdpa_feature_bits[] =3D { VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_MTU, + VIRTIO_NET_F_CTRL_RX, + VIRTIO_NET_F_CTRL_RX_EXTRA, + VIRTIO_NET_F_CTRL_VLAN, + VIRTIO_NET_F_GUEST_ANNOUNCE, + VIRTIO_NET_F_CTRL_MAC_ADDR, + VIRTIO_NET_F_RSS, + VIRTIO_NET_F_MQ, + VIRTIO_NET_F_CTRL_VQ, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_PACKED, VIRTIO_NET_F_RSS, @@ -81,7 +90,8 @@ static int vhost_vdpa_net_check_device_id(struct vhost_ne= t *net) return ret; } =20 -static int vhost_vdpa_add(NetClientState *ncs, void *be) +static int vhost_vdpa_add(NetClientState *ncs, void *be, + int queue_pair_index, int nvqs) { VhostNetOptions options; struct vhost_net *net =3D NULL; @@ -94,7 +104,7 @@ static int vhost_vdpa_add(NetClientState *ncs, void *be) options.net_backend =3D ncs; options.opaque =3D be; options.busyloop_timeout =3D 0; - options.nvqs =3D 2; + options.nvqs =3D nvqs; =20 net =3D vhost_net_init(&options); if (!net) { @@ -158,18 +168,28 @@ static NetClientInfo net_vhost_vdpa_info =3D { static NetClientState *net_vhost_vdpa_init(NetClientState *peer, const char *device, const char *name, - int vdpa_device_fd) + int vdpa_device_fd, + int queue_pair_index, + int nvqs, + bool is_datapath) { NetClientState *nc =3D NULL; VhostVDPAState *s; int ret =3D 0; assert(name); - nc =3D qemu_new_net_client(&net_vhost_vdpa_info, peer, device, name); + if (is_datapath) { + nc =3D qemu_new_net_client(&net_vhost_vdpa_info, peer, device, + name); + } else { + nc =3D qemu_new_net_control_client(&net_vhost_vdpa_info, peer, + device, name); + } snprintf(nc->info_str, sizeof(nc->info_str), TYPE_VHOST_VDPA); s =3D DO_UPCAST(VhostVDPAState, nc, nc); =20 s->vhost_vdpa.device_fd =3D vdpa_device_fd; - ret =3D vhost_vdpa_add(nc, (void *)&s->vhost_vdpa); + s->vhost_vdpa.index =3D queue_pair_index; + ret =3D vhost_vdpa_add(nc, (void *)&s->vhost_vdpa, queue_pair_index, n= vqs); if (ret) { qemu_del_net_client(nc); return NULL; @@ -195,12 +215,52 @@ static int net_vhost_check_net(void *opaque, QemuOpts= *opts, Error **errp) return 0; } =20 +static int vhost_vdpa_get_max_queue_pairs(int fd, int *has_cvq, Error **er= rp) +{ + unsigned long config_size =3D offsetof(struct vhost_vdpa_config, buf); + struct vhost_vdpa_config *config; + __virtio16 *max_queue_pairs; + uint64_t features; + int ret; + + ret =3D ioctl(fd, VHOST_GET_FEATURES, &features); + if (ret) { + error_setg(errp, "Fail to query features from vhost-vDPA device"); + return ret; + } + + if (features & (1 << VIRTIO_NET_F_CTRL_VQ)) { + *has_cvq =3D 1; + } else { + *has_cvq =3D 0; + } + + if (features & (1 << VIRTIO_NET_F_MQ)) { + config =3D g_malloc0(config_size + sizeof(*max_queue_pairs)); + config->off =3D offsetof(struct virtio_net_config, max_virtqueue_p= airs); + config->len =3D sizeof(*max_queue_pairs); + + ret =3D ioctl(fd, VHOST_VDPA_GET_CONFIG, config); + if (ret) { + error_setg(errp, "Fail to get config from vhost-vDPA device"); + return -ret; + } + + max_queue_pairs =3D (__virtio16 *)&config->buf; + + return lduw_le_p(max_queue_pairs); + } + + return 1; +} + int net_init_vhost_vdpa(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { const NetdevVhostVDPAOptions *opts; int vdpa_device_fd; - NetClientState *nc; + NetClientState **ncs, *nc; + int queue_pairs, i, has_cvq =3D 0; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); opts =3D &netdev->u.vhost_vdpa; @@ -215,11 +275,38 @@ int net_init_vhost_vdpa(const Netdev *netdev, const c= har *name, return -errno; } =20 - nc =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd= ); - if (!nc) { + queue_pairs =3D vhost_vdpa_get_max_queue_pairs(vdpa_device_fd, + &has_cvq, errp); + if (queue_pairs < 0) { qemu_close(vdpa_device_fd); - return -1; + return queue_pairs; } =20 + ncs =3D g_malloc0(sizeof(*ncs) * queue_pairs); + + for (i =3D 0; i < queue_pairs; i++) { + ncs[i] =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, + vdpa_device_fd, i, 2, true); + if (!ncs[i]) + goto err; + } + + if (has_cvq) { + nc =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, + vdpa_device_fd, i, 1, false); + if (!nc) + goto err; + } + + g_free(ncs); return 0; + +err: + if (i) { + qemu_del_net_client(ncs[0]); + } + qemu_close(vdpa_device_fd); + g_free(ncs); + + return -1; } --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633451854073254.42078519388212; Tue, 5 Oct 2021 09:37:34 -0700 (PDT) Received: from localhost ([::1]:39144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnRc-0002di-WD for importer@patchew.org; Tue, 05 Oct 2021 12:37:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsw-0000F2-RT for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21130) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsu-00055H-4l for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:42 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-63-ANSAZk5ePU2hCvrXMO2bSQ-1; Tue, 05 Oct 2021 12:01:34 -0400 Received: by mail-wm1-f72.google.com with SMTP id 13-20020a05600c230d00b0030d762b5832so957334wmo.9 for ; Tue, 05 Oct 2021 09:01:33 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id o19sm19065749wrg.60.2021.10.05.09.01.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449696; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Fs2jGv1ZGLGWfNNqaXvArTOk/Hk3P7U2RtH4BA/MbhI=; b=E02xj45cRd9QsU/dszJOss4tT7WFyBhtzfuGqMRTtNFGzGgDPowBrWEXT4ccMvU5R32uVU 7R8fac+zn39DUKEZF6VovCNIQvpJmUgmlO79UKa+UT1b7nfv/sVkE6KdUQdF5kDMWIGmvG eZGPk24n/K5LjODz2rJvaZnJpx3bWqA= X-MC-Unique: ANSAZk5ePU2hCvrXMO2bSQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Fs2jGv1ZGLGWfNNqaXvArTOk/Hk3P7U2RtH4BA/MbhI=; b=vwMSi5HK7Y8KrBsnBdnKiDXCyTeyXnaz40iaXiVoC/CMfFQaiEhYX+6aUtPcUYTXDz PR7Wovcny7L+4APkC9I+uBqSJZKDCUaIBV/4VHP5J+jefqY7PFgOO/n8+bgLQQ7vfdq9 JVH6pUMZWo7NUv3AZ5pjAYGLlM2b3Sxuwm6NW62OPNC5nSOXaYwZYH7rXXTUrx5fIJ7H Z0RhJNXeAr53nJRCFEAVSA6m7lZIHjImFlg7lc4xmOqEcH6PyfSexRtYyEIb5aL+oEw/ qBjoU9iY8uOKWnKXue9XsWGhu20EX+QClsbmuqfxdiCbwLUoS8SkYeKLDbmUi6MYAo+K v33g== X-Gm-Message-State: AOAM533v0p5Bpw2Al6Y9Qx8kgHIFF9rxC8FAa/aiLk/bjCXj79wX7KOo IXP0livPPwHGjBpSaPwXtZLDC3H4myMrEZuhzTErZBnWLqr+HePpMYtY1xxrqj4dUjZqKchsmJ3 6srGSCxpXfQcwaC3Bm7jIedKFk2edH2n9McgenapsXCuaoPooOPT4bLPunz2t X-Received: by 2002:adf:9d47:: with SMTP id o7mr22912102wre.50.1633449692081; Tue, 05 Oct 2021 09:01:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyhIil+A2dE+e5z3LVeqsbh0w5d827MXLnNciuRdWpfirOe4uqbiA9gidpboN2TvOGJTaWaA== X-Received: by 2002:adf:9d47:: with SMTP id o7mr22912063wre.50.1633449691804; Tue, 05 Oct 2021 09:01:31 -0700 (PDT) Date: Tue, 5 Oct 2021 12:01:27 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 13/57] vhost-vsock: fix migration issue when seqpacket is supported Message-ID: <20211005155946.513818-14-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Jiang Wang , qemu-stable@nongnu.org, Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633451855852100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella Commit 1e08fd0a46 ("vhost-vsock: SOCK_SEQPACKET feature bit support") enabled the SEQPACKET feature bit. This commit is released with QEMU 6.1, so if we try to migrate a VM where the host kernel supports SEQPACKET but machine type version is less than 6.1, we get the following errors: Features 0x130000002 unsupported. Allowed features: 0x179000000 Failed to load virtio-vhost_vsock:virtio error while loading state for instance 0x0 of device '0000:00:05.0/virt= io-vhost_vsock' load of migration failed: Operation not permitted Let's disable the feature bit for machine types < 6.1. We add a new OnOffAuto property for this, called `seqpacket`. When it is `auto` (default), QEMU behaves as before, trying to enable the feature, when it is `on` QEMU will fail if the backend (vhost-vsock kernel module) doesn't support it. Fixes: 1e08fd0a46 ("vhost-vsock: SOCK_SEQPACKET feature bit support") Cc: qemu-stable@nongnu.org Reported-by: Jiang Wang Signed-off-by: Stefano Garzarella Message-Id: <20210921161642.206461-2-sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-vsock.h | 3 +++ hw/core/machine.c | 1 + hw/virtio/vhost-vsock.c | 19 ++++++++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/hw/virtio/vhost-vsock.h b/include/hw/virtio/vhost-vsoc= k.h index 84f4e727c7..3f121a624f 100644 --- a/include/hw/virtio/vhost-vsock.h +++ b/include/hw/virtio/vhost-vsock.h @@ -30,6 +30,9 @@ struct VHostVSock { VHostVSockCommon parent; VHostVSockConf conf; =20 + /* features */ + OnOffAuto seqpacket; + /*< public >*/ }; =20 diff --git a/hw/core/machine.c b/hw/core/machine.c index 3920a2f2af..74f2a9a984 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -46,6 +46,7 @@ GlobalProperty hw_compat_6_0[] =3D { { "nvme-ns", "eui64-default", "off"}, { "e1000", "init-vet", "off" }, { "e1000e", "init-vet", "off" }, + { "vhost-vsock-device", "seqpacket", "off" }, }; const size_t hw_compat_6_0_len =3D G_N_ELEMENTS(hw_compat_6_0); =20 diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 1b1a5c70ed..dade0da031 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -114,10 +114,21 @@ static uint64_t vhost_vsock_get_features(VirtIODevice= *vdev, Error **errp) { VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); + VHostVSock *vsock =3D VHOST_VSOCK(vdev); =20 - virtio_add_feature(&requested_features, VIRTIO_VSOCK_F_SEQPACKET); - return vhost_get_features(&vvc->vhost_dev, feature_bits, - requested_features); + if (vsock->seqpacket !=3D ON_OFF_AUTO_OFF) { + virtio_add_feature(&requested_features, VIRTIO_VSOCK_F_SEQPACKET); + } + + requested_features =3D vhost_get_features(&vvc->vhost_dev, feature_bit= s, + requested_features); + + if (vsock->seqpacket =3D=3D ON_OFF_AUTO_ON && + !virtio_has_feature(requested_features, VIRTIO_VSOCK_F_SEQPACKET))= { + error_setg(errp, "vhost-vsock backend doesn't support seqpacket"); + } + + return requested_features; } =20 static const VMStateDescription vmstate_virtio_vhost_vsock =3D { @@ -218,6 +229,8 @@ static void vhost_vsock_device_unrealize(DeviceState *d= ev) static Property vhost_vsock_properties[] =3D { DEFINE_PROP_UINT64("guest-cid", VHostVSock, conf.guest_cid, 0), DEFINE_PROP_STRING("vhostfd", VHostVSock, conf.vhostfd), + DEFINE_PROP_ON_OFF_AUTO("seqpacket", VHostVSock, seqpacket, + ON_OFF_AUTO_AUTO), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633450924785510.84123274611284; Tue, 5 Oct 2021 09:22:04 -0700 (PDT) Received: from localhost ([::1]:60894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnCd-0004LP-Oq for importer@patchew.org; Tue, 05 Oct 2021 12:22:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsw-0000F1-RA for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37883) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmsu-00058A-5B for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:42 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-326-TqYtCYOcOeqmAv1_KQhdlw-1; Tue, 05 Oct 2021 12:01:37 -0400 Received: by mail-wr1-f71.google.com with SMTP id d13-20020adf9b8d000000b00160a94c235aso2296109wrc.2 for ; Tue, 05 Oct 2021 09:01:37 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id m21sm2590940wmq.37.2021.10.05.09.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449698; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dLqgegjxL7pN0HDxyZfbuN/wY/nTKcbE0sqdZS/D2ns=; b=ERKiT1TEvy47vKg5GhTp4ipg4W6dys9KT/oius/4RHlDjL1vbiMqmWPTi/ovbmq1ACfGYb vMY9Y3rpgpvYmdNrv8y9RsGc2utgPQkbO4x/p8ZQp27UlMHnjQ/9iIjON6/wUr5kFM2EV9 t9bxlMHMrsOpdnKlxWgM5Y5LeNClQoU= X-MC-Unique: TqYtCYOcOeqmAv1_KQhdlw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dLqgegjxL7pN0HDxyZfbuN/wY/nTKcbE0sqdZS/D2ns=; b=4SxRwINC1uGy+FLKP6tsdEoZH9F0YfL4ysWsYWG4WvjZLDxTWYJeHea0GB/dBhQNvs wi2bPPSPRlcSQxuF17yYnHnsqyJ0h+5SzmA9NdrHAX2RAxkHiupk+xONFINvBEdDFYr8 k+BjnMt2Az0R62fxyjqqSsJjSg13GBaqZJ70wo4La+SuxJNNcX1RekP3xXrLq+wmUg6G jwvx5UG2F1uOzzy/elyNf+6JcPW9vEHZ03EYU25JE85BL6JmTBfSQ37Q+hvtl4s1PZlt BXGrwfMnHkBWV/ft+aoajqB562ydarVnLWe+6VbQh3KIrgy6ub+66pVRvQMbiprZxq8y y/Hw== X-Gm-Message-State: AOAM530aA2CeqmH/j23kVDGVcPsCCX3yL7AaBHncUMnkWBU2ZeafstcY x7PzGa1WZbhSwu4GwZu067ygSRQ1CTzV7G9uS6asOIBRIjMZ8McTqeLO7anJS1MuyVMNnvtQNw9 m/6QLu2abwkG/HV0PglmK2dMceGS+LuOX7BaWtFpiILfL+kR+PFjOZYz6TsND X-Received: by 2002:adf:a3da:: with SMTP id m26mr2806918wrb.336.1633449695611; Tue, 05 Oct 2021 09:01:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyizjBrO0BBuFhhC9BZp7QlEj3t0qktPjfuXlzrIil1UjAc/GNsJdhrEN+24Hl3gheHiJQ4Fw== X-Received: by 2002:adf:a3da:: with SMTP id m26mr2806885wrb.336.1633449695381; Tue, 05 Oct 2021 09:01:35 -0700 (PDT) Date: Tue, 5 Oct 2021 12:01:32 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 14/57] vhost-vsock: handle common features in vhost-vsock-common Message-ID: <20211005155946.513818-15-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633450925105100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella virtio-vsock features, like VIRTIO_VSOCK_F_SEQPACKET, can be handled by vhost-vsock-common parent class. In this way, we can reuse the same code for all virtio-vsock backends (i.e. vhost-vsock, vhost-user-vsock). Let's move `seqpacket` property to vhost-vsock-common class, add vhost_vsock_common_get_features() used by children, and disable `seqpacket` for vhost-user-vsock device for machine types < 6.2. The behavior of vhost-vsock device doesn't change; vhost-user-vsock device now supports `seqpacket` property. Signed-off-by: Stefano Garzarella Message-Id: <20210921161642.206461-3-sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-vsock-common.h | 5 +++++ include/hw/virtio/vhost-vsock.h | 3 --- hw/core/machine.c | 4 +++- hw/virtio/vhost-user-vsock.c | 4 +++- hw/virtio/vhost-vsock-common.c | 31 ++++++++++++++++++++++++++ hw/virtio/vhost-vsock.c | 24 +------------------- 6 files changed, 43 insertions(+), 28 deletions(-) diff --git a/include/hw/virtio/vhost-vsock-common.h b/include/hw/virtio/vho= st-vsock-common.h index e412b5ee98..d8b565b4da 100644 --- a/include/hw/virtio/vhost-vsock-common.h +++ b/include/hw/virtio/vhost-vsock-common.h @@ -35,6 +35,9 @@ struct VHostVSockCommon { VirtQueue *trans_vq; =20 QEMUTimer *post_load_timer; + + /* features */ + OnOffAuto seqpacket; }; =20 int vhost_vsock_common_start(VirtIODevice *vdev); @@ -43,5 +46,7 @@ int vhost_vsock_common_pre_save(void *opaque); int vhost_vsock_common_post_load(void *opaque, int version_id); void vhost_vsock_common_realize(VirtIODevice *vdev, const char *name); void vhost_vsock_common_unrealize(VirtIODevice *vdev); +uint64_t vhost_vsock_common_get_features(VirtIODevice *vdev, uint64_t feat= ures, + Error **errp); =20 #endif /* _QEMU_VHOST_VSOCK_COMMON_H */ diff --git a/include/hw/virtio/vhost-vsock.h b/include/hw/virtio/vhost-vsoc= k.h index 3f121a624f..84f4e727c7 100644 --- a/include/hw/virtio/vhost-vsock.h +++ b/include/hw/virtio/vhost-vsock.h @@ -30,9 +30,6 @@ struct VHostVSock { VHostVSockCommon parent; VHostVSockConf conf; =20 - /* features */ - OnOffAuto seqpacket; - /*< public >*/ }; =20 diff --git a/hw/core/machine.c b/hw/core/machine.c index 74f2a9a984..b8d95eec32 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -37,7 +37,9 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-pci.h" =20 -GlobalProperty hw_compat_6_1[] =3D {}; +GlobalProperty hw_compat_6_1[] =3D { + { "vhost-user-vsock-device", "seqpacket", "off" }, +}; const size_t hw_compat_6_1_len =3D G_N_ELEMENTS(hw_compat_6_1); =20 GlobalProperty hw_compat_6_0[] =3D { diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 6095ed7349..52bd682c34 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -81,7 +81,9 @@ static uint64_t vuv_get_features(VirtIODevice *vdev, { VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); =20 - return vhost_get_features(&vvc->vhost_dev, user_feature_bits, features= ); + features =3D vhost_get_features(&vvc->vhost_dev, user_feature_bits, fe= atures); + + return vhost_vsock_common_get_features(vdev, features, errp); } =20 static const VMStateDescription vuv_vmstate =3D { diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 4ad6e234ad..3f3771274e 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -18,6 +18,30 @@ #include "qemu/iov.h" #include "monitor/monitor.h" =20 +const int feature_bits[] =3D { + VIRTIO_VSOCK_F_SEQPACKET, + VHOST_INVALID_FEATURE_BIT +}; + +uint64_t vhost_vsock_common_get_features(VirtIODevice *vdev, uint64_t feat= ures, + Error **errp) +{ + VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); + + if (vvc->seqpacket !=3D ON_OFF_AUTO_OFF) { + virtio_add_feature(&features, VIRTIO_VSOCK_F_SEQPACKET); + } + + features =3D vhost_get_features(&vvc->vhost_dev, feature_bits, feature= s); + + if (vvc->seqpacket =3D=3D ON_OFF_AUTO_ON && + !virtio_has_feature(features, VIRTIO_VSOCK_F_SEQPACKET)) { + error_setg(errp, "vhost-vsock backend doesn't support seqpacket"); + } + + return features; +} + int vhost_vsock_common_start(VirtIODevice *vdev) { VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); @@ -231,11 +255,18 @@ void vhost_vsock_common_unrealize(VirtIODevice *vdev) virtio_cleanup(vdev); } =20 +static Property vhost_vsock_common_properties[] =3D { + DEFINE_PROP_ON_OFF_AUTO("seqpacket", VHostVSockCommon, seqpacket, + ON_OFF_AUTO_AUTO), + DEFINE_PROP_END_OF_LIST(), +}; + static void vhost_vsock_common_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_CLASS(klass); =20 + device_class_set_props(dc, vhost_vsock_common_properties); set_bit(DEVICE_CATEGORY_MISC, dc->categories); vdc->guest_notifier_mask =3D vhost_vsock_common_guest_notifier_mask; vdc->guest_notifier_pending =3D vhost_vsock_common_guest_notifier_pend= ing; diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index dade0da031..478c0c9a87 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -21,11 +21,6 @@ #include "hw/virtio/vhost-vsock.h" #include "monitor/monitor.h" =20 -const int feature_bits[] =3D { - VIRTIO_VSOCK_F_SEQPACKET, - VHOST_INVALID_FEATURE_BIT -}; - static void vhost_vsock_get_config(VirtIODevice *vdev, uint8_t *config) { VHostVSock *vsock =3D VHOST_VSOCK(vdev); @@ -113,22 +108,7 @@ static uint64_t vhost_vsock_get_features(VirtIODevice = *vdev, uint64_t requested_features, Error **errp) { - VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); - VHostVSock *vsock =3D VHOST_VSOCK(vdev); - - if (vsock->seqpacket !=3D ON_OFF_AUTO_OFF) { - virtio_add_feature(&requested_features, VIRTIO_VSOCK_F_SEQPACKET); - } - - requested_features =3D vhost_get_features(&vvc->vhost_dev, feature_bit= s, - requested_features); - - if (vsock->seqpacket =3D=3D ON_OFF_AUTO_ON && - !virtio_has_feature(requested_features, VIRTIO_VSOCK_F_SEQPACKET))= { - error_setg(errp, "vhost-vsock backend doesn't support seqpacket"); - } - - return requested_features; + return vhost_vsock_common_get_features(vdev, requested_features, errp); } =20 static const VMStateDescription vmstate_virtio_vhost_vsock =3D { @@ -229,8 +209,6 @@ static void vhost_vsock_device_unrealize(DeviceState *d= ev) static Property vhost_vsock_properties[] =3D { DEFINE_PROP_UINT64("guest-cid", VHostVSock, conf.guest_cid, 0), DEFINE_PROP_STRING("vhostfd", VHostVSock, conf.vhostfd), - DEFINE_PROP_ON_OFF_AUTO("seqpacket", VHostVSock, seqpacket, - ON_OFF_AUTO_AUTO), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633450857085370.81652238459367; Tue, 5 Oct 2021 09:20:57 -0700 (PDT) Received: from localhost ([::1]:57486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnBX-0001yc-Sk for importer@patchew.org; Tue, 05 Oct 2021 12:20:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmt5-0000TO-5P for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21926) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmt2-0005F3-2i for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:49 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-309-4YcHcSEDNiG8-HQXjN7tlw-1; Tue, 05 Oct 2021 12:01:41 -0400 Received: by mail-wr1-f72.google.com with SMTP id n18-20020adff092000000b001609d9081d4so2919538wro.18 for ; Tue, 05 Oct 2021 09:01:41 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id d129sm2670136wmd.23.2021.10.05.09.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:01:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GewG1EB37GBDRhgQ1Kl9yzLGlVVtEVSTzhe6jW3BaLE=; b=WteKGAvS3LscAfhovCTbndd7VhvXEAMahtOiZyfl8RBEgJuHU1Ctt7aHP/qu4xscyzf44O uevbF9crdjetZpeW7YsFMJHO11HGykdxPYEfbMujAPTirQ/+Co3TFXaYq6tSV5ejYHS9Nl qyozhyD9tcmJ7w+TiTbhYPZm0sqNfVU= X-MC-Unique: 4YcHcSEDNiG8-HQXjN7tlw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GewG1EB37GBDRhgQ1Kl9yzLGlVVtEVSTzhe6jW3BaLE=; b=ernQmdOhROb9Dqtljm5Tz0nM1f4jnkVkj0tcxiYRhj0cd00+OKiFKFkE6N1+NnnrZR +5FjNwU7VXAORbwyogouW4r4OOpjVEm0TwlB67beiRHTSTgrA/FKxNHJg709lxdF3DJ9 SXtFBSyh0jICBFUrTo68q3mXK415K/dUiV82HG57dMTKxgnU328N+vJ+gmXMpytkoBHp m3JeoTP8bPNrSq3iWE3mIPxQQfmvTa98jUvKlvLY2lV9kNcANwg38uJuAGBOeotRAGBM A32u4JfxB/AuFRxfzJ6yzvO3zYJXhEslplTPGn99BIbmWlbY55OVDpZsS9A4mH7SnicT iUmA== X-Gm-Message-State: AOAM532h5dB7VzjRVvF/0K8Wra+nRZiDDh3OSLeVmByt4Cwvf/Be5Jq4 SSjzYw1BMMBSvf/w4UoGdDcpY66AvnX/IWKmn/Pp8113vtp2qilv/Z/hF3Pz36VmxAfCjVUCg+C ISKii9BNjaNa5O6lP2OcQR7OdEm7miKbbvcySZ4Fxv8xVX+9VnVVh9meEpW6A X-Received: by 2002:adf:e6d0:: with SMTP id y16mr22571106wrm.181.1633449699118; Tue, 05 Oct 2021 09:01:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/d6sl5bo0zuNf0CKoWSQNUFhGEtor1u2LVmVB8619MzHeYpmpkkxvEfmzYVFB9czCYHZ5JQ== X-Received: by 2002:adf:e6d0:: with SMTP id y16mr22571054wrm.181.1633449698837; Tue, 05 Oct 2021 09:01:38 -0700 (PDT) Date: Tue, 5 Oct 2021 12:01:35 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 15/57] acpi: add helper routines to initialize ACPI tables Message-ID: <20211005155946.513818-16-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Yanan Wang , Eric Auger , Ani Sinha , Igor Mammedov , Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633450858614100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Patch introduces acpi_table_begin()/ acpi_table_end() API that hides pointer/offset arithmetic from user as opposed to build_header(), to prevent errors caused by it [1]. acpi_table_begin(): initializes table header and keeps track of table data/offsets acpi_table_end(): sets actual table length and tells bios loader where table is for the later initialization on guest side. 1) commits bb9feea43179 x86: acpi: use offset instead of pointer when using build_h= eader() 4d027afeb3a9 Virt: ACPI: fix qemu assert due to re-assigned table data a= ddress Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-2-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Tested-by: Stefan Berger Tested-by: Yanan Wang --- include/hw/acpi/aml-build.h | 31 +++++++++++++++++++ hw/acpi/aml-build.c | 62 +++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 471266d739..4242382399 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -413,6 +413,37 @@ Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *= target); Aml *aml_object_type(Aml *object); =20 void build_append_int_noprefix(GArray *table, uint64_t value, int size); + +typedef struct AcpiTable { + const char *sig; + const uint8_t rev; + const char *oem_id; + const char *oem_table_id; + /* private vars tracking table state */ + GArray *array; + unsigned table_offset; +} AcpiTable; + +/** + * acpi_table_begin: + * initializes table header and keeps track of + * table data/offsets + * @desc: ACPI table descriptor + * @array: blob where the ACPI table will be composed/stored. + */ +void acpi_table_begin(AcpiTable *desc, GArray *array); + +/** + * acpi_table_end: + * sets actual table length and tells bios loader + * where table is for the later initialization on + * guest side. + * @linker: reference to BIOSLinker object to use for the table + * @table: ACPI table descriptor that was used with @acpi_table_begin + * counterpart + */ +void acpi_table_end(BIOSLinker *linker, AcpiTable *table); + void build_header(BIOSLinker *linker, GArray *table_data, AcpiTableHeader *h, const char *sig, int len, uint8_t rev, diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index d5103e6d7b..229a3eb654 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -52,6 +52,19 @@ static void build_append_byte(GArray *array, uint8_t val) g_array_append_val(array, val); } =20 +static void build_append_padded_str(GArray *array, const char *str, + size_t maxlen, char pad) +{ + size_t i; + size_t len =3D strlen(str); + + g_assert(len <=3D maxlen); + g_array_append_vals(array, str, len); + for (i =3D maxlen - len; i > 0; i--) { + g_array_append_val(array, pad); + } +} + static void build_append_array(GArray *array, GArray *val) { g_array_append_vals(array, val->data, val->len); @@ -1692,6 +1705,55 @@ Aml *aml_object_type(Aml *object) return var; } =20 +void acpi_table_begin(AcpiTable *desc, GArray *array) +{ + + desc->array =3D array; + desc->table_offset =3D array->len; + + /* + * ACPI spec 1.0b + * 5.2.3 System Description Table Header + */ + g_assert(strlen(desc->sig) =3D=3D 4); + g_array_append_vals(array, desc->sig, 4); /* Signature */ + /* + * reserve space for Length field, which will be patched by + * acpi_table_end() when the table creation is finished. + */ + build_append_int_noprefix(array, 0, 4); /* Length */ + build_append_int_noprefix(array, desc->rev, 1); /* Revision */ + build_append_int_noprefix(array, 0, 1); /* Checksum */ + build_append_padded_str(array, desc->oem_id, 6, ' '); /* OEMID */ + /* OEM Table ID */ + build_append_padded_str(array, desc->oem_table_id, 8, ' '); + build_append_int_noprefix(array, 1, 4); /* OEM Revision */ + g_array_append_vals(array, ACPI_BUILD_APPNAME8, 4); /* Creator ID */ + build_append_int_noprefix(array, 1, 4); /* Creator Revision */ +} + +void acpi_table_end(BIOSLinker *linker, AcpiTable *desc) +{ + /* + * ACPI spec 1.0b + * 5.2.3 System Description Table Header + * Table 5-2 DESCRIPTION_HEADER Fields + */ + const unsigned checksum_offset =3D 9; + uint32_t table_len =3D desc->array->len - desc->table_offset; + uint32_t table_len_le =3D cpu_to_le32(table_len); + gchar *len_ptr =3D &desc->array->data[desc->table_offset + 4]; + + /* patch "Length" field that has been reserved by acpi_table_begin() + * to the actual length, i.e. accumulated table length from + * acpi_table_begin() till acpi_table_end() + */ + memcpy(len_ptr, &table_len_le, sizeof table_len_le); + + bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE, + desc->table_offset, table_len, desc->table_offset + checksum_offse= t); +} + void build_header(BIOSLinker *linker, GArray *table_data, AcpiTableHeader *h, const char *sig, int len, uint8_t rev, --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633452006528760.1627948686801; Tue, 5 Oct 2021 09:40:06 -0700 (PDT) Received: from localhost ([::1]:47546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnU4-0008S0-GM for importer@patchew.org; Tue, 05 Oct 2021 12:40:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmt2-0000Pb-Oa for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21589) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmt1-0005Eh-11 for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:48 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-38--jhJZuHhMCSt1No7v7My_g-1; Tue, 05 Oct 2021 12:01:45 -0400 Received: by mail-wr1-f72.google.com with SMTP id r15-20020adfce8f000000b0015df1098ccbso5899890wrn.4 for ; Tue, 05 Oct 2021 09:01:45 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id z133sm2715428wmc.45.2021.10.05.09.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:01:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=K+DILqdRPrmyt7zpDyv69OZUbVta4rTANUIRBMHOu6g=; b=TvVE4kBGyRjFgOszQFjmUAPtnoxzk03jwXNJGaeCFdpuHp/Jgxnoe472wFnf5puu8OvO6S bK07YdubbiUtwMpOpn/MmiOXPpnxFRTxvALa2S+50f2SalxUmO59HJA2wS49ABnbMlPVZp VTPURXWtGj69yRgzY8H72s3xM7pB1Yg= X-MC-Unique: -jhJZuHhMCSt1No7v7My_g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=K+DILqdRPrmyt7zpDyv69OZUbVta4rTANUIRBMHOu6g=; b=vB32Tduql6JnQ9m2xNfXuhflLTHhjue/hMNcJ2pmMmsUy2SnFeoAT/zq5C/TKgJELm 8c9kOjbRiVvYjDRMX5HJulVwsroFqtJbmJlesVWMf2c9rprJc6CcypxS50Kz8vusDBPK 5qf47RA3pItJzv66EzvOjT+2pWVlTrdsSVevPIxjXxrJRyNs/D5vn9LXoiCxqbsE0Tte obHYe+OUXlRJanwSQk/b8UgWEcyPpvJcwuFwJETn9Siai64bfgLvRV+0OBWAI+DivqiN bzRMXGWensmAOFVDRBzZfTC73jye+VPx6+nI5+OzfYKJ2qXSDEx0XOCtZVQ/BZsTAgQJ 7qfg== X-Gm-Message-State: AOAM532MaCFjGO4RfDrf94t2q8GH+12hrKmSaQ7+/gMUR/MBqPYsQVuN kZBHWWxSCOAINhqBG0rzcszVmv/slvS0Bkawvxty+foFjqIzxO5U73gmhEqhyGjgXUWzApnBPud s93k1aEf8msh/o5IQ4cJgy3hOWb/Z0ZtOKlQVFqQPpjfZS0wVeSEnMxGf9/bv X-Received: by 2002:adf:bbc2:: with SMTP id z2mr21859550wrg.359.1633449703448; Tue, 05 Oct 2021 09:01:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyey59N4Du9ia15xXrFU13z7vRaqdIjDqpgty3Y7U9hec1shzMjAEC8JMMJ9pg4mJuAsge0Ag== X-Received: by 2002:adf:bbc2:: with SMTP id z2mr21859522wrg.359.1633449703246; Tue, 05 Oct 2021 09:01:43 -0700 (PDT) Date: Tue, 5 Oct 2021 12:01:39 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 16/57] acpi: build_rsdt: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-17-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Eric Auger , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452008092100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offests magic from API user. While at it switch to build_append_int_noprefix() to build entries to other tables (which also removes some manual offset calculations). Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-3-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 10 ---------- hw/acpi/aml-build.c | 29 ++++++++++++++--------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index cf9f44299c..ccfa3382aa 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -149,16 +149,6 @@ struct AcpiSerialPortConsoleRedirection { typedef struct AcpiSerialPortConsoleRedirection AcpiSerialPortConsoleRedirection; =20 -/* - * ACPI 1.0 Root System Description Table (RSDT) - */ -struct AcpiRsdtDescriptorRev1 { - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint32_t table_offset_entry[]; /* Array of pointers to other */ - /* ACPI tables */ -} QEMU_PACKED; -typedef struct AcpiRsdtDescriptorRev1 AcpiRsdtDescriptorRev1; - /* * ACPI 2.0 eXtended System Description Table (XSDT) */ diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 229a3eb654..616a292229 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1884,33 +1884,32 @@ build_rsdp(GArray *tbl, BIOSLinker *linker, AcpiRsd= pData *rsdp_data) 32); } =20 -/* Build rsdt table */ +/* + * ACPI 1.0 Root System Description Table (RSDT) + */ void build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets, const char *oem_id, const char *oem_table_id) { int i; - unsigned rsdt_entries_offset; - AcpiRsdtDescriptorRev1 *rsdt; - int rsdt_start =3D table_data->len; - const unsigned table_data_len =3D (sizeof(uint32_t) * table_offsets->l= en); - const unsigned rsdt_entry_size =3D sizeof(rsdt->table_offset_entry[0]); - const size_t rsdt_len =3D sizeof(*rsdt) + table_data_len; + AcpiTable table =3D { .sig =3D "RSDT", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 - rsdt =3D acpi_data_push(table_data, rsdt_len); - rsdt_entries_offset =3D (char *)rsdt->table_offset_entry - table_data-= >data; + acpi_table_begin(&table, table_data); for (i =3D 0; i < table_offsets->len; ++i) { uint32_t ref_tbl_offset =3D g_array_index(table_offsets, uint32_t,= i); - uint32_t rsdt_entry_offset =3D rsdt_entries_offset + rsdt_entry_si= ze * i; + uint32_t rsdt_entry_offset =3D table.array->len; =20 - /* rsdt->table_offset_entry to be filled by Guest linker */ + /* reserve space for entry */ + build_append_int_noprefix(table.array, 0, 4); + + /* mark position of RSDT entry to be filled by Guest linker */ bios_linker_loader_add_pointer(linker, - ACPI_BUILD_TABLE_FILE, rsdt_entry_offset, rsdt_entry_size, + ACPI_BUILD_TABLE_FILE, rsdt_entry_offset, 4, ACPI_BUILD_TABLE_FILE, ref_tbl_offset); + } - build_header(linker, table_data, - (void *)(table_data->data + rsdt_start), - "RSDT", rsdt_len, 1, oem_id, oem_table_id); + acpi_table_end(linker, &table); } =20 /* Build xsdt table */ --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633451130046331.36921820065015; Tue, 5 Oct 2021 09:25:30 -0700 (PDT) Received: from localhost ([::1]:41562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnFw-0001sq-Ml for importer@patchew.org; Tue, 05 Oct 2021 12:25:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmtA-0000ZP-6y for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50192) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmt8-0005HD-9U for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:55 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-422-GgL2gOmKOuaEjCXKg6tPgQ-1; Tue, 05 Oct 2021 12:01:48 -0400 Received: by mail-wm1-f71.google.com with SMTP id 10-20020a05600c240a00b0030d403f24e2so1483022wmp.9 for ; Tue, 05 Oct 2021 09:01:48 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id h18sm2804067wmq.23.2021.10.05.09.01.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:01:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449709; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Ubtv06sdXqWfSsbHdaI94YkCgWlWrYubEpResPKOljE=; b=CbH6lhyLEoJdF2f4XT7J3ZcNVJ04iAAIsgkYcj8LjXIdFip0ZrT88fwF2d6P0oMaOwPkV+ Z60G7WqJt2qN8afdOmLT4Ixrxe5tHlXXMB0AMSn06xjS7IV1alLKQNN/2NhG1cZvF2roV0 5Qa/t8050p1lttuQeVNtoSWIH4XzRRg= X-MC-Unique: GgL2gOmKOuaEjCXKg6tPgQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Ubtv06sdXqWfSsbHdaI94YkCgWlWrYubEpResPKOljE=; b=tSXujfOnCvtd0w3BzVLsm+QcSYjzjE7k+eRhDMaK/b41r4qXdkLi3oOiVtHvBcCp/H pmzQ07Kn++/L1Gb9+KiQInIvXO7h2YzkYslZ6q2c2Bja3ndKC/x44h8aHxn7XAKvTmhF uct0VaqZLTnfJt7O6EDkMPnwT86lNBsYddr8iDpBIJ87Pz9pwsDko/G8Jt0bMnDdbg88 AeXEjKJmSOCvG2gKDfk6cjUnBeKad3DRa/esGozT6chl+Fk8bOLeiBPvTLpmJXk6u7h0 efdWtO6P04jLRxJnb1+1SH+V9ZV3ytEPngN+22/nZTrQwZU6Wus1fC/vra0LpZa0c61J Un1g== X-Gm-Message-State: AOAM533mOkHOJhVObpQXMrlebHq4jVTJaKYhkF2/VlyZOe9NFZPUWPCq SrBBXJng78Y60dVq24aYyhL/+Jr9B7EV/9+S8meE+bOIEG9puUOkyjbduRtgv+PHtBBnVlLN4dd QvvEueQ/9A5ii9wrNVOOTbJYwpYh0tU/pUE1Kh7oQz8t+jFf4DXeg6g8PJDqB X-Received: by 2002:a5d:59a4:: with SMTP id p4mr21847161wrr.332.1633449707269; Tue, 05 Oct 2021 09:01:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqY1ykQlm0m1AO4j8IENyOJbOFBBHhESskgVer5Azur6EbSbmA28uEA8qMI4rAFX+MoXwpDQ== X-Received: by 2002:a5d:59a4:: with SMTP id p4mr21847107wrr.332.1633449706961; Tue, 05 Oct 2021 09:01:46 -0700 (PDT) Date: Tue, 5 Oct 2021 12:01:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 17/57] acpi: build_xsdt: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-18-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Eric Auger , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633451131463100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. While at it switch to build_append_int_noprefix() to build entries to other tables (which also removes some manual offset calculations). Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-4-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 10 ---------- hw/acpi/aml-build.c | 29 ++++++++++++++--------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index ccfa3382aa..f6d2ca172b 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -149,16 +149,6 @@ struct AcpiSerialPortConsoleRedirection { typedef struct AcpiSerialPortConsoleRedirection AcpiSerialPortConsoleRedirection; =20 -/* - * ACPI 2.0 eXtended System Description Table (XSDT) - */ -struct AcpiXsdtDescriptorRev2 { - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint64_t table_offset_entry[]; /* Array of pointers to other */ - /* ACPI tables */ -} QEMU_PACKED; -typedef struct AcpiXsdtDescriptorRev2 AcpiXsdtDescriptorRev2; - /* * ACPI 1.0 Firmware ACPI Control Structure (FACS) */ diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 616a292229..86b8322ee1 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1912,33 +1912,32 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, = GArray *table_offsets, acpi_table_end(linker, &table); } =20 -/* Build xsdt table */ +/* + * ACPI 2.0 eXtended System Description Table (XSDT) + */ void build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets, const char *oem_id, const char *oem_table_id) { int i; - unsigned xsdt_entries_offset; - AcpiXsdtDescriptorRev2 *xsdt; - int xsdt_start =3D table_data->len; - const unsigned table_data_len =3D (sizeof(uint64_t) * table_offsets->l= en); - const unsigned xsdt_entry_size =3D sizeof(xsdt->table_offset_entry[0]); - const size_t xsdt_len =3D sizeof(*xsdt) + table_data_len; + AcpiTable table =3D { .sig =3D "XSDT", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; + + acpi_table_begin(&table, table_data); =20 - xsdt =3D acpi_data_push(table_data, xsdt_len); - xsdt_entries_offset =3D (char *)xsdt->table_offset_entry - table_data-= >data; for (i =3D 0; i < table_offsets->len; ++i) { uint64_t ref_tbl_offset =3D g_array_index(table_offsets, uint32_t,= i); - uint64_t xsdt_entry_offset =3D xsdt_entries_offset + xsdt_entry_si= ze * i; + uint64_t xsdt_entry_offset =3D table.array->len; =20 - /* xsdt->table_offset_entry to be filled by Guest linker */ + /* reserve space for entry */ + build_append_int_noprefix(table.array, 0, 8); + + /* mark position of RSDT entry to be filled by Guest linker */ bios_linker_loader_add_pointer(linker, - ACPI_BUILD_TABLE_FILE, xsdt_entry_offset, xsdt_entry_size, + ACPI_BUILD_TABLE_FILE, xsdt_entry_offset, 8, ACPI_BUILD_TABLE_FILE, ref_tbl_offset); } - build_header(linker, table_data, - (void *)(table_data->data + xsdt_start), - "XSDT", xsdt_len, 1, oem_id, oem_table_id); + acpi_table_end(linker, &table); } =20 void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633451380445495.5902015143014; Tue, 5 Oct 2021 09:29:40 -0700 (PDT) Received: from localhost ([::1]:50040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnJz-0007ft-Au for importer@patchew.org; Tue, 05 Oct 2021 12:29:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmtB-0000bl-9d for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmt8-0005KE-Do for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:01:57 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-187-72DnoAGaMSGKtcXnxVqbqA-1; Tue, 05 Oct 2021 12:01:52 -0400 Received: by mail-wm1-f70.google.com with SMTP id d7-20020a1c7307000000b0030d6982305bso1494340wmb.5 for ; Tue, 05 Oct 2021 09:01:52 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id r26sm2294835wmh.35.2021.10.05.09.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:01:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449713; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qwecV/HMx7pl/yc/ZHCbGktA++haMiU72fN1swDGVcY=; b=EVKs1MrRCkJZTkhqBYBfsndEnVHydREsp3ZZ6Xb2SE2y+Ih6+GGAnhftOmMOsEazNWzVXY fKxSt19aBBnmfm7GfNrJiIPdGZNkTbBbsnKGL62rUvbCnyqs8SdOShJTP2vxjKMxz6o3QM iPjFh0JI2J2NdGh42JNNXmJdg+Hg8kA= X-MC-Unique: 72DnoAGaMSGKtcXnxVqbqA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=qwecV/HMx7pl/yc/ZHCbGktA++haMiU72fN1swDGVcY=; b=o0YwHn7ygEGNkKc/u9eHGYA2L8WtohmYXrbZz9VrrUlx8MrPTqS/vix2tQyXvbOxBL Wyxc+XCkXdlgP0UE+fspZ+YNipg2aKkmaM/R2qqWBSaM3sbxzjjtbcSrZmg+6DxXTKhM SJ4hLCm2k4AhilKDJdU/iSxWz0A+Df5rAys0OeTIAD57XTuEiEwiGpjdmHYhhmsdh625 pBFwJ/ZOpCaAtgbM9HosQ6UhmUXjXraRSfCNCG5NwHgveyxRFTpPdwSm6jDx0rqDRDXo 5CTLIzfaExCgolZ0yel0gzdGMbUi0o0VyVSt3xe9E86Ct77tcKpT/t+UDXl/2bvS4Iy2 Y+ug== X-Gm-Message-State: AOAM532XCKed2aIsXyzuyELDWgIsJK6WjQBSKDF50l/GnLSdbDZdmIdd OCRnRVkaUmCElHpSOYJFhetIBbV/XGeLAfq8E8Tk/AyMH7X16Av9FtmHN7UNJj5icZ+MgOOd07b mHjNIOsmrfh7aSSwuVCW8tLKsZnQzU02gjKcw2KtdruAzE3I+CGBD3xbimruP X-Received: by 2002:a5d:4882:: with SMTP id g2mr22007270wrq.399.1633449711052; Tue, 05 Oct 2021 09:01:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwl+pMZbU+3YxTrmZOrbZYSaDMqD8wRrEE+YUJ6ciLZbQkxXbdlP0xeOplbdLItGXfnrS9zGQ== X-Received: by 2002:a5d:4882:: with SMTP id g2mr22007234wrq.399.1633449710821; Tue, 05 Oct 2021 09:01:50 -0700 (PDT) Date: Tue, 5 Oct 2021 12:01:47 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 18/57] acpi: build_slit: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-19-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Eric Auger , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633451381140100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-5-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/aml-build.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 86b8322ee1..ec870f53ba 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1958,11 +1958,12 @@ void build_srat_memory(AcpiSratMemoryAffinity *numa= mem, uint64_t base, void build_slit(GArray *table_data, BIOSLinker *linker, MachineState *ms, const char *oem_id, const char *oem_table_id) { - int slit_start, i, j; - slit_start =3D table_data->len; + int i, j; int nb_numa_nodes =3D ms->numa_state->num_nodes; + AcpiTable table =3D { .sig =3D "SLIT", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 - acpi_data_push(table_data, sizeof(AcpiTableHeader)); + acpi_table_begin(&table, table_data); =20 build_append_int_noprefix(table_data, nb_numa_nodes, 8); for (i =3D 0; i < nb_numa_nodes; i++) { @@ -1973,11 +1974,7 @@ void build_slit(GArray *table_data, BIOSLinker *link= er, MachineState *ms, 1); } } - - build_header(linker, table_data, - (void *)(table_data->data + slit_start), - "SLIT", - table_data->len - slit_start, 1, oem_id, oem_table_id); + acpi_table_end(linker, &table); } =20 /* build rev1/rev3/rev5.1 FADT */ --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633451644171868.3428169416613; Tue, 5 Oct 2021 09:34:04 -0700 (PDT) Received: from localhost ([::1]:58804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnOF-0005BO-3D for importer@patchew.org; Tue, 05 Oct 2021 12:34:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47088) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmtF-0000mG-Uj for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:02:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27912) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmtE-0005PV-86 for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:02:01 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-244-1S0WBL32OyGb6dje1olnjA-1; Tue, 05 Oct 2021 12:01:57 -0400 Received: by mail-wm1-f71.google.com with SMTP id z194-20020a1c7ecb000000b0030b7ccea080so1486762wmc.8 for ; Tue, 05 Oct 2021 09:01:57 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id o12sm2998168wms.15.2021.10.05.09.01.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449719; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Rct0JANkkDI5GIKB26klU3//BV/Oq9xx5ob6TEYXS/U=; b=VkUv/e715DCRCK02ouoY2ExuOH+yYjePTvrfcEoasl7NIepI182QTQCRhbUoCDa68skbk0 9mmcycTNyR3YIzsula7IfuzcWMn+nFh/yWCCwi+T/uo4+v9mylATJ5WZ2ruTk+9w9TYAQg C+zTAd3nxQO8V+D8aAZebVt9oZlUu/k= X-MC-Unique: 1S0WBL32OyGb6dje1olnjA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Rct0JANkkDI5GIKB26klU3//BV/Oq9xx5ob6TEYXS/U=; b=RPa+1gcPSAhf3G4dStG4A/d9VxnCwfT/UFZybHV46QDNQ7bmyJbCnUeGaZQ9nIozLo lBIVtxGoB7C+YRcy69LXYKAnfDgxRY0KHhQjNrwcjl6cQYP31pXbOmDf3WbC64UKNVm3 G3J9VIEqgCE7LYon9LihGoGmLYtSNbHZ0P1q5rOJdfvezDhaVe0liCxitFy2RZ0/s6lX K3W4N8kqTbL2481LeigSNjwWKQmKGeiawOY30CqY64/G9Wk65ryBM/MyJ5jWWkl5X6Fx BuClJ8amuBWfdKdkr7EvZYOP+cB0dYJGjAFwc0YaCHAvS9s+YtcEQe+TqhpL3oErcatD G4NA== X-Gm-Message-State: AOAM531C5RZMxRiUP5Ahv414Lzh3ToYUnP02Z6LG4T0EnH9rP0yG0H7u dgcxTwPS+kCasSrIJFNyTeGYMVY5HEKnR+cJ4nmZLYJwB5HzV5ELQIWx9xANe+g1xtkJUH1on86 i50NHilJewDNgn5wiXBIzBVIegBlymTOgMBSwMRFZdsnZ7/trDXGsp/AGoKPT X-Received: by 2002:a1c:1f86:: with SMTP id f128mr4370675wmf.124.1633449715556; Tue, 05 Oct 2021 09:01:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyi0j32N1RVV63zlKIm4niFHbdQoVOxjv7+F7HQt4dm8sbw5lddibcMAEAcORgm7JwZjBwprw== X-Received: by 2002:a1c:1f86:: with SMTP id f128mr4370624wmf.124.1633449715176; Tue, 05 Oct 2021 09:01:55 -0700 (PDT) Date: Tue, 5 Oct 2021 12:01:50 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 19/57] acpi: build_fadt: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-20-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Eric Auger , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633451644982100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-6-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/aml-build.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index ec870f53ba..4d0ff6e5f3 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1982,9 +1982,10 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, con= st AcpiFadtData *f, const char *oem_id, const char *oem_table_id) { int off; - int fadt_start =3D tbl->len; + AcpiTable table =3D { .sig =3D "FACP", .rev =3D f->rev, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 - acpi_data_push(tbl, sizeof(AcpiTableHeader)); + acpi_table_begin(&table, tbl); =20 /* FACS address to be filled by Guest linker at runtime */ off =3D tbl->len; @@ -2048,7 +2049,7 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, cons= t AcpiFadtData *f, build_append_int_noprefix(tbl, f->flags, 4); /* Flags */ =20 if (f->rev =3D=3D 1) { - goto build_hdr; + goto done; } =20 build_append_gas_from_struct(tbl, &f->reset_reg); /* RESET_REG */ @@ -2085,7 +2086,7 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, cons= t AcpiFadtData *f, build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); /* X_GPE1_BL= K */ =20 if (f->rev <=3D 4) { - goto build_hdr; + goto done; } =20 /* SLEEP_CONTROL_REG */ @@ -2096,9 +2097,8 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, cons= t AcpiFadtData *f, /* TODO: extra fields need to be added to support revisions above rev5= */ assert(f->rev =3D=3D 5); =20 -build_hdr: - build_header(linker, tbl, (void *)(tbl->data + fadt_start), - "FACP", tbl->len - fadt_start, f->rev, oem_id, oem_table_= id); +done: + acpi_table_end(linker, &table); } =20 #ifdef CONFIG_TPM --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633452223604216.60812538067432; Tue, 5 Oct 2021 09:43:43 -0700 (PDT) Received: from localhost ([::1]:55810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnXa-0005nG-Jd for importer@patchew.org; Tue, 05 Oct 2021 12:43:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmtM-0000s1-Dx for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:02:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23395) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmtK-0005S8-Lb for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:02:08 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-69-wggme-86OB6ESPGxgnSYMA-1; Tue, 05 Oct 2021 12:02:01 -0400 Received: by mail-wm1-f71.google.com with SMTP id f11-20020a7bcd0b000000b0030d72d5d0bcso1457989wmj.7 for ; Tue, 05 Oct 2021 09:02:01 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id n14sm5105393wrm.78.2021.10.05.09.01.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:01:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449722; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AUlMLhF7lHwLJN9qe1cXBZOGqAksRpcgI2Cp4ZjL4m8=; b=KujiNZuKLv9I8JChbMGAJHWmiSAHbyhejvs6bhR31jS3c3/rWbig+/qfzZtSyol8mL85XM 8i7ti6Fj8gCRvQCqtpmX5z/2/HwT9kh/4QKElmH73/TI9hMsyhpTTP+7RYl83UCCTliohf xR/DoUJrhyzScTHmLRQrXsq/xbAdTHI= X-MC-Unique: wggme-86OB6ESPGxgnSYMA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=AUlMLhF7lHwLJN9qe1cXBZOGqAksRpcgI2Cp4ZjL4m8=; b=45L646Xvyomrn2yy7tWhY4UIhrCAUNq0QOR7LsSf25c80WJaISfuWn/vr/t4FnP12y fW0lRHvfs3SbFLZq91Cu+aaYaKgHghmvpj36mbCyrvVF8UmnJFhAvnCdUZOZ6XbdEbO+ pNZD1h+6zqK49rUmnU8KL3L38qbe8hIIWYFVIazOjilhAu2xogcOPi9ZI1uVcCD6mLXA ydFFnKQRr9PLgnRawfCRW+QdsSjYefdFb77c/ANxGNGmScksYicC4cW7i+qvtvU0ukQa Xa8CdmKwZYvf/Bpfw27GyI548a03j1vLe4mFxu0onCRmQfGm8dSVQLW+CZbNoTgH8Aaj TFMA== X-Gm-Message-State: AOAM533NvTZ0YAt6Dx1gVObAY3RnAhynd/lNIh6MsykkwF2qUwm1IvDB qa/gUFMtOusmKwU3EvMH4T/0bdmoKtVyllJCup5xvduhP5x/X44yrfS9xvmAmV+MPA1V7DPreGM KbxAIjvmqvBEjo4WSojwFM9DPJJS1Iy8NrPc4cuW6Xp7pwE/ymW+yIxuYbGg3 X-Received: by 2002:adf:fe4e:: with SMTP id m14mr1181231wrs.14.1633449719768; Tue, 05 Oct 2021 09:01:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6l9JjRNItDWDiI72C30IgdM7AuXVubp9yCGQ/4MNDnGBDX+YLI1CpkXdka6HOXKHpHzgrmw== X-Received: by 2002:adf:fe4e:: with SMTP id m14mr1181189wrs.14.1633449719490; Tue, 05 Oct 2021 09:01:59 -0700 (PDT) Date: Tue, 5 Oct 2021 12:01:55 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 20/57] acpi: build_tpm2: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-21-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Stefan Berger , Eric Auger , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452225462100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. Signed-off-by: Igor Mammedov Tested-by: Stefan Berger Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-7-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/aml-build.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 4d0ff6e5f3..23cda45ee0 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -2111,13 +2111,14 @@ void build_tpm2(GArray *table_data, BIOSLinker *lin= ker, GArray *tcpalog, const char *oem_id, const char *oem_table_id) { uint8_t start_method_params[12] =3D {}; - unsigned log_addr_offset, tpm2_start; + unsigned log_addr_offset; uint64_t control_area_start_address; TPMIf *tpmif =3D tpm_find(); uint32_t start_method; + AcpiTable table =3D { .sig =3D "TPM2", .rev =3D 4, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 - tpm2_start =3D table_data->len; - acpi_data_push(table_data, sizeof(AcpiTableHeader)); + acpi_table_begin(&table, table_data); =20 /* Platform Class */ build_append_int_noprefix(table_data, TPM2_ACPI_CLASS_CLIENT, 2); @@ -2155,9 +2156,7 @@ void build_tpm2(GArray *table_data, BIOSLinker *linke= r, GArray *tcpalog, bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, log_addr_offset, 8, ACPI_BUILD_TPMLOG_FILE, 0); - build_header(linker, table_data, - (void *)(table_data->data + tpm2_start), - "TPM2", table_data->len - tpm2_start, 4, oem_id, oem_tabl= e_id); + acpi_table_end(linker, &table); } #endif =20 --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633451620437575.8702441551097; Tue, 5 Oct 2021 09:33:40 -0700 (PDT) Received: from localhost ([::1]:58360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnNq-0004tS-M7 for importer@patchew.org; Tue, 05 Oct 2021 12:33:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmtO-0000vp-1t for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:02:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29847) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmtL-0005Un-Me for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:02:09 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-485-cRWTrjCNNR23ic2mKhUNOw-1; Tue, 05 Oct 2021 12:02:05 -0400 Received: by mail-wr1-f72.google.com with SMTP id l9-20020adfc789000000b00160111fd4e8so5896750wrg.17 for ; Tue, 05 Oct 2021 09:02:05 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id t11sm17911151wrz.65.2021.10.05.09.02.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449727; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OCIxQsk7jhQmV5lumZAqEAV5I0Q6nMdVi6zQWr5NyRs=; b=Y8ggc8Z+u3fCPZVE9THBR3SaRC2p+U2wM60edkVJY45yp+01tbS6KVZFptuWW/CwkQTrj1 6hSAlt0Mf3LzB1qid3hw4AgKKeSQfBfcKRaz3eO8TgOeUJaoli7SEvrOL9X9MI8apTdOOE mjasYuhIXvZx6D11p+FdBKaUI9PnxPk= X-MC-Unique: cRWTrjCNNR23ic2mKhUNOw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=OCIxQsk7jhQmV5lumZAqEAV5I0Q6nMdVi6zQWr5NyRs=; b=6nqxalS/v6M4nW3UhqOO6MyovLlAMv639Trwy4PfSFIpZykVekJGs+pKxGqxOnUrOl 8ZWiT2v9USUniUQUKpuJP99NRT979F4xM11FhAd1eiI5oEoPOemeZXWK2lKkYQUvVRv6 WGfMYFQblGqAIg9m6ylNYlhyGXGodXBgo7zyo7M+zuod7rZDTpD3ZAwtXptjbBg3lZUN 2KQr5mhRGGwF1qb81WpYpIXHswqqQFG0irq53xHRKVKtc2/mvgrkK/WMK77x8+atLxvx 6xl4VAP7J9AZdNAk822nvjhCf4/Lu0PjiWVNKKXgD0dC2DCZTonNzlTb6TJQ0YhFPtpM NP9A== X-Gm-Message-State: AOAM5338jmmtVzbfxiw04GkgsRzKYO5G7MaupzDyuBMFN2vKGPATNz4v 866Zh3oGleWseiJ+Sj7kfa1plgY9AfGr/taDOauxfMUsmeKdiLj6UVs/uoTQ7/Cybz73TUsTFgR rDknYRBjhoeB+GewsbRfQhk2lg9a5RFM2D5LG1e4U7Uq0VmegHmRLZR2KaJyx X-Received: by 2002:adf:a4c7:: with SMTP id h7mr10063435wrb.57.1633449724274; Tue, 05 Oct 2021 09:02:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXs7R2TLmoUx3vSIyaz6Tt9kNx2jCSseo0H1eKMVR7rps/U3kGUJKmnZRpEeT6aEACn3KvQQ== X-Received: by 2002:adf:a4c7:: with SMTP id h7mr10063402wrb.57.1633449724089; Tue, 05 Oct 2021 09:02:04 -0700 (PDT) Date: Tue, 5 Oct 2021 12:01:59 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 21/57] acpi: acpi_build_hest: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-22-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Dongjiu Geng , Eric Auger , qemu-arm@nongnu.org, Ani Sinha , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633451621550100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. Signed-off-by: Igor Mammedov Reviewed-by: Dongjiu Geng Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-8-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/ghes.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index a749b84d62..45d9a809cc 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -362,18 +362,16 @@ static void build_ghes_v2(GArray *table_data, int sou= rce_id, BIOSLinker *linker) void acpi_build_hest(GArray *table_data, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) { - uint64_t hest_start =3D table_data->len; + AcpiTable table =3D { .sig =3D "HEST", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 - /* Hardware Error Source Table header*/ - acpi_data_push(table_data, sizeof(AcpiTableHeader)); + acpi_table_begin(&table, table_data); =20 /* Error Source Count */ build_append_int_noprefix(table_data, ACPI_GHES_ERROR_SOURCE_COUNT, 4); - build_ghes_v2(table_data, ACPI_HEST_SRC_ID_SEA, linker); =20 - build_header(linker, table_data, (void *)(table_data->data + hest_star= t), - "HEST", table_data->len - hest_start, 1, oem_id, oem_tabl= e_id); + acpi_table_end(linker, &table); } =20 void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgState *s, --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633452878135379.1751151670993; Tue, 5 Oct 2021 09:54:38 -0700 (PDT) Received: from localhost ([::1]:53240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXni8-000722-UB for importer@patchew.org; Tue, 05 Oct 2021 12:54:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmwE-0002UR-SZ for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:05:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40229) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmwD-0007q4-1O for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:05:06 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-246-909-QsX7Pxip4Wzmu4MA-g-1; Tue, 05 Oct 2021 12:02:14 -0400 Received: by mail-wr1-f72.google.com with SMTP id d13-20020adfa34d000000b00160aa1cc5f1so2192415wrb.14 for ; Tue, 05 Oct 2021 09:02:14 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id c7sm3140606wmq.13.2021.10.05.09.02.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:02:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449904; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Mu9xnyW+1taNhY3PRRzUfTRjJRG2AuAujyDOpNuF+30=; b=I/qGz48EcIejhMyktZuQISyFEYF9VMR7oyoPJjozcRGU5kOB17KVSD91LGopjovg7Sbnv6 pQyQ32JkIDalM1Lt5DNOJ6wI+Ae1VkBL9cHzBDocnA8ql8FvlUq1hGn0IH1vg1/zIB4E6v HJ7wrR6hWrIgndS6yI/xIaLDO/Gyu1s= X-MC-Unique: 909-QsX7Pxip4Wzmu4MA-g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Mu9xnyW+1taNhY3PRRzUfTRjJRG2AuAujyDOpNuF+30=; b=TmHeH+aNz2DHH/eHSjMqAt35WtIj2Th0c4HvlR8a6KA/ET0duzwWFm7ObzrrUCsLzK G9jQ43XfoFZ6KAOWiFnwNlpniFoYex/NfImNpxijGVDxe4MI0PL55D/+Loq+53ruF1zK Qk5MYmIrktkFXePGDPfZxRRE33F9pqh6NGGsSlPWeTPX6hOTH6Lf90VNbFUNhfOru+Ow UXf8SMWSEENkteWlPjB1Z3uRcGp5Wu9zo189ebe/Fk/rWqGOPjBh9ln7u1UhuRxo5MXk aONaBTdPBZFuJpyCucgZFd4oM2DwEivKZRXnMap0MAKsGoqL4IF/qvHl/6MxWGsW49q5 jWvg== X-Gm-Message-State: AOAM530uSENZKU1JKG08hftR/nAEqTIxhG4ouASr57E8Sorw8UNv0GDl HeyWrFAzPUFPp7noXqDHJNDN170xmlFl9fFYIFnYsmb0H7huvVtA19fO3v3OksAjIc4NbU/+4qo GG57d3hkgaO98YrY3YO/nvyZzcGg3n+3OQOqRFcaPlMtxclpl0NaPB1TZ5fX2 X-Received: by 2002:adf:a292:: with SMTP id s18mr3881233wra.42.1633449732454; Tue, 05 Oct 2021 09:02:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzUVlGszHLJnPwykD3Uvmewm9caC3u2yYJVb7DWtFdcuxNtbdjd+rGHKI9D0K+3uT6At85MA== X-Received: by 2002:adf:a292:: with SMTP id s18mr3880687wra.42.1633449728657; Tue, 05 Oct 2021 09:02:08 -0700 (PDT) Date: Tue, 5 Oct 2021 12:02:04 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 22/57] acpi: build_mcfg: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-23-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Eric Auger , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452879025100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-9-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/pci.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/acpi/pci.c b/hw/acpi/pci.c index 75b1103ec4..20b70dcd81 100644 --- a/hw/acpi/pci.c +++ b/hw/acpi/pci.c @@ -28,19 +28,20 @@ #include "hw/acpi/pci.h" #include "hw/pci/pcie_host.h" =20 +/* + * PCI Firmware Specification, Revision 3.0 + * 4.1.2 MCFG Table Description. + */ void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info, const char *oem_id, const char *oem_table_id) { - int mcfg_start =3D table_data->len; + AcpiTable table =3D { .sig =3D "MCFG", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; + + acpi_table_begin(&table, table_data); =20 - /* - * PCI Firmware Specification, Revision 3.0 - * 4.1.2 MCFG Table Description. - */ - acpi_data_push(table_data, sizeof(AcpiTableHeader)); /* Reserved */ build_append_int_noprefix(table_data, 0, 8); - /* * Memory Mapped Enhanced Configuration Space Base Address Allocation * Structure @@ -56,6 +57,5 @@ void build_mcfg(GArray *table_data, BIOSLinker *linker, A= cpiMcfgInfo *info, /* Reserved */ build_append_int_noprefix(table_data, 0, 4); =20 - build_header(linker, table_data, (void *)(table_data->data + mcfg_star= t), - "MCFG", table_data->len - mcfg_start, 1, oem_id, oem_tabl= e_id); + acpi_table_end(linker, &table); } --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633452465373368.3983770757427; Tue, 5 Oct 2021 09:47:45 -0700 (PDT) Received: from localhost ([::1]:35914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnbU-0003Q7-A0 for importer@patchew.org; Tue, 05 Oct 2021 12:47:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmte-00019C-5x for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:02:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30167) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmtX-0005de-Fs for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:02:25 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-123-tLf2uC5CNxOCT4yKAJmSmw-1; Tue, 05 Oct 2021 12:02:17 -0400 Received: by mail-wm1-f71.google.com with SMTP id d16-20020a1c1d10000000b0030d738feddfso1236692wmd.0 for ; Tue, 05 Oct 2021 09:02:17 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id l16sm2499311wmj.33.2021.10.05.09.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449738; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mXSlFA6w5LGo32CneZXNbHeK35lLFoOJ1E7B23moMNw=; b=fU+EUx4k00oIn3WtHYdYtWq+QczAp3r0Hz4n4CLOV5GFo2ThsGcDKdAG48rsl9kn/5Od+J WLx18QbkSUMAJkrSu68J84+fAT9sGgsVo+piJfMhDBQNtmYkBxSGJ468uzI2rWCpGjAKHi VUlo9UumtixFFoxzYa9kX1jCZPmaDQA= X-MC-Unique: tLf2uC5CNxOCT4yKAJmSmw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mXSlFA6w5LGo32CneZXNbHeK35lLFoOJ1E7B23moMNw=; b=0WDNafTIOp/sRpQFAJp6cJGSbsBVimDQ0Ys04WtAiDKgxtFWRp1KpO1lrgW32Naja/ F5QMDES7UEolgxjZa35wkD4kmUT4y9tdMLlz5AFYRzpPGaKa+Uk0p28kJWLyknms0e2x zCT759ky0yj3I8phmZw/oOgJPg449IgOdsNIsPOE0CVvWNNXszoOTlp8MwMrIjH55zVr 6aMk4zGmY8JeFJMKyiWfn/TX9rZNoc4DgakCo7mU/TizaccyZVCMf/vOab/fZ9eCdzZH VkH/MYfGLcekumEli3HN5Ugj70HKTx7To19AgIV/qDx/cDXcevmcN9qsBKmn/GkpSTWm 60bg== X-Gm-Message-State: AOAM532sBxvJtYuXEytSULJLQm+YZL6P9Z5bCHX3DDsrLW0fCp4oL0mg hRA/ObLOKdHqpyUbC01E5MVwAm7B3g9jHtQ1JsjFxrm5L9Dx+D+RDmIXZETEs57QJjOeMjx4QWR Nk/ULi6xPad3JchPdK3AiXWk28yp9+7lhN46IBz/q3w1FDBHuZDsRW+CEKB1g X-Received: by 2002:adf:c78d:: with SMTP id l13mr9016501wrg.134.1633449736198; Tue, 05 Oct 2021 09:02:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySuskqIN0ckI7jxzJ7ltshJAz4wlO4E4WY8SMoW8XQYtTMC8+L+ph3LkmegPnTw7MeLM3u9g== X-Received: by 2002:adf:c78d:: with SMTP id l13mr9016459wrg.134.1633449735933; Tue, 05 Oct 2021 09:02:15 -0700 (PDT) Date: Tue, 5 Oct 2021 12:02:11 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 23/57] acpi: build_hmat: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-24-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Eric Auger , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452467064100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. Also since acpi_table_begin() reserves space only for standard header while previous acpi_data_push() reserved the header + 4 bytes field, add 4 bytes 'Reserved' field into hmat_build_table_structs() which didn have it. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-10-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/hmat.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/hw/acpi/hmat.c b/hw/acpi/hmat.c index edb3fd91b2..6913ebf730 100644 --- a/hw/acpi/hmat.c +++ b/hw/acpi/hmat.c @@ -200,6 +200,8 @@ static void hmat_build_table_structs(GArray *table_data= , NumaState *numa_state) HMAT_LB_Info *hmat_lb; NumaHmatCacheOptions *hmat_cache; =20 + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ + for (i =3D 0; i < numa_state->num_nodes; i++) { flags =3D 0; =20 @@ -256,14 +258,10 @@ static void hmat_build_table_structs(GArray *table_da= ta, NumaState *numa_state) void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_st= ate, const char *oem_id, const char *oem_table_id) { - int hmat_start =3D table_data->len; - - /* reserve space for HMAT header */ - acpi_data_push(table_data, 40); + AcpiTable table =3D { .sig =3D "HMAT", .rev =3D 2, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 + acpi_table_begin(&table, table_data); hmat_build_table_structs(table_data, numa_state); - - build_header(linker, table_data, - (void *)(table_data->data + hmat_start), - "HMAT", table_data->len - hmat_start, 2, oem_id, oem_tabl= e_id); + acpi_table_end(linker, &table); } --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633451852194828.2498724097526; Tue, 5 Oct 2021 09:37:32 -0700 (PDT) Received: from localhost ([::1]:39034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnRb-0002ZN-7H for importer@patchew.org; Tue, 05 Oct 2021 12:37:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmto-0001Cr-89 for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:02:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54185) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmtd-0005hc-KP for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:02:33 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-191-XMmK4Ko6M-K465YSh263xQ-1; Tue, 05 Oct 2021 12:02:23 -0400 Received: by mail-wm1-f69.google.com with SMTP id 3-20020a05600c22c300b0030d6a6a28f8so1217426wmg.5 for ; Tue, 05 Oct 2021 09:02:22 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id z17sm2283052wml.24.2021.10.05.09.02.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449744; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Pyxz/AAK48QVMZFo15zTre3YEn4vxWBMxwl4pRwjT14=; b=ELUY0D9GLmqXHJyMCq5TyjeBtwf46aPMiY7oCR+2shBFAo3O3ZGc83v98YQ6g2GSxdn9Lg KF6WEpwoHK4iiV4cmtMftMbZ06OYepseC+50LSR+OQR2DfxRs4k4ndkLVaFn7P/MejfCeS hrKme6rIJUTjFtGNvFg+A9ma3z2/uLQ= X-MC-Unique: XMmK4Ko6M-K465YSh263xQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Pyxz/AAK48QVMZFo15zTre3YEn4vxWBMxwl4pRwjT14=; b=xmdgJfo76q1v8a+LkhvhLtc8COgrFtC8mOsGiU6i+kXyO2U9fE/iWaIQTDZL2bxunZ AzGMUycFipe+wphllgh7MW/nhYnPmFAoVtdxef18EvXDFEK4PIKggH2r5a/SwrffP8Ju fs5nWFK+h9JMXLMP2ER8HH26+hW8L2fi/CRbgN+E4lRXzQ3j/YDAJw9flhS6yRg4YqKA nBBjQvUBf3cKAIt0ytc+rVwMgt1rsHP0kFwBmNR2Y6z9xXpTFZPq62I2sPTtsjH/TnY7 905O0v/KxsZjzlOL85QRm4G95WOYyNNP2yMZKj4grqO5cjZeIZfkBvPKdi9EPQ1VzlDH nrmA== X-Gm-Message-State: AOAM532wng276XwBMQ2EcWr83IG0sVA970zCH1kDOaRsoeEX/ld+R7aE TI/VBXWkw9uyVydkRXtcmk5Zo7/6AIomOEWi75Bvs6o40b7BwzbQmp+z7qpcam8i9nU/IiLm0dK pe35qR7NqLBZDrTXwBfCwiBo7c22nDgeZBkMynQPJTk24IZ9OYV/fuw1Ewf11 X-Received: by 2002:adf:a4c7:: with SMTP id h7mr10065844wrb.57.1633449741396; Tue, 05 Oct 2021 09:02:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxIlPaIL7pTPPhMDqNF4zv32q1QkhMGCb/aYOk+MqsmD/vG2wT2v4dCyWBwADXN+4NxHt3kg== X-Received: by 2002:adf:a4c7:: with SMTP id h7mr10065801wrb.57.1633449741142; Tue, 05 Oct 2021 09:02:21 -0700 (PDT) Date: Tue, 5 Oct 2021 12:02:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 24/57] acpi: nvdimm_build_nfit: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-25-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Xiao Guangrong , Eric Auger , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633451853561100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. Also since acpi_table_begin() reserves space only for standard header while previous acpi_data_push() reserved the header + 4 bytes field, add 4 bytes 'Reserved' field into nvdimm_build_nfit() which didn't have it. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-11-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/nvdimm.c | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index e3d5fe1939..15f6ca82ca 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -44,22 +44,6 @@ static const uint8_t nvdimm_nfit_spa_uuid[] =3D UUID_LE(0x66f0d379, 0xb4f3, 0x4074, 0xac, 0x43, 0x0d, 0x33, 0x18, 0xb7, 0x8c, 0xdb); =20 -/* - * NVDIMM Firmware Interface Table - * @signature: "NFIT" - * - * It provides information that allows OSPM to enumerate NVDIMM present in - * the platform and associate system physical address ranges created by the - * NVDIMMs. - * - * It is defined in ACPI 6.0: 5.2.25 NVDIMM Firmware Interface Table (NFIT) - */ -struct NvdimmNfitHeader { - ACPI_TABLE_HEADER_DEF - uint32_t reserved; -} QEMU_PACKED; -typedef struct NvdimmNfitHeader NvdimmNfitHeader; - /* * define NFIT structures according to ACPI 6.0: 5.2.25 NVDIMM Firmware * Interface Table (NFIT). @@ -401,25 +385,33 @@ void nvdimm_plug(NVDIMMState *state) nvdimm_build_fit_buffer(state); } =20 +/* + * NVDIMM Firmware Interface Table + * @signature: "NFIT" + * + * It provides information that allows OSPM to enumerate NVDIMM present in + * the platform and associate system physical address ranges created by the + * NVDIMMs. + * + * It is defined in ACPI 6.0: 5.2.25 NVDIMM Firmware Interface Table (NFIT) + */ + static void nvdimm_build_nfit(NVDIMMState *state, GArray *table_offsets, GArray *table_data, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) { NvdimmFitBuffer *fit_buf =3D &state->fit_buf; - unsigned int header; + AcpiTable table =3D { .sig =3D "NFIT", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 acpi_add_table(table_offsets, table_data); =20 - /* NFIT header. */ - header =3D table_data->len; - acpi_data_push(table_data, sizeof(NvdimmNfitHeader)); + acpi_table_begin(&table, table_data); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); /* NVDIMM device structures. */ g_array_append_vals(table_data, fit_buf->fit->data, fit_buf->fit->len); - - build_header(linker, table_data, - (void *)(table_data->data + header), "NFIT", - sizeof(NvdimmNfitHeader) + fit_buf->fit->len, 1, oem_id, - oem_table_id); + acpi_table_end(linker, &table); } =20 #define NVDIMM_DSM_MEMORY_SIZE 4096 --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633451066000837.3411211503748; Tue, 5 Oct 2021 09:24:26 -0700 (PDT) Received: from localhost ([::1]:38962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnEv-00007n-04 for importer@patchew.org; Tue, 05 Oct 2021 12:24:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmts-0001EG-7z for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:02:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25397) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmtj-0005lo-7y for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:02:38 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-453-qFQdpNvjMQqlxCTK7_Y8Gg-1; Tue, 05 Oct 2021 12:02:27 -0400 Received: by mail-wr1-f69.google.com with SMTP id r15-20020adfce8f000000b0015df1098ccbso5900651wrn.4 for ; Tue, 05 Oct 2021 09:02:27 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id n15sm18787269wrg.58.2021.10.05.09.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RaPq5iLVSqv5CKFO6b2yRg6rjdJgidYZmZppuNmLLzA=; b=YMS3jd7DJoAOqvXZ+JH72bVdud+PPZkChwT1SPvF3Iq5puksWO8tmK/ztV+WxTDy2EvK0f rgWc64ZDefHNVRaicKB7qqHj95PPEdAJhAb+As8Go7tQpdwTrXHkHgqlmPMRfEM9l4lGmM +//O0Z/Q1L2tmKG4JjPhvEFc9eGPMSo= X-MC-Unique: qFQdpNvjMQqlxCTK7_Y8Gg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=RaPq5iLVSqv5CKFO6b2yRg6rjdJgidYZmZppuNmLLzA=; b=RKOIQ8JPZbMrpXMTO4clr8I0tUQ+mJsm+MhKW8WJwx4sagpQXEzce/LOgN7DF5ahP+ ZF/G4C/jwKu6gHLD15owmboQ00Y5/bJsV0aG50TTiB83ApIz8psFCc6nOcK8xFpNgmf6 rpu+6L8Ji+174okb0EREXJRRWXwuuUjKpzc9hufZffzc2lE51Oc4Ke8fbAeZSLX1VX+z ZmtePT+NqG353KwDFcod2gAwtkYXrovXhEpLfGJwXvd+ZG1FV8D2Yn0qS4Vp2g6d9jPd 3jtn/Rn8VRquk1sehr2boZfTp94YwIsiiNokJluQxOoMa1TNEGz6X3vEYrwsa41hTluy UuuA== X-Gm-Message-State: AOAM530990tLI6wE55MjEpsTuN/DH5WqfIn7sqTn0Dg1RRZcFhMfbR5S Mo7/yoP0v6kHreJc7Jy2g0ccia/wNcATING9/1L6BjwB+HvYOu2mLZKWDvZSrnjpZz/SV58mHg4 72Z2q4nbZn+9gp5BHjRz88OeZ3kvfl/ILKG6voRR/WaaidmJbMLMarTS9w6FW X-Received: by 2002:a5d:49c5:: with SMTP id t5mr23168640wrs.295.1633449746017; Tue, 05 Oct 2021 09:02:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEZvx3aGU6gmEznAo7QleslkEM42wt+CwTZFNy9r6S6ApZgasKsHBDM5Scqw/p18JeutjkpQ== X-Received: by 2002:a5d:49c5:: with SMTP id t5mr23168607wrs.295.1633449745810; Tue, 05 Oct 2021 09:02:25 -0700 (PDT) Date: Tue, 5 Oct 2021 12:02:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 25/57] acpi: nvdimm_build_ssdt: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-26-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Xiao Guangrong , Eric Auger , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633451067206100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-12-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/nvdimm.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 15f6ca82ca..a7539cfe89 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -1274,14 +1274,15 @@ static void nvdimm_build_ssdt(GArray *table_offsets= , GArray *table_data, NVDIMMState *nvdimm_state, uint32_t ram_slots, const char *oem_id) { + int mem_addr_offset; Aml *ssdt, *sb_scope, *dev; - int mem_addr_offset, nvdimm_ssdt; + AcpiTable table =3D { .sig =3D "SSDT", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D "NVDIMM" }; =20 acpi_add_table(table_offsets, table_data); =20 + acpi_table_begin(&table, table_data); ssdt =3D init_aml_allocator(); - acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader)); - sb_scope =3D aml_scope("\\_SB"); =20 dev =3D aml_device("NVDR"); @@ -1310,8 +1311,6 @@ static void nvdimm_build_ssdt(GArray *table_offsets, = GArray *table_data, aml_append(sb_scope, dev); aml_append(ssdt, sb_scope); =20 - nvdimm_ssdt =3D table_data->len; - /* copy AML table into ACPI tables blob and patch header there */ g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len); mem_addr_offset =3D build_append_named_dword(table_data, @@ -1323,10 +1322,13 @@ static void nvdimm_build_ssdt(GArray *table_offsets= , GArray *table_data, bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, mem_addr_offset, sizeof(uint32_t), NVDIMM_DSM_MEM_FILE, 0); - build_header(linker, table_data, - (void *)(table_data->data + nvdimm_ssdt), - "SSDT", table_data->len - nvdimm_ssdt, 1, oem_id, "NVDIMM= "); free_aml_allocator(); + /* + * must be executed as the last so that pointer patching command above + * would be executed by guest before it recalculated checksum which we= re + * scheduled by acpi_table_end() + */ + acpi_table_end(linker, &table); } =20 void nvdimm_build_srat(GArray *table_data) --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633451348681292.7343998424626; Tue, 5 Oct 2021 09:29:08 -0700 (PDT) Received: from localhost ([::1]:47352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnJT-0005s4-L1 for importer@patchew.org; Tue, 05 Oct 2021 12:29:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmts-0001EF-7z for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:02:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28284) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmto-0005om-5j for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:02:39 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-227-S3qykfYBM4KOkFO2v_RH8A-1; Tue, 05 Oct 2021 12:02:34 -0400 Received: by mail-wm1-f69.google.com with SMTP id 129-20020a1c1987000000b0030cd1616fbfso1494595wmz.3 for ; Tue, 05 Oct 2021 09:02:34 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id u5sm18917658wrg.57.2021.10.05.09.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449755; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=n6qYsjx2thlrSC+Rpf1F8d62tJ8rgin8MMtTqkd/rDY=; b=P2zIZk5yiwQ0rwtBC/KAAerEb5C4Y0yq0TYEIvZwsiiyL5cSDXqskaqDHqa8+O+WUB6TJj uNSedOmYhJxO+poAZwyLY1HUH5lLFTLrAZ/3HUrpLsoWvRVkrCK7pZ86uQcjmGU3gftwuS d9expD5AT2KgNJbkwsXmEQqE7kyh2dU= X-MC-Unique: S3qykfYBM4KOkFO2v_RH8A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=n6qYsjx2thlrSC+Rpf1F8d62tJ8rgin8MMtTqkd/rDY=; b=5FnZ1ZbRKYWtck2lXeyuZORTsXIQttjbfCrKEKvThMkotTgdCrjmOHPcDfjhnTAQnR uTKFJ8Z9cN5X6VzjSEdEww0xUZGDP6qmZ5yNMA0miyIUEBl/TvUrviqpVK01JY/wQFDB yLqcx28/efVIg4p5Rj7zzJbNsepMboC3TZax+eLB1MTbXjzu7GnTBZ9b9OahwzeGtg41 7U2b64Nwc7OKyi5u29soPcpagl0R18bVPoTLqtWK5JQHkO4KM/SbQ4HLhmTsegFTg7Ea B375vG0y6Piy1OwRI8lCG6HMt+RiyUJqIv/FKuAGQvOaV+M2bezOe18c5gK864lItx8Z 0rvA== X-Gm-Message-State: AOAM532gWyqmmYMB2P95kPVBITafaqRRb+wGUtylkSGZOSANaIiXLLv9 zgoHElaCDsNpjhPeYllMrqDoJutYH7rI3Yqp9at5339oVz5/vRfEyYZ51rKUa5byCWY+3M6E8YA EeJojzBzNejZcmjmAkyz6UdTgAi5pVDhLAVm9pWC7JsE2+6A52jeM3AM2TqV0 X-Received: by 2002:adf:fe0b:: with SMTP id n11mr22849665wrr.371.1633449752959; Tue, 05 Oct 2021 09:02:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAz0M7oi8ssmtZaoDdhFuY0Jz5XrtPt9UwhmSJbCAPJlDsRqgltuzA0Lgc+biwmrOvrmldNg== X-Received: by 2002:adf:fe0b:: with SMTP id n11mr22849633wrr.371.1633449752757; Tue, 05 Oct 2021 09:02:32 -0700 (PDT) Date: Tue, 5 Oct 2021 12:02:26 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 26/57] acpi: vmgenid_build_acpi: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-27-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Eric Auger , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633451350566100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-13-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/vmgenid.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hw/acpi/vmgenid.c b/hw/acpi/vmgenid.c index 4f41a13ea0..0c9f158ac9 100644 --- a/hw/acpi/vmgenid.c +++ b/hw/acpi/vmgenid.c @@ -29,6 +29,8 @@ void vmgenid_build_acpi(VmGenIdState *vms, GArray *table_= data, GArray *guid, Aml *ssdt, *dev, *scope, *method, *addr, *if_ctx; uint32_t vgia_offset; QemuUUID guid_le; + AcpiTable table =3D { .sig =3D "SSDT", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D "VMGENID" }; =20 /* Fill in the GUID values. These need to be converted to little-endi= an * first, since that's what the guest expects @@ -42,12 +44,10 @@ void vmgenid_build_acpi(VmGenIdState *vms, GArray *tabl= e_data, GArray *guid, g_array_insert_vals(guid, VMGENID_GUID_OFFSET, guid_le.data, ARRAY_SIZE(guid_le.data)); =20 - /* Put this in a separate SSDT table */ + /* Put VMGNEID into a separate SSDT table */ + acpi_table_begin(&table, table_data); ssdt =3D init_aml_allocator(); =20 - /* Reserve space for header */ - acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader)); - /* Storage for the GUID address */ vgia_offset =3D table_data->len + build_append_named_dword(ssdt->buf, "VGIA"); @@ -116,9 +116,8 @@ void vmgenid_build_acpi(VmGenIdState *vms, GArray *tabl= e_data, GArray *guid, ACPI_BUILD_TABLE_FILE, vgia_offset, sizeof(uint32_t), VMGENID_GUID_FW_CFG_FILE, 0); =20 - build_header(linker, table_data, - (void *)(table_data->data + table_data->len - ssdt->buf->len), - "SSDT", ssdt->buf->len, 1, oem_id, "VMGENID"); + /* must be called after above command to ensure correct table checksum= */ + acpi_table_end(linker, &table); free_aml_allocator(); } =20 --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633455350358727.5382341917615; Tue, 5 Oct 2021 10:35:50 -0700 (PDT) Received: from localhost ([::1]:36608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXoLz-0006PP-Vh for importer@patchew.org; Tue, 05 Oct 2021 13:35:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmxH-0002tE-Hj for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:06:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54859) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmxB-0000Gv-Ek for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:06:11 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-185-yaACObwfOHyICh2Pm3a2rw-1; Tue, 05 Oct 2021 12:02:42 -0400 Received: by mail-wr1-f71.google.com with SMTP id r25-20020adfab59000000b001609ddd5579so2868718wrc.21 for ; Tue, 05 Oct 2021 09:02:41 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id n11sm2510331wmq.19.2021.10.05.09.02.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449964; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=m5WIudgdGV/fTsKWLR/EBdq7ujMlfVtUKhh5wWohWOA=; b=ce1yG+ODkeT/adXJq1zXGk20fq6paVgzjvdJH202bsuvP35PWqARoXheII9Y3+E8hS3P+m J50wSaBeXhRaP1fIO2VaHir54RE/hwUeUOicoOHj5hL+YaoIPTlbSo8QdwdkjsSuPHR61o ONDvrt0IkXFLYghQaeaunYslsuUDILI= X-MC-Unique: yaACObwfOHyICh2Pm3a2rw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=m5WIudgdGV/fTsKWLR/EBdq7ujMlfVtUKhh5wWohWOA=; b=B16H1y19hzU94YaSqXz96B0VgmlXFXfaO/bIxwoNzsq1/DBdne6hsiBrxUKHRzvhCJ bW3B0gTJI1MiDmvZfRmUQ6Frq5CrKpZFbbQ/+li85ltIJQWhu+n+i+2MWjAVuugDPi6x 59bsZvqKxuJYEYZdj8C7m0WpB98zuPZx1+PBTf7sPGsEg22w7Elovisor16cMvDthb8F L8D9gnQcYQypZ7d8szRkBiJi4HtNednwY6Q/z1a0rFO8UBNvgA4UfgS6bSV4jwkOfm1O 828AdiX2iph8nHjU7eKx6VaRF4W257ZWJahvLs/Ech0Bj/PK/L4v3+Q7+VwIfE8IwlUY 0nyQ== X-Gm-Message-State: AOAM530TXXoo+BnrUuElMxVLSyXFqok+TarkC2ohnFROjdRdywiGBCwt ZYXc/wJX0O5tWGKBdYiasa/2C0L7s4NRSzQZ82vi0UJa/GnADYdeL8NQPvnsLsa+4/Pm91q9w3/ KSYsLRkpqmg+BikfYPMeZSnr/942sD8/+sJ0pt8o25ow3gE7r/qwWQ/tECtXa X-Received: by 2002:a7b:c14d:: with SMTP id z13mr4297278wmi.112.1633449760368; Tue, 05 Oct 2021 09:02:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqiyngSq4m/Ed7H6YjTqVa6nZzscn6vUIIl0a2Blq6CDFs6tVzMLtoNAZoDoJkk4kcIFY+RA== X-Received: by 2002:a7b:c14d:: with SMTP id z13mr4297241wmi.112.1633449760093; Tue, 05 Oct 2021 09:02:40 -0700 (PDT) Date: Tue, 5 Oct 2021 12:02:32 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 27/57] acpi: x86: build_dsdt: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-28-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , Eric Auger , Igor Mammedov , Ani Sinha , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633455352223100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-14-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index f4d6ae3d02..e17451bc6d 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1405,12 +1405,12 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, #endif int i; VMBusBridge *vmbus_bridge =3D vmbus_bridge_find(); + AcpiTable table =3D { .sig =3D "DSDT", .rev =3D 1, .oem_id =3D x86ms->= oem_id, + .oem_table_id =3D x86ms->oem_table_id }; =20 + acpi_table_begin(&table, table_data); dsdt =3D init_aml_allocator(); =20 - /* Reserve space for header */ - acpi_data_push(dsdt->buf, sizeof(AcpiTableHeader)); - build_dbg_aml(dsdt); if (misc->is_piix4) { sb_scope =3D aml_scope("_SB"); @@ -1867,9 +1867,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, =20 /* copy AML table into ACPI tables blob and patch header there */ g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len); - build_header(linker, table_data, - (void *)(table_data->data + table_data->len - dsdt->buf->len), - "DSDT", dsdt->buf->len, 1, x86ms->oem_id, x86ms->oem_tabl= e_id); + acpi_table_end(linker, &table); free_aml_allocator(); } =20 --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633451847240849.3016302836822; Tue, 5 Oct 2021 09:37:27 -0700 (PDT) Received: from localhost ([::1]:38568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnRW-0002GL-74 for importer@patchew.org; Tue, 05 Oct 2021 12:37:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmuD-0001KF-3y for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48056) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmu7-00064C-M1 for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:00 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-82-JU4Yf8oXM_eomN67LWv2lg-1; Tue, 05 Oct 2021 12:02:54 -0400 Received: by mail-wr1-f71.google.com with SMTP id f11-20020adfc98b000000b0015fedc2a8d4so5923444wrh.0 for ; Tue, 05 Oct 2021 09:02:53 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id w1sm2248213wmc.19.2021.10.05.09.02.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449775; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=O14S/Nap5OwplpMPbE33Eg7WKkAgoaoLhJvZHDTVT6Q=; b=S00wStVOylPwJ4iQl1yMY5NCjfHmt1mpiqzDrGxYjaNvhNTYpyXfQcuw62xul97SwsiY5d ausF73zGPHdJd80UFD/1fZu1tgGfLuiD0m6gXUP/Eeg9SrxT3nBTaj9EGWt5uSU1FVkVE4 MnQ9Dlq3xzd9IPaQtBIH2V1jap+5TqE= X-MC-Unique: JU4Yf8oXM_eomN67LWv2lg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=O14S/Nap5OwplpMPbE33Eg7WKkAgoaoLhJvZHDTVT6Q=; b=clMgasPfRHdwol/emn44/rTcyCS8DV72T67+0+zJAt0c4gLCmFkXeV3j10LTqdu8bH fcfmrNiBvsVOp2h9LMVaxAcK+0h+gxozQxit/otxC7I0HM2liCAmzJQ+9l7mnzWIse5i 7wRjsYVa0SCauX0cduZmKasoOCuSe6Sn8pZSupbUf0M+dfevve8ciddWI1Xy5v+UmBKl 4ibtsA+0FIu5s5SPai2judRvyoGB3I5JhL/GFE3aZ2CI2iRNVs7Mamagg13Sh6Fer9lG ZKEue1f+TdEe5h0NsVhNWeSNYnT57+VNsjhlkoz09ACjZFiU1VbLsN6FyoGJUff2fIeP CIXA== X-Gm-Message-State: AOAM531wcYwuaPTQ3ok0PxyIfNZ0e09fKRod97Uc+68dRD4/HU5v+cMS 1dmgeaOYtF3oIJ+4a3DswQL8uFi0UgP0UAmtEwSRUrKXA5+bk5j86boaNRGkH8VlsCFfJHajwc+ 0fRuybdaUNQ8AU9hzYn8AKW+AKqPImcnGVU2HYvXYwWB/rpN8QreixDrkfYTc X-Received: by 2002:adf:9bd3:: with SMTP id e19mr23156062wrc.167.1633449769179; Tue, 05 Oct 2021 09:02:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFaRiC1qEA/NELnvelfZlSrZYUUDNymopJiIaBKWOq3W3zulO++wUccNyoKkA5mX4ygMMA3g== X-Received: by 2002:adf:9bd3:: with SMTP id e19mr23155634wrc.167.1633449766187; Tue, 05 Oct 2021 09:02:46 -0700 (PDT) Date: Tue, 5 Oct 2021 12:02:40 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 28/57] acpi: build_hpet: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-29-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , Igor Mammedov , Ani Sinha , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633451848738100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. while at it convert build_hpet() to endian agnostic build_append_FOO() API Signed-off-by: Igor Mammedov Message-Id: <20210924122802.1455362-15-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 13 ------------- hw/i386/acpi-build.c | 26 ++++++++++++++++++-------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index f6d2ca172b..4d8f8b34b0 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -358,19 +358,6 @@ struct AcpiGenericTimerTable { } QEMU_PACKED; typedef struct AcpiGenericTimerTable AcpiGenericTimerTable; =20 -/* - * HPET Description Table - */ -struct Acpi20Hpet { - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint32_t timer_block_id; - struct AcpiGenericAddress addr; - uint8_t hpet_number; - uint16_t min_tick; - uint8_t page_protect; -} QEMU_PACKED; -typedef struct Acpi20Hpet Acpi20Hpet; - /* * SRAT (NUMA topology description) table */ diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index e17451bc6d..12d743d529 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1871,22 +1871,32 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, free_aml_allocator(); } =20 +/* + * IA-PC HPET (High Precision Event Timers) Specification (Revision: 1.0a) + * 3.2.4The ACPI 2.0 HPET Description Table (HPET) + */ static void build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) { - Acpi20Hpet *hpet; - int hpet_start =3D table_data->len; + AcpiTable table =3D { .sig =3D "HPET", .rev =3D 1, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 - hpet =3D acpi_data_push(table_data, sizeof(*hpet)); + acpi_table_begin(&table, table_data); /* Note timer_block_id value must be kept in sync with value advertise= d by * emulated hpet */ - hpet->timer_block_id =3D cpu_to_le32(0x8086a201); - hpet->addr.address =3D cpu_to_le64(HPET_BASE); - build_header(linker, table_data, - (void *)(table_data->data + hpet_start), - "HPET", sizeof(*hpet), 1, oem_id, oem_table_id); + /* Event Timer Block ID */ + build_append_int_noprefix(table_data, 0x8086a201, 4); + /* BASE_ADDRESS */ + build_append_gas(table_data, AML_AS_SYSTEM_MEMORY, 0, 0, 0, HPET_BASE); + /* HPET Number */ + build_append_int_noprefix(table_data, 0, 1); + /* Main Counter Minimum Clock_tick in Periodic Mode */ + build_append_int_noprefix(table_data, 0, 2); + /* Page Protection And OEM Attribute */ + build_append_int_noprefix(table_data, 0, 1); + acpi_table_end(linker, &table); } =20 #ifdef CONFIG_TPM --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633451818677828.7342709728883; Tue, 5 Oct 2021 09:36:58 -0700 (PDT) Received: from localhost ([::1]:37420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnR3-0001Ti-KK for importer@patchew.org; Tue, 05 Oct 2021 12:36:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmuP-0001Zl-Dv for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32320) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmuG-00069D-UB for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:13 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-233-BDm8XrtJNG6fPeMj2uqolg-1; Tue, 05 Oct 2021 12:02:55 -0400 Received: by mail-wm1-f70.google.com with SMTP id s10-20020a1cf20a000000b0030d66991388so1490053wmc.7 for ; Tue, 05 Oct 2021 09:02:55 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id l11sm3101143wms.45.2021.10.05.09.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449780; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nZ0kMDIZcaXR+/0+/mgU2Zp3J1xHpo24a4ipyZEtxio=; b=Ze/rLz5DW70eLbf0buRA8meQWlphJpT+NF0hJQyW5BsjdrkwVyGWSBmKL0GTkbkm0blkfY wzMNreOJpSHPiS4rffte2nZgOSdOs2aKU9A4n5prUeBt8lUArZQSxuswA0cZ4qofB+0NAi olPnGv1X///e1irGhIm1Rw43CinQJ2k= X-MC-Unique: BDm8XrtJNG6fPeMj2uqolg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=nZ0kMDIZcaXR+/0+/mgU2Zp3J1xHpo24a4ipyZEtxio=; b=23osnVHg1nMq3VdMq4Ttsjd+eAOsCXra/dji9RvE5no7YWEnC9lADAKO+zgC2mqusY rALCJ9MdEqNKG6id5zHKE5GxD2QZIgqVQFeWM3kSnKTmixYcYSsaH+Q8weNZ6HCzjtz3 v1DxnI6QQ/mroIj9rmqzxSvzvOSoud4MfJyj44i3OTiok5PRyDx7I2/qBl+8XaKN2LB/ XGs3zwk2QMABaIwk7UqJejzLDmGMe1/zZTOzak4rT1fnercqOj3qVGVUNZB9ylxU8+KH 4ncRLk1Xb8vIdJ+uJ4kKMIJAsHdrCCzvdLUYbs7dwk59oxVpJYKK8t8Jlon5HE4tpbtq /CDw== X-Gm-Message-State: AOAM5302vAW9aJd0K1xGLTLl/YUZpGGXfTu3K0uofMl6oPRVacdigTSK 8Y4MDVoa/qwHGpc80l4+I1uzcX1T0uvG7YLWc4CrG9Nil3XDTkmqZScyR6GDU9s8zx0kL+645HT g33q3fzQ49NBPhpRUI//x3wc//EkrNcmlymLz+7mseZfSyCjhuHukLiHBDbrY X-Received: by 2002:adf:8b47:: with SMTP id v7mr22322706wra.321.1633449773441; Tue, 05 Oct 2021 09:02:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxS8mT7JWUA5srwQjljC0SIJb57tsZ3SwNLQ+/gdObk9+ynYYEDdMcxer+8WhKlZeb9TZVxmg== X-Received: by 2002:adf:8b47:: with SMTP id v7mr22322556wra.321.1633449772362; Tue, 05 Oct 2021 09:02:52 -0700 (PDT) Date: Tue, 5 Oct 2021 12:02:48 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 29/57] acpi: build_tpm_tcpa: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-30-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , Eric Auger , Igor Mammedov , Ani Sinha , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633451821027100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. While at it switch to build_append_int_noprefix() to build table entries (which also removes some manual offset calculations). Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-16-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 14 -------------- hw/i386/acpi-build.c | 38 ++++++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 4d8f8b34b0..3b42b138f0 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -418,20 +418,6 @@ struct AcpiSratProcessorGiccAffinity { =20 typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity; =20 -/* - * TCPA Description Table - * - * Following Level 00, Rev 00.37 of specs: - * http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification - */ -struct Acpi20Tcpa { - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint16_t platform_class; - uint32_t log_area_minimum_length; - uint64_t log_area_start_address; -} QEMU_PACKED; -typedef struct Acpi20Tcpa Acpi20Tcpa; - /* DMAR - DMA Remapping table r2.2 */ struct AcpiTableDmar { ACPI_TABLE_HEADER_DEF diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 12d743d529..3310a3efc3 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1900,31 +1900,39 @@ build_hpet(GArray *table_data, BIOSLinker *linker, = const char *oem_id, } =20 #ifdef CONFIG_TPM +/* + * TCPA Description Table + * + * Following Level 00, Rev 00.37 of specs: + * http://www.trustedcomputinggroup.org/resources/tcg_acpi_specification + * 7.1.2 ACPI Table Layout + */ static void build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog, const char *oem_id, const char *oem_table_id) { - int tcpa_start =3D table_data->len; - Acpi20Tcpa *tcpa =3D acpi_data_push(table_data, sizeof *tcpa); - unsigned log_addr_size =3D sizeof(tcpa->log_area_start_address); - unsigned log_addr_offset =3D - (char *)&tcpa->log_area_start_address - table_data->data; + unsigned log_addr_offset; + AcpiTable table =3D { .sig =3D "TCPA", .rev =3D 2, + .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 - tcpa->platform_class =3D cpu_to_le16(TPM_TCPA_ACPI_CLASS_CLIENT); - tcpa->log_area_minimum_length =3D cpu_to_le32(TPM_LOG_AREA_MINIMUM_SIZ= E); - acpi_data_push(tcpalog, le32_to_cpu(tcpa->log_area_minimum_length)); + acpi_table_begin(&table, table_data); + /* Platform Class */ + build_append_int_noprefix(table_data, TPM_TCPA_ACPI_CLASS_CLIENT, 2); + /* Log Area Minimum Length (LAML) */ + build_append_int_noprefix(table_data, TPM_LOG_AREA_MINIMUM_SIZE, 4); + /* Log Area Start Address (LASA) */ + log_addr_offset =3D table_data->len; + build_append_int_noprefix(table_data, 0, 8); =20 + /* allocate/reserve space for TPM log area */ + acpi_data_push(tcpalog, TPM_LOG_AREA_MINIMUM_SIZE); bios_linker_loader_alloc(linker, ACPI_BUILD_TPMLOG_FILE, tcpalog, 1, false /* high memory */); - /* log area start address to be filled by Guest linker */ - bios_linker_loader_add_pointer(linker, - ACPI_BUILD_TABLE_FILE, log_addr_offset, log_addr_size, - ACPI_BUILD_TPMLOG_FILE, 0); + bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, + log_addr_offset, 8, ACPI_BUILD_TPMLOG_FILE, 0); =20 - build_header(linker, table_data, - (void *)(table_data->data + tcpa_start), - "TCPA", sizeof(*tcpa), 2, oem_id, oem_table_id); + acpi_table_end(linker, &table); } #endif =20 --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633451581731419.99512571935554; Tue, 5 Oct 2021 09:33:01 -0700 (PDT) Received: from localhost ([::1]:56882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnNE-0003tF-Ds for importer@patchew.org; Tue, 05 Oct 2021 12:33:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmuJ-0001N8-6K for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41116) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmuG-00068b-Tc for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:06 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-Rmpnj6exMDmkNihgAobp-A-1; Tue, 05 Oct 2021 12:02:59 -0400 Received: by mail-wr1-f71.google.com with SMTP id c2-20020adfa302000000b0015e4260febdso5866647wrb.20 for ; Tue, 05 Oct 2021 09:02:59 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id u17sm3967462wrw.85.2021.10.05.09.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449780; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NpF8lgnfc5+t/i9eKuzzdBBnMNRAQzYvNectRQcnBkM=; b=Nty32VETyFFY6up+7afbSCvP8kFFJVhRCsgHuZ0c9Lgdlmae5qCVDiivQs4xelP9rglx6D SFiG+MxXoUeasXL2uyPOKQAv7LhKCZiQxkyw0Q/1fm4HrxO9krMwc5zQU0ufhXoHTjDBDR 6rRELZTNKuX/DE01nSOHHbDkp6Ldk3Y= X-MC-Unique: Rmpnj6exMDmkNihgAobp-A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=NpF8lgnfc5+t/i9eKuzzdBBnMNRAQzYvNectRQcnBkM=; b=ES05QXyo31UXNqmVKE4gjom9oJ1HtfWpfzmmIaVlDPmEyf+Jhbysg/2LVwlXiv0Up3 73DLn3mBqRC2xLrzw/dRgd2RN11Qtae7fvWCotDsjSWWBsOZzcQQClgYYCO5n/giOh7U +/cZPsmL6Vj6POesqxnTPEi8CScsniqI8xCn44C54lffK7zWBEOvlbDXDOF0M27xaFzD RP+/NsgTN5k4GDBxg9wpgX5v15tlvrWvgXyXqxVO8MEAIV0hZSQbvE7fFnPk7hNx40yp 6zKzZFL8H/m5A+dBQ6MaehR7lXUwxRv/meqDR5fMnT08Ne+7DqXFLNPEJNwHAqUmyx0L KvTw== X-Gm-Message-State: AOAM530gWiO73DAtxknQBOHY+bo6pmP3f1a6acBJpeGwDZ0WTbIYaeY9 YJc/rKWAxGmakrnGe1ahcE7bQIEgyXGTqHJmunt9t2TyhRyaemUX6MqMigithmkOix5rNrinZqM hVSyJ4tcNa6wFyFHI7jZROxs2UySHrCq8l2AN+Vnfs7qkZqjY95696eUaweFj X-Received: by 2002:a05:600c:1c9e:: with SMTP id k30mr4217156wms.74.1633449777671; Tue, 05 Oct 2021 09:02:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeNmGdthn/9kKWT2kVLlxWhh6YQTp0MvYWhUepFm4kNsXEIYgHRFyK3gspUxTO6la+Ii3aBw== X-Received: by 2002:a05:600c:1c9e:: with SMTP id k30mr4217110wms.74.1633449777363; Tue, 05 Oct 2021 09:02:57 -0700 (PDT) Date: Tue, 5 Oct 2021 12:02:52 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 30/57] acpi: arm/x86: build_srat: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-31-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Eric Auger , Richard Henderson , Shannon Zhao , qemu-arm@nongnu.org, Igor Mammedov , Ani Sinha , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633451582281100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. While at it switch to build_append_int_noprefix() to build table entries (which also removes some manual offset calculations) Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-17-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 11 ----------- hw/arm/virt-acpi-build.c | 15 +++++++-------- hw/i386/acpi-build.c | 18 +++++++----------- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 3b42b138f0..5826ee04b6 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -358,17 +358,6 @@ struct AcpiGenericTimerTable { } QEMU_PACKED; typedef struct AcpiGenericTimerTable AcpiGenericTimerTable; =20 -/* - * SRAT (NUMA topology description) table - */ - -struct AcpiSystemResourceAffinityTable { - ACPI_TABLE_HEADER_DEF - uint32_t reserved1; - uint32_t reserved2[2]; -} QEMU_PACKED; -typedef struct AcpiSystemResourceAffinityTable AcpiSystemResourceAffinityT= able; - #define ACPI_SRAT_PROCESSOR_APIC 0 #define ACPI_SRAT_MEMORY 1 #define ACPI_SRAT_PROCESSOR_x2APIC 2 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 037cc1fd82..21efe7fe34 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -477,18 +477,19 @@ build_spcr(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) static void build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { - AcpiSystemResourceAffinityTable *srat; AcpiSratProcessorGiccAffinity *core; AcpiSratMemoryAffinity *numamem; - int i, srat_start; + int i; uint64_t mem_base; MachineClass *mc =3D MACHINE_GET_CLASS(vms); MachineState *ms =3D MACHINE(vms); const CPUArchIdList *cpu_list =3D mc->possible_cpu_arch_ids(ms); + AcpiTable table =3D { .sig =3D "SRAT", .rev =3D 3, .oem_id =3D vms->oe= m_id, + .oem_table_id =3D vms->oem_table_id }; =20 - srat_start =3D table_data->len; - srat =3D acpi_data_push(table_data, sizeof(*srat)); - srat->reserved1 =3D cpu_to_le32(1); + acpi_table_begin(&table, table_data); + build_append_int_noprefix(table_data, 1, 4); /* Reserved */ + build_append_int_noprefix(table_data, 0, 8); /* Reserved */ =20 for (i =3D 0; i < cpu_list->len; ++i) { core =3D acpi_data_push(table_data, sizeof(*core)); @@ -522,9 +523,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED= ); } =20 - build_header(linker, table_data, (void *)(table_data->data + srat_star= t), - "SRAT", table_data->len - srat_start, 3, vms->oem_id, - vms->oem_table_id); + acpi_table_end(linker, &table); } =20 /* GTDT */ diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 3310a3efc3..1ce808c576 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1942,11 +1942,10 @@ build_tpm_tcpa(GArray *table_data, BIOSLinker *link= er, GArray *tcpalog, static void build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) { - AcpiSystemResourceAffinityTable *srat; AcpiSratMemoryAffinity *numamem; =20 int i; - int srat_start, numa_start, slots; + int numa_start, slots; uint64_t mem_len, mem_base, next_base; MachineClass *mc =3D MACHINE_GET_CLASS(machine); X86MachineState *x86ms =3D X86_MACHINE(machine); @@ -1957,11 +1956,12 @@ build_srat(GArray *table_data, BIOSLinker *linker, = MachineState *machine) ram_addr_t hotpluggable_address_space_size =3D object_property_get_int(OBJECT(pcms), PC_MACHINE_DEVMEM_REGION_SIZ= E, NULL); + AcpiTable table =3D { .sig =3D "SRAT", .rev =3D 1, .oem_id =3D x86ms->= oem_id, + .oem_table_id =3D x86ms->oem_table_id }; =20 - srat_start =3D table_data->len; - - srat =3D acpi_data_push(table_data, sizeof *srat); - srat->reserved1 =3D cpu_to_le32(1); + acpi_table_begin(&table, table_data); + build_append_int_noprefix(table_data, 1, 4); /* Reserved */ + build_append_int_noprefix(table_data, 0, 8); /* Reserved */ =20 for (i =3D 0; i < apic_ids->len; i++) { int node_id =3D apic_ids->cpus[i].props.node_id; @@ -2067,11 +2067,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, M= achineState *machine) MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED= ); } =20 - build_header(linker, table_data, - (void *)(table_data->data + srat_start), - "SRAT", - table_data->len - srat_start, 1, x86ms->oem_id, - x86ms->oem_table_id); + acpi_table_end(linker, &table); } =20 /* --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633451954694694.6483926646986; Tue, 5 Oct 2021 09:39:14 -0700 (PDT) Received: from localhost ([::1]:45668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnTF-00079D-9T for importer@patchew.org; Tue, 05 Oct 2021 12:39:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmuO-0001YQ-FX for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30827) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmuJ-0006Dk-9X for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:11 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-463-hiURpff1OBuuhjpUamnYhA-1; Tue, 05 Oct 2021 12:03:05 -0400 Received: by mail-wr1-f69.google.com with SMTP id d13-20020adfa34d000000b00160aa1cc5f1so2193347wrb.14 for ; Tue, 05 Oct 2021 09:03:05 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id n66sm2486265wmn.2.2021.10.05.09.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449786; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3DwFtuti80YCvkyahMaSmY/s+KW5J9Y1bN6GlNEW1AU=; b=Q1mIN5f01ek5DfCVYXd9BEusEPY2aC5/rclJlsoxpGT3A+s8mU05rOLHTJdlyF3mJzQ3Nr jDeADtOr9YxF6F0h7JdNxHT9v1IQVfKYeq2UpIW9NNNISHEbfstIk7NANwmhcTBK7oMfTM bDN5ikL+wtQQSgiQtZiQjN08WYt3N3I= X-MC-Unique: hiURpff1OBuuhjpUamnYhA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3DwFtuti80YCvkyahMaSmY/s+KW5J9Y1bN6GlNEW1AU=; b=Y9q20hVJBnys/2GtJeHHmfizrDrf1oOYvMCoyLU+RfNo7E4Zx2FfmIYopM6O9Mf3CN aQh7nylmTf1eovFhWmsXsPIPEnlb3bMQvRtHWY1+qS2dafUbApiSIxfAJVpqdj4aGpND fET5TIsI7DYIFb0TxIG5kETRVcJg2lfZDNCaG0p5ZAvXUNw9WAUK0YKgnLrPO6usuR64 uosaTmthY5o2e3pAXSjVAVF5v4k6EXcUFeVjed21JgAFSm8GTujDRSIKC/dhoxz4ptFV /RosOliPu1mKN7T7bWpyxlwOD5W1nLRPdz7yzEyG65KEmgMBn7uUdi5ZUUdirjySxicD uc3Q== X-Gm-Message-State: AOAM5304b9wW+ZmELagrmGtI9Gn5YuuuAZolcWLVfMFR/7vMfPbih0gm X8HbsCgWrgSdhRarkJ3POb3pFbTFcbmdaSTrkayOPkeffEi/PI6iSW5zXdVs8xyzwdwDO5K8TPw ADKanrylBfMz4XvmryENNHckprVypQ+IhJBBROzAOJIAesbxGUr42ktiySDla X-Received: by 2002:adf:a54f:: with SMTP id j15mr17330740wrb.218.1633449782996; Tue, 05 Oct 2021 09:03:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgQJHYkQbyqLcnbszMZpxeBKNJAXBdbzXGFz0CyFEds32meRG0EzS6TyDCd+0L8dM24JyXMg== X-Received: by 2002:adf:a54f:: with SMTP id j15mr17330675wrb.218.1633449782572; Tue, 05 Oct 2021 09:03:02 -0700 (PDT) Date: Tue, 5 Oct 2021 12:02:57 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 31/57] acpi: use build_append_int_noprefix() API to compose SRAT table Message-ID: <20211005155946.513818-32-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Xiao Guangrong , Eric Auger , Richard Henderson , Shannon Zhao , qemu-arm@nongnu.org, Paolo Bonzini , Ani Sinha , Igor Mammedov , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633451955824100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Drop usage of packed structures and explicit endian conversions when building SRAT tables for arm/x86 and use endian agnostic build_append_int_noprefix() API to build it. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-18-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 49 ----------------------- include/hw/acpi/aml-build.h | 2 +- hw/acpi/aml-build.c | 24 ++++++++---- hw/acpi/nvdimm.c | 4 +- hw/arm/virt-acpi-build.c | 29 ++++++++------ hw/i386/acpi-build.c | 78 +++++++++++++++++++++---------------- 6 files changed, 80 insertions(+), 106 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 5826ee04b6..d293304f9c 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -358,55 +358,6 @@ struct AcpiGenericTimerTable { } QEMU_PACKED; typedef struct AcpiGenericTimerTable AcpiGenericTimerTable; =20 -#define ACPI_SRAT_PROCESSOR_APIC 0 -#define ACPI_SRAT_MEMORY 1 -#define ACPI_SRAT_PROCESSOR_x2APIC 2 -#define ACPI_SRAT_PROCESSOR_GICC 3 - -struct AcpiSratProcessorAffinity { - ACPI_SUB_HEADER_DEF - uint8_t proximity_lo; - uint8_t local_apic_id; - uint32_t flags; - uint8_t local_sapic_eid; - uint8_t proximity_hi[3]; - uint32_t reserved; -} QEMU_PACKED; -typedef struct AcpiSratProcessorAffinity AcpiSratProcessorAffinity; - -struct AcpiSratProcessorX2ApicAffinity { - ACPI_SUB_HEADER_DEF - uint16_t reserved; - uint32_t proximity_domain; - uint32_t x2apic_id; - uint32_t flags; - uint32_t clk_domain; - uint32_t reserved2; -} QEMU_PACKED; -typedef struct AcpiSratProcessorX2ApicAffinity AcpiSratProcessorX2ApicAffi= nity; - -struct AcpiSratMemoryAffinity { - ACPI_SUB_HEADER_DEF - uint32_t proximity; - uint16_t reserved1; - uint64_t base_addr; - uint64_t range_length; - uint32_t reserved2; - uint32_t flags; - uint32_t reserved3[2]; -} QEMU_PACKED; -typedef struct AcpiSratMemoryAffinity AcpiSratMemoryAffinity; - -struct AcpiSratProcessorGiccAffinity { - ACPI_SUB_HEADER_DEF - uint32_t proximity; - uint32_t acpi_processor_uid; - uint32_t flags; - uint32_t clock_domain; -} QEMU_PACKED; - -typedef struct AcpiSratProcessorGiccAffinity AcpiSratProcessorGiccAffinity; - /* DMAR - DMA Remapping table r2.2 */ struct AcpiTableDmar { ACPI_TABLE_HEADER_DEF diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 4242382399..6e1f42e119 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -487,7 +487,7 @@ Aml *build_crs(PCIHostState *host, CrsRangeSet *range_s= et, uint32_t io_offset, uint32_t mmio32_offset, uint64_t mmio64_offset, uint16_t bus_nr_offset); =20 -void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, +void build_srat_memory(GArray *table_data, uint64_t base, uint64_t len, int node, MemoryAffinityFlags flags); =20 void build_slit(GArray *table_data, BIOSLinker *linker, MachineState *ms, diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 23cda45ee0..c0f339847a 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1940,15 +1940,25 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, = GArray *table_offsets, acpi_table_end(linker, &table); } =20 -void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, +/* + * ACPI spec, Revision 4.0 + * 5.2.16.2 Memory Affinity Structure + */ +void build_srat_memory(GArray *table_data, uint64_t base, uint64_t len, int node, MemoryAffinityFlags flags) { - numamem->type =3D ACPI_SRAT_MEMORY; - numamem->length =3D sizeof(*numamem); - numamem->proximity =3D cpu_to_le32(node); - numamem->flags =3D cpu_to_le32(flags); - numamem->base_addr =3D cpu_to_le64(base); - numamem->range_length =3D cpu_to_le64(len); + build_append_int_noprefix(table_data, 1, 1); /* Type */ + build_append_int_noprefix(table_data, 40, 1); /* Length */ + build_append_int_noprefix(table_data, node, 4); /* Proximity Domain */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + build_append_int_noprefix(table_data, base, 4); /* Base Address Low */ + /* Base Address High */ + build_append_int_noprefix(table_data, base >> 32, 4); + build_append_int_noprefix(table_data, len, 4); /* Length Low */ + build_append_int_noprefix(table_data, len >> 32, 4); /* Length High */ + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ + build_append_int_noprefix(table_data, flags, 4); /* Flags */ + build_append_int_noprefix(table_data, 0, 8); /* Reserved */ } =20 /* diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index a7539cfe89..5f9b552d6a 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -1336,7 +1336,6 @@ void nvdimm_build_srat(GArray *table_data) GSList *device_list =3D nvdimm_get_device_list(); =20 for (; device_list; device_list =3D device_list->next) { - AcpiSratMemoryAffinity *numamem =3D NULL; DeviceState *dev =3D device_list->data; Object *obj =3D OBJECT(dev); uint64_t addr, size; @@ -1346,8 +1345,7 @@ void nvdimm_build_srat(GArray *table_data) addr =3D object_property_get_uint(obj, PC_DIMM_ADDR_PROP, &error_a= bort); size =3D object_property_get_uint(obj, PC_DIMM_SIZE_PROP, &error_a= bort); =20 - numamem =3D acpi_data_push(table_data, sizeof *numamem); - build_srat_memory(numamem, addr, size, node, + build_srat_memory(table_data, addr, size, node, MEM_AFFINITY_ENABLED | MEM_AFFINITY_NON_VOLATILE= ); } g_slist_free(device_list); diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 21efe7fe34..6ba02cf281 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -474,11 +474,13 @@ build_spcr(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) vms->oem_table_id); } =20 +/* + * ACPI spec, Revision 5.1 + * 5.2.16 System Resource Affinity Table (SRAT) + */ static void build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { - AcpiSratProcessorGiccAffinity *core; - AcpiSratMemoryAffinity *numamem; int i; uint64_t mem_base; MachineClass *mc =3D MACHINE_GET_CLASS(vms); @@ -492,19 +494,23 @@ build_srat(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) build_append_int_noprefix(table_data, 0, 8); /* Reserved */ =20 for (i =3D 0; i < cpu_list->len; ++i) { - core =3D acpi_data_push(table_data, sizeof(*core)); - core->type =3D ACPI_SRAT_PROCESSOR_GICC; - core->length =3D sizeof(*core); - core->proximity =3D cpu_to_le32(cpu_list->cpus[i].props.node_id); - core->acpi_processor_uid =3D cpu_to_le32(i); - core->flags =3D cpu_to_le32(1); + uint32_t nodeid =3D cpu_list->cpus[i].props.node_id; + /* + * 5.2.16.4 GICC Affinity Structure + */ + build_append_int_noprefix(table_data, 3, 1); /* Type */ + build_append_int_noprefix(table_data, 18, 1); /* Length */ + build_append_int_noprefix(table_data, nodeid, 4); /* Proximity Dom= ain */ + build_append_int_noprefix(table_data, i, 4); /* ACPI Processor UID= */ + /* Flags, Table 5-76 */ + build_append_int_noprefix(table_data, 1 /* Enabled */, 4); + build_append_int_noprefix(table_data, 0, 4); /* Clock Domain */ } =20 mem_base =3D vms->memmap[VIRT_MEM].base; for (i =3D 0; i < ms->numa_state->num_nodes; ++i) { if (ms->numa_state->nodes[i].node_mem > 0) { - numamem =3D acpi_data_push(table_data, sizeof(*numamem)); - build_srat_memory(numamem, mem_base, + build_srat_memory(table_data, mem_base, ms->numa_state->nodes[i].node_mem, i, MEM_AFFINITY_ENABLED); mem_base +=3D ms->numa_state->nodes[i].node_mem; @@ -516,8 +522,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) } =20 if (ms->device_memory) { - numamem =3D acpi_data_push(table_data, sizeof *numamem); - build_srat_memory(numamem, ms->device_memory->base, + build_srat_memory(table_data, ms->device_memory->base, memory_region_size(&ms->device_memory->mr), ms->numa_state->num_nodes - 1, MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED= ); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 1ce808c576..078097a060 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1939,13 +1939,15 @@ build_tpm_tcpa(GArray *table_data, BIOSLinker *link= er, GArray *tcpalog, #define HOLE_640K_START (640 * KiB) #define HOLE_640K_END (1 * MiB) =20 +/* + * ACPI spec, Revision 3.0 + * 5.2.15 System Resource Affinity Table (SRAT) + */ static void build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) { - AcpiSratMemoryAffinity *numamem; - int i; - int numa_start, slots; + int numa_mem_start, slots; uint64_t mem_len, mem_base, next_base; MachineClass *mc =3D MACHINE_GET_CLASS(machine); X86MachineState *x86ms =3D X86_MACHINE(machine); @@ -1968,34 +1970,41 @@ build_srat(GArray *table_data, BIOSLinker *linker, = MachineState *machine) uint32_t apic_id =3D apic_ids->cpus[i].arch_id; =20 if (apic_id < 255) { - AcpiSratProcessorAffinity *core; - - core =3D acpi_data_push(table_data, sizeof *core); - core->type =3D ACPI_SRAT_PROCESSOR_APIC; - core->length =3D sizeof(*core); - core->local_apic_id =3D apic_id; - core->proximity_lo =3D node_id; - memset(core->proximity_hi, 0, 3); - core->local_sapic_eid =3D 0; - core->flags =3D cpu_to_le32(1); + /* 5.2.15.1 Processor Local APIC/SAPIC Affinity Structure */ + build_append_int_noprefix(table_data, 0, 1); /* Type */ + build_append_int_noprefix(table_data, 16, 1); /* Length */ + /* Proximity Domain [7:0] */ + build_append_int_noprefix(table_data, node_id, 1); + build_append_int_noprefix(table_data, apic_id, 1); /* APIC ID = */ + /* Flags, Table 5-36 */ + build_append_int_noprefix(table_data, 1, 4); + build_append_int_noprefix(table_data, 0, 1); /* Local SAPIC EI= D */ + /* Proximity Domain [31:8] */ + build_append_int_noprefix(table_data, 0, 3); + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ } else { - AcpiSratProcessorX2ApicAffinity *core; - - core =3D acpi_data_push(table_data, sizeof *core); - core->type =3D ACPI_SRAT_PROCESSOR_x2APIC; - core->length =3D sizeof(*core); - core->x2apic_id =3D cpu_to_le32(apic_id); - core->proximity_domain =3D cpu_to_le32(node_id); - core->flags =3D cpu_to_le32(1); + /* + * ACPI spec, Revision 4.0 + * 5.2.16.3 Processor Local x2APIC Affinity Structure + */ + build_append_int_noprefix(table_data, 2, 1); /* Type */ + build_append_int_noprefix(table_data, 24, 1); /* Length */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + /* Proximity Domain */ + build_append_int_noprefix(table_data, node_id, 4); + build_append_int_noprefix(table_data, apic_id, 4); /* X2APIC I= D */ + /* Flags, Table 5-39 */ + build_append_int_noprefix(table_data, 1 /* Enabled */, 4); + build_append_int_noprefix(table_data, 0, 4); /* Clock Domain */ + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ } } =20 - /* the memory map is a bit tricky, it contains at least one hole * from 640k-1M and possibly another one from 3.5G-4G. */ next_base =3D 0; - numa_start =3D table_data->len; + numa_mem_start =3D table_data->len; =20 for (i =3D 1; i < nb_numa_nodes + 1; ++i) { mem_base =3D next_base; @@ -2007,8 +2016,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) next_base > HOLE_640K_START) { mem_len -=3D next_base - HOLE_640K_START; if (mem_len > 0) { - numamem =3D acpi_data_push(table_data, sizeof *numamem); - build_srat_memory(numamem, mem_base, mem_len, i - 1, + build_srat_memory(table_data, mem_base, mem_len, i - 1, MEM_AFFINITY_ENABLED); } =20 @@ -2026,8 +2034,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) next_base > x86ms->below_4g_mem_size) { mem_len -=3D next_base - x86ms->below_4g_mem_size; if (mem_len > 0) { - numamem =3D acpi_data_push(table_data, sizeof *numamem); - build_srat_memory(numamem, mem_base, mem_len, i - 1, + build_srat_memory(table_data, mem_base, mem_len, i - 1, MEM_AFFINITY_ENABLED); } mem_base =3D 1ULL << 32; @@ -2036,8 +2043,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) } =20 if (mem_len > 0) { - numamem =3D acpi_data_push(table_data, sizeof *numamem); - build_srat_memory(numamem, mem_base, mem_len, i - 1, + build_srat_memory(table_data, mem_base, mem_len, i - 1, MEM_AFFINITY_ENABLED); } } @@ -2046,10 +2052,15 @@ build_srat(GArray *table_data, BIOSLinker *linker, = MachineState *machine) nvdimm_build_srat(table_data); } =20 - slots =3D (table_data->len - numa_start) / sizeof *numamem; + /* + * TODO: this part is not in ACPI spec and current linux kernel boots = fine + * without these entries. But I recall there were issues the last time= I + * tried to remove it with some ancient guest OS, however I can't reme= mber + * what that was so keep this around for now + */ + slots =3D (table_data->len - numa_mem_start) / 40 /* mem affinity len = */; for (; slots < nb_numa_nodes + 2; slots++) { - numamem =3D acpi_data_push(table_data, sizeof *numamem); - build_srat_memory(numamem, 0, 0, 0, MEM_AFFINITY_NOFLAGS); + build_srat_memory(table_data, 0, 0, 0, MEM_AFFINITY_NOFLAGS); } =20 /* @@ -2061,8 +2072,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) * providing _PXM method if necessary. */ if (hotpluggable_address_space_size) { - numamem =3D acpi_data_push(table_data, sizeof *numamem); - build_srat_memory(numamem, machine->device_memory->base, + build_srat_memory(table_data, machine->device_memory->base, hotpluggable_address_space_size, nb_numa_nodes -= 1, MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED= ); } --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633452695711400.9786703554564; Tue, 5 Oct 2021 09:51:35 -0700 (PDT) Received: from localhost ([::1]:44298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnfC-00013q-Kb for importer@patchew.org; Tue, 05 Oct 2021 12:51:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmuU-0001cp-DA for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40784) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmuS-0006LV-6W for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:18 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-505-t-xw3kU6NnehyYYEcBCdaA-1; Tue, 05 Oct 2021 12:03:14 -0400 Received: by mail-wm1-f69.google.com with SMTP id x23-20020a05600c21d700b0030d23749278so1502644wmj.2 for ; Tue, 05 Oct 2021 09:03:14 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id w5sm17949753wrq.86.2021.10.05.09.03.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449795; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hLUEbIzvV2N7lkZsbc8CHTUdFKm2dW0+2UECt7Ns1Mg=; b=IvRFn+ab2w7QhgOwOOYQ3BU3wTCTqQKB9LFuPSfopXE4QoYCz3uzG06jDcd+SfU26LaInx LwOoMkz40Wp1lJTTXBH4uwNbr+BXuwk/9CKZuvGB01amFOfUoT+muXZoANgn4kdS0m1chN OLfbOb8VrNfDFGhb3cBR0fMlLrN6MqY= X-MC-Unique: t-xw3kU6NnehyYYEcBCdaA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=hLUEbIzvV2N7lkZsbc8CHTUdFKm2dW0+2UECt7Ns1Mg=; b=W5JayEaQFAhf2BX4vFHI9bi3By8kX+xN7moJ46sx0j3j1CHlWTw+LpvHfUGytmfSze P/FfVc7AyZEhMX88pYeecjFL0TvPexTRXKOwdvjVgvqilTxvLrWKCskp54mfIm1CWrxW 8bfeeWqoTmwiL+0ISlY4lhbM+CyBmwoGR7hi3+7BMaeXohvHbrYtEKQIrMV0FUZHnP7h MHmigmJy02xvBAsEgzFk0/CRCCy6eDxuRu/h5mCeu8Qm60VkBNOf54eWJfriMCP+AJE1 E+o2sA1pk2wi+VdfcF5f6fYdYJrThAQyDxNF929A++zahI6QA96ek9rKg4RuYIWXP/0k l5Yw== X-Gm-Message-State: AOAM531MueIJkVlHFuIrln0D6x2S+HkvoZ81IehWlxfGGwCOGNWnG4Zj bIkI9knYILLvNXtN//sYKaVqTA6+oGlIuCEas0pfrxKQrlHaUnRPMpEBldlmSg4fgfQBRswYPvv o7jt6x/wqjLM+N32ztN6vEYTtCnLJeICE3AQJ8rZNPGGwiOaACwgZlqgBe7Re X-Received: by 2002:a1c:ac03:: with SMTP id v3mr4304856wme.13.1633449791606; Tue, 05 Oct 2021 09:03:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5bB2qWqsinJXb5hSwh/qRQe85pV2uTw86JRI+TVr5jDKueiWM0ppy8BE0Q1Z40eICCqY07g== X-Received: by 2002:a1c:ac03:: with SMTP id v3mr4304590wme.13.1633449789282; Tue, 05 Oct 2021 09:03:09 -0700 (PDT) Date: Tue, 5 Oct 2021 12:03:02 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 32/57] acpi: build_dmar_q35: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-33-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , Eric Auger , Igor Mammedov , Ani Sinha , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452697867100001 From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. While at it switch to build_append_int_noprefix() to build table entries tables. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-19-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 68 ----------------------------- hw/i386/acpi-build.c | 85 ++++++++++++++++++++----------------- 2 files changed, 47 insertions(+), 106 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index d293304f9c..c4f0a202e8 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -358,74 +358,6 @@ struct AcpiGenericTimerTable { } QEMU_PACKED; typedef struct AcpiGenericTimerTable AcpiGenericTimerTable; =20 -/* DMAR - DMA Remapping table r2.2 */ -struct AcpiTableDmar { - ACPI_TABLE_HEADER_DEF - uint8_t host_address_width; /* Maximum DMA physical addressability */ - uint8_t flags; - uint8_t reserved[10]; -} QEMU_PACKED; -typedef struct AcpiTableDmar AcpiTableDmar; - -/* Masks for Flags field above */ -#define ACPI_DMAR_INTR_REMAP 1 -#define ACPI_DMAR_X2APIC_OPT_OUT (1 << 1) - -/* Values for sub-structure type for DMAR */ -enum { - ACPI_DMAR_TYPE_HARDWARE_UNIT =3D 0, /* DRHD */ - ACPI_DMAR_TYPE_RESERVED_MEMORY =3D 1, /* RMRR */ - ACPI_DMAR_TYPE_ATSR =3D 2, /* ATSR */ - ACPI_DMAR_TYPE_HARDWARE_AFFINITY =3D 3, /* RHSR */ - ACPI_DMAR_TYPE_ANDD =3D 4, /* ANDD */ - ACPI_DMAR_TYPE_RESERVED =3D 5 /* Reserved for furture use = */ -}; - -/* - * Sub-structures for DMAR - */ - -/* Device scope structure for DRHD. */ -struct AcpiDmarDeviceScope { - uint8_t entry_type; - uint8_t length; - uint16_t reserved; - uint8_t enumeration_id; - uint8_t bus; - struct { - uint8_t device; - uint8_t function; - } path[]; -} QEMU_PACKED; -typedef struct AcpiDmarDeviceScope AcpiDmarDeviceScope; - -/* Type 0: Hardware Unit Definition */ -struct AcpiDmarHardwareUnit { - uint16_t type; - uint16_t length; - uint8_t flags; - uint8_t reserved; - uint16_t pci_segment; /* The PCI Segment associated with this unit */ - uint64_t address; /* Base address of remapping hardware register-set= */ - AcpiDmarDeviceScope scope[]; -} QEMU_PACKED; -typedef struct AcpiDmarHardwareUnit AcpiDmarHardwareUnit; - -/* Type 2: Root Port ATS Capability Reporting Structure */ -struct AcpiDmarRootPortATS { - uint16_t type; - uint16_t length; - uint8_t flags; - uint8_t reserved; - uint16_t pci_segment; - AcpiDmarDeviceScope scope[]; -} QEMU_PACKED; -typedef struct AcpiDmarRootPortATS AcpiDmarRootPortATS; - -/* Masks for Flags field above */ -#define ACPI_DMAR_INCLUDE_PCI_ALL 1 -#define ACPI_DMAR_ATSR_ALL_PORTS 1 - /* * Input Output Remapping Table (IORT) * Conforms to "IO Remapping Table System Software on ARM Platforms", diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 078097a060..c65ab1d6a5 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2086,8 +2086,9 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) static void insert_scope(PCIBus *bus, PCIDevice *dev, void *opaque) { + const size_t device_scope_size =3D 6 /* device scope structure */ + + 2 /* 1 path entry */; GArray *scope_blob =3D opaque; - AcpiDmarDeviceScope *scope =3D NULL; =20 if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_BRIDGE)) { /* Dmar Scope Type: 0x02 for PCI Bridge */ @@ -2098,8 +2099,7 @@ insert_scope(PCIBus *bus, PCIDevice *dev, void *opaqu= e) } =20 /* length */ - build_append_int_noprefix(scope_blob, - sizeof(*scope) + sizeof(scope->path[0]), 1); + build_append_int_noprefix(scope_blob, device_scope_size, 1); /* reserved */ build_append_int_noprefix(scope_blob, 0, 2); /* enumeration_id */ @@ -2131,26 +2131,26 @@ dmar_host_bridges(Object *obj, void *opaque) } =20 /* - * VT-d spec 8.1 DMA Remapping Reporting Structure - * (version Oct. 2014 or later) + * Intel =C2=AE Virtualization Technology for Directed I/O + * Architecture Specification. Revision 3.3 + * 8.1 DMA Remapping Reporting Structure */ static void build_dmar_q35(GArray *table_data, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) { - int dmar_start =3D table_data->len; - - AcpiTableDmar *dmar; - AcpiDmarHardwareUnit *drhd; - AcpiDmarRootPortATS *atsr; uint8_t dmar_flags =3D 0; + uint8_t rsvd10[10] =3D {}; + /* Root complex IOAPIC uses one path only */ + const size_t ioapic_scope_size =3D 6 /* device scope structure */ + + 2 /* 1 path entry */; X86IOMMUState *iommu =3D x86_iommu_get_default(); - AcpiDmarDeviceScope *scope =3D NULL; - /* Root complex IOAPIC use one path[0] only */ - size_t ioapic_scope_size =3D sizeof(*scope) + sizeof(scope->path[0]); IntelIOMMUState *intel_iommu =3D INTEL_IOMMU_DEVICE(iommu); GArray *scope_blob =3D g_array_new(false, true, 1); =20 + AcpiTable table =3D { .sig =3D "DMAR", .rev =3D 1, .oem_id =3D oem_id, + .oem_table_id =3D oem_table_id }; + /* * A PCI bus walk, for each PCI host bridge. * Insert scope for each PCI bridge and endpoint device which @@ -2164,43 +2164,52 @@ build_dmar_q35(GArray *table_data, BIOSLinker *link= er, const char *oem_id, dmar_flags |=3D 0x1; /* Flags: 0x1: INT_REMAP */ } =20 - dmar =3D acpi_data_push(table_data, sizeof(*dmar)); - dmar->host_address_width =3D intel_iommu->aw_bits - 1; - dmar->flags =3D dmar_flags; + acpi_table_begin(&table, table_data); + /* Host Address Width */ + build_append_int_noprefix(table_data, intel_iommu->aw_bits - 1, 1); + build_append_int_noprefix(table_data, dmar_flags, 1); /* Flags */ + g_array_append_vals(table_data, rsvd10, sizeof(rsvd10)); /* Reserved */ =20 - /* DMAR Remapping Hardware Unit Definition structure */ - drhd =3D acpi_data_push(table_data, sizeof(*drhd) + ioapic_scope_size); - drhd->type =3D cpu_to_le16(ACPI_DMAR_TYPE_HARDWARE_UNIT); - drhd->length =3D - cpu_to_le16(sizeof(*drhd) + ioapic_scope_size + scope_blob->len); - drhd->flags =3D 0; /* Don't include all pci device */ - drhd->pci_segment =3D cpu_to_le16(0); - drhd->address =3D cpu_to_le64(Q35_HOST_BRIDGE_IOMMU_ADDR); + /* 8.3 DMAR Remapping Hardware Unit Definition structure */ + build_append_int_noprefix(table_data, 0, 2); /* Type */ + /* Length */ + build_append_int_noprefix(table_data, + 16 + ioapic_scope_size + scope_blob->len, 2); + /* Flags */ + build_append_int_noprefix(table_data, 0 /* Don't include all pci devic= e */ , + 1); + build_append_int_noprefix(table_data, 0 , 1); /* Reserved */ + build_append_int_noprefix(table_data, 0 , 2); /* Segment Number */ + /* Register Base Address */ + build_append_int_noprefix(table_data, Q35_HOST_BRIDGE_IOMMU_ADDR , 8); =20 /* Scope definition for the root-complex IOAPIC. See VT-d spec * 8.3.1 (version Oct. 2014 or later). */ - scope =3D &drhd->scope[0]; - scope->entry_type =3D 0x03; /* Type: 0x03 for IOAPIC */ - scope->length =3D ioapic_scope_size; - scope->enumeration_id =3D ACPI_BUILD_IOAPIC_ID; - scope->bus =3D Q35_PSEUDO_BUS_PLATFORM; - scope->path[0].device =3D PCI_SLOT(Q35_PSEUDO_DEVFN_IOAPIC); - scope->path[0].function =3D PCI_FUNC(Q35_PSEUDO_DEVFN_IOAPIC); + build_append_int_noprefix(table_data, 0x03 /* IOAPIC */, 1); /* Type */ + build_append_int_noprefix(table_data, ioapic_scope_size, 1); /* Length= */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + /* Enumeration ID */ + build_append_int_noprefix(table_data, ACPI_BUILD_IOAPIC_ID, 1); + /* Start Bus Number */ + build_append_int_noprefix(table_data, Q35_PSEUDO_BUS_PLATFORM, 1); + /* Path, {Device, Function} pair */ + build_append_int_noprefix(table_data, PCI_SLOT(Q35_PSEUDO_DEVFN_IOAPIC= ), 1); + build_append_int_noprefix(table_data, PCI_FUNC(Q35_PSEUDO_DEVFN_IOAPIC= ), 1); =20 /* Add scope found above */ g_array_append_vals(table_data, scope_blob->data, scope_blob->len); g_array_free(scope_blob, true); =20 if (iommu->dt_supported) { - atsr =3D acpi_data_push(table_data, sizeof(*atsr)); - atsr->type =3D cpu_to_le16(ACPI_DMAR_TYPE_ATSR); - atsr->length =3D cpu_to_le16(sizeof(*atsr)); - atsr->flags =3D ACPI_DMAR_ATSR_ALL_PORTS; - atsr->pci_segment =3D cpu_to_le16(0); + /* 8.5 Root Port ATS Capability Reporting Structure */ + build_append_int_noprefix(table_data, 2, 2); /* Type */ + build_append_int_noprefix(table_data, 8, 2); /* Length */ + build_append_int_noprefix(table_data, 1 /* ALL_PORTS */, 1); /* Fl= ags */ + build_append_int_noprefix(table_data, 0, 1); /* Reserved */ + build_append_int_noprefix(table_data, 0, 2); /* Segment Number */ } =20 - build_header(linker, table_data, (void *)(table_data->data + dmar_star= t), - "DMAR", table_data->len - dmar_start, 1, oem_id, oem_tabl= e_id); + acpi_table_end(linker, &table); } =20 /* --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633455603554115.57775339439854; Tue, 5 Oct 2021 10:40:03 -0700 (PDT) Received: from localhost ([::1]:45306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXoPx-0004Fq-Rv for importer@patchew.org; Tue, 05 Oct 2021 13:39:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmxP-0003EB-Di for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:06:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45029) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmxM-0000R1-PB for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:06:19 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-125-24VR8nCIOcu5QxRS_PWtEA-1; Tue, 05 Oct 2021 12:03:17 -0400 Received: by mail-wr1-f70.google.com with SMTP id f11-20020adfc98b000000b0015fedc2a8d4so5923848wrh.0 for ; Tue, 05 Oct 2021 09:03:17 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id q16sm1203776wrw.23.2021.10.05.09.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:03:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hV6lu5dUHVTxYU1SPD7OKPspvEIPuBQVzBTSIWyD7ms=; b=TCxSYoaFI3w3a5T6ASalKAz7NZTmLGvDhOKgEn312pZVg740hhjQlf/8G6cQgnpfaSn8aw EO62aTPn7ZeVkGbO/72IgUqWVieUsqHIMAGQ68MCdvsKCOyDPYVwJOnEihxG57u6yVZtwG kbf+lXMDk4+d/7tNIkoAsA7xKK6JMnk= X-MC-Unique: 24VR8nCIOcu5QxRS_PWtEA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=hV6lu5dUHVTxYU1SPD7OKPspvEIPuBQVzBTSIWyD7ms=; b=skPOQCK9puD/mBquSLM095GospzlNo77Ovtk8cOmWi63tKwhNbu7f07ltozPvIN/IV Y3fbA8xaS9XpMqiAFkRuECBog1ptvA9+9NEI3QY8N0TICSniIZsIMuTDtJhc/xKJsFVF z1x6fGEe4xhny662BE/QTd2KtmBmf6yyW1YJVC5X7414mAGHyMjVUHQ+GfivfxqlGp+0 bL5WbUJQpUjC4bl9nTaRVGaDlSAeonnvRz3sLuzwKalXi2abXmltjEosTVsZYxYFaj5M ZlkUAmYmkaATUzNb9kxCUUn4qSAZzVUnirIRbceZnly7QlLtzCokKYGvHYdGGjc4Puz7 g9CQ== X-Gm-Message-State: AOAM530FXs4bz+bGG9zgr/FPRdK29lsfgqAd7Y2Hm0csiDVkCehVFeCc JcETsQQaX/rK/nldlcnKRadBd5SnUz3YM4DhmWXpZLIHEzBruxDxBNdU7c1g3Ue1uidDZbYhHZE /OMuHMQHHiPbRtkL5My6Se+vb5n7DaMtfLPJX3YGRuy2OKbM1XD9S2aWSlvtL X-Received: by 2002:adf:e390:: with SMTP id e16mr22441727wrm.217.1633449796254; Tue, 05 Oct 2021 09:03:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZ3PidJ0X2LhA0U7ZTNA+ZWRzD2b1V8hX7MaLr4VweNOU039M9rcY+D5X88peXJtFrM0tt8A== X-Received: by 2002:adf:e390:: with SMTP id e16mr22441678wrm.217.1633449795969; Tue, 05 Oct 2021 09:03:15 -0700 (PDT) Date: Tue, 5 Oct 2021 12:03:10 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 33/57] acpi: build_waet: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-34-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , Eric Auger , Igor Mammedov , Ani Sinha , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633455604391100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-20-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index c65ab1d6a5..e5cc4f7daa 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2223,10 +2223,10 @@ static void build_waet(GArray *table_data, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) { - int waet_start =3D table_data->len; + AcpiTable table =3D { .sig =3D "WAET", .rev =3D 1, .oem_id =3D oem_id, + .oem_table_id =3D oem_table_id }; =20 - /* WAET header */ - acpi_data_push(table_data, sizeof(AcpiTableHeader)); + acpi_table_begin(&table, table_data); /* * Set "ACPI PM timer good" flag. * @@ -2235,9 +2235,7 @@ build_waet(GArray *table_data, BIOSLinker *linker, co= nst char *oem_id, * Which avoids costly VMExits caused by guest re-reading it unnecessa= rily. */ build_append_int_noprefix(table_data, 1 << 1 /* ACPI PM timer good */,= 4); - - build_header(linker, table_data, (void *)(table_data->data + waet_star= t), - "WAET", table_data->len - waet_start, 1, oem_id, oem_tabl= e_id); + acpi_table_end(linker, &table); } =20 /* --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633452869967420.10186270158215; Tue, 5 Oct 2021 09:54:29 -0700 (PDT) Received: from localhost ([::1]:52708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXni0-0006fR-RS for importer@patchew.org; Tue, 05 Oct 2021 12:54:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmui-0001i2-7e for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41510) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmug-0006Z9-8n for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:31 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-561-7HL3FJaxOEK_MlcJLiAUOw-1; Tue, 05 Oct 2021 12:03:27 -0400 Received: by mail-wm1-f72.google.com with SMTP id x3-20020a05600c21c300b0030d2b0fb3b4so7772285wmj.5 for ; Tue, 05 Oct 2021 09:03:27 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id c204sm2455716wme.11.2021.10.05.09.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PTZ0QEKaqIGauDOtftBKPDb8LmMe7stdH5L6Fe5udyY=; b=a2Gf9+rpHUGuHMVPETTjJpvhRVlXVR1dR8RAAod/LoSo7i3WKxJbAHzbpCIQ8Q0ckU5kir zV9/OCWpKe6RtDVtDwaZNHj+UhABrfujBY7JBoggQlPZaBPKVrXbJxF+UL9FuW3A9KAOeU bS7yzeUkSHmuO3bEhXTs9Yo1CU/0vs4= X-MC-Unique: 7HL3FJaxOEK_MlcJLiAUOw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PTZ0QEKaqIGauDOtftBKPDb8LmMe7stdH5L6Fe5udyY=; b=GFeCBGIpcsTsq4jBcT4ltjkssms+OR7q5onBtsutUMJ/f0Lu83UDpNiKhMydF4uLSn 2wc/Vfu1LFuZ3mwkEJxadUHIQhAg5/rewqgH2ua0U5KuTsm7w+oz1t1JLJA/RCdaxSog yYpVBt8winwR6+dhtAa5UZOK5N4Za2dnzeAbsTS1zt5adv3wG1EgKHCPqINs2eZOZ0y5 54LcDhVnDFiA5l7lny23/49skqp8c4dZAKxYctrmojZEw0c1u0RyzoMujofDADrtRFCi G2LgT9v0aC2cAXr/OvFhdt3L0BHemsTSuFxjrK0efxUR/Ynq/dW/r/XdCXVi9qFmALBW zkPg== X-Gm-Message-State: AOAM530xjxYI/Uut9KVLJhnbciX+tFEtx0ndD4ceIaf5THlYd8lkh303 59dJaSHX4YjQLt/kanHG4W+Vp99Wy4qt+WBUF1tdhaueTDuS09CEz9I+kNb5a1JpZmKPjVFKc6z e9BKYwO+lX4lVqMd8o3z36QVmBGyhRf7Lf1yWPTo8VGB9GXR71FcIOxHKWq7v X-Received: by 2002:adf:9b91:: with SMTP id d17mr16923541wrc.131.1633449804079; Tue, 05 Oct 2021 09:03:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypHUfhAE7VxUcSbesdFU3JJjdD0Ibk884neWAmTOpYmuORA6tSJYzmAXmexg9eI4OXJoA23Q== X-Received: by 2002:adf:9b91:: with SMTP id d17mr16923340wrc.131.1633449802612; Tue, 05 Oct 2021 09:03:22 -0700 (PDT) Date: Tue, 5 Oct 2021 12:03:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 34/57] acpi: build_amd_iommu: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-35-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , Eric Auger , Igor Mammedov , Ani Sinha , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452870349100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-21-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index e5cc4f7daa..d9e2b5dc30 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2341,12 +2341,12 @@ build_amd_iommu(GArray *table_data, BIOSLinker *lin= ker, const char *oem_id, const char *oem_table_id) { int ivhd_table_len =3D 24; - int iommu_start =3D table_data->len; AMDVIState *s =3D AMD_IOMMU_DEVICE(x86_iommu_get_default()); GArray *ivhd_blob =3D g_array_new(false, true, 1); + AcpiTable table =3D { .sig =3D "IVRS", .rev =3D 1, .oem_id =3D oem_id, + .oem_table_id =3D oem_table_id }; =20 - /* IVRS header */ - acpi_data_push(table_data, sizeof(AcpiTableHeader)); + acpi_table_begin(&table, table_data); /* IVinfo - IO virtualization information common to all * IOMMU units in a system */ @@ -2431,10 +2431,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *link= er, const char *oem_id, 0x48, /* special dev= ice */ 8); } - - build_header(linker, table_data, (void *)(table_data->data + iommu_sta= rt), - "IVRS", table_data->len - iommu_start, 1, oem_id, - oem_table_id); + acpi_table_end(linker, &table); } =20 typedef --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633453088969669.4059226127275; Tue, 5 Oct 2021 09:58:08 -0700 (PDT) Received: from localhost ([::1]:33136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnlY-00045H-0X for importer@patchew.org; Tue, 05 Oct 2021 12:58:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmux-0001yR-OE for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47888) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmui-0006cO-Mv for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:46 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-366-5rhBfpNiOjq95gHkS2vN1A-1; Tue, 05 Oct 2021 12:03:30 -0400 Received: by mail-wm1-f70.google.com with SMTP id 3-20020a05600c22c300b0030d6a6a28f8so1218578wmg.5 for ; Tue, 05 Oct 2021 09:03:30 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id l16sm2502701wmj.33.2021.10.05.09.03.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IJsGrjG7v7nwRM18b6PA9SOYSO3Rcoy2CdAVeRcpvfA=; b=YClobf1i2mh1f1937xQzCrHzMVhUkGVqOmQJbL78IoET3LOc2aj/HSHUpLHhfSy4t0PjS+ DUvpcYNpR9EDLnyvMJmicv3A0Zg9Q18+KEEYWGYbsBNJpgBLSP1HKZ7EmFFLNxSB+hkf6C HkdhQVGboLLKTIDk7FS1jEDP4IAwt8Y= X-MC-Unique: 5rhBfpNiOjq95gHkS2vN1A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=IJsGrjG7v7nwRM18b6PA9SOYSO3Rcoy2CdAVeRcpvfA=; b=4ssrNvEN57hiKIQzPiiZ770VR/VaImSgTJPsY/+568LI/UJVSckDnz7HZVPicGL1dC m3ywqOzpuf1CCNlvkNMtqo3LLBqP/AwDPbblQ8cYw8wWUOAEhRfKWlYzCeTd64092Ao1 eL9eGTD1admeIOuksyMkl5o1OwSXHAVWcpArzJO5tMS5CmppIllOJBCj/K1wRjQspnZg d4FtZTXO/9KccaM996ZiKPUn2QebNzC0KTabltfMTDMksQPiIUb+1SF3shzTFiPxsuTL hFdNjVpjUYkJGBNpjoCh/igNl50HsMbyuAqUhHLcbNwMdQGTCHN20ISVO3CvZImKi7B0 853w== X-Gm-Message-State: AOAM532NCeA4zfX9COfS8C+gmQDGkWBcJBClb4sHFt0ZQn0gqF28Vhz9 miehMKdznYvsWvUZkBPIAwgS22nhwi5m0XXQDn8XSOjjVVfpjZX/0J5juZPWpNjQlZxmA5QHyXU ElMUiGPPZpNTnwESvQX3PIhjXlZotRUNacicS3KsWwM4/D+KqNeECDu1oXceB X-Received: by 2002:a05:6000:1885:: with SMTP id a5mr4268779wri.64.1633449808586; Tue, 05 Oct 2021 09:03:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZd9+AfV/NDIjRawoYdtaXgs2c6oLnfJ+aWdNNCuajUgJ7yARLj5Vk8+uouB+BxpIjVAJDSQ== X-Received: by 2002:a05:6000:1885:: with SMTP id a5mr4268720wri.64.1633449808303; Tue, 05 Oct 2021 09:03:28 -0700 (PDT) Date: Tue, 5 Oct 2021 12:03:23 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 35/57] acpi: madt: arm/x86: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-36-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Eric Auger , Richard Henderson , Shannon Zhao , qemu-arm@nongnu.org, Igor Mammedov , Ani Sinha , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633453090349100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-22-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 9 --------- hw/arm/virt-acpi-build.c | 19 +++++++++++-------- hw/i386/acpi-common.c | 19 +++++++++++-------- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index c4f0a202e8..c7fa5caa06 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -176,15 +176,6 @@ typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescript= orRev1; #define ACPI_DUAL_PIC 0 #define ACPI_MULTIPLE_APIC 1 =20 -/* Master MADT */ - -struct AcpiMultipleApicTable { - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint32_t local_apic_address; /* Physical address of local APIC */ - uint32_t flags; -} QEMU_PACKED; -typedef struct AcpiMultipleApicTable AcpiMultipleApicTable; - /* Values for Type in APIC sub-headers */ =20 #define ACPI_APIC_PROCESSOR 0 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 6ba02cf281..e3bdcd44e8 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -567,19 +567,26 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) vms->oem_table_id); } =20 -/* MADT */ +/* + * ACPI spec, Revision 5.0 + * 5.2.12 Multiple APIC Description Table (MADT) + */ static void build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); - int madt_start =3D table_data->len; const MemMapEntry *memmap =3D vms->memmap; const int *irqmap =3D vms->irqmap; AcpiMadtGenericDistributor *gicd; AcpiMadtGenericMsiFrame *gic_msi; int i; + AcpiTable table =3D { .sig =3D "APIC", .rev =3D 3, .oem_id =3D vms->oe= m_id, + .oem_table_id =3D vms->oem_table_id }; =20 - acpi_data_push(table_data, sizeof(AcpiMultipleApicTable)); + acpi_table_begin(&table, table_data); + /* Local Interrupt Controller Address */ + build_append_int_noprefix(table_data, 0, 4); + build_append_int_noprefix(table_data, 0, 4); /* Flags */ =20 gicd =3D acpi_data_push(table_data, sizeof *gicd); gicd->type =3D ACPI_APIC_GENERIC_DISTRIBUTOR; @@ -650,11 +657,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, Vir= tMachineState *vms) gic_msi->spi_count =3D cpu_to_le16(NUM_GICV2M_SPIS); gic_msi->spi_base =3D cpu_to_le16(irqmap[VIRT_GIC_V2M] + ARM_SPI_B= ASE); } - - build_header(linker, table_data, - (void *)(table_data->data + madt_start), "APIC", - table_data->len - madt_start, 3, vms->oem_id, - vms->oem_table_id); + acpi_table_end(linker, &table); } =20 /* FADT */ diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c index 1f5947fcf9..a0cde1d874 100644 --- a/hw/i386/acpi-common.c +++ b/hw/i386/acpi-common.c @@ -71,24 +71,29 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, } } =20 +/* + * ACPI spec, Revision 1.0b + * 5.2.8 Multiple APIC Description Table + */ void acpi_build_madt(GArray *table_data, BIOSLinker *linker, X86MachineState *x86ms, AcpiDeviceIf *adev, const char *oem_id, const char *oem_table_id) { MachineClass *mc =3D MACHINE_GET_CLASS(x86ms); const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(MACHINE(x8= 6ms)); - int madt_start =3D table_data->len; AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_GET_CLASS(adev); bool x2apic_mode =3D false; =20 - AcpiMultipleApicTable *madt; AcpiMadtIoApic *io_apic; AcpiMadtIntsrcovr *intsrcovr; int i; + AcpiTable table =3D { .sig =3D "APIC", .rev =3D 1, .oem_id =3D oem_id, + .oem_table_id =3D oem_table_id }; =20 - madt =3D acpi_data_push(table_data, sizeof *madt); - madt->local_apic_address =3D cpu_to_le32(APIC_DEFAULT_ADDRESS); - madt->flags =3D cpu_to_le32(1); + acpi_table_begin(&table, table_data); + /* Local APIC Address */ + build_append_int_noprefix(table_data, APIC_DEFAULT_ADDRESS, 4); + build_append_int_noprefix(table_data, 1 /* PCAT_COMPAT */, 4); /* Flag= s */ =20 for (i =3D 0; i < apic_ids->len; i++) { adevc->madt_cpu(adev, i, apic_ids, table_data); @@ -156,8 +161,6 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *li= nker, local_nmi->lint =3D 1; /* ACPI_LINT1 */ } =20 - build_header(linker, table_data, - (void *)(table_data->data + madt_start), "APIC", - table_data->len - madt_start, 1, oem_id, oem_table_id); + acpi_table_end(linker, &table); } =20 --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633452203898422.37032610106223; Tue, 5 Oct 2021 09:43:23 -0700 (PDT) Received: from localhost ([::1]:55272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnXG-0005Ro-IP for importer@patchew.org; Tue, 05 Oct 2021 12:43:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmut-0001oS-9n for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38529) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmul-0006eW-4h for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:43 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-449-0xmcUa5wO9qA63Wao4wXxA-1; Tue, 05 Oct 2021 12:03:33 -0400 Received: by mail-wr1-f70.google.com with SMTP id k2-20020adff5c2000000b00160b12639a5so1699105wrp.3 for ; Tue, 05 Oct 2021 09:03:33 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id s24sm2169566wmh.34.2021.10.05.09.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449814; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iAzL/wufk6tcA8Ix7aJbETc2s1jG6V3MD8hzC48k5Dg=; b=X3hl3V7SiX5jT8tWONHAxinVmwXXVV4PiyBilzocCcjgldNaNfLwzE4/3tQCc1HQRZ9FeH nBhqzCPDbtyplOZFVm0xuM/4EBBqTUKPRUYCPVOzOSPe8iJxHGamsD9Vxttr3aEUW4/OIo hkUBpMtZvEYdh844dFUBm+X58q6hiuc= X-MC-Unique: 0xmcUa5wO9qA63Wao4wXxA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=iAzL/wufk6tcA8Ix7aJbETc2s1jG6V3MD8hzC48k5Dg=; b=ACL2qbbpqZm6C5KnO2KuX8yW2EoNsyKkUCFCOJzpx7su4Rs6hE+AtpgzuPnrbmJKk0 lbi/N/6kRGdlZjw9McuanTJpbBcMIa5DyFbCm56ctw0hRi6UVvuUODdkE2tzBRCxCRx1 41+nYhw7CtvXAgt7JECg73hn5XjXcxhrwEfDezwDoXr+/XK+E6rY3Ho2ijte5BZQA4af zjEexFDj+a40lIH+5fFE1JAnYyxU5ttJhCU1OAnnErDBDfawZIkO5nfT3kUVMyx2yfqT tIgCdBJ2p+S2BKafkEtRgQXcKVa5W/uH/ma5I5zJLiBFe8VyZos41mVmRUdG0fWo/+OH b6qA== X-Gm-Message-State: AOAM532pZdShDdJWLsDH8smLUeTcUwnfEydZgWkqeB8uFTb2NxuBI4J5 DZ7AEbzLz/xleopG+8aqg2/61teHyIVxcWZW1GnvfyLTadpjRZa42Ka5/84zuHcVqd4gMt4Vlnc fhEaidi/4hbT0h9+WolWpzb47z2CkrwvQJ2CYe2rU41mhYqgZaaO0xC26H0Pn X-Received: by 2002:adf:df91:: with SMTP id z17mr11461007wrl.434.1633449811917; Tue, 05 Oct 2021 09:03:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4QxjQWuyC7Zu19s7u18PO86E+Fdzxvw+yvF+6tZ2plajyQlWdLGMoCEeP2SdzAyFzWK8MCg== X-Received: by 2002:adf:df91:: with SMTP id z17mr11460968wrl.434.1633449811659; Tue, 05 Oct 2021 09:03:31 -0700 (PDT) Date: Tue, 5 Oct 2021 12:03:28 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 36/57] acpi: x86: remove dead code Message-ID: <20211005155946.513818-37-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Eric Auger , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452205616100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-23-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index c7fa5caa06..af4fa412a5 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -163,19 +163,6 @@ struct AcpiFacsDescriptorRev1 { } QEMU_PACKED; typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1; =20 -/* - * Differentiated System Description Table (DSDT) - */ - -/* - * MADT values and structures - */ - -/* Values for MADT PCATCompat */ - -#define ACPI_DUAL_PIC 0 -#define ACPI_MULTIPLE_APIC 1 - /* Values for Type in APIC sub-headers */ =20 #define ACPI_APIC_PROCESSOR 0 --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163345201596259.41430788025434; Tue, 5 Oct 2021 09:40:15 -0700 (PDT) Received: from localhost ([::1]:48026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnUE-0000La-Tu for importer@patchew.org; Tue, 05 Oct 2021 12:40:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmuv-0001uJ-2X for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:33340) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmuq-0006iK-51 for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:44 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-49-F-VkFqMrPEaFMupD3Ph6Sw-1; Tue, 05 Oct 2021 12:03:37 -0400 Received: by mail-wr1-f70.google.com with SMTP id m17-20020adffa11000000b00160c1ac74e9so195195wrr.9 for ; Tue, 05 Oct 2021 09:03:37 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id c7sm3145881wmq.13.2021.10.05.09.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449819; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ALs3jGGOQlHPAzn+Qwvy3twsZGp1E3tRIkmyfM0wCks=; b=dGd0Yj03/larKYKKGSlWaExTJpkD3JK63plicfYgrr+liDJpYVXGQIJIK5rWCjnlEddxG3 2JS0lJLLXOownIPSs/b2zYH8sTp19A6emAvycEfLp0Ums/7xfGij6ZVzPD1IgSBUYDMgtW MsLIQSkoqTTRjQo6iFzLXpKSUI99HPc= X-MC-Unique: F-VkFqMrPEaFMupD3Ph6Sw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ALs3jGGOQlHPAzn+Qwvy3twsZGp1E3tRIkmyfM0wCks=; b=qWNd9h5zNyE6ZksRSbdFqO8h0ZWDlca+idTJRCj3UgCPjiRlyBDOaTpIS4NIJSlLls f0DEPx0NMNMTHO9fl7F5yk3Lrea6sxyefkuZ30U9w6aPIhAsY7tfuKbSk02Hfb4Di/1D vB95CTEJbFl1PaNmVh/+D9m/+WyWFWT5n56vGhfPj2MSFkJosLsPk5C7TRfTzQEDE8SQ kDtY60YWV7G4+EcnbYB8YP+lOkz3ZDU5Clt6Gsq9MRGxRNne+oGYdNXzE39H/NItJUch QeuojjB5xuTNL7NaTKkCVh6+aEoWjhmyPz9o3McvLwJ+AiOiJX54mNzqtCNEJHIiAcM7 gx5w== X-Gm-Message-State: AOAM531NILXiHVgLjxt1le7q0Lxpc7ivqkO2099+jRr6MV4CamZdLws0 zcGrxHTJ9IZxpkXcUyQ+PkYlqwA1ePq4unfWBz8X+GKcqAjTLvtP+bM7znMhEQL5QtPMAD/eMgd gdYs3G+rSBZLZGwEENkJwSyBi3cY4riqN1jG+jr2LTeCkPYwl+WOR+bmDavc0 X-Received: by 2002:a05:600c:1553:: with SMTP id f19mr4382213wmg.66.1633449815863; Tue, 05 Oct 2021 09:03:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy28zU+S4Owa4IGmD5UpyyO5TkHmvOeXzUhMyCZjjkOGwqo/TRk1Tn8Abg2/94LEBl7wRcnag== X-Received: by 2002:a05:600c:1553:: with SMTP id f19mr4382162wmg.66.1633449815519; Tue, 05 Oct 2021 09:03:35 -0700 (PDT) Date: Tue, 5 Oct 2021 12:03:31 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 37/57] acpi: x86: set enabled when composing _MAT entries Message-ID: <20211005155946.513818-38-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , Eric Auger , Igor Mammedov , Ani Sinha , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452017569100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Instead of composing disabled _MAT entry and then later on patching it to enabled for hotpluggbale CPUs in DSDT, set it to enabled at the time _MAT entry is built. It will allow to drop usage of packed structures in following patches when build_madt() is switched to use build_append_int_noprefix() API. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-24-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi_dev_interface.h | 3 ++- include/hw/i386/pc.h | 6 +++--- hw/acpi/acpi-x86-stub.c | 3 ++- hw/acpi/cpu.c | 17 ++--------------- hw/i386/acpi-common.c | 18 ++++++------------ 5 files changed, 15 insertions(+), 32 deletions(-) diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_de= v_interface.h index 769ff55c7e..ea6056ab92 100644 --- a/include/hw/acpi/acpi_dev_interface.h +++ b/include/hw/acpi/acpi_dev_interface.h @@ -53,6 +53,7 @@ struct AcpiDeviceIfClass { void (*ospm_status)(AcpiDeviceIf *adev, ACPIOSTInfoList ***list); void (*send_event)(AcpiDeviceIf *adev, AcpiEventStatusBits ev); void (*madt_cpu)(AcpiDeviceIf *adev, int uid, - const CPUArchIdList *apic_ids, GArray *entry); + const CPUArchIdList *apic_ids, GArray *entry, + bool force_enabled); }; #endif diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 5748d7c55f..11426e26dc 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -190,10 +190,10 @@ bool pc_system_ovmf_table_find(const char *entry, uin= t8_t **data, int *data_len); void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size_t flash_size); =20 - -/* acpi-build.c */ +/* hw/i386/acpi-common.c */ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, - const CPUArchIdList *apic_ids, GArray *entry); + const CPUArchIdList *apic_ids, GArray *entry, + bool force_enabled); =20 /* sgx.c */ void pc_machine_init_sgx_epc(PCMachineState *pcms); diff --git a/hw/acpi/acpi-x86-stub.c b/hw/acpi/acpi-x86-stub.c index e9e46c5c5f..3df1e090f4 100644 --- a/hw/acpi/acpi-x86-stub.c +++ b/hw/acpi/acpi-x86-stub.c @@ -3,7 +3,8 @@ #include "hw/i386/acpi-build.h" =20 void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, - const CPUArchIdList *apic_ids, GArray *entry) + const CPUArchIdList *apic_ids, GArray *entry, + bool force_enabled) { } =20 diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index f82e9512fd..b20903ea30 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -669,21 +669,8 @@ void build_cpus_aml(Aml *table, MachineState *machine,= CPUHotplugFeatures opts, =20 /* build _MAT object */ assert(adevc && adevc->madt_cpu); - adevc->madt_cpu(adev, i, arch_ids, madt_buf); - switch (madt_buf->data[0]) { - case ACPI_APIC_PROCESSOR: { - AcpiMadtProcessorApic *apic =3D (void *)madt_buf->data; - apic->flags =3D cpu_to_le32(1); - break; - } - case ACPI_APIC_LOCAL_X2APIC: { - AcpiMadtProcessorX2Apic *apic =3D (void *)madt_buf->data; - apic->flags =3D cpu_to_le32(1); - break; - } - default: - assert(0); - } + adevc->madt_cpu(adev, i, arch_ids, madt_buf, + true); /* set enabled flag */ aml_append(dev, aml_name_decl("_MAT", aml_buffer(madt_buf->len, (uint8_t *)madt_buf->data))); g_array_free(madt_buf, true); diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c index a0cde1d874..7983a13a93 100644 --- a/hw/i386/acpi-common.c +++ b/hw/i386/acpi-common.c @@ -34,9 +34,11 @@ #include "acpi-common.h" =20 void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, - const CPUArchIdList *apic_ids, GArray *entry) + const CPUArchIdList *apic_ids, GArray *entry, + bool force_enabled) { uint32_t apic_id =3D apic_ids->cpus[uid].arch_id; + uint32_t flags =3D apic_ids->cpus[uid].cpu !=3D NULL || force_enabled = ? 1 : 0; =20 /* ACPI spec says that LAPIC entry for non present * CPU may be omitted from MADT or it must be marked @@ -51,11 +53,7 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, apic->length =3D sizeof(*apic); apic->processor_id =3D uid; apic->local_apic_id =3D apic_id; - if (apic_ids->cpus[uid].cpu !=3D NULL) { - apic->flags =3D cpu_to_le32(1); - } else { - apic->flags =3D cpu_to_le32(0); - } + apic->flags =3D cpu_to_le32(flags); } else { AcpiMadtProcessorX2Apic *apic =3D acpi_data_push(entry, sizeof *ap= ic); =20 @@ -63,11 +61,7 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, apic->length =3D sizeof(*apic); apic->uid =3D cpu_to_le32(uid); apic->x2apic_id =3D cpu_to_le32(apic_id); - if (apic_ids->cpus[uid].cpu !=3D NULL) { - apic->flags =3D cpu_to_le32(1); - } else { - apic->flags =3D cpu_to_le32(0); - } + apic->flags =3D cpu_to_le32(flags); } } =20 @@ -96,7 +90,7 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *link= er, build_append_int_noprefix(table_data, 1 /* PCAT_COMPAT */, 4); /* Flag= s */ =20 for (i =3D 0; i < apic_ids->len; i++) { - adevc->madt_cpu(adev, i, apic_ids, table_data); + adevc->madt_cpu(adev, i, apic_ids, table_data, false); if (apic_ids->cpus[i].arch_id > 254) { x2apic_mode =3D true; } --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633452241429695.453402876538; Tue, 5 Oct 2021 09:44:01 -0700 (PDT) Received: from localhost ([::1]:56564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnXq-0006IW-J3 for importer@patchew.org; Tue, 05 Oct 2021 12:44:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmuy-0001zZ-E0 for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31886) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmuw-0006nE-4s for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:48 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247-LJKvgy8RNy-Z3IlcVYiJyA-1; Tue, 05 Oct 2021 12:03:41 -0400 Received: by mail-wm1-f71.google.com with SMTP id x23-20020a05600c21d700b0030d23749278so1503173wmj.2 for ; Tue, 05 Oct 2021 09:03:40 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id o1sm18106059wru.91.2021.10.05.09.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:03:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449825; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jcVjkn40dXJnt0SRinvAbwQ4Tsn9n9c0MB6NMS/GVJc=; b=JYwJM71d03RcUVXLkBSNI/Ex1i97Aia6Km7YVQ4m4H1EbHr49dMFKyAoZpFjb9H59p1oT7 BhMPK94IRyj8s31JiuNfXDiEn4YiY8EJgHIpvBqFdfxDWtRXUT82wowAOwVSUD1Z+G0Q8S k9cNBnzENwM0JfEhHXIETkm09K5L5o4= X-MC-Unique: LJKvgy8RNy-Z3IlcVYiJyA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=jcVjkn40dXJnt0SRinvAbwQ4Tsn9n9c0MB6NMS/GVJc=; b=1nBhRcW2V+KTGyPe2+5NVVx2sgpt42N8hOrRCCnfsYOwRXPor3RJLjorOnJXRQp2uX azQpOHegPENJSkwrfO6pfk6px1VjRuZ/BB77gH5IW46i8H65xsxeAw0Ljp8ZLVAdYCb0 z+KfekzqHHRvGpv3VDrgNWiPtYVmIuv0gIB2axzAwMAZE7AsIru/qTmXRO59ocQJMIFS Kg/1ex/XOsLNc1Lu3ZmjoUx22li61jbJHt+ICTeLNx8fY04MxMkdWt5FIMWJK2RLIX9l 7D5SDaFWpNrWENJCErEXxswHVaM5KWEY1kKsO+IBNLPt32ocn2bEYMvuUDpYKWlYY7Kh PJuw== X-Gm-Message-State: AOAM531hSTBQWc15n+HbLyzAVG04V166bsZjyLdU919Z2G6OcGDC9pzX 1o1WzXJxuz81EenCVU2h6zmN4RZr7jqrs+t154dxrlcuUt2OO99RT9OGPHCwo4hBIHZu8KJQ9VA UjMOiNBYDg2/PhkVoBsPpb78Qdu6yblxa0PhAqnRiVdefWeUWTg1Pz0VRv1o4 X-Received: by 2002:adf:f486:: with SMTP id l6mr21736343wro.375.1633449819371; Tue, 05 Oct 2021 09:03:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQfgXOdNutJDq2MPdBvvcpQ59k8sx6aEI3bDCw90pWoC6/k+BGIgfJgnGDSQ3x2ouYenwYPw== X-Received: by 2002:adf:f486:: with SMTP id l6mr21736297wro.375.1633449819042; Tue, 05 Oct 2021 09:03:39 -0700 (PDT) Date: Tue, 5 Oct 2021 12:03:35 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 38/57] acpi: x86: madt: use build_append_int_noprefix() API to compose MADT table Message-ID: <20211005155946.513818-39-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , Eric Auger , Igor Mammedov , Ani Sinha , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452241993100001 From: Igor Mammedov Drop usage of packed structures and explicit endian conversions when building MADT table for arm/x86 and use endian agnostic build_append_int_noprefix() API to build it. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-25-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 64 ------------------ hw/i386/acpi-common.c | 129 +++++++++++++++++++----------------- 2 files changed, 67 insertions(+), 126 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index af4fa412a5..3f174ba208 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -165,17 +165,6 @@ typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescript= orRev1; =20 /* Values for Type in APIC sub-headers */ =20 -#define ACPI_APIC_PROCESSOR 0 -#define ACPI_APIC_IO 1 -#define ACPI_APIC_XRUPT_OVERRIDE 2 -#define ACPI_APIC_NMI 3 -#define ACPI_APIC_LOCAL_NMI 4 -#define ACPI_APIC_ADDRESS_OVERRIDE 5 -#define ACPI_APIC_IO_SAPIC 6 -#define ACPI_APIC_LOCAL_SAPIC 7 -#define ACPI_APIC_XRUPT_SOURCE 8 -#define ACPI_APIC_LOCAL_X2APIC 9 -#define ACPI_APIC_LOCAL_X2APIC_NMI 10 #define ACPI_APIC_GENERIC_CPU_INTERFACE 11 #define ACPI_APIC_GENERIC_DISTRIBUTOR 12 #define ACPI_APIC_GENERIC_MSI_FRAME 13 @@ -192,59 +181,6 @@ typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescript= orRev1; =20 /* Sub-structures for MADT */ =20 -struct AcpiMadtProcessorApic { - ACPI_SUB_HEADER_DEF - uint8_t processor_id; /* ACPI processor id */ - uint8_t local_apic_id; /* Processor's local APIC id */ - uint32_t flags; -} QEMU_PACKED; -typedef struct AcpiMadtProcessorApic AcpiMadtProcessorApic; - -struct AcpiMadtIoApic { - ACPI_SUB_HEADER_DEF - uint8_t io_apic_id; /* I/O APIC ID */ - uint8_t reserved; /* Reserved - must be zero */ - uint32_t address; /* APIC physical address */ - uint32_t interrupt; /* Global system interrupt where INTI - * lines start */ -} QEMU_PACKED; -typedef struct AcpiMadtIoApic AcpiMadtIoApic; - -struct AcpiMadtIntsrcovr { - ACPI_SUB_HEADER_DEF - uint8_t bus; - uint8_t source; - uint32_t gsi; - uint16_t flags; -} QEMU_PACKED; -typedef struct AcpiMadtIntsrcovr AcpiMadtIntsrcovr; - -struct AcpiMadtLocalNmi { - ACPI_SUB_HEADER_DEF - uint8_t processor_id; /* ACPI processor id */ - uint16_t flags; /* MPS INTI flags */ - uint8_t lint; /* Local APIC LINT# */ -} QEMU_PACKED; -typedef struct AcpiMadtLocalNmi AcpiMadtLocalNmi; - -struct AcpiMadtProcessorX2Apic { - ACPI_SUB_HEADER_DEF - uint16_t reserved; - uint32_t x2apic_id; /* Processor's local x2APIC ID */ - uint32_t flags; - uint32_t uid; /* Processor object _UID */ -} QEMU_PACKED; -typedef struct AcpiMadtProcessorX2Apic AcpiMadtProcessorX2Apic; - -struct AcpiMadtLocalX2ApicNmi { - ACPI_SUB_HEADER_DEF - uint16_t flags; /* MPS INTI flags */ - uint32_t uid; /* Processor object _UID */ - uint8_t lint; /* Local APIC LINT# */ - uint8_t reserved[3]; /* Local APIC LINT# */ -} QEMU_PACKED; -typedef struct AcpiMadtLocalX2ApicNmi AcpiMadtLocalX2ApicNmi; - struct AcpiMadtGenericCpuInterface { ACPI_SUB_HEADER_DEF uint16_t reserved; diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c index 7983a13a93..4aaafbdd7b 100644 --- a/hw/i386/acpi-common.c +++ b/hw/i386/acpi-common.c @@ -38,7 +38,9 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, bool force_enabled) { uint32_t apic_id =3D apic_ids->cpus[uid].arch_id; - uint32_t flags =3D apic_ids->cpus[uid].cpu !=3D NULL || force_enabled = ? 1 : 0; + /* Flags =E2=80=93 Local APIC Flags */ + uint32_t flags =3D apic_ids->cpus[uid].cpu !=3D NULL || force_enabled ? + 1 /* Enabled */ : 0; =20 /* ACPI spec says that LAPIC entry for non present * CPU may be omitted from MADT or it must be marked @@ -47,24 +49,47 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, * should be put in MADT but kept disabled. */ if (apic_id < 255) { - AcpiMadtProcessorApic *apic =3D acpi_data_push(entry, sizeof *apic= ); - - apic->type =3D ACPI_APIC_PROCESSOR; - apic->length =3D sizeof(*apic); - apic->processor_id =3D uid; - apic->local_apic_id =3D apic_id; - apic->flags =3D cpu_to_le32(flags); + /* Rev 1.0b, Table 5-13 Processor Local APIC Structure */ + build_append_int_noprefix(entry, 0, 1); /* Type */ + build_append_int_noprefix(entry, 8, 1); /* Length */ + build_append_int_noprefix(entry, uid, 1); /* ACPI Processor ID= */ + build_append_int_noprefix(entry, apic_id, 1); /* APIC ID */ + build_append_int_noprefix(entry, flags, 4); /* Flags */ } else { - AcpiMadtProcessorX2Apic *apic =3D acpi_data_push(entry, sizeof *ap= ic); - - apic->type =3D ACPI_APIC_LOCAL_X2APIC; - apic->length =3D sizeof(*apic); - apic->uid =3D cpu_to_le32(uid); - apic->x2apic_id =3D cpu_to_le32(apic_id); - apic->flags =3D cpu_to_le32(flags); + /* Rev 4.0, 5.2.12.12 Processor Local x2APIC Structure */ + build_append_int_noprefix(entry, 9, 1); /* Type */ + build_append_int_noprefix(entry, 16, 1); /* Length */ + build_append_int_noprefix(entry, 0, 2); /* Reserved */ + build_append_int_noprefix(entry, apic_id, 4); /* X2APIC ID */ + build_append_int_noprefix(entry, flags, 4); /* Flags */ + build_append_int_noprefix(entry, uid, 4); /* ACPI Processor UI= D */ } } =20 +static void build_ioapic(GArray *entry, uint8_t id, uint32_t addr, uint32_= t irq) +{ + /* Rev 1.0b, 5.2.8.2 IO APIC */ + build_append_int_noprefix(entry, 1, 1); /* Type */ + build_append_int_noprefix(entry, 12, 1); /* Length */ + build_append_int_noprefix(entry, id, 1); /* IO APIC ID */ + build_append_int_noprefix(entry, 0, 1); /* Reserved */ + build_append_int_noprefix(entry, addr, 4); /* IO APIC Address */ + build_append_int_noprefix(entry, irq, 4); /* System Vector Base */ +} + +static void +build_xrupt_override(GArray *entry, uint8_t src, uint32_t gsi, uint16_t fl= ags) +{ + /* Rev 1.0b, 5.2.8.3.1 Interrupt Source Overrides */ + build_append_int_noprefix(entry, 2, 1); /* Type */ + build_append_int_noprefix(entry, 10, 1); /* Length */ + build_append_int_noprefix(entry, 0, 1); /* Bus */ + build_append_int_noprefix(entry, src, 1); /* Source */ + /* Global System Interrupt Vector */ + build_append_int_noprefix(entry, gsi, 4); + build_append_int_noprefix(entry, flags, 2); /* Flags */ +} + /* * ACPI spec, Revision 1.0b * 5.2.8 Multiple APIC Description Table @@ -73,14 +98,11 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *li= nker, X86MachineState *x86ms, AcpiDeviceIf *adev, const char *oem_id, const char *oem_table_id) { + int i; + bool x2apic_mode =3D false; MachineClass *mc =3D MACHINE_GET_CLASS(x86ms); const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(MACHINE(x8= 6ms)); AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_GET_CLASS(adev); - bool x2apic_mode =3D false; - - AcpiMadtIoApic *io_apic; - AcpiMadtIntsrcovr *intsrcovr; - int i; AcpiTable table =3D { .sig =3D "APIC", .rev =3D 1, .oem_id =3D oem_id, .oem_table_id =3D oem_table_id }; =20 @@ -96,30 +118,15 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *l= inker, } } =20 - io_apic =3D acpi_data_push(table_data, sizeof *io_apic); - io_apic->type =3D ACPI_APIC_IO; - io_apic->length =3D sizeof(*io_apic); - io_apic->io_apic_id =3D ACPI_BUILD_IOAPIC_ID; - io_apic->address =3D cpu_to_le32(IO_APIC_DEFAULT_ADDRESS); - io_apic->interrupt =3D cpu_to_le32(0); - + build_ioapic(table_data, ACPI_BUILD_IOAPIC_ID, IO_APIC_DEFAULT_ADDRESS= , 0); if (x86ms->ioapic2) { - AcpiMadtIoApic *io_apic2; - io_apic2 =3D acpi_data_push(table_data, sizeof *io_apic); - io_apic2->type =3D ACPI_APIC_IO; - io_apic2->length =3D sizeof(*io_apic); - io_apic2->io_apic_id =3D ACPI_BUILD_IOAPIC_ID + 1; - io_apic2->address =3D cpu_to_le32(IO_APIC_SECONDARY_ADDRESS); - io_apic2->interrupt =3D cpu_to_le32(IO_APIC_SECONDARY_IRQBASE); + build_ioapic(table_data, ACPI_BUILD_IOAPIC_ID + 1, + IO_APIC_SECONDARY_ADDRESS, IO_APIC_SECONDARY_IRQBASE); } =20 if (x86ms->apic_xrupt_override) { - intsrcovr =3D acpi_data_push(table_data, sizeof *intsrcovr); - intsrcovr->type =3D ACPI_APIC_XRUPT_OVERRIDE; - intsrcovr->length =3D sizeof(*intsrcovr); - intsrcovr->source =3D 0; - intsrcovr->gsi =3D cpu_to_le32(2); - intsrcovr->flags =3D cpu_to_le16(0); /* conforms to bus specifica= tions */ + build_xrupt_override(table_data, 0, 2, + 0 /* Flags: Conforms to the specifications of the bus */); } =20 for (i =3D 1; i < 16; i++) { @@ -127,32 +134,30 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *= linker, /* No need for a INT source override structure. */ continue; } - intsrcovr =3D acpi_data_push(table_data, sizeof *intsrcovr); - intsrcovr->type =3D ACPI_APIC_XRUPT_OVERRIDE; - intsrcovr->length =3D sizeof(*intsrcovr); - intsrcovr->source =3D i; - intsrcovr->gsi =3D cpu_to_le32(i); - intsrcovr->flags =3D cpu_to_le16(0xd); /* active high, level trig= gered */ + build_xrupt_override(table_data, i, i, + 0xd /* Flags: Active high, Level Triggered */); } =20 if (x2apic_mode) { - AcpiMadtLocalX2ApicNmi *local_nmi; - - local_nmi =3D acpi_data_push(table_data, sizeof *local_nmi); - local_nmi->type =3D ACPI_APIC_LOCAL_X2APIC_NMI; - local_nmi->length =3D sizeof(*local_nmi); - local_nmi->uid =3D 0xFFFFFFFF; /* all processors */ - local_nmi->flags =3D cpu_to_le16(0); - local_nmi->lint =3D 1; /* ACPI_LINT1 */ + /* Rev 4.0, 5.2.12.13 Local x2APIC NMI Structure*/ + build_append_int_noprefix(table_data, 0xA, 1); /* Type */ + build_append_int_noprefix(table_data, 12, 1); /* Length */ + build_append_int_noprefix(table_data, 0, 2); /* Flags */ + /* ACPI Processor UID */ + build_append_int_noprefix(table_data, 0xFFFFFFFF /* all processors= */, + 4); + /* Local x2APIC LINT# */ + build_append_int_noprefix(table_data, 1 /* ACPI_LINT1 */, 1); + build_append_int_noprefix(table_data, 0, 3); /* Reserved */ } else { - AcpiMadtLocalNmi *local_nmi; - - local_nmi =3D acpi_data_push(table_data, sizeof *local_nmi); - local_nmi->type =3D ACPI_APIC_LOCAL_NMI; - local_nmi->length =3D sizeof(*local_nmi); - local_nmi->processor_id =3D 0xff; /* all processors */ - local_nmi->flags =3D cpu_to_le16(0); - local_nmi->lint =3D 1; /* ACPI_LINT1 */ + /* Rev 1.0b, 5.2.8.3.3 Local APIC NMI */ + build_append_int_noprefix(table_data, 4, 1); /* Type */ + build_append_int_noprefix(table_data, 6, 1); /* Length */ + /* ACPI Processor ID */ + build_append_int_noprefix(table_data, 0xFF /* all processors */, 1= ); + build_append_int_noprefix(table_data, 0, 2); /* Flags */ + /* Local APIC INTI# */ + build_append_int_noprefix(table_data, 1 /* ACPI_LINT1 */, 1); } =20 acpi_table_end(linker, &table); --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633453433866517.7930859118677; Tue, 5 Oct 2021 10:03:53 -0700 (PDT) Received: from localhost ([::1]:42002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnr5-0002TU-AX for importer@patchew.org; Tue, 05 Oct 2021 13:03:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmv4-00020j-5X for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33495) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmuw-0006ne-EY for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:53 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-392-wGhWkZiLOfGv785-p0OUZA-1; Tue, 05 Oct 2021 12:03:44 -0400 Received: by mail-wm1-f71.google.com with SMTP id m2-20020a05600c3b0200b0030cd1310631so1218446wms.7 for ; Tue, 05 Oct 2021 09:03:44 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id z18sm11456594wro.25.2021.10.05.09.03.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449825; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nmIowrhu+9mjFv5KTzuVGlB15O8eraSlWO3HkaxiyKg=; b=DIMBPU2RSSPbk9FfdUy02/jeQ3DmED3LERQMh8TBr+TrShrxHBdwmtx5kWZSM8F1iYxbot Dh/pBS6b0PjUGb5MHtsR8WqHkjsGDvwLhZJQVUvAR7VlmIL+Zbzs5GSUjslBZfw/T2+GcY xQ2roHmr2uYU8ab0WFyN9ARnpBvQyfA= X-MC-Unique: wGhWkZiLOfGv785-p0OUZA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=nmIowrhu+9mjFv5KTzuVGlB15O8eraSlWO3HkaxiyKg=; b=WH0polW5aF0HAPElVI63PtE/1vEItCLb291NokQENlbgMM0QUEuPyTHGkOvMOd9q+4 F2vQiNpNrlg3YplXnKtqwdZc7h6yHFod15uNotAOda72OjiIorM82MosrI29shcAcRcf eJZTUt0uuwk31dpNyzxG76amwzfkOFJ1sUe3DE2ygDfT1YarZO4SGkSty23D7TtHpue6 3RhaVIIA0RDrR4mXRNJ3mfyqIIqbTnh+bMNAcT2txsEWq0tAbmCAbnPavTo+xxQz4LbW SmBB/36M8K9ZXACTSEcXlGCOxWEz05dillXNin90etONbGD5M0iYqggvtIKnF4wVIxxq +5RQ== X-Gm-Message-State: AOAM531fTeRdRr+jmMbWVqLh533dOCrqD6E0HjxwZU62uSNf70lXpTUw ciiYu5jYNniR6kEm2ymoLKDLjpR6sR/pIjQdeC6JEYK/Ak14bpIjO9SO9gofBQDDEDS/IoEsuAi 0590hu1ldkICSyOwnzw89TGnowZvBAcTcfDAGrm/3ta1cmuwawJhK3h6AoA9V X-Received: by 2002:a5d:6da9:: with SMTP id u9mr22616009wrs.155.1633449822775; Tue, 05 Oct 2021 09:03:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwdWgz4eSDIq4E3W95izems4T4z4+vZiABEVJ6nJNnaivdbT0WOtH6DYehCVCUTCOzPkIctA== X-Received: by 2002:a5d:6da9:: with SMTP id u9mr22615947wrs.155.1633449822389; Tue, 05 Oct 2021 09:03:42 -0700 (PDT) Date: Tue, 5 Oct 2021 12:03:39 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 39/57] acpi: arm/virt: madt: use build_append_int_noprefix() API to compose MADT table Message-ID: <20211005155946.513818-40-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eric Auger , Shannon Zhao , qemu-arm@nongnu.org, Ani Sinha , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633453436169100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Drop usage of packed structures and explicit endian conversions when building MADT table for arm/x86 and use endian agnostic build_append_int_noprefix() API to build it. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-26-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 84 -------------------- hw/arm/virt-acpi-build.c | 148 ++++++++++++++++++++++-------------- 2 files changed, 89 insertions(+), 143 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 3f174ba208..bcada37601 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -163,90 +163,6 @@ struct AcpiFacsDescriptorRev1 { } QEMU_PACKED; typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1; =20 -/* Values for Type in APIC sub-headers */ - -#define ACPI_APIC_GENERIC_CPU_INTERFACE 11 -#define ACPI_APIC_GENERIC_DISTRIBUTOR 12 -#define ACPI_APIC_GENERIC_MSI_FRAME 13 -#define ACPI_APIC_GENERIC_REDISTRIBUTOR 14 -#define ACPI_APIC_GENERIC_TRANSLATOR 15 -#define ACPI_APIC_RESERVED 16 /* 16 and greater are reserve= d */ - -/* - * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE) - */ -#define ACPI_SUB_HEADER_DEF /* Common ACPI sub-structure header */\ - uint8_t type; \ - uint8_t length; - -/* Sub-structures for MADT */ - -struct AcpiMadtGenericCpuInterface { - ACPI_SUB_HEADER_DEF - uint16_t reserved; - uint32_t cpu_interface_number; - uint32_t uid; - uint32_t flags; - uint32_t parking_version; - uint32_t performance_interrupt; - uint64_t parked_address; - uint64_t base_address; - uint64_t gicv_base_address; - uint64_t gich_base_address; - uint32_t vgic_interrupt; - uint64_t gicr_base_address; - uint64_t arm_mpidr; -} QEMU_PACKED; - -typedef struct AcpiMadtGenericCpuInterface AcpiMadtGenericCpuInterface; - -/* GICC CPU Interface Flags */ -#define ACPI_MADT_GICC_ENABLED 1 - -struct AcpiMadtGenericDistributor { - ACPI_SUB_HEADER_DEF - uint16_t reserved; - uint32_t gic_id; - uint64_t base_address; - uint32_t global_irq_base; - /* ACPI 5.1 Errata 1228 Present GIC version in MADT table */ - uint8_t version; - uint8_t reserved2[3]; -} QEMU_PACKED; - -typedef struct AcpiMadtGenericDistributor AcpiMadtGenericDistributor; - -struct AcpiMadtGenericMsiFrame { - ACPI_SUB_HEADER_DEF - uint16_t reserved; - uint32_t gic_msi_frame_id; - uint64_t base_address; - uint32_t flags; - uint16_t spi_count; - uint16_t spi_base; -} QEMU_PACKED; - -typedef struct AcpiMadtGenericMsiFrame AcpiMadtGenericMsiFrame; - -struct AcpiMadtGenericRedistributor { - ACPI_SUB_HEADER_DEF - uint16_t reserved; - uint64_t base_address; - uint32_t range_length; -} QEMU_PACKED; - -typedef struct AcpiMadtGenericRedistributor AcpiMadtGenericRedistributor; - -struct AcpiMadtGenericTranslator { - ACPI_SUB_HEADER_DEF - uint16_t reserved; - uint32_t translation_id; - uint64_t base_address; - uint32_t reserved2; -} QEMU_PACKED; - -typedef struct AcpiMadtGenericTranslator AcpiMadtGenericTranslator; - /* * Generic Timer Description Table (GTDT) */ diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index e3bdcd44e8..a9a78d904a 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -568,94 +568,124 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, V= irtMachineState *vms) } =20 /* - * ACPI spec, Revision 5.0 + * ACPI spec, Revision 5.1 Errata A * 5.2.12 Multiple APIC Description Table (MADT) */ +static void build_append_gicr(GArray *table_data, uint64_t base, uint32_t = size) +{ + build_append_int_noprefix(table_data, 0xE, 1); /* Type */ + build_append_int_noprefix(table_data, 16, 1); /* Length */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + /* Discovery Range Base Addres */ + build_append_int_noprefix(table_data, base, 8); + build_append_int_noprefix(table_data, size, 4); /* Discovery Range Len= gth */ +} + static void build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { + int i; VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); const MemMapEntry *memmap =3D vms->memmap; - const int *irqmap =3D vms->irqmap; - AcpiMadtGenericDistributor *gicd; - AcpiMadtGenericMsiFrame *gic_msi; - int i; AcpiTable table =3D { .sig =3D "APIC", .rev =3D 3, .oem_id =3D vms->oe= m_id, .oem_table_id =3D vms->oem_table_id }; =20 acpi_table_begin(&table, table_data); /* Local Interrupt Controller Address */ build_append_int_noprefix(table_data, 0, 4); - build_append_int_noprefix(table_data, 0, 4); /* Flags */ + build_append_int_noprefix(table_data, 0, 4); /* Flags */ =20 - gicd =3D acpi_data_push(table_data, sizeof *gicd); - gicd->type =3D ACPI_APIC_GENERIC_DISTRIBUTOR; - gicd->length =3D sizeof(*gicd); - gicd->base_address =3D cpu_to_le64(memmap[VIRT_GIC_DIST].base); - gicd->version =3D vms->gic_version; + /* 5.2.12.15 GIC Distributor Structure */ + build_append_int_noprefix(table_data, 0xC, 1); /* Type */ + build_append_int_noprefix(table_data, 24, 1); /* Length */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); /* GIC ID */ + /* Physical Base Address */ + build_append_int_noprefix(table_data, memmap[VIRT_GIC_DIST].base, 8); + build_append_int_noprefix(table_data, 0, 4); /* System Vector Base */ + /* GIC version */ + build_append_int_noprefix(table_data, vms->gic_version, 1); + build_append_int_noprefix(table_data, 0, 3); /* Reserved */ =20 for (i =3D 0; i < MACHINE(vms)->smp.cpus; i++) { - AcpiMadtGenericCpuInterface *gicc =3D acpi_data_push(table_data, - sizeof(*gicc)); ARMCPU *armcpu =3D ARM_CPU(qemu_get_cpu(i)); + uint64_t physical_base_address =3D 0, gich =3D 0, gicv =3D 0; + uint32_t vgic_interrupt =3D vms->virt ? PPI(ARCH_GIC_MAINT_IRQ) : = 0; + uint32_t pmu_interrupt =3D arm_feature(&armcpu->env, ARM_FEATURE_P= MU) ? + PPI(VIRTUAL_PMU_IRQ) : 0; =20 - gicc->type =3D ACPI_APIC_GENERIC_CPU_INTERFACE; - gicc->length =3D sizeof(*gicc); if (vms->gic_version =3D=3D 2) { - gicc->base_address =3D cpu_to_le64(memmap[VIRT_GIC_CPU].base); - gicc->gich_base_address =3D cpu_to_le64(memmap[VIRT_GIC_HYP].b= ase); - gicc->gicv_base_address =3D cpu_to_le64(memmap[VIRT_GIC_VCPU].= base); + physical_base_address =3D memmap[VIRT_GIC_CPU].base; + gicv =3D memmap[VIRT_GIC_VCPU].base; + gich =3D memmap[VIRT_GIC_HYP].base; } - gicc->cpu_interface_number =3D cpu_to_le32(i); - gicc->arm_mpidr =3D cpu_to_le64(armcpu->mp_affinity); - gicc->uid =3D cpu_to_le32(i); - gicc->flags =3D cpu_to_le32(ACPI_MADT_GICC_ENABLED); =20 - if (arm_feature(&armcpu->env, ARM_FEATURE_PMU)) { - gicc->performance_interrupt =3D cpu_to_le32(PPI(VIRTUAL_PMU_IR= Q)); - } - if (vms->virt) { - gicc->vgic_interrupt =3D cpu_to_le32(PPI(ARCH_GIC_MAINT_IRQ)); - } + /* 5.2.12.14 GIC Structure */ + build_append_int_noprefix(table_data, 0xB, 1); /* Type */ + build_append_int_noprefix(table_data, 76, 1); /* Length */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + build_append_int_noprefix(table_data, i, 4); /* GIC ID */ + build_append_int_noprefix(table_data, i, 4); /* ACPI Processor = UID */ + /* Flags */ + build_append_int_noprefix(table_data, 1, 4); /* Enabled */ + /* Parking Protocol Version */ + build_append_int_noprefix(table_data, 0, 4); + /* Performance Interrupt GSIV */ + build_append_int_noprefix(table_data, pmu_interrupt, 4); + build_append_int_noprefix(table_data, 0, 8); /* Parked Address */ + /* Physical Base Address */ + build_append_int_noprefix(table_data, physical_base_address, 8); + build_append_int_noprefix(table_data, gicv, 8); /* GICV */ + build_append_int_noprefix(table_data, gich, 8); /* GICH */ + /* VGIC Maintenance interrupt */ + build_append_int_noprefix(table_data, vgic_interrupt, 4); + build_append_int_noprefix(table_data, 0, 8); /* GICR Base Addre= ss*/ + /* MPIDR */ + build_append_int_noprefix(table_data, armcpu->mp_affinity, 8); } =20 if (vms->gic_version =3D=3D 3) { - AcpiMadtGenericTranslator *gic_its; - int nb_redist_regions =3D virt_gicv3_redist_region_count(vms); - AcpiMadtGenericRedistributor *gicr =3D acpi_data_push(table_data, - sizeof *gicr); - - gicr->type =3D ACPI_APIC_GENERIC_REDISTRIBUTOR; - gicr->length =3D sizeof(*gicr); - gicr->base_address =3D cpu_to_le64(memmap[VIRT_GIC_REDIST].base); - gicr->range_length =3D cpu_to_le32(memmap[VIRT_GIC_REDIST].size); - - if (nb_redist_regions =3D=3D 2) { - gicr =3D acpi_data_push(table_data, sizeof(*gicr)); - gicr->type =3D ACPI_APIC_GENERIC_REDISTRIBUTOR; - gicr->length =3D sizeof(*gicr); - gicr->base_address =3D - cpu_to_le64(memmap[VIRT_HIGH_GIC_REDIST2].base); - gicr->range_length =3D - cpu_to_le32(memmap[VIRT_HIGH_GIC_REDIST2].size); + build_append_gicr(table_data, memmap[VIRT_GIC_REDIST].base, + memmap[VIRT_GIC_REDIST].size); + if (virt_gicv3_redist_region_count(vms) =3D=3D 2) { + build_append_gicr(table_data, memmap[VIRT_HIGH_GIC_REDIST2].ba= se, + memmap[VIRT_HIGH_GIC_REDIST2].si= ze); } =20 if (its_class_name() && !vmc->no_its) { - gic_its =3D acpi_data_push(table_data, sizeof *gic_its); - gic_its->type =3D ACPI_APIC_GENERIC_TRANSLATOR; - gic_its->length =3D sizeof(*gic_its); - gic_its->translation_id =3D 0; - gic_its->base_address =3D cpu_to_le64(memmap[VIRT_GIC_ITS].bas= e); + /* + * FIXME: Structure is from Revision 6.0 where 'GIC Structure' + * has additional fields on top of implemented 5.1 Errata A, + * to make it consistent with v6.0 we need to bump everything + * to v6.0 + */ + /* + * ACPI spec, Revision 6.0 Errata A + * (original 6.0 definition has invalid Length) + * 5.2.12.18 GIC ITS Structure + */ + build_append_int_noprefix(table_data, 0xF, 1); /* Type */ + build_append_int_noprefix(table_data, 20, 1); /* Length */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); /* GIC ITS ID = */ + /* Physical Base Address */ + build_append_int_noprefix(table_data, memmap[VIRT_GIC_ITS].bas= e, 8); + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ } } else { - gic_msi =3D acpi_data_push(table_data, sizeof *gic_msi); - gic_msi->type =3D ACPI_APIC_GENERIC_MSI_FRAME; - gic_msi->length =3D sizeof(*gic_msi); - gic_msi->gic_msi_frame_id =3D 0; - gic_msi->base_address =3D cpu_to_le64(memmap[VIRT_GIC_V2M].base); - gic_msi->flags =3D cpu_to_le32(1); - gic_msi->spi_count =3D cpu_to_le16(NUM_GICV2M_SPIS); - gic_msi->spi_base =3D cpu_to_le16(irqmap[VIRT_GIC_V2M] + ARM_SPI_B= ASE); + const uint16_t spi_base =3D vms->irqmap[VIRT_GIC_V2M] + ARM_SPI_BA= SE; + + /* 5.2.12.16 GIC MSI Frame Structure */ + build_append_int_noprefix(table_data, 0xD, 1); /* Type */ + build_append_int_noprefix(table_data, 24, 1); /* Length */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); /* GIC MSI Frame I= D */ + /* Physical Base Address */ + build_append_int_noprefix(table_data, memmap[VIRT_GIC_V2M].base, 8= ); + build_append_int_noprefix(table_data, 1, 4); /* Flags */ + /* SPI Count */ + build_append_int_noprefix(table_data, NUM_GICV2M_SPIS, 2); + build_append_int_noprefix(table_data, spi_base, 2); /* SPI Base */ } acpi_table_end(linker, &table); } --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633452491075497.5557616707724; Tue, 5 Oct 2021 09:48:11 -0700 (PDT) Received: from localhost ([::1]:36802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnbu-00041h-0j for importer@patchew.org; Tue, 05 Oct 2021 12:48:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmv9-00022p-82 for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28013) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmv3-0006rJ-Tb for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:58 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-329-lwW4p8uaMV6oKIUjZzV_Rw-1; Tue, 05 Oct 2021 12:03:48 -0400 Received: by mail-wm1-f71.google.com with SMTP id f12-20020a1c6a0c000000b0030d696e37b7so1494628wmc.4 for ; Tue, 05 Oct 2021 09:03:48 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id 189sm2744685wmz.27.2021.10.05.09.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449830; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ekV4rsvEqzPbqhC9VJ6Rw4BlulbNEjFP62bPhfPBwpY=; b=cu+cA3kJQvdCzod3ONb7JsTlbirk23nil0hxijwo1LjZ83rGxTW5fd8hh00uvtqGkmUGxc GAy66zS6rzawgEWUnO+gRb3hKhBCjy4fe53v6ARUEzIynLbz0aUncRYeX0aNYJuQ92z6SA Pt/5Ag5ejYwY2eRAvPsetm1XsEZpD7c= X-MC-Unique: lwW4p8uaMV6oKIUjZzV_Rw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ekV4rsvEqzPbqhC9VJ6Rw4BlulbNEjFP62bPhfPBwpY=; b=Vmv2Ha/KMdQz3IxARXBDQnJ7Gao8PYTjlAg/9c6Ofd5nhGDc1qQgrnWJaC6jxCkddJ pHWMxN6LaOhMdRJjwrBMcVg3MefJ2ZwrNMmOYCNCvvfRyGVjfWlZ4z089xUGQNi+js4F cEde1m7L5WFN6tQRjSn+w7zoDAbZwpYc+1WYs8JexYKyJB6YkXGekPSryAYA7SV7P7GF zzE4ioUZKH/o4/vWxunnqj/9oc/jnHWtEyw3Jy5ukM4UY4CJ4mK/ZpKSs6y1opx1ksS0 IrZl/T956vbHvjwvFjdzM8/afVYvvHzwF7PNJmXe6wR4Fv4R//2Mxy5YUkWrXaxxNyaP w98w== X-Gm-Message-State: AOAM531qyXad3twJUMrnNDfQFchngZbbtBkpePm+CyZxa+wuMo6GYkBj 3aA8LLalfHpgwcnlJAl19kw6QK7oGM0GZAl63SJXF8/nQTI9EftfvXCAiEZGUULBIPbfavSBhEP tTBU+cPwT/b0mfAYW1r9UlysUSwyQdM9CAYpBFG0sKmoI2WcFAkVdLM6UWTQ1 X-Received: by 2002:adf:a454:: with SMTP id e20mr17513074wra.310.1633449826726; Tue, 05 Oct 2021 09:03:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxObHg/UcjgS53cFbw7+C8o5A7zdWmkfKIZJU5fwVJ29+tJ97H5IZjtayeaK0Z2K2hLgEv8PQ== X-Received: by 2002:adf:a454:: with SMTP id e20mr17513034wra.310.1633449826478; Tue, 05 Oct 2021 09:03:46 -0700 (PDT) Date: Tue, 5 Oct 2021 12:03:42 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 40/57] acpi: build_dsdt_microvm: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-41-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , Eric Auger , Igor Mammedov , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452491894100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-27-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-microvm.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c index 1a0f77b911..196d318499 100644 --- a/hw/i386/acpi-microvm.c +++ b/hw/i386/acpi-microvm.c @@ -113,16 +113,16 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *li= nker, Aml *dsdt, *sb_scope, *scope, *pkg; bool ambiguous; Object *isabus; + AcpiTable table =3D { .sig =3D "DSDT", .rev =3D 2, .oem_id =3D x86ms->= oem_id, + .oem_table_id =3D x86ms->oem_table_id }; =20 isabus =3D object_resolve_path_type("", TYPE_ISA_BUS, &ambiguous); assert(isabus); assert(!ambiguous); =20 + acpi_table_begin(&table, table_data); dsdt =3D init_aml_allocator(); =20 - /* Reserve space for header */ - acpi_data_push(dsdt->buf, sizeof(AcpiTableHeader)); - sb_scope =3D aml_scope("_SB"); fw_cfg_add_acpi_dsdt(sb_scope, x86ms->fw_cfg); isa_build_aml(ISA_BUS(isabus), sb_scope); @@ -144,11 +144,10 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *li= nker, aml_append(scope, aml_name_decl("_S5", pkg)); aml_append(dsdt, scope); =20 - /* copy AML table into ACPI tables blob and patch header there */ + /* copy AML bytecode into ACPI tables blob */ g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len); - build_header(linker, table_data, - (void *)(table_data->data + table_data->len - dsdt->buf->len), - "DSDT", dsdt->buf->len, 2, x86ms->oem_id, x86ms->oem_tabl= e_id); + + acpi_table_end(linker, &table); free_aml_allocator(); } =20 --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633452458234264.8383910358813; Tue, 5 Oct 2021 09:47:38 -0700 (PDT) Received: from localhost ([::1]:35254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnbM-0002wr-Uh for importer@patchew.org; Tue, 05 Oct 2021 12:47:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmv7-00021W-4V for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33429) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmv4-0006rU-8w for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:03:56 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-231-GWO7COwAOtWGDOIxfxqU6A-1; Tue, 05 Oct 2021 12:03:52 -0400 Received: by mail-wm1-f71.google.com with SMTP id m9-20020a05600c4f4900b003057c761567so1504615wmq.1 for ; Tue, 05 Oct 2021 09:03:52 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id t15sm8836412wru.6.2021.10.05.09.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:03:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=R4wGL6P6mQ8b+hHluivUshpdu4ZjMd9sQXmFz3Odljs=; b=OMXVDK+R4JeTtFDJIbFIsqZ4RAqbp+RcXl4MvfyQnXvmrzcKlyvCChwiq72dFW1n3GD7rV mgSqdmbbovd9Ca9X2YADOb6ERMUYTJ2vScLKGtiYt+kGUg/v7dUzaqaZ22dUAehUSFVAYH AOgxRFzlGOm9A/2hmA/6qJthhoaqSg4= X-MC-Unique: GWO7COwAOtWGDOIxfxqU6A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=R4wGL6P6mQ8b+hHluivUshpdu4ZjMd9sQXmFz3Odljs=; b=2R7RPA23mAhXOlG0bWSsMDekchk/ubMdI6KiIImv2cddp4HCLNmEL6ayvOQF/bxRby l2tsc136I9sJ/sXqyCos90BZd1BW+/32srbCHI262E+ovoNyraFtsZIJc1h4wlFWSl/L swRopy10j8q5z25/vekz9fESZulBR1nuRCFG/uZ0Grr13joeV1G/CH0dck4XoI3KNKMK TU4/Au1aH2vTr5FTPwyqnkJ09o3C8XEEBhRhOWV83vf4B5h/DwaOgdEeNHcJW2db7JlE lu8luuRmUmihQw1/h1iaWpPoa7mgdWXdscMn2Ak+5F2OPB1OXwXWtp08Pzh7JKiO40FE pmQg== X-Gm-Message-State: AOAM533AKTBdjbYzbyUzfrGQ8QisJ6VaOZ7c7DOxaV7+8JEG33Rvp92E RCXGj2G4zLofXrg07BQeLlQPjOqwCQip9+7DyHO+3xAy99yGw7eRrqmTSi9UGyjw98JTmHqPeSV zQ2Fwk8vKnnQZheBfGTFW6DEDbH+7jEmgKaLjwD20DPTOPiANj3VsQ/WnpObj X-Received: by 2002:adf:bc48:: with SMTP id a8mr2437566wrh.19.1633449830784; Tue, 05 Oct 2021 09:03:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjDIvzfQiZtkQoQSan22UGJLft3XPPgEWl48cmC1lDkFfg3wUcRWZlLm/VGQnQYYUJuQqEUA== X-Received: by 2002:adf:bc48:: with SMTP id a8mr2437528wrh.19.1633449830530; Tue, 05 Oct 2021 09:03:50 -0700 (PDT) Date: Tue, 5 Oct 2021 12:03:46 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 41/57] acpi: arm: virt: build_dsdt: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-42-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eric Auger , Shannon Zhao , qemu-arm@nongnu.org, Ani Sinha , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452460126100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-28-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/arm/virt-acpi-build.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index a9a78d904a..4b9687439d 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -729,10 +729,11 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) MachineState *ms =3D MACHINE(vms); const MemMapEntry *memmap =3D vms->memmap; const int *irqmap =3D vms->irqmap; + AcpiTable table =3D { .sig =3D "DSDT", .rev =3D 2, .oem_id =3D vms->oe= m_id, + .oem_table_id =3D vms->oem_table_id }; =20 + acpi_table_begin(&table, table_data); dsdt =3D init_aml_allocator(); - /* Reserve space for header */ - acpi_data_push(dsdt->buf, sizeof(AcpiTableHeader)); =20 /* When booting the VM with UEFI, UEFI takes ownership of the RTC hard= ware. * While UEFI can use libfdt to disable the RTC device node in the DTB= that @@ -779,12 +780,10 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) =20 aml_append(dsdt, scope); =20 - /* copy AML table into ACPI tables blob and patch header there */ + /* copy AML table into ACPI tables blob */ g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len); - build_header(linker, table_data, - (void *)(table_data->data + table_data->len - dsdt->buf->len), - "DSDT", dsdt->buf->len, 2, vms->oem_id, - vms->oem_table_id); + + acpi_table_end(linker, &table); free_aml_allocator(); } =20 --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633452132021831.5326393094381; Tue, 5 Oct 2021 09:42:12 -0700 (PDT) Received: from localhost ([::1]:51348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnW6-0002lI-Ls for importer@patchew.org; Tue, 05 Oct 2021 12:42:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvB-00022y-Hb for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:59771) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmv7-0006vb-Qc for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:01 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-63-LKr6Yp09MPWdY2CreUL-AQ-1; Tue, 05 Oct 2021 12:03:56 -0400 Received: by mail-wm1-f71.google.com with SMTP id n3-20020a7bcbc3000000b0030b68c4de38so1216831wmi.8 for ; Tue, 05 Oct 2021 09:03:55 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id c14sm17876664wrd.50.2021.10.05.09.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:03:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449837; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kCUnt/5lnjXWXncziu2KeMM1suaM9LHoeUo+n9gijko=; b=S5GXS3561cCpOkgeuKl9UKWaBOQzKvl3pXf1f4IpglTUklS6y85K6bqs/pf/LFwgBt5Buo Y4nzM6MSZYCvW/FFd3HPgZxccrZsw0lLkfAP9qbgbJ+OKYYdjDU7MfhUnh7rdbOD380PP6 k23f3shMtyYWmN5weYcAgbmAtjuxkIg= X-MC-Unique: LKr6Yp09MPWdY2CreUL-AQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kCUnt/5lnjXWXncziu2KeMM1suaM9LHoeUo+n9gijko=; b=Y+fPXVzFDzh5acXl4XOhFUMi7o7BlWFQWJtKE4a/tuCKgiVMn2BhaOQlt8SEhJ+6pn GxmoKc0pVp+UncKDU5DjSGwF6P93pEXy4EiBQ97W43xeY2SaYMwKSs9u3dDoM3n83mCl ZzEOHhbniELENE/bFxzVqAXwM+kucNjk/7dUFOkPgDkgQm7o4UnwCXTeWHFEbs75+VoT UHJLDdiQQ8vPmVyx89SBpPv2m5mwJuCbwGAfGagzF7IreebApxs74rvLcoEz+TloR/cI h6eKsw5Dkj1a+nWEgkP7/Dt8M1vmRUuHJUwqJaWJ64wizx50xcIaBolPJ3gD/SRUHe/K dEpA== X-Gm-Message-State: AOAM532E52K8Okj6BwjWba0rwxGj15adTVQoIVBlFXZ2Yij3ap3plY1f yKIJaeJUJOup6F/n7njZ/UxermsI39dtgfDrWlw7rdpDUGL3tsKZw1JJbOIcHUsmVoz26/zb+av urweB45G0jvBj+qEpOnFK3ctCqEm0pmBD+XaAX36epNRVE5J3iXWzhqUlI3DV X-Received: by 2002:adf:bb52:: with SMTP id x18mr16266614wrg.169.1633449834360; Tue, 05 Oct 2021 09:03:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxG8g3hY/MoT6x6Zf7OH3VIa6+b/cg/8jJNKyuaV1pCsGF2LYza9WX/EN/WzD51937FhBTq5g== X-Received: by 2002:adf:bb52:: with SMTP id x18mr16266570wrg.169.1633449834085; Tue, 05 Oct 2021 09:03:54 -0700 (PDT) Date: Tue, 5 Oct 2021 12:03:50 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 42/57] acpi: arm: virt: build_iort: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-43-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eric Auger , Shannon Zhao , qemu-arm@nongnu.org, Ani Sinha , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452133110100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Tested-by: Eric Auger Message-Id: <20210924122802.1455362-29-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 14 ------------ hw/arm/virt-acpi-build.c | 44 +++++++++++++++---------------------- 2 files changed, 18 insertions(+), 40 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index bcada37601..195f90caf6 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -188,20 +188,6 @@ struct AcpiGenericTimerTable { } QEMU_PACKED; typedef struct AcpiGenericTimerTable AcpiGenericTimerTable; =20 -/* - * Input Output Remapping Table (IORT) - * Conforms to "IO Remapping Table System Software on ARM Platforms", - * Document number: ARM DEN 0049B, October 2015 - */ - -struct AcpiIortTable { - ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint32_t node_count; - uint32_t node_offset; - uint32_t reserved; -} QEMU_PACKED; -typedef struct AcpiIortTable AcpiIortTable; - /* * IORT node types */ diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 4b9687439d..42ea460313 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -273,20 +273,26 @@ static int iort_idmap_compare(gconstpointer a, gconst= pointer b) return idmap_a->input_base - idmap_b->input_base; } =20 +/* + * Input Output Remapping Table (IORT) + * Conforms to "IO Remapping Table System Software on ARM Platforms", + * Document number: ARM DEN 0049B, October 2015 + */ static void build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { - int i, nb_nodes, rc_mapping_count, iort_start =3D table_data->len; + int i, nb_nodes, rc_mapping_count; AcpiIortIdMapping *idmap; AcpiIortItsGroup *its; - AcpiIortTable *iort; AcpiIortSmmu3 *smmu; - size_t node_size, iort_node_offset, iort_length, smmu_offset =3D 0; AcpiIortRC *rc; + const uint32_t iort_node_offset =3D 48; + size_t node_size, smmu_offset =3D 0; GArray *smmu_idmaps =3D g_array_new(false, true, sizeof(AcpiIortIdMapp= ing)); GArray *its_idmaps =3D g_array_new(false, true, sizeof(AcpiIortIdMappi= ng)); =20 - iort =3D acpi_data_push(table_data, sizeof(*iort)); + AcpiTable table =3D { .sig =3D "IORT", .rev =3D 0, .oem_id =3D vms->oe= m_id, + .oem_table_id =3D vms->oem_table_id }; =20 if (vms->iommu =3D=3D VIRT_IOMMU_SMMUV3) { AcpiIortIdMapping next_range =3D {0}; @@ -325,18 +331,16 @@ build_iort(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) rc_mapping_count =3D 1; } =20 - iort_length =3D sizeof(*iort); - iort->node_count =3D cpu_to_le32(nb_nodes); - /* - * Use a copy in case table_data->data moves during acpi_data_push - * operations. - */ - iort_node_offset =3D sizeof(*iort); - iort->node_offset =3D cpu_to_le32(iort_node_offset); + /* Table 2 The IORT */ + acpi_table_begin(&table, table_data); + /* Number of IORT Nodes */ + build_append_int_noprefix(table_data, nb_nodes, 4); + /* Offset to Array of IORT Nodes */ + build_append_int_noprefix(table_data, iort_node_offset, 4); + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ =20 /* ITS group node */ node_size =3D sizeof(*its) + sizeof(uint32_t); - iort_length +=3D node_size; its =3D acpi_data_push(table_data, node_size); =20 its->type =3D ACPI_IORT_NODE_ITS_GROUP; @@ -350,7 +354,6 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) /* SMMUv3 node */ smmu_offset =3D iort_node_offset + node_size; node_size =3D sizeof(*smmu) + sizeof(*idmap); - iort_length +=3D node_size; smmu =3D acpi_data_push(table_data, node_size); =20 smmu->type =3D ACPI_IORT_NODE_SMMU_V3; @@ -375,7 +378,6 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) =20 /* Root Complex Node */ node_size =3D sizeof(*rc) + sizeof(*idmap) * rc_mapping_count; - iort_length +=3D node_size; rc =3D acpi_data_push(table_data, node_size); =20 rc->type =3D ACPI_IORT_NODE_PCI_ROOT_COMPLEX; @@ -424,19 +426,9 @@ build_iort(GArray *table_data, BIOSLinker *linker, Vir= tMachineState *vms) idmap->output_reference =3D cpu_to_le32(iort_node_offset); } =20 + acpi_table_end(linker, &table); g_array_free(smmu_idmaps, true); g_array_free(its_idmaps, true); - - /* - * Update the pointer address in case table_data->data moves during ab= ove - * acpi_data_push operations. - */ - iort =3D (AcpiIortTable *)(table_data->data + iort_start); - iort->length =3D cpu_to_le32(iort_length); - - build_header(linker, table_data, (void *)(table_data->data + iort_star= t), - "IORT", table_data->len - iort_start, 0, vms->oem_id, - vms->oem_table_id); } =20 static void --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633453706370303.5815469925494; Tue, 5 Oct 2021 10:08:26 -0700 (PDT) Received: from localhost ([::1]:52768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnvV-000288-8y for importer@patchew.org; Tue, 05 Oct 2021 13:08:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvG-00023d-Dh for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44986) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvE-0006zN-0B for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:06 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-58-cRRgTr4kP3GtLeeRaQV95Q-1; Tue, 05 Oct 2021 12:04:00 -0400 Received: by mail-wr1-f71.google.com with SMTP id l9-20020adfc789000000b00160111fd4e8so5898830wrg.17 for ; Tue, 05 Oct 2021 09:03:59 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id i3sm2405689wrn.34.2021.10.05.09.03.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=uGFiGPDbrAIreFwmA8TQWcha/YYnuyPR6xzHHOliFOs=; b=Oh43K+S3S0vCnxpp6oKFQtV+yRz0g5xr58isgI7uNpQX6vxd3MC7KLoTmIHUgh4mwHTmoP +zNKz5AQwXjz3adlo/rcnCZkzliscu1IV0VcbeY+8eQHh5GJhZu/N1x9DWp8iuHrh0FOVM nGJZTF0U/rDzsuFWAXeU1xl190yAhr0= X-MC-Unique: cRRgTr4kP3GtLeeRaQV95Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=uGFiGPDbrAIreFwmA8TQWcha/YYnuyPR6xzHHOliFOs=; b=xWugqoGv2B1XwrFslqD+wp3ht7+gS6BoCbQ+RrIAyyWFqE/cAz/Te6KhoV9gjAXp8V 653rlwfa5ovdEcnjSZKW4mbEEZh4yfLTJxeIlvJqkjKU8CNYU7BzZrSOJZ8AoTfJBq1O V1HXDZbL2zF3R8S6gXUBFzPZYu9JEakVibP87TNaScykK3194kbLRqhIiEFniwME9LAP eGLJpjG5Jg/DwVGS9VrUsJkblzT8Bgl7Ulum6+bohX5eHZV7WbiEM3CqVFHu8P8FEOhN bjEV8vANjLl7TkKiN/apVMtAZ3seTIOhY8/NsDmqhMsAKQ3JcVcDFEX5JJUru5VVMXTh xpBQ== X-Gm-Message-State: AOAM530cR26kcwfbM14WLTq7UFQq38Rd1KQ394F8iPvz3hdmZxMJy3Im eiP2TjAWHdNz1ZCV4SyIzb/5TrimAyBoVCcZ94uAzExdy0q5oBU70YWpy7dK9HtPlOR4U/P0V4t LCpGJzrBRi3DPcd/SonzUh/C1qQvfC2EkvL5yidmIiw+OiF3mY0hforIwKd2B X-Received: by 2002:a1c:4484:: with SMTP id r126mr4319754wma.150.1633449837990; Tue, 05 Oct 2021 09:03:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcHdF7k895/0SWdLgUxGRoervDgO5H8yWIRF1ZWLwzV06HxcSHENqHMKaiEIL1iSIyF8QT8g== X-Received: by 2002:a1c:4484:: with SMTP id r126mr4319702wma.150.1633449837555; Tue, 05 Oct 2021 09:03:57 -0700 (PDT) Date: Tue, 5 Oct 2021 12:03:54 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 43/57] acpi: arm/virt: convert build_iort() to endian agnostic build_append_FOO() API Message-ID: <20211005155946.513818-44-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eric Auger , Shannon Zhao , qemu-arm@nongnu.org, Ani Sinha , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633453706933100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Drop usage of packed structures and explicit endian conversions when building IORT table use endian agnostic build_append_int_noprefix() API to build it. Signed-off-by: Igor Mammedov Message-Id: <20210924122802.1455362-30-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Eric Auger Tested-by: Eric Auger --- include/hw/acpi/acpi-defs.h | 71 ---------------- hw/arm/virt-acpi-build.c | 156 ++++++++++++++++++++---------------- 2 files changed, 89 insertions(+), 138 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 195f90caf6..6f2f08a9de 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -188,75 +188,4 @@ struct AcpiGenericTimerTable { } QEMU_PACKED; typedef struct AcpiGenericTimerTable AcpiGenericTimerTable; =20 -/* - * IORT node types - */ - -#define ACPI_IORT_NODE_HEADER_DEF /* Node format common fields */ \ - uint8_t type; \ - uint16_t length; \ - uint8_t revision; \ - uint32_t reserved; \ - uint32_t mapping_count; \ - uint32_t mapping_offset; - -/* Values for node Type above */ -enum { - ACPI_IORT_NODE_ITS_GROUP =3D 0x00, - ACPI_IORT_NODE_NAMED_COMPONENT =3D 0x01, - ACPI_IORT_NODE_PCI_ROOT_COMPLEX =3D 0x02, - ACPI_IORT_NODE_SMMU =3D 0x03, - ACPI_IORT_NODE_SMMU_V3 =3D 0x04 -}; - -struct AcpiIortIdMapping { - uint32_t input_base; - uint32_t id_count; - uint32_t output_base; - uint32_t output_reference; - uint32_t flags; -} QEMU_PACKED; -typedef struct AcpiIortIdMapping AcpiIortIdMapping; - -struct AcpiIortMemoryAccess { - uint32_t cache_coherency; - uint8_t hints; - uint16_t reserved; - uint8_t memory_flags; -} QEMU_PACKED; -typedef struct AcpiIortMemoryAccess AcpiIortMemoryAccess; - -struct AcpiIortItsGroup { - ACPI_IORT_NODE_HEADER_DEF - uint32_t its_count; - uint32_t identifiers[]; -} QEMU_PACKED; -typedef struct AcpiIortItsGroup AcpiIortItsGroup; - -#define ACPI_IORT_SMMU_V3_COHACC_OVERRIDE 1 - -struct AcpiIortSmmu3 { - ACPI_IORT_NODE_HEADER_DEF - uint64_t base_address; - uint32_t flags; - uint32_t reserved2; - uint64_t vatos_address; - uint32_t model; - uint32_t event_gsiv; - uint32_t pri_gsiv; - uint32_t gerr_gsiv; - uint32_t sync_gsiv; - AcpiIortIdMapping id_mapping_array[]; -} QEMU_PACKED; -typedef struct AcpiIortSmmu3 AcpiIortSmmu3; - -struct AcpiIortRC { - ACPI_IORT_NODE_HEADER_DEF - AcpiIortMemoryAccess memory_properties; - uint32_t ats_attribute; - uint32_t pci_segment_number; - AcpiIortIdMapping id_mapping_array[]; -} QEMU_PACKED; -typedef struct AcpiIortRC AcpiIortRC; - #endif diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 42ea460313..8c382915a9 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -240,6 +240,28 @@ static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineS= tate *vms) } #endif =20 +#define ID_MAPPING_ENTRY_SIZE 20 +#define SMMU_V3_ENTRY_SIZE 60 +#define ROOT_COMPLEX_ENTRY_SIZE 32 +#define IORT_NODE_OFFSET 48 + +static void build_iort_id_mapping(GArray *table_data, uint32_t input_base, + uint32_t id_count, uint32_t out_ref) +{ + /* Identity RID mapping covering the whole input RID range */ + build_append_int_noprefix(table_data, input_base, 4); /* Input base */ + build_append_int_noprefix(table_data, id_count, 4); /* Number of IDs */ + build_append_int_noprefix(table_data, input_base, 4); /* Output base */ + build_append_int_noprefix(table_data, out_ref, 4); /* Output Reference= */ + build_append_int_noprefix(table_data, 0, 4); /* Flags */ +} + +struct AcpiIortIdMapping { + uint32_t input_base; + uint32_t id_count; +}; +typedef struct AcpiIortIdMapping AcpiIortIdMapping; + /* Build the iort ID mapping to SMMUv3 for a given PCI host bridge */ static int iort_host_bridges(Object *obj, void *opaque) @@ -282,17 +304,16 @@ static void build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { int i, nb_nodes, rc_mapping_count; - AcpiIortIdMapping *idmap; - AcpiIortItsGroup *its; - AcpiIortSmmu3 *smmu; - AcpiIortRC *rc; - const uint32_t iort_node_offset =3D 48; + const uint32_t iort_node_offset =3D IORT_NODE_OFFSET; size_t node_size, smmu_offset =3D 0; + AcpiIortIdMapping *idmap; GArray *smmu_idmaps =3D g_array_new(false, true, sizeof(AcpiIortIdMapp= ing)); GArray *its_idmaps =3D g_array_new(false, true, sizeof(AcpiIortIdMappi= ng)); =20 AcpiTable table =3D { .sig =3D "IORT", .rev =3D 0, .oem_id =3D vms->oe= m_id, .oem_table_id =3D vms->oem_table_id }; + /* Table 2 The IORT */ + acpi_table_begin(&table, table_data); =20 if (vms->iommu =3D=3D VIRT_IOMMU_SMMUV3) { AcpiIortIdMapping next_range =3D {0}; @@ -330,100 +351,101 @@ build_iort(GArray *table_data, BIOSLinker *linker, = VirtMachineState *vms) nb_nodes =3D 2; /* RC, ITS */ rc_mapping_count =3D 1; } - - /* Table 2 The IORT */ - acpi_table_begin(&table, table_data); /* Number of IORT Nodes */ build_append_int_noprefix(table_data, nb_nodes, 4); + /* Offset to Array of IORT Nodes */ - build_append_int_noprefix(table_data, iort_node_offset, 4); + build_append_int_noprefix(table_data, IORT_NODE_OFFSET, 4); build_append_int_noprefix(table_data, 0, 4); /* Reserved */ =20 - /* ITS group node */ - node_size =3D sizeof(*its) + sizeof(uint32_t); - its =3D acpi_data_push(table_data, node_size); - - its->type =3D ACPI_IORT_NODE_ITS_GROUP; - its->length =3D cpu_to_le16(node_size); - its->its_count =3D cpu_to_le32(1); - its->identifiers[0] =3D 0; /* MADT translation_id */ + /* 3.1.1.3 ITS group node */ + build_append_int_noprefix(table_data, 0 /* ITS Group */, 1); /* Type */ + node_size =3D 20 /* fixed header size */ + 4 /* 1 GIC ITS Identifier = */; + build_append_int_noprefix(table_data, node_size, 2); /* Length */ + build_append_int_noprefix(table_data, 0, 1); /* Revision */ + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); /* Number of ID mappings = */ + build_append_int_noprefix(table_data, 0, 4); /* Reference to ID Array = */ + build_append_int_noprefix(table_data, 1, 4); /* Number of ITSs */ + /* GIC ITS Identifier Array */ + build_append_int_noprefix(table_data, 0 /* MADT translation_id */, 4); =20 if (vms->iommu =3D=3D VIRT_IOMMU_SMMUV3) { int irq =3D vms->irqmap[VIRT_SMMU] + ARM_SPI_BASE; =20 - /* SMMUv3 node */ - smmu_offset =3D iort_node_offset + node_size; - node_size =3D sizeof(*smmu) + sizeof(*idmap); - smmu =3D acpi_data_push(table_data, node_size); + smmu_offset =3D table_data->len - table.table_offset; + /* 3.1.1.2 SMMUv3 */ + build_append_int_noprefix(table_data, 4 /* SMMUv3 */, 1); /* Type = */ + node_size =3D SMMU_V3_ENTRY_SIZE + ID_MAPPING_ENTRY_SIZE; + build_append_int_noprefix(table_data, node_size, 2); /* Length */ + build_append_int_noprefix(table_data, 0, 1); /* Revision */ + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ + build_append_int_noprefix(table_data, 1, 4); /* Number of ID mappi= ngs */ + /* Reference to ID Array */ + build_append_int_noprefix(table_data, SMMU_V3_ENTRY_SIZE, 4); + /* Base address */ + build_append_int_noprefix(table_data, vms->memmap[VIRT_SMMU].base,= 8); + /* Flags */ + build_append_int_noprefix(table_data, 1 /* COHACC OverrideNote */,= 4); + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ + build_append_int_noprefix(table_data, 0, 8); /* VATOS address */ + /* Model */ + build_append_int_noprefix(table_data, 0 /* Generic SMMU-v3 */, 4); + build_append_int_noprefix(table_data, irq, 4); /* Event */ + build_append_int_noprefix(table_data, irq + 1, 4); /* PRI */ + build_append_int_noprefix(table_data, irq + 3, 4); /* GERR */ + build_append_int_noprefix(table_data, irq + 2, 4); /* Sync */ =20 - smmu->type =3D ACPI_IORT_NODE_SMMU_V3; - smmu->length =3D cpu_to_le16(node_size); - smmu->mapping_count =3D cpu_to_le32(1); - smmu->mapping_offset =3D cpu_to_le32(sizeof(*smmu)); - smmu->base_address =3D cpu_to_le64(vms->memmap[VIRT_SMMU].base); - smmu->flags =3D cpu_to_le32(ACPI_IORT_SMMU_V3_COHACC_OVERRIDE); - smmu->event_gsiv =3D cpu_to_le32(irq); - smmu->pri_gsiv =3D cpu_to_le32(irq + 1); - smmu->sync_gsiv =3D cpu_to_le32(irq + 2); - smmu->gerr_gsiv =3D cpu_to_le32(irq + 3); - - /* Identity RID mapping covering the whole input RID range */ - idmap =3D &smmu->id_mapping_array[0]; - idmap->input_base =3D 0; - idmap->id_count =3D cpu_to_le32(0xFFFF); - idmap->output_base =3D 0; /* output IORT node is the ITS group node (the first node) */ - idmap->output_reference =3D cpu_to_le32(iort_node_offset); + build_iort_id_mapping(table_data, 0, 0xFFFF, IORT_NODE_OFFSET); } =20 - /* Root Complex Node */ - node_size =3D sizeof(*rc) + sizeof(*idmap) * rc_mapping_count; - rc =3D acpi_data_push(table_data, node_size); + /* Table 16 Root Complex Node */ + build_append_int_noprefix(table_data, 2 /* Root complex */, 1); /* Typ= e */ + node_size =3D ROOT_COMPLEX_ENTRY_SIZE + + ID_MAPPING_ENTRY_SIZE * rc_mapping_count; + build_append_int_noprefix(table_data, node_size, 2); /* Length */ + build_append_int_noprefix(table_data, 0, 1); /* Revision */ + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ + /* Number of ID mappings */ + build_append_int_noprefix(table_data, rc_mapping_count, 4); + /* Reference to ID Array */ + build_append_int_noprefix(table_data, ROOT_COMPLEX_ENTRY_SIZE, 4); =20 - rc->type =3D ACPI_IORT_NODE_PCI_ROOT_COMPLEX; - rc->length =3D cpu_to_le16(node_size); - rc->mapping_count =3D cpu_to_le32(rc_mapping_count); - rc->mapping_offset =3D cpu_to_le32(sizeof(*rc)); + /* Table 13 Memory access properties */ + /* CCA: Cache Coherent Attribute */ + build_append_int_noprefix(table_data, 1 /* fully coherent */, 4); + build_append_int_noprefix(table_data, 0, 1); /* AH: Note Allocation Hi= nts */ + build_append_int_noprefix(table_data, 0, 2); /* Reserved */ + /* MAF: Note Memory Access Flags */ + build_append_int_noprefix(table_data, 0x3 /* CCA =3D CPM =3D DCAS =3D = 1 */, 1); =20 - /* fully coherent device */ - rc->memory_properties.cache_coherency =3D cpu_to_le32(1); - rc->memory_properties.memory_flags =3D 0x3; /* CCA =3D CPM =3D DCAS = =3D 1 */ - rc->pci_segment_number =3D 0; /* MCFG pci_segment */ + build_append_int_noprefix(table_data, 0, 4); /* ATS Attribute */ + /* MCFG pci_segment */ + build_append_int_noprefix(table_data, 0, 4); /* PCI Segment number */ =20 + /* Output Reference */ if (vms->iommu =3D=3D VIRT_IOMMU_SMMUV3) { AcpiIortIdMapping *range; =20 /* translated RIDs connect to SMMUv3 node: RC -> SMMUv3 -> ITS */ for (i =3D 0; i < smmu_idmaps->len; i++) { - idmap =3D &rc->id_mapping_array[i]; range =3D &g_array_index(smmu_idmaps, AcpiIortIdMapping, i); - - idmap->input_base =3D cpu_to_le32(range->input_base); - idmap->id_count =3D cpu_to_le32(range->id_count); - idmap->output_base =3D cpu_to_le32(range->input_base); /* output IORT node is the smmuv3 node */ - idmap->output_reference =3D cpu_to_le32(smmu_offset); + build_iort_id_mapping(table_data, range->input_base, + range->id_count, smmu_offset); } =20 /* bypassed RIDs connect to ITS group node directly: RC -> ITS */ for (i =3D 0; i < its_idmaps->len; i++) { - idmap =3D &rc->id_mapping_array[smmu_idmaps->len + i]; range =3D &g_array_index(its_idmaps, AcpiIortIdMapping, i); - - idmap->input_base =3D cpu_to_le32(range->input_base); - idmap->id_count =3D cpu_to_le32(range->id_count); - idmap->output_base =3D cpu_to_le32(range->input_base); /* output IORT node is the ITS group node (the first node) */ - idmap->output_reference =3D cpu_to_le32(iort_node_offset); + build_iort_id_mapping(table_data, range->input_base, + range->id_count, iort_node_offset); } } else { - /* Identity RID mapping covering the whole input RID range */ - idmap =3D &rc->id_mapping_array[0]; - idmap->input_base =3D cpu_to_le32(0); - idmap->id_count =3D cpu_to_le32(0xFFFF); - idmap->output_base =3D cpu_to_le32(0); /* output IORT node is the ITS group node (the first node) */ - idmap->output_reference =3D cpu_to_le32(iort_node_offset); + build_iort_id_mapping(table_data, 0, 0xFFFF, IORT_NODE_OFFSET); } =20 acpi_table_end(linker, &table); --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633454211483416.564053938336; Tue, 5 Oct 2021 10:16:51 -0700 (PDT) Received: from localhost ([::1]:39282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXo3d-0003wT-5G for importer@patchew.org; Tue, 05 Oct 2021 13:16:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvI-000253-Ic for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49121) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvF-00072Z-NQ for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:08 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-62-bR8vsMfKM1mNSy4Cn0L8-g-1; Tue, 05 Oct 2021 12:04:03 -0400 Received: by mail-wm1-f69.google.com with SMTP id n5-20020a05600c3b8500b0030d78b00850so930566wms.0 for ; Tue, 05 Oct 2021 09:04:03 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id x17sm18155197wrc.51.2021.10.05.09.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:04:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449844; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5qdBB3e2aqHCZf1beIc5KB9cT1s1yThVZMmqsQpwWFQ=; b=BKKOLb0fbSx74lGsnO9YddAo99XClhyCe5VpE0RMcV2zfNP0e1OyOuFbZKqW9e7IE+UERV HTtNf/u3rr+HmBxMak6NzE0+mAp/xzg4dt/DUH/Z1Bw/dajdn7/wGMLpfR6r/zBLjyJ9hu HzdM2+fWxSi8glxGDyYV/8ZzGukxO6U= X-MC-Unique: bR8vsMfKM1mNSy4Cn0L8-g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=5qdBB3e2aqHCZf1beIc5KB9cT1s1yThVZMmqsQpwWFQ=; b=0xmO5MZQD7iB5MXWSU16zcDBD3giiKULOYJNUChWhJBgD7jLgx3Fk7lueVQKgEmOfx OC0IHUxQOWwiDGmyCC/X87DJ4X8dgKpp4PHn2Sho/kQuSZ521QLTLxihohb6ohY5SnWo TPXeAqdvJkw1mZV9rHbwyD0RCfVazsxLqPRxWvJgfnty/KoE4S//34kMEpNyY9tMuhkz jWv0x/wYgq4CMp/dptwVwCi3xGTCZb1wKLJ0l5T5RoUMMcet2Xz9MmWN+0fTJk4EsfaS /sN0oNAw8Nvw5NNQXQ0oECcTwQ4TZzDSfoT/JI8TG+GLCC+xCjAd2rbOYEYrV7yJpve8 soHA== X-Gm-Message-State: AOAM531J5hU7tH1Xxh4ycUpRBketBzsMY63Xr0pQCIZn5m8wERD6+htW WaFh2uf+Q3Dr/hfW5TQLWGR5jp3FK0yJbBdIMdRUN/nPgpI8TfipfTwWmNH1nBxv607RMDmm/gM Kwxu35LXoTh0FHg5FaUCyn5sSsOu8AJ24uKC97SbG4w+QbBxuP4zYnsjnAiRJ X-Received: by 2002:a5d:47c3:: with SMTP id o3mr23441112wrc.25.1633449841871; Tue, 05 Oct 2021 09:04:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw92VFnOWKWtcUtjUlKeGTG14hWDNZNck+otddZIWTOnp3MA9Shltq9UgsvAIQA8UTNxILymA== X-Received: by 2002:a5d:47c3:: with SMTP id o3mr23441075wrc.25.1633449841644; Tue, 05 Oct 2021 09:04:01 -0700 (PDT) Date: Tue, 5 Oct 2021 12:03:57 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 44/57] acpi: arm/virt: build_spcr: fix invalid cast Message-ID: <20211005155946.513818-45-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eric Auger , Shannon Zhao , qemu-arm@nongnu.org, Ani Sinha , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633454213705100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov implicit cast to structure uint8_t member didn't raise error when assigning value from incorrect enum, but when using build_append_gas() (next patch) it will error out with (clang): implicit conversion from enumeration type 'AmlRegionSpace' to different enumeration type 'AmlAddressSpace' fix cast error by using correct AML_AS_SYSTEM_MEMORY enum Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-31-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/arm/virt-acpi-build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 8c382915a9..7b8706b305 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -465,7 +465,7 @@ build_spcr(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) =20 spcr->interface_type =3D 0x3; /* ARM PL011 UART */ =20 - spcr->base_address.space_id =3D AML_SYSTEM_MEMORY; + spcr->base_address.space_id =3D AML_AS_SYSTEM_MEMORY; spcr->base_address.bit_width =3D 8; spcr->base_address.bit_offset =3D 0; spcr->base_address.access_width =3D 1; --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633452727943370.9796426121201; Tue, 5 Oct 2021 09:52:07 -0700 (PDT) Received: from localhost ([::1]:45492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnfi-0001qC-Pr for importer@patchew.org; Tue, 05 Oct 2021 12:52:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmva-0002KD-HQ for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:33150) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvI-00075D-WB for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:26 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-65-AuTYOAOPOQakrhFSfmJtOA-1; Tue, 05 Oct 2021 12:04:07 -0400 Received: by mail-wm1-f70.google.com with SMTP id n5-20020a05600c3b8500b0030d78b00850so930638wms.0 for ; Tue, 05 Oct 2021 09:04:06 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id r26sm2300554wmh.35.2021.10.05.09.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:04:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=umsrLqiFttFCgIiszM/ZAkN29JEPz4rp7f/6mGF1LTk=; b=i0API5ol6qPI/Xw0fPxf41UZgIac2vLHI1hwkm7fxXh83/UOuvVOFfrX5bz0KBrUUUBeW7 D8YRtqKN2Fysj8x2mmT4F//er0UveuGYLq4BAYpA2ISRjVccUMKdKYHgos8qRIewmL/wDB lvR8TB/l4i7tfilkFew30BJQaXAZLHs= X-MC-Unique: AuTYOAOPOQakrhFSfmJtOA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=umsrLqiFttFCgIiszM/ZAkN29JEPz4rp7f/6mGF1LTk=; b=WWUlmRfx+0wKjJpol1gUcvbky3XZwkGkEMoifMhH3jR0EsIj5FYkL29iT0Tx0btud1 hrMh9X70ashkaxD09zHxztowJvybwR1cibjMOXR2JsW7W2gzQIhSCKBY4KqsxY1CetFL t2mH8DP/8e8dfLn9KPOfuVN/Zn40lJVwewyjfZyQSkaXxI7a+Z7VNd9jr4sB9Su7iiwk kHJJT5AHNAnxdpc6HIcvNnnolljytSmIYIZLA2h1gSDjhC5woo4zEzUKrb1OSiAWzd2U dp1MVHck5ev/yJwTaBNwghYpGhbNYPPoAiRoubm5oD9q4C05toM6pHPQV49FzsH2U1VU bxtw== X-Gm-Message-State: AOAM53207Hcxxy3KxLyfQxzzA+uPSHb/maM5XbC1i+nCZZKoh2B+ZpT1 qugntymDvEVUtOfwBomWAAEGrDGcqPkgFILjESDDKcwwxCkMgsYzTugpQW1PQojDRLRIVDLgHNS nDP+gZyxUb1dNuAwmX2dSqYpkDr/bmzbT6ezTfBnzdELRX1EjONsSaGvQLEbu X-Received: by 2002:a5d:4911:: with SMTP id x17mr19457744wrq.173.1633449845460; Tue, 05 Oct 2021 09:04:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysYbvjQiQCB9I3QDDop3dVJMsTINcmHrozkPXGABQ/vs8lrHGT8qMUm1a4n1eU0ifqUs0hKA== X-Received: by 2002:a5d:4911:: with SMTP id x17mr19457695wrq.173.1633449845148; Tue, 05 Oct 2021 09:04:05 -0700 (PDT) Date: Tue, 5 Oct 2021 12:04:01 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 45/57] acpi: arm/virt: build_spcr: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-46-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eric Auger , Shannon Zhao , qemu-arm@nongnu.org, Ani Sinha , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452729168100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. while at it, replace packed structure with endian agnostic build_append_FOO() API. PS: Spec is Microsoft hosted, however 1.02 is no where to be found (MS lists only the current revision) and the current revision is 1.07, so bring comments in line with 1.07 as this is the only available spec. There is no content change between originally implemented 1.02 (using QEMU code as reference) and 1.07. The only change is renaming 'Reserved2' field to 'Language', with the same 0 value. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-32-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 32 ----------------- hw/arm/virt-acpi-build.c | 68 ++++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 59 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 6f2f08a9de..012c4ffb3a 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -117,38 +117,6 @@ typedef struct AcpiFadtData { #define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0) #define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1) =20 -/* - * Serial Port Console Redirection Table (SPCR), Rev. 1.02 - * - * For .interface_type see Debug Port Table 2 (DBG2) serial port - * subtypes in Table 3, Rev. May 22, 2012 - */ -struct AcpiSerialPortConsoleRedirection { - ACPI_TABLE_HEADER_DEF - uint8_t interface_type; - uint8_t reserved1[3]; - struct AcpiGenericAddress base_address; - uint8_t interrupt_types; - uint8_t irq; - uint32_t gsi; - uint8_t baud; - uint8_t parity; - uint8_t stopbits; - uint8_t flowctrl; - uint8_t term_type; - uint8_t reserved2; - uint16_t pci_device_id; - uint16_t pci_vendor_id; - uint8_t pci_bus; - uint8_t pci_slot; - uint8_t pci_func; - uint32_t pci_flags; - uint8_t pci_seg; - uint32_t reserved3; -} QEMU_PACKED; -typedef struct AcpiSerialPortConsoleRedirection - AcpiSerialPortConsoleRedirection; - /* * ACPI 1.0 Firmware ACPI Control Structure (FACS) */ diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 7b8706b305..7b79fae0ad 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -453,39 +453,53 @@ build_iort(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) g_array_free(its_idmaps, true); } =20 +/* + * Serial Port Console Redirection Table (SPCR) + * Rev: 1.07 + */ static void build_spcr(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { - AcpiSerialPortConsoleRedirection *spcr; - const MemMapEntry *uart_memmap =3D &vms->memmap[VIRT_UART]; - int irq =3D vms->irqmap[VIRT_UART] + ARM_SPI_BASE; - int spcr_start =3D table_data->len; + AcpiTable table =3D { .sig =3D "SPCR", .rev =3D 2, .oem_id =3D vms->oe= m_id, + .oem_table_id =3D vms->oem_table_id }; =20 - spcr =3D acpi_data_push(table_data, sizeof(*spcr)); + acpi_table_begin(&table, table_data); =20 - spcr->interface_type =3D 0x3; /* ARM PL011 UART */ + /* Interface Type */ + build_append_int_noprefix(table_data, 3, 1); /* ARM PL011 UART */ + build_append_int_noprefix(table_data, 0, 3); /* Reserved */ + /* Base Address */ + build_append_gas(table_data, AML_AS_SYSTEM_MEMORY, 8, 0, 1, + vms->memmap[VIRT_UART].base); + /* Interrupt Type */ + build_append_int_noprefix(table_data, + (1 << 3) /* Bit[3] ARMH GIC interrupt */, 1); + build_append_int_noprefix(table_data, 0, 1); /* IRQ */ + /* Global System Interrupt */ + build_append_int_noprefix(table_data, + vms->irqmap[VIRT_UART] + ARM_SPI_BASE, 4); + build_append_int_noprefix(table_data, 3 /* 9600 */, 1); /* Baud Rate */ + build_append_int_noprefix(table_data, 0 /* No Parity */, 1); /* Parity= */ + /* Stop Bits */ + build_append_int_noprefix(table_data, 1 /* 1 Stop bit */, 1); + /* Flow Control */ + build_append_int_noprefix(table_data, + (1 << 1) /* RTS/CTS hardware flow control */, 1); + /* Terminal Type */ + build_append_int_noprefix(table_data, 0 /* VT100 */, 1); + build_append_int_noprefix(table_data, 0, 1); /* Language */ + /* PCI Device ID */ + build_append_int_noprefix(table_data, 0xffff /* not a PCI device*/, 2); + /* PCI Vendor ID */ + build_append_int_noprefix(table_data, 0xffff /* not a PCI device*/, 2); + build_append_int_noprefix(table_data, 0, 1); /* PCI Bus Number */ + build_append_int_noprefix(table_data, 0, 1); /* PCI Device Number */ + build_append_int_noprefix(table_data, 0, 1); /* PCI Function Number */ + build_append_int_noprefix(table_data, 0, 4); /* PCI Flags */ + build_append_int_noprefix(table_data, 0, 1); /* PCI Segment */ + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ =20 - spcr->base_address.space_id =3D AML_AS_SYSTEM_MEMORY; - spcr->base_address.bit_width =3D 8; - spcr->base_address.bit_offset =3D 0; - spcr->base_address.access_width =3D 1; - spcr->base_address.address =3D cpu_to_le64(uart_memmap->base); - - spcr->interrupt_types =3D (1 << 3); /* Bit[3] ARMH GIC interrupt */ - spcr->gsi =3D cpu_to_le32(irq); /* Global System Interrupt */ - - spcr->baud =3D 3; /* Baud Rate: 3 =3D 9600 */ - spcr->parity =3D 0; /* No Parity */ - spcr->stopbits =3D 1; /* 1 Stop bit */ - spcr->flowctrl =3D (1 << 1); /* Bit[1] =3D RTS/CTS hardware flow c= ontrol */ - spcr->term_type =3D 0; /* Terminal Type: 0 =3D VT100 */ - - spcr->pci_device_id =3D 0xffff; /* PCI Device ID: not a PCI device */ - spcr->pci_vendor_id =3D 0xffff; /* PCI Vendor ID: not a PCI device */ - - build_header(linker, table_data, (void *)(table_data->data + spcr_star= t), - "SPCR", table_data->len - spcr_start, 2, vms->oem_id, - vms->oem_table_id); + acpi_table_end(linker, &table); } =20 /* --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633454581774160.69371322465452; Tue, 5 Oct 2021 10:23:01 -0700 (PDT) Received: from localhost ([::1]:58498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXo9c-0008UL-Ga for importer@patchew.org; Tue, 05 Oct 2021 13:23:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvR-0002BK-Fk for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48805) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvP-0007Ar-Gy for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:17 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-123-6EIWE64eM82PEf8WQvtBHw-1; Tue, 05 Oct 2021 12:04:12 -0400 Received: by mail-wm1-f69.google.com with SMTP id p63-20020a1c2942000000b0030ccf0767baso1494402wmp.6 for ; Tue, 05 Oct 2021 09:04:12 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id r2sm2467543wmq.28.2021.10.05.09.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:04:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+Iuc8htto9LuwnN0+7rdvNY/Z62qo8OZ/1lpPAB9rng=; b=N0+33Rl2dKvpyZLryRB5CBk5KS+WcgoZG/By3/LW64D2cn6fcWSzFlXs7wNmjdrXzlU9+T ej5BelvlUnJwERQYn9WIR/dbNR2eO2R9kkKOcoRzHdJpvneebWDIMYw0Bktca+chF2eLvb Cf3Vdhebw0su2WeGhLL9ufc+qfhx6Dc= X-MC-Unique: 6EIWE64eM82PEf8WQvtBHw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=+Iuc8htto9LuwnN0+7rdvNY/Z62qo8OZ/1lpPAB9rng=; b=3jbiTRI7D21fDz5TqHRGabikvJcZhH1qQU85lrbR4d5SeeMvLPPZV4enkIQO+ss0Uy CXGe7ytz9KKQWhEtc+e+tauWozXheaYbuxPcmt5ne/Cf4rrkWNf2i1O+sSBCum1MapQW 2v+ZnVcT9VAmlHeuSbEIg4DMxvCT6JJ0gk4CoY3YPUDojElbdzKIc3urVJugRd7YhDsB WYMgFqeSKCeNjQQ6q6ver811W52OFqg3BCf2WdOnXbeAR7xGgmN0su3qw/OG9zmHwbev SVc2kJTBZmEjAJEtVxzR3tNseJkXv/YncFqxMTu8EcnzH0G7rkQ9U0Fh1VsJK01ru+6S d6WA== X-Gm-Message-State: AOAM530KudpLRKL0RU5rHCNe5e/Z3aBPwtMb8dj1FoMvRzsACL5387/i lxkHtlcFvB/KC4U3Zd68z95aqT8DCZu+J1JHzc+6S7P5Geg+nHnuGhSjijcQIT2Eek+VBEPBop5 n6DkWqrG46Kmu0pJuslo2EGnzvplWONnAvKybSclHwNul85lwhqIxIPv3l78a X-Received: by 2002:a05:6000:1546:: with SMTP id 6mr22639347wry.305.1633449849478; Tue, 05 Oct 2021 09:04:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzu8QI5q0k0T1ol0fPzCu+hovsqb79IfgSONjXsrHT+x+m6KGBIbyaRGLjdxy+RFeZJ79Pymw== X-Received: by 2002:a05:6000:1546:: with SMTP id 6mr22639251wry.305.1633449849192; Tue, 05 Oct 2021 09:04:09 -0700 (PDT) Date: Tue, 5 Oct 2021 12:04:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 46/57] acpi: arm/virt: build_gtdt: use acpi_table_begin()/acpi_table_end() instead of build_header() Message-ID: <20211005155946.513818-47-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eric Auger , Shannon Zhao , qemu-arm@nongnu.org, Ani Sinha , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633454582956100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it replaces error-prone pointer arithmetic for build_header() API, with 2 calls to start and finish table creation, which hides offsets magic from API user. while at it, replace packed structure with endian agnostic build_append_FOO() API. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-33-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 25 ------------- hw/arm/virt-acpi-build.c | 75 ++++++++++++++++++++++++------------- 2 files changed, 48 insertions(+), 52 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 012c4ffb3a..0b375e7589 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -131,29 +131,4 @@ struct AcpiFacsDescriptorRev1 { } QEMU_PACKED; typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1; =20 -/* - * Generic Timer Description Table (GTDT) - */ -#define ACPI_GTDT_INTERRUPT_MODE_LEVEL (0 << 0) -#define ACPI_GTDT_INTERRUPT_MODE_EDGE (1 << 0) -#define ACPI_GTDT_CAP_ALWAYS_ON (1 << 2) - -struct AcpiGenericTimerTable { - ACPI_TABLE_HEADER_DEF - uint64_t counter_block_addresss; - uint32_t reserved; - uint32_t secure_el1_interrupt; - uint32_t secure_el1_flags; - uint32_t non_secure_el1_interrupt; - uint32_t non_secure_el1_flags; - uint32_t virtual_timer_interrupt; - uint32_t virtual_timer_flags; - uint32_t non_secure_el2_interrupt; - uint32_t non_secure_el2_flags; - uint64_t counter_read_block_address; - uint32_t platform_timer_count; - uint32_t platform_timer_offset; -} QEMU_PACKED; -typedef struct AcpiGenericTimerTable AcpiGenericTimerTable; - #endif diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 7b79fae0ad..6cec97352b 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -559,40 +559,61 @@ build_srat(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) acpi_table_end(linker, &table); } =20 -/* GTDT */ +/* + * ACPI spec, Revision 5.1 + * 5.2.24 Generic Timer Description Table (GTDT) + */ static void build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); - int gtdt_start =3D table_data->len; - AcpiGenericTimerTable *gtdt; - uint32_t irqflags; + /* + * Table 5-117 Flag Definitions + * set only "Timer interrupt Mode" and assume "Timer Interrupt + * polarity" bit as '0: Interrupt is Active high' + */ + uint32_t irqflags =3D vmc->claim_edge_triggered_timers ? + 1 : /* Interrupt is Edge triggered */ + 0; /* Interrupt is Level triggered */ + AcpiTable table =3D { .sig =3D "GTDT", .rev =3D 2, .oem_id =3D vms->oe= m_id, + .oem_table_id =3D vms->oem_table_id }; =20 - if (vmc->claim_edge_triggered_timers) { - irqflags =3D ACPI_GTDT_INTERRUPT_MODE_EDGE; - } else { - irqflags =3D ACPI_GTDT_INTERRUPT_MODE_LEVEL; - } + acpi_table_begin(&table, table_data); =20 - gtdt =3D acpi_data_push(table_data, sizeof *gtdt); - /* The interrupt values are the same with the device tree when adding = 16 */ - gtdt->secure_el1_interrupt =3D cpu_to_le32(ARCH_TIMER_S_EL1_IRQ + 16); - gtdt->secure_el1_flags =3D cpu_to_le32(irqflags); + /* CntControlBase Physical Address */ + /* FIXME: invalid value, should be 0xFFFFFFFFFFFFFFFF if not impl. ? */ + build_append_int_noprefix(table_data, 0, 8); + build_append_int_noprefix(table_data, 0, 4); /* Reserved */ + /* + * FIXME: clarify comment: + * The interrupt values are the same with the device tree when adding = 16 + */ + /* Secure EL1 timer GSIV */ + build_append_int_noprefix(table_data, ARCH_TIMER_S_EL1_IRQ + 16, 4); + /* Secure EL1 timer Flags */ + build_append_int_noprefix(table_data, irqflags, 4); + /* Non-Secure EL1 timer GSIV */ + build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL1_IRQ + 16, 4); + /* Non-Secure EL1 timer Flags */ + build_append_int_noprefix(table_data, irqflags | + 1UL << 2, /* Always-on Capability */ + 4); + /* Virtual timer GSIV */ + build_append_int_noprefix(table_data, ARCH_TIMER_VIRT_IRQ + 16, 4); + /* Virtual Timer Flags */ + build_append_int_noprefix(table_data, irqflags, 4); + /* Non-Secure EL2 timer GSIV */ + build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL2_IRQ + 16, 4); + /* Non-Secure EL2 timer Flags */ + build_append_int_noprefix(table_data, irqflags, 4); + /* CntReadBase Physical address */ + build_append_int_noprefix(table_data, 0, 8); + /* Platform Timer Count */ + build_append_int_noprefix(table_data, 0, 4); + /* Platform Timer Offset */ + build_append_int_noprefix(table_data, 0, 4); =20 - gtdt->non_secure_el1_interrupt =3D cpu_to_le32(ARCH_TIMER_NS_EL1_IRQ += 16); - gtdt->non_secure_el1_flags =3D cpu_to_le32(irqflags | - ACPI_GTDT_CAP_ALWAYS_ON); - - gtdt->virtual_timer_interrupt =3D cpu_to_le32(ARCH_TIMER_VIRT_IRQ + 16= ); - gtdt->virtual_timer_flags =3D cpu_to_le32(irqflags); - - gtdt->non_secure_el2_interrupt =3D cpu_to_le32(ARCH_TIMER_NS_EL2_IRQ += 16); - gtdt->non_secure_el2_flags =3D cpu_to_le32(irqflags); - - build_header(linker, table_data, - (void *)(table_data->data + gtdt_start), "GTDT", - table_data->len - gtdt_start, 2, vms->oem_id, - vms->oem_table_id); + acpi_table_end(linker, &table); } =20 /* --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633452390295712.4071300431071; Tue, 5 Oct 2021 09:46:30 -0700 (PDT) Received: from localhost ([::1]:59682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnaH-00008u-5X for importer@patchew.org; Tue, 05 Oct 2021 12:46:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvW-0002FO-PW for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52462) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvU-0007Fb-Pe for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:22 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-572-NOll4cHTMXWA_zv7nIw2wQ-1; Tue, 05 Oct 2021 12:04:16 -0400 Received: by mail-wm1-f72.google.com with SMTP id f11-20020a7bcd0b000000b0030d72d5d0bcso1460702wmj.7 for ; Tue, 05 Oct 2021 09:04:15 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id q10sm2275160wmq.12.2021.10.05.09.04.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449860; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0PANg3UMhdpM5Nn2b2Ias45rHv5Z0AE9cqmvr/cfJ94=; b=eRQpuxlY8K+MdDtMspamtD41CrRqn558nptFr1kFeEODM0zjiSxhf2eh5zulPGsc2IQohl +6dda6EjSfIOsHCQg9tTzUsXy444JpuFFZoWAVE6TSxcaI5E/zd4Idl5ZrSClzTF/vztg8 sRI6NlSebJq8w4ZvmcSSduqLut3TdwQ= X-MC-Unique: NOll4cHTMXWA_zv7nIw2wQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0PANg3UMhdpM5Nn2b2Ias45rHv5Z0AE9cqmvr/cfJ94=; b=0fzvbVExdyslOAflfPMdzUNSMmwL/bXEOeOb2U5D9KoOC2pqDb4rV2IvknOo8Gh6hl 9eP5v9oNc6AhlycgpnGRNW77FzeEQnAkpUpYK8QfIngUxGiSwfg7MNYQjIunyaHypDmy a/i4Y7pUJFk/npTTP7KteCyt6ILbqx5eNWHvh+BhgrJz0kTUapouBaRObLIAMV+fU7Qg 1awdD9iex0ptmay3zc4dDrGM/04jNUeQ5lY2FtMAFT8SWDcZnIy0WKKzWz6uLHvcMoIB sDLGE+L26FcAq/4CHP1FR397DVprW0XPiH+3hjd1EkOCv8+IPv3TpM+cWoFjxXfZsiYC x2mA== X-Gm-Message-State: AOAM531iXqdywvRlsEGzQ2K+kWA7o7m3VYhlryfVsyy6R8+ttVg2SFCv WgCGcMNlK0scOZ2rM6miFFEogVu/HHZMRFkOp5SnoJx1JSMLY0/h2fjd5bbnJ9iiNVVX2SycABH SfBEe/z5dle9kIR1j9VP+Wh9OQlpvIjC6gDt3xBjZOg7IGOzvz/0R6VTrS6oj X-Received: by 2002:a1c:f219:: with SMTP id s25mr4234734wmc.31.1633449854129; Tue, 05 Oct 2021 09:04:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0+PxQeHiVrzwrdMfuz55qMMgu71CBU9mb4TG7AwDd9Lg44xU2W9rV9iXsUCRehAal01Yw1Q== X-Received: by 2002:a1c:f219:: with SMTP id s25mr4234700wmc.31.1633449853861; Tue, 05 Oct 2021 09:04:13 -0700 (PDT) Date: Tue, 5 Oct 2021 12:04:09 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 47/57] acpi: build_facs: use build_append_int_noprefix() API to compose table Message-ID: <20211005155946.513818-48-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , Eric Auger , Igor Mammedov , Ani Sinha , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452392234100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Drop usage of packed structures and explicit endian conversions when building table and use endian agnostic build_append_int_noprefix() API to build it. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-34-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 14 -------------- hw/i386/acpi-build.c | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 0b375e7589..1a0774edd6 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -117,18 +117,4 @@ typedef struct AcpiFadtData { #define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0) #define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1) =20 -/* - * ACPI 1.0 Firmware ACPI Control Structure (FACS) - */ -struct AcpiFacsDescriptorRev1 { - uint32_t signature; /* ACPI Signature */ - uint32_t length; /* Length of structure, in bytes */ - uint32_t hardware_signature; /* Hardware configuration signature */ - uint32_t firmware_waking_vector; /* ACPI OS waking vector */ - uint32_t global_lock; /* Global Lock */ - uint32_t flags; - uint8_t resverved3 [40]; /* Reserved - must be zero */ -} QEMU_PACKED; -typedef struct AcpiFacsDescriptorRev1 AcpiFacsDescriptorRev1; - #endif diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index d9e2b5dc30..81418b7911 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -345,13 +345,23 @@ static void acpi_align_size(GArray *blob, unsigned al= ign) g_array_set_size(blob, ROUND_UP(acpi_data_len(blob), align)); } =20 -/* FACS */ +/* + * ACPI spec 1.0b, + * 5.2.6 Firmware ACPI Control Structure + */ static void build_facs(GArray *table_data) { - AcpiFacsDescriptorRev1 *facs =3D acpi_data_push(table_data, sizeof *fa= cs); - memcpy(&facs->signature, "FACS", 4); - facs->length =3D cpu_to_le32(sizeof(*facs)); + const char *sig =3D "FACS"; + const uint8_t reserved[40] =3D {}; + + g_array_append_vals(table_data, sig, 4); /* Signature */ + build_append_int_noprefix(table_data, 64, 4); /* Length */ + build_append_int_noprefix(table_data, 0, 4); /* Hardware Signature */ + build_append_int_noprefix(table_data, 0, 4); /* Firmware Waking Vector= */ + build_append_int_noprefix(table_data, 0, 4); /* Global Lock */ + build_append_int_noprefix(table_data, 0, 4); /* Flags */ + g_array_append_vals(table_data, reserved, 40); /* Reserved */ } =20 static void build_append_pcihp_notify_entry(Aml *method, int slot) --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633452591290680.5476106356771; Tue, 5 Oct 2021 09:49:51 -0700 (PDT) Received: from localhost ([::1]:39842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXndW-0006HU-1v for importer@patchew.org; Tue, 05 Oct 2021 12:49:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvY-0002HX-O8 for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21727) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvV-0007GI-Gw for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:24 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-183-2reFsZ1BOPu3H7tbVG5HZw-1; Tue, 05 Oct 2021 12:04:19 -0400 Received: by mail-wm1-f72.google.com with SMTP id 13-20020a05600c230d00b0030d762b5832so960641wmo.9 for ; Tue, 05 Oct 2021 09:04:19 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id t15sm8837659wru.6.2021.10.05.09.04.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:04:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449860; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=V0izss/WrIaICyHQd8e5VrOUHntowQ9kw1uV7gNZ/NQ=; b=KW7pS12apofR3gbE8DpYT7olhnQrRzozuQlHy1TH221R6GqoDF4adMddgRgGfhJS+0SQ+7 mdR58kOF6h6DHuAKxCnJWT1u5cbTY+AP0u/bTDUc1awFvYNY15oTAuTFylTxNh2wOnjIzc bWwNKZJ4kfCG/C/g3sF4OJUbHITQyRs= X-MC-Unique: 2reFsZ1BOPu3H7tbVG5HZw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=V0izss/WrIaICyHQd8e5VrOUHntowQ9kw1uV7gNZ/NQ=; b=UrdY6V+TZMrq6LXo0GwLdV7pdiwVL1kGoXnHDadq30MF4TqAX24RF3crRdtOeghXnJ fl57SwaUMOkq1hH5XUzJSwkMy08QVrw5gKTQmq3FGfUwIxha5SrwcYUTFSqnsx9RYwQE Y4q9arqU0ePWKxbnceN2u7E6j1AljP3xp3BQQWq2VOhQtyKfG2rXz81oH3mzYlLojH8+ IhlM7Pqf6e53Dm5KISwHwTxlGq8m5yDcRP8jzmYxA9UkJeIIEmBBXto0+ofFchrLJn+i j6Ig1o1Qlx4kN9qqoCL3uSgoWb6Ois0K5Kz5USdPVlhEuBNPy2Yjaqs9K0kJJz/eePGZ +MTA== X-Gm-Message-State: AOAM533fkKeCPIG/J61iy/OGEYNZ0kMIGbMftWvm++180+6MM0c2ecS9 XhI7rqGgdgI4k/GVEsXBLjPI93ILj1GKwySYad3kSQNsFTovZZ2xzq48XSTTHGPoCE/Rb/FggIQ J4HCqZVFc2K/m96ia08DjiXa7UFw00MuUgj5luRLrzKemCt/wKvmE5YiYLxKy X-Received: by 2002:a7b:cf18:: with SMTP id l24mr2414287wmg.162.1633449857934; Tue, 05 Oct 2021 09:04:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxhWOfRJzlI5eT02zEFPNCR/StX2cdFhLmBzBChMMheznb6DO0tUzCELNTrL7qU1vWsgqFYQ== X-Received: by 2002:a7b:cf18:: with SMTP id l24mr2414250wmg.162.1633449857654; Tue, 05 Oct 2021 09:04:17 -0700 (PDT) Date: Tue, 5 Oct 2021 12:04:14 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 48/57] acpi: remove no longer used build_header() Message-ID: <20211005155946.513818-49-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Eric Auger , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452592497100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-35-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 25 ------------------------- include/hw/acpi/aml-build.h | 4 ---- hw/acpi/aml-build.c | 23 ----------------------- 3 files changed, 52 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 1a0774edd6..ee733840aa 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -48,31 +48,6 @@ typedef struct AcpiRsdpData { unsigned *xsdt_tbl_offset; } AcpiRsdpData; =20 -/* Table structure from Linux kernel (the ACPI tables are under the - BSD license) */ - - -#define ACPI_TABLE_HEADER_DEF /* ACPI common table header */ \ - uint32_t signature; /* ACPI signature (4 ASCII characters) */= \ - uint32_t length; /* Length of table, in bytes, includi= ng header */ \ - uint8_t revision; /* ACPI Specification minor version #= */ \ - uint8_t checksum; /* To make sum of entire table =3D=3D= 0 */ \ - uint8_t oem_id[6] \ - QEMU_NONSTRING; /* OEM identification */ \ - uint8_t oem_table_id[8] \ - QEMU_NONSTRING; /* OEM table identification */ \ - uint32_t oem_revision; /* OEM revision number */ \ - uint8_t asl_compiler_id[4] \ - QEMU_NONSTRING; /* ASL compiler vendor ID */ \ - uint32_t asl_compiler_revision; /* ASL compiler revision number */ - - -/* ACPI common table header */ -struct AcpiTableHeader { - ACPI_TABLE_HEADER_DEF -} QEMU_PACKED; -typedef struct AcpiTableHeader AcpiTableHeader; - struct AcpiGenericAddress { uint8_t space_id; /* Address space where struct or register exi= sts */ uint8_t bit_width; /* Size in bits of given register */ diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 6e1f42e119..3cf6f2c1b9 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -444,10 +444,6 @@ void acpi_table_begin(AcpiTable *desc, GArray *array); */ void acpi_table_end(BIOSLinker *linker, AcpiTable *table); =20 -void -build_header(BIOSLinker *linker, GArray *table_data, - AcpiTableHeader *h, const char *sig, int len, uint8_t rev, - const char *oem_id, const char *oem_table_id); void *acpi_data_push(GArray *table_data, unsigned size); unsigned acpi_data_len(GArray *table); void acpi_add_table(GArray *table_offsets, GArray *table_data); diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index c0f339847a..76af0ebaf9 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1754,29 +1754,6 @@ void acpi_table_end(BIOSLinker *linker, AcpiTable *d= esc) desc->table_offset, table_len, desc->table_offset + checksum_offse= t); } =20 -void -build_header(BIOSLinker *linker, GArray *table_data, - AcpiTableHeader *h, const char *sig, int len, uint8_t rev, - const char *oem_id, const char *oem_table_id) -{ - unsigned tbl_offset =3D (char *)h - table_data->data; - unsigned checksum_offset =3D (char *)&h->checksum - table_data->data; - memcpy(&h->signature, sig, 4); - h->length =3D cpu_to_le32(len); - h->revision =3D rev; - - strpadcpy((char *)h->oem_id, sizeof h->oem_id, oem_id, ' '); - strpadcpy((char *)h->oem_table_id, sizeof h->oem_table_id, - oem_table_id, ' '); - - h->oem_revision =3D cpu_to_le32(1); - memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME8, 4); - h->asl_compiler_revision =3D cpu_to_le32(1); - /* Checksum to be filled in by Guest linker */ - bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE, - tbl_offset, len, checksum_offset); -} - void *acpi_data_push(GArray *table_data, unsigned size) { unsigned off =3D table_data->len; --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633454837577123.199513153888; Tue, 5 Oct 2021 10:27:17 -0700 (PDT) Received: from localhost ([::1]:39136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXoDk-00062s-J6 for importer@patchew.org; Tue, 05 Oct 2021 13:27:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvn-0002Oa-A7 for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42951) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvZ-0007J6-IH for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:39 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-67-qNFTKqcYO_WzsOuVKZihyg-1; Tue, 05 Oct 2021 12:04:23 -0400 Received: by mail-wm1-f70.google.com with SMTP id d7-20020a1c7307000000b0030d6982305bso1497637wmb.5 for ; Tue, 05 Oct 2021 09:04:22 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id j6sm4442102wrh.76.2021.10.05.09.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449864; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=irel6CMQ0akhtmSUsZfVhTgoEW0RWATql/OJv9DFUtE=; b=ZqbJcGa+8CSpgA96HSJ6JMZQ5kjD+dNPVKwSAMDonpd0c7aDPx+GKWBxGsFmOZDWuVctYF plfT66QymSqDk5286RuiUfueDcHwqHG8Veje1/SnzxWrzkmZE1j2VDAqn2v4XtwIDe1t49 4FFg2bhlpuSwwFEGCJbByLEYax2sqjg= X-MC-Unique: qNFTKqcYO_WzsOuVKZihyg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=irel6CMQ0akhtmSUsZfVhTgoEW0RWATql/OJv9DFUtE=; b=T2h8gz/FUk7vshX1YTmtDHxq9wId93L66CRSaKENZZRGTG3iq/Aj+cu6XO5KVHEev7 SOvnM9zWaKmNsNWmPRvZQzrUW1IR/LnT3oVj/le6MmrQJggLF4/4UtoCKYomWjlx1NTb qVrV5HhNY5oINJ7WTkAKid54OR4ZbVimO3Ci2NvsxmfAUDi+2Ay7RmnD/6JP579VzDij u2BtSmOqiDiRMgIhcT2a4DK+EyUL3k59/FhfIkelk84FuIfxzOT284H2UrSza5epg8hz xBS4RY0uDT3XDVf+qqUMNcifu8STOqAcjQwGRjdzynanzt3oO8CshqB297xia7p7oRUL liZA== X-Gm-Message-State: AOAM53122Y4tVxDPZWasqPNcBHhFT2Ua37ahvyQMULv85568/hXDI0In RRZ2ru5cV7/0wWkR3JyQjvIZnnzVuZQP3iEnq+y2KxBWYxcWJ4sRHxDw8R6aiqCmyZbL6qbAi6s 8rOymv0g1r5lslC1k3YHvtmwRMIccr/4ELzsqEG0GoZ6mOamb7+QxfMwglE8a X-Received: by 2002:adf:a35d:: with SMTP id d29mr22069296wrb.318.1633449861504; Tue, 05 Oct 2021 09:04:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLnofy00wNYxEaw1K4Z7Re2lwCAhBoTY2Ns1elMXQh5XC+adJUHfWSCFEyjmEh0aP592zifg== X-Received: by 2002:adf:a35d:: with SMTP id d29mr22069262wrb.318.1633449861210; Tue, 05 Oct 2021 09:04:21 -0700 (PDT) Date: Tue, 5 Oct 2021 12:04:17 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 49/57] acpi: AcpiGenericAddress no longer used to map/access fields of MMIO, drop packed attribute Message-ID: <20211005155946.513818-50-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Eric Auger , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633454839411100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Message-Id: <20210924122802.1455362-36-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index ee733840aa..c97e8633ad 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -55,7 +55,7 @@ struct AcpiGenericAddress { uint8_t access_width; /* ACPI 3.0: Minimum Access size (ACPI 3.0), ACPI 2.0: Reserved, Table 5-1 */ uint64_t address; /* 64-bit address of struct or register */ -} QEMU_PACKED; +}; =20 typedef struct AcpiFadtData { struct AcpiGenericAddress pm1a_cnt; /* PM1a_CNT_BLK */ --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633453123796324.79767488688026; Tue, 5 Oct 2021 09:58:43 -0700 (PDT) Received: from localhost ([::1]:34962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnm6-0005JA-Gd for importer@patchew.org; Tue, 05 Oct 2021 12:58:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48244) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmve-0002NF-AJ for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50633) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvc-0007Mo-No for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:30 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-396-dTt4Cu-tMH-myaJh5-Uu8Q-1; Tue, 05 Oct 2021 12:04:26 -0400 Received: by mail-wr1-f71.google.com with SMTP id r16-20020adfb1d0000000b00160bf8972ceso455415wra.13 for ; Tue, 05 Oct 2021 09:04:26 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id 73sm2438711wmb.40.2021.10.05.09.04.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bUAeVkPkH7/rxBBxuqaE+VtjPUbGqfvU4B5RRV+zUrM=; b=G0eGibIgp4JHnhpFTeHzGTa5BtXd/lurQc4rFG1+/LbnhbZjl39MqC3EmjnFLnZUqxB+f3 Dxqi+17tYuuedfWT7WCvOYsU2PuPtfI1zVWv900lru15vp6x+4ERifFV1w3B/0kk2iHnfv 6BXon7qCxKkNbWvajz06u32KhxZa+g0= X-MC-Unique: dTt4Cu-tMH-myaJh5-Uu8Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bUAeVkPkH7/rxBBxuqaE+VtjPUbGqfvU4B5RRV+zUrM=; b=tJnKH+cXm8GqbbGC8DORVP3mYnEd7/uNdoMUlOR4yVvVif6M+2XouXgr8ZPrB38UC+ jO3BqTMrZ/G+D1K8IkwwbeV56ztoOlC2CtwLcWLNziBFsCNr3hGBJd2TY4JS0i6PGTdT Pty4+Jd3vXfRwwx6cbQR9Jkh59z6cZHLfjA3GrqFQGi+a4SwNpDseSnzYA/UodqnQMUc uGTpCcx+l7ezZ5NVv53C0Iino8lPfcBQQOeWoS2wjgV5qDf24YyU1w8MUQIyW1i5DWU3 mRj8yJg/4cav250Jz7RtC/6HumNDw9GkmkqJZ8SuAHYitEG/S+4PBcgCGX9/aYe3ipR7 FULA== X-Gm-Message-State: AOAM530OH1UOmOTrbu2qu88GVoJoK+NqhtgcK77j7l17wUPnGFWCinnJ EePDwSHOO06OzpYY2DTjEAQ76i9DrnZXRzXxla+t4LoMHjTAz6NTkq3XWE6cZflDTSlmyzLA3AX W1zqpbVR/ehLfVad1o6pWfhNT24aYaQjfYIg54ajre27JyvGMgWVpoLavR84Q X-Received: by 2002:a1c:2089:: with SMTP id g131mr4366653wmg.192.1633449865204; Tue, 05 Oct 2021 09:04:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2ctP6i4oN92FysQeRaq6ZHrn/hho96VNgiG0U1dEY0cg8q0r2vNr/o+dSResqi2Mhyv0L3w== X-Received: by 2002:a1c:2089:: with SMTP id g131mr4366616wmg.192.1633449864878; Tue, 05 Oct 2021 09:04:24 -0700 (PDT) Date: Tue, 5 Oct 2021 12:04:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 50/57] bios-tables-test: allow changes in DSDT ACPI tables for q35 Message-ID: <20211005155946.513818-51-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633453124130100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ani Sinha We are going to commit a change to fix IO address range allocated for acpi = pci hotplug in q35. This affects DSDT tables. This change allows DSDT table modification so that unit tests are not broken. Signed-off-by: Ani Sinha Acked-by: Igor Mammedov Message-Id: <20210916132838.3469580-2-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..c06da38af3 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,13 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/DSDT", +"tests/data/acpi/q35/DSDT.tis.tpm12", +"tests/data/acpi/q35/DSDT.tis.tpm2", +"tests/data/acpi/q35/DSDT.bridge", +"tests/data/acpi/q35/DSDT.mmio64", +"tests/data/acpi/q35/DSDT.ipmibt", +"tests/data/acpi/q35/DSDT.cphp", +"tests/data/acpi/q35/DSDT.memhp", +"tests/data/acpi/q35/DSDT.numamem", +"tests/data/acpi/q35/DSDT.nohpet", +"tests/data/acpi/q35/DSDT.dimmpxm", +"tests/data/acpi/q35/DSDT.acpihmat", --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633452835877638.413820167503; Tue, 5 Oct 2021 09:53:55 -0700 (PDT) Received: from localhost ([::1]:51222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnhS-0005du-Nw for importer@patchew.org; Tue, 05 Oct 2021 12:53:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvi-0002Nq-Rt for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58115) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvg-0007QP-6o for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:34 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-324-DJhmfcXBM9yKRCm9CT2hDQ-1; Tue, 05 Oct 2021 12:04:30 -0400 Received: by mail-wr1-f69.google.com with SMTP id m17-20020adffa11000000b00160c1ac74e9so196383wrr.9 for ; Tue, 05 Oct 2021 09:04:30 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id a2sm4503309wru.82.2021.10.05.09.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:04:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449871; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lHHs6Vz7+L9GpkA+xcD4+gX89xg4Q8BgFi/Oic5oyms=; b=e6s4+1yUaQ/K6Gb9/YPooVDmpcDeBi4SVPJjX5SroxmClB7CqmaHk6uVw9ABq/hJ0aFpKj UVFaZZVGiSBU49oRZAN5CaQ35WzCdGLYar/QkTxHF8qEAL467f35xMafs1cagibjri6OYK o+V6B5mPU9fhKOelSJobeCa1e6irLTY= X-MC-Unique: DJhmfcXBM9yKRCm9CT2hDQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=lHHs6Vz7+L9GpkA+xcD4+gX89xg4Q8BgFi/Oic5oyms=; b=UUMI2zjeTadIlIKAm2zgC72SoTQ+GXUVdNafm+WXiuny2/g8eePR4tv4rdTPLM1QmZ +508tOnVVlUAPUuPw3QaG6oyeqd7UTv5Dgf3RvQqpn5Ue0hAAspmS751HnNF75hVWsg3 eFh3BFjWsjLlO3X81XyEUG0seuxkxpb6KODndkKy0GL4wN2M67vRB1guaKoqi1FHacfo s3WgLCRQw+p8Z5tU5i2nSHH1EojIY0KyV1FEGv1yQFOte4h+KwiQA1oD/73pSsOBHqs/ oST9OUB1siUoMRnuOwntWfEaV+9rwTTuYOXKMznseERgD/1aMQN5t1/l94+btOVpBmTp RHDw== X-Gm-Message-State: AOAM530+V95/nu4Num1vPsxC6/ZgY4X1PhNiGBCIbvjWHFfz5fG3kj+9 GIEqsCYcNbdBgkitjJ4LVC4j8135Q0IsHjNdGadJt+FGnQtISi56jVucjYUWCVvtWiHHZJJyj1Z tJpRkeHdcR06U+hxKbYIhPgExWdV7QWbsEBmtN/z50mqMSLuW7U7FR9k9UB1p X-Received: by 2002:adf:e549:: with SMTP id z9mr3870600wrm.334.1633449868777; Tue, 05 Oct 2021 09:04:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuCW+A1xUO9mTH+ZMXvCm+0VCrThFmQGa3PxSYYBh9PX/vETXMASB13Uwm5dJrXmV3eC5f7g== X-Received: by 2002:adf:e549:: with SMTP id z9mr3870568wrm.334.1633449868522; Tue, 05 Oct 2021 09:04:28 -0700 (PDT) Date: Tue, 5 Oct 2021 12:04:25 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 51/57] hw/i386/acpi: fix conflicting IO address range for acpi pci hotplug in q35 Message-ID: <20211005155946.513818-52-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Julia Suvorova , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452837744100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ani Sinha Change caf108bc58790 ("hw/i386/acpi-build: Add ACPI PCI hot-plug methods to= Q35") selects an IO address range for acpi based PCI hotplug for q35 arbitrarily.= It starts at address 0x0cc4 and ends at 0x0cdb. At the time when the patch was written but the final version of the patch was not yet pushed upstream, this address range was free and did not conflict with any other IO address range= s. However, with the following change, this address range was no longer conflict free as in this change, the IO address range (value of ACPI_PCIHP_SIZE) was incremented by four bytes: b32bd763a1ca92 ("pci: introduce acpi-index property for PCI device") This can be seen from the output of QMP command 'info mtree' : 0000000000000600-0000000000000603 (prio 0, i/o): acpi-evt 0000000000000604-0000000000000605 (prio 0, i/o): acpi-cnt 0000000000000608-000000000000060b (prio 0, i/o): acpi-tmr 0000000000000620-000000000000062f (prio 0, i/o): acpi-gpe0 0000000000000630-0000000000000637 (prio 0, i/o): acpi-smi 0000000000000cc4-0000000000000cdb (prio 0, i/o): acpi-pci-hotplug 0000000000000cd8-0000000000000ce3 (prio 0, i/o): acpi-cpu-hotplug It shows that there is a region of conflict between IO regions of acpi pci hotplug and acpi cpu hotplug. Unfortunately, the change caf108bc58790 did not update the IO address range appropriately before it was pushed upstream to accommodate the increased length of the IO address space introduced in change b32bd763a1ca92. Due to this bug, windows guests complain 'This device cannot find enough free resources it can use' in the device manager panel for extended IO buses. This issue also breaks the correct functioning of pci hotplug as = the following shows that the IO space for pci hotplug has been truncated: (qemu) info mtree -f FlatView #0 AS "I/O", root: io Root memory region: io 0000000000000cc4-0000000000000cd7 (prio 0, i/o): acpi-pci-hotplug 0000000000000cd8-0000000000000cf7 (prio 0, i/o): acpi-cpu-hotplug Therefore, in this fix, we adjust the IO address range for the acpi pci hotplug so that it does not conflict with cpu hotplug and there is no truncation of IO spaces. The starting IO address of PCI hotplug region has been decremented by four bytes in order to accommodate four byte increment in the IO address space introduced by change b32bd763a1ca92 ("pci: introduce acpi-index property for PCI device") After fixing, the following are the corrected IO ranges: 0000000000000600-0000000000000603 (prio 0, i/o): acpi-evt 0000000000000604-0000000000000605 (prio 0, i/o): acpi-cnt 0000000000000608-000000000000060b (prio 0, i/o): acpi-tmr 0000000000000620-000000000000062f (prio 0, i/o): acpi-gpe0 0000000000000630-0000000000000637 (prio 0, i/o): acpi-smi 0000000000000cc0-0000000000000cd7 (prio 0, i/o): acpi-pci-hotplug 0000000000000cd8-0000000000000ce3 (prio 0, i/o): acpi-cpu-hotplug This change has been tested using a Windows Server 2019 guest VM. Windows no longer complains after this change. Fixes: caf108bc58790 ("hw/i386/acpi-build: Add ACPI PCI hot-plug methods to= Q35") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/561 Signed-off-by: Ani Sinha Reviewed-by: Igor Mammedov Reviewed-by: Julia Suvorova Message-Id: <20210916132838.3469580-3-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/ich9.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h index a329ce43ab..f04f1791bd 100644 --- a/include/hw/acpi/ich9.h +++ b/include/hw/acpi/ich9.h @@ -29,7 +29,7 @@ #include "hw/acpi/acpi_dev_interface.h" #include "hw/acpi/tco.h" =20 -#define ACPI_PCIHP_ADDR_ICH9 0x0cc4 +#define ACPI_PCIHP_ADDR_ICH9 0x0cc0 =20 typedef struct ICH9LPCPMRegs { /* --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633453696536557.1725095244524; Tue, 5 Oct 2021 10:08:16 -0700 (PDT) Received: from localhost ([::1]:51798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnvL-0001Rn-9a for importer@patchew.org; Tue, 05 Oct 2021 13:08:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmw4-0002SL-Sf for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31452) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvy-0007dl-FN for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:54 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-114-_8IjLB5SM-ykQZJTS9EiQA-1; Tue, 05 Oct 2021 12:04:47 -0400 Received: by mail-wm1-f69.google.com with SMTP id z22-20020a7bc7d6000000b0030d5c26120fso1225086wmk.1 for ; Tue, 05 Oct 2021 09:04:46 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id d3sm21016109wrb.36.2021.10.05.09.04.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449888; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aCqYaH0mubcZlZRADdcF8JXVVsXmramhvbMxn5JfQ6A=; b=f1d40pcSKnxqSypgu/lrNLfPMa3yuCI02/3nSOLGbaSgKFXfPAj+cuO/nkfYXT+S8HfZKJ rIyT7HZi05aVYOqxlPlhLD6GTLAC5TpnvUDieseWODuEDvkdqikPOQXGLGSJf8JqZLcabx yp8hugqZOn63DBw8F9Ivowj8O+ZOBBw= X-MC-Unique: _8IjLB5SM-ykQZJTS9EiQA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=aCqYaH0mubcZlZRADdcF8JXVVsXmramhvbMxn5JfQ6A=; b=B8Q5tbcKD8vtwR3JeDOUYGV0Z2NAXaFNy0/J8HbNCP1JUQTc/NYqzV9/aFt0YCCqcu RV/+Ugfb0R4NdQSUBb6t1B8lgSxNFE3bCEnrTjWP7quUjI08+AFkrsM3kDaGRSE8JuYJ +2JqUL/P8RJoPCAqZbC4sl/w+RrUG6qT9SwrcCFGXF5LpXB8s3+xILiojViJoND8kWk/ 17f7YwzWFbsA2ctsbuonmuqJVKbwskRbWYRH4vXjUAp5G2er6IIEyGof60ciK48dErYM e+i3Tur3yOrOr1GFrPxrwPmQ4iXqfOBf+ktp4YVhF8BAEmqoIwXwBsZKed+dPd0ldjW9 l8kQ== X-Gm-Message-State: AOAM533wHy9Fgl/oivWDAhX64NtKjiM28Dd2UbOiTtHVXwUdRE3kRv78 oWT2jBz1+b1G4SOPk07B9QAawBe02zFFKzCYZG/VGPT3RadYIXe0pp0FsRTowOcElkKuwnmYFAz PSbcLA2w4Py/NucDNfUg5f4x33oNCPaERXiQitSTtnz6ecwhK3YNgrt3Esa1E X-Received: by 2002:adf:a1cc:: with SMTP id v12mr22777968wrv.48.1633449878562; Tue, 05 Oct 2021 09:04:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgHq5lB/I9nLmzBDeTHfRwCFDS1pA1JLNUFRxI55mLa9Ss7vkxxVCKM4Sh/2djP1bi4rw2WQ== X-Received: by 2002:adf:a1cc:: with SMTP id v12mr22777159wrv.48.1633449871569; Tue, 05 Oct 2021 09:04:31 -0700 (PDT) Date: Tue, 5 Oct 2021 12:04:28 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 52/57] bios-tables-test: Update ACPI DSDT table golden blobs for q35 Message-ID: <20211005155946.513818-53-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633453697044100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ani Sinha We have modified the IO address range for ACPI pci hotplug in q35. See chan= ge: 5adcc9e39e6a5 ("hw/i386/acpi: fix conflicting IO address range for acpi pci= hotplug in q35") The ACPI DSDT table golden blobs must be regenrated in order to make the un= it tests pass. This change updates the golden ACPI DSDT table blobs. Following is the ASL diff between the blobs: @@ -1,30 +1,30 @@ /* * Intel ACPI Component Architecture * AML/ASL+ Disassembler version 20190509 (64-bit version) * Copyright (c) 2000 - 2019 Intel Corporation * * Disassembling to symbolic ASL+ operators * - * Disassembly of tests/data/acpi/q35/DSDT, Tue Sep 14 09:04:06 2021 + * Disassembly of /tmp/aml-52DP90, Tue Sep 14 09:04:06 2021 * * Original Table Header: * Signature "DSDT" * Length 0x00002061 (8289) * Revision 0x01 **** 32-bit table (V1), no 64-bit math support - * Checksum 0xE5 + * Checksum 0xF9 * OEM ID "BOCHS " * OEM Table ID "BXPC " * OEM Revision 0x00000001 (1) * Compiler ID "BXPC" * Compiler Version 0x00000001 (1) */ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001) { Scope (\) { OperationRegion (DBG, SystemIO, 0x0402, One) Field (DBG, ByteAcc, NoLock, Preserve) { DBGB, 8 } @@ -226,46 +226,46 @@ Name (_CRS, ResourceTemplate () // _CRS: Current Resource Set= tings { IO (Decode16, 0x0070, // Range Minimum 0x0070, // Range Maximum 0x01, // Alignment 0x08, // Length ) IRQNoFlags () {8} }) } } Scope (_SB.PCI0) { - OperationRegion (PCST, SystemIO, 0x0CC4, 0x08) + OperationRegion (PCST, SystemIO, 0x0CC0, 0x08) Field (PCST, DWordAcc, NoLock, WriteAsZeros) { PCIU, 32, PCID, 32 } - OperationRegion (SEJ, SystemIO, 0x0CCC, 0x04) + OperationRegion (SEJ, SystemIO, 0x0CC8, 0x04) Field (SEJ, DWordAcc, NoLock, WriteAsZeros) { B0EJ, 32 } - OperationRegion (BNMR, SystemIO, 0x0CD4, 0x08) + OperationRegion (BNMR, SystemIO, 0x0CD0, 0x08) Field (BNMR, DWordAcc, NoLock, WriteAsZeros) { BNUM, 32, PIDX, 32 } Mutex (BLCK, 0x00) Method (PCEJ, 2, NotSerialized) { Acquire (BLCK, 0xFFFF) BNUM =3D Arg0 B0EJ =3D (One << Arg1) Release (BLCK) Return (Zero) } @@ -3185,34 +3185,34 @@ 0x0620, // Range Minimum 0x0620, // Range Maximum 0x01, // Alignment 0x10, // Length ) }) } Device (PHPR) { Name (_HID, "PNP0A06" /* Generic Container Device */) // _HID= : Hardware ID Name (_UID, "PCI Hotplug resources") // _UID: Unique ID Name (_STA, 0x0B) // _STA: Status Name (_CRS, ResourceTemplate () // _CRS: Current Resource Set= tings { IO (Decode16, - 0x0CC4, // Range Minimum - 0x0CC4, // Range Maximum + 0x0CC0, // Range Minimum + 0x0CC0, // Range Maximum 0x01, // Alignment 0x18, // Length ) }) } } Scope (\) { Name (_S3, Package (0x04) // _S3_: S3 System State { One, One, Zero, Zero }) Signed-off-by: Ani Sinha Acked-by: Igor Mammedov Message-Id: <20210916132838.3469580-4-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 12 ------------ tests/data/acpi/q35/DSDT | Bin 8289 -> 8289 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9614 -> 9614 bytes tests/data/acpi/q35/DSDT.bridge | Bin 11003 -> 11003 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8753 -> 8753 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9943 -> 9943 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 8364 -> 8364 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9648 -> 9648 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 9419 -> 9419 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 8147 -> 8147 bytes tests/data/acpi/q35/DSDT.numamem | Bin 8295 -> 8295 bytes tests/data/acpi/q35/DSDT.tis.tpm12 | Bin 8894 -> 8894 bytes tests/data/acpi/q35/DSDT.tis.tpm2 | Bin 8894 -> 8894 bytes 13 files changed, 12 deletions(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index c06da38af3..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,13 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/DSDT", -"tests/data/acpi/q35/DSDT.tis.tpm12", -"tests/data/acpi/q35/DSDT.tis.tpm2", -"tests/data/acpi/q35/DSDT.bridge", -"tests/data/acpi/q35/DSDT.mmio64", -"tests/data/acpi/q35/DSDT.ipmibt", -"tests/data/acpi/q35/DSDT.cphp", -"tests/data/acpi/q35/DSDT.memhp", -"tests/data/acpi/q35/DSDT.numamem", -"tests/data/acpi/q35/DSDT.nohpet", -"tests/data/acpi/q35/DSDT.dimmpxm", -"tests/data/acpi/q35/DSDT.acpihmat", diff --git a/tests/data/acpi/q35/DSDT b/tests/data/acpi/q35/DSDT index 842533f53e6db40935c3cdecd1d182edba6c17d4..281fc82c03b2562d2e6b7caec0d= 817b034a47138 100644 GIT binary patch delta 65 zcmaFp@X&$FCD+tn9LO9j!+e0}z~trfy8v~b6W9O% delta 65 zcmaFp@X&$FCD+to9LO9j!+eD2$mHeny8v@q6W9O% diff --git a/tests/data/acpi/q35/DSDT.acpihmat b/tests/data/acpi/q35/DSDT.a= cpihmat index 8d00f2ea0dd78f962e136273d68cb0c568e43c27..8c1e05a11a328ec1cc6f86e36e5= 2c28f41f9744e 100644 GIT binary patch delta 65 zcmeD4?(^ny33dtTQ)OUa+_sU6pPBK%WGQA@sS`Y0EYXeJ!LDBM&Q1odUJB6-PJX^Y VjNBJC2QoJ(G9TbMF!_qgE&x%Q6Po}4 delta 65 zcmeD4?(^ny33dtTQ)OUaT(pskpPBK+tn9LO9j!+e0}z~<%hA>06yixa5; delta 66 zcmewz`a6`%CDF$oF?J&tKQrTj$x_U+QYU!0SfU%bgI&Giot+F^y%eGwocw%) V7`ZQO4rErAV?MxhU~;+QE&wzZ5?TNN delta 65 zcmdn!veAXhCDF$o(Q_jgKQrTz$x_U+QfGL$SfU%bgI&Giot+F^y%eGwocw%) V7`d-(4rErAV?M%jWOBLUE&wso5?TNN diff --git a/tests/data/acpi/q35/DSDT.dimmpxm b/tests/data/acpi/q35/DSDT.di= mmpxm index b062e30117f955c7a2ac9629a0512324bbd28bf2..fe5820d93d057ef09a001662369= b15afbc5b87e2 100644 GIT binary patch delta 65 zcmccad)=3D4ICD+tn9LRi9iTMD}fyuIJy8v+to9LRi9iTMc6k;$@Zy8v&d6QKYA diff --git a/tests/data/acpi/q35/DSDT.ipmibt b/tests/data/acpi/q35/DSDT.ipm= ibt index 1c5737692f56fc678e685a4ad0bb1df38d487a14..631741065860fd5036aa303904d= abd1d2839f9c6 100644 GIT binary patch delta 89 zcmZ4ExWnjRFDA!6D88&YqzPK*B{Kx*^!rE1r@2 p1P>QWbR##2IIZ=3D^79R1njRFDA!6D88&YqzPK*B{Kx*^!rE1r@2 p3=3DbDebR##2IIZ=3D^79R1+tn9LO9g!+e0}z~r^^y8vk#6QBS9 delta 65 zcmaFv@Z5pRCDxg*6QBS9 diff --git a/tests/data/acpi/q35/DSDT.tis.tpm12 b/tests/data/acpi/q35/DSDT.= tis.tpm12 index 6735e73971c6be95deceb23051a78af6a4573bd8..c96b5277a14ae98174408d690d6= e0246bd932623 100644 GIT binary patch delta 66 zcmdnzy3du%CD+tn9LO9m!+e0}z~;^J+{^%EauT!v delta 66 zcmdnzy3du%CD+to9LO9m!+eD2$mY%R+{^%CE)ui=3D diff --git a/tests/data/acpi/q35/DSDT.tis.tpm2 b/tests/data/acpi/q35/DSDT.t= is.tpm2 index d1433e3c14570bbd17b029a9aec6bc53134c3b7d..c92d4d29c79352a60974ea9f665= d0b9a410a4bac 100644 GIT binary patch delta 66 zcmdnzy3du%CD (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 1633454983101178.46084272104486; Tue, 5 Oct 2021 10:29:43 -0700 (PDT) Received: from localhost ([::1]:47748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXoG6-0003Lz-2Y for importer@patchew.org; Tue, 05 Oct 2021 13:29:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvu-0002Qq-1U for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40081) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvs-0007a9-8X for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:45 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-209-YFxdVa1RM122XAmanfdrrA-1; Tue, 05 Oct 2021 12:04:42 -0400 Received: by mail-wm1-f69.google.com with SMTP id f11-20020a7bcd0b000000b0030d72d5d0bcso1461320wmj.7 for ; Tue, 05 Oct 2021 09:04:42 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id w5sm17777657wra.87.2021.10.05.09.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449883; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=L5Ob6Qrwd+OTuC9y1hEz99v/MrcHnJwVa3TGabDbl64=; b=Yd6tZi/wEPpUOtFF8Ajc/GqmXlWnhG5g1O7TJMkbRo5JrHKYqrvEBlFfwwv4dPbwX0neh1 AfL9Lcxxjb3vs6buPs76X1+JRUTMq8RWn4agZQM6EucZdH1uS7UxPvbpi6hewJcj6+quWV Sb8VVrE/sNcLeeYmMD6tx7ZhDfrY5T0= X-MC-Unique: YFxdVa1RM122XAmanfdrrA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=L5Ob6Qrwd+OTuC9y1hEz99v/MrcHnJwVa3TGabDbl64=; b=Eu0L+Cd74Ja+MtPxBC/z/Gi+pCiayGAluVt9oJr/fWj7Q6RFJ733Db34/SA6lEsSSy tWao7Y89673q+X69uoXTvWme+rsCM1UZaliCIP8LM378lFB4klzn6A2t/419eGN3T773 nDk1S4blABEsw7IXVsc0TbFBB0Y0C8Wm2BnU1rI2BwDd92caUjofjrza0yUNuqNKWF+F mCFOZZmXe6UElcDjajlDTuDhjwnxOKsFHsymMSHVWdFVc/BUbQp2HmPpE9M9hWSVkiMF hwtWwK3E6leEO9UlHQxrTjGpruaiuOXUAe7yJm9oT5PAQvHFcJUpdS2vtz6aXflMFbvN ShXw== X-Gm-Message-State: AOAM53132FLRnHcly4BnpOf4ztWQFe2CGUQJXOn/DYgpNxhR849ZQiM9 JFCGo/WhHJJZJlNz2wMkAGS4gYeQE0edo1g9/An/YpLX1kUGKZcZ+Zs0HoXWx3a9WYps7m/9496 RXwwdk0MMQ8n77mUhk3SjEI6X+qRgeYJWh1qlOM4kgxKpX4e3RGPoIDR/+TyM X-Received: by 2002:a05:600c:a08:: with SMTP id z8mr4324195wmp.165.1633449879852; Tue, 05 Oct 2021 09:04:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmhgQ9kCeqUCiazAL07wrkzA67YiGl2yW/gx474MkTcjTfQVbR1qjUFtL5HRiNP+Nl8gplzA== X-Received: by 2002:a05:600c:a08:: with SMTP id z8mr4324148wmp.165.1633449879484; Tue, 05 Oct 2021 09:04:39 -0700 (PDT) Date: Tue, 5 Oct 2021 12:04:35 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 53/57] virtio-balloon: Fix page-poison subsection name Message-ID: <20211005155946.513818-54-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Dr. David Alan Gilbert" , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633454983684100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" The subsection name for page-poison was typo'd as: vitio-balloon-device/page-poison Note the missing 'r' in virtio. When we have a machine type that enables page poison, and the guest enables it (which needs a new kernel), things fail rather unpredictably. The fallout from this is that most of the other subsections fail to load, including things like the feature bits in the device, one possible fallout is that the physical addresses of the queues then get aligned differently and we fail with an error about last_avail_idx being wrong. It's not obvious to me why this doesn't produce a more obvious failure, but virtio's vmstate loading is a bit open-coded. Fixes: 7483cbbaf82 ("virtio-balloon: Implement support for page poison repo= rting feature") bz: https://bugzilla.redhat.com/show_bug.cgi?id=3D1984401 Signed-off-by: Dr. David Alan Gilbert Message-Id: <20210914131716.102851-1-dgilbert@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: David Hildenbrand --- hw/virtio/virtio-balloon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 5a69dce35d..c6962fcbfe 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -852,7 +852,7 @@ static const VMStateDescription vmstate_virtio_balloon_= free_page_hint =3D { }; =20 static const VMStateDescription vmstate_virtio_balloon_page_poison =3D { - .name =3D "vitio-balloon-device/page-poison", + .name =3D "virtio-balloon-device/page-poison", .version_id =3D 1, .minimum_version_id =3D 1, .needed =3D virtio_balloon_page_poison_support, --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633453457693977.7768699348086; Tue, 5 Oct 2021 10:04:17 -0700 (PDT) Received: from localhost ([::1]:43302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnrU-0003bP-Na for importer@patchew.org; Tue, 05 Oct 2021 13:04:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvx-0002RC-5c for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24444) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmvv-0007ca-Dx for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:48 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-355-5obmGbNHMiaTRc44bAtShA-1; Tue, 05 Oct 2021 12:04:45 -0400 Received: by mail-wr1-f69.google.com with SMTP id f11-20020adfc98b000000b0015fedc2a8d4so5925863wrh.0 for ; Tue, 05 Oct 2021 09:04:45 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id m14sm2289062wmi.47.2021.10.05.09.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:04:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449886; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OBdD4BTsDqZ+kiWNNePrFOaPe7shpwKkuU8DhGPxYvA=; b=iyaPr66FdhtxKOp8+nILsk8KOG0jjpnwTmxs74HJJ2p0JVm0Js+yLSAzwKOSmKwqT+tBXF NayUXB5VJzn6/yL1tnxJwe43f4TFqiLCgK1WHHm+Hush7VThafPOFIsukXlOtt2nf00gDW bbp2+E3Uzou5z81bl/qkwfH5deSjvZk= X-MC-Unique: 5obmGbNHMiaTRc44bAtShA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=OBdD4BTsDqZ+kiWNNePrFOaPe7shpwKkuU8DhGPxYvA=; b=Kjg9F1TtFcDDMJiWMa42Hqi9fYx6xuS1iAV8YqCrrVCJuVccardKNzE1Yuv7lAuV1x W+6CZ0TdKhf7FMOf55qbeDY/PoDfXgEIVfPVTn9hJ50gfFkyEMJCxnerjXSw2tG4ZLiQ mM5RmC4zIcQ/inx9iVci7PqRiNXP32JZTx29nh4okbLNdRZjLQ1XCQ0wnyUVbt0xTyFF LvYl2EWweLWS52htHT5rTUNYYnyGLXddkXL/1lO2YOOB2JJVPoROigWeASbh4u6TrSS9 OMCm11g7Yp36d7qWKumbnfezJYGkWowaVHw5nSuMe/Bh9xJMPFi6GHAjEIMy6O0OreRX Z00g== X-Gm-Message-State: AOAM533yKgK+y5/iJJnQSKTfzm1kfaDcUt3rRJVaJ2eJYrwhuoOX185R 6LB2RlYapXBFFgC5GiA+asS1v0PGo53PFK+Xv4iW+galQnii+zEe9Rc8Pivp+EJRI1ty7yzjxPh yniW7ExRWHDikwDb5T/d8UX2o4J5BC8KcohkBlL1I1oIXdCna/uozxY3ur7cd X-Received: by 2002:adf:b19c:: with SMTP id q28mr22689949wra.348.1633449884001; Tue, 05 Oct 2021 09:04:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+58O7IBu5nWgU/3KFkuRVy+jRco78nGALhIQdDb03zLkrwFJdF61w7+07Ia8Ot+z1O6TkGw== X-Received: by 2002:adf:b19c:: with SMTP id q28mr22689892wra.348.1633449883571; Tue, 05 Oct 2021 09:04:43 -0700 (PDT) Date: Tue, 5 Oct 2021 12:04:39 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 54/57] nvdimm: release the correct device list Message-ID: <20211005155946.513818-55-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ani Sinha , Peter Maydell , Xiao Guangrong , Li Zhijian , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633453459648100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Li Zhijian Signed-off-by: Li Zhijian Message-Id: <20210624110415.187164-1-lizhijian@cn.fujitsu.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov --- hw/acpi/nvdimm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 5f9b552d6a..0d43da19ea 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -339,10 +339,10 @@ nvdimm_build_structure_caps(GArray *structures, uint3= 2_t capabilities) =20 static GArray *nvdimm_build_device_structure(NVDIMMState *state) { - GSList *device_list =3D nvdimm_get_device_list(); + GSList *device_list, *list =3D nvdimm_get_device_list(); GArray *structures =3D g_array_new(false, true /* clear */, 1); =20 - for (; device_list; device_list =3D device_list->next) { + for (device_list =3D list; device_list; device_list =3D device_list->n= ext) { DeviceState *dev =3D device_list->data; =20 /* build System Physical Address Range Structure. */ @@ -357,7 +357,7 @@ static GArray *nvdimm_build_device_structure(NVDIMMStat= e *state) /* build NVDIMM Control Region Structure. */ nvdimm_build_structure_dcr(structures, dev); } - g_slist_free(device_list); + g_slist_free(list); =20 if (state->persistence) { nvdimm_build_structure_caps(structures, state->persistence); @@ -1333,9 +1333,9 @@ static void nvdimm_build_ssdt(GArray *table_offsets, = GArray *table_data, =20 void nvdimm_build_srat(GArray *table_data) { - GSList *device_list =3D nvdimm_get_device_list(); + GSList *device_list, *list =3D nvdimm_get_device_list(); =20 - for (; device_list; device_list =3D device_list->next) { + for (device_list =3D list; device_list; device_list =3D device_list->n= ext) { DeviceState *dev =3D device_list->data; Object *obj =3D OBJECT(dev); uint64_t addr, size; @@ -1348,7 +1348,7 @@ void nvdimm_build_srat(GArray *table_data) build_srat_memory(table_data, addr, size, node, MEM_AFFINITY_ENABLED | MEM_AFFINITY_NON_VOLATILE= ); } - g_slist_free(device_list); + g_slist_free(list); } =20 void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data, --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633455153707607.7736145763392; Tue, 5 Oct 2021 10:32:33 -0700 (PDT) Received: from localhost ([::1]:56482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXoIq-0000pm-Lz for importer@patchew.org; Tue, 05 Oct 2021 13:32:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmw6-0002Sz-P2 for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:05:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmw0-0007gE-73 for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:04:57 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-488-g90h6jhvPvWdijdanyzqHQ-1; Tue, 05 Oct 2021 12:04:49 -0400 Received: by mail-wr1-f70.google.com with SMTP id k16-20020a5d6290000000b00160753b430fso5912145wru.11 for ; Tue, 05 Oct 2021 09:04:49 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id d24sm2229044wmb.35.2021.10.05.09.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:04:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449890; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AWC3XKuAFgu2XB5Lo01m20qnKYTT1H0S1+taYRlAw38=; b=RSYaKQUWT4iLCFU+kzqCnYP/BuUBlfISO6I6pHgsYiU4n3Nn/nFC7tiO2zBpkRmMBQqyhK VOtezlRow/FitoQc4l+TVSqZ07SzTt4QdTXi02YMqWdOmH0qA+Rrpz6pyG09Lkm4uejEfs BkrNwKubqCGuZI9LZ/kt//2hNRrFGM4= X-MC-Unique: g90h6jhvPvWdijdanyzqHQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=AWC3XKuAFgu2XB5Lo01m20qnKYTT1H0S1+taYRlAw38=; b=XxxptqSY7rksAOm5c9Lies10vK3vI93jFQMR3sjf5Zme7HYD20qBoSfonLmTlmYyJe g6te4FeZPa52TE+4SVf+t+lx1mmVkP5vuqbcwW6hwUKOrBlOVu1a4OIQzka+TckUNMYQ q1365ZUhGnudWt3YKtHFQZtDXU3GPqPCig/hDX408DTa5MTmEApePa/jVgvMbd5WdJjw VAS6HvT2pW/2T5IXALwTFO3BXss82UOXqsNJBJRo4E+QMuHI+x0UGjJ8HbobCK7yfSNH u6HlNj7NGN4AF/gh1mZH9MIMmPbxafccaxkXrD0MVsFZTBXIQwycvxOeE4h0gVBmrugT 55Sg== X-Gm-Message-State: AOAM531JpQTNmIQVBADyxBzzoeMkHgIZuW2wt54i/P5NNbjD4B+1fWFK aA31JoQXFNxXqyK5o8nulEQbKWrKj/ORWSsFD4kCrNiVMI9hSb6Oz5BRSkLHXDor77Y8UyHLtVE lS6RiY/g7KHG6xmus+2VPUSoVsiVt+ruNKdffNOD7j4IHj0njLVWCM5R1C5Ro X-Received: by 2002:adf:b348:: with SMTP id k8mr21499685wrd.435.1633449887664; Tue, 05 Oct 2021 09:04:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxL779pJg6S8zSY/P+AXZWm2EOgp0/uZdVeEkbNfhh8pNw2MQiRB04/Dq7OEmBPMX15juWlrQ== X-Received: by 2002:adf:b348:: with SMTP id k8mr21499649wrd.435.1633449887465; Tue, 05 Oct 2021 09:04:47 -0700 (PDT) Date: Tue, 5 Oct 2021 12:04:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 55/57] hw/i386/amd_iommu: Rename amdviPCI TypeInfo Message-ID: <20211005155946.513818-56-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633455155599100001 From: Philippe Mathieu-Daud=C3=A9 Per 'QEMU Coding Style': Naming =3D=3D=3D=3D=3D=3D Variables are lower_case_with_underscores; easy to type and read. Rename amdviPCI variable as amdvi_pci. amdviPCI_register_types() register more than PCI types: TYPE_AMD_IOMMU_DEVICE inherits TYPE_X86_IOMMU_DEVICE which itself inherits TYPE_SYS_BUS_DEVICE. Rename it more generically as amdvi_register_types(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210926175648.1649075-2-f4bug@amsat.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 2801dff97c..0c994facde 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1621,7 +1621,7 @@ static const TypeInfo amdvi =3D { .class_init =3D amdvi_class_init }; =20 -static const TypeInfo amdviPCI =3D { +static const TypeInfo amdvi_pci =3D { .name =3D TYPE_AMD_IOMMU_PCI, .parent =3D TYPE_PCI_DEVICE, .instance_size =3D sizeof(AMDVIPCIState), @@ -1645,11 +1645,11 @@ static const TypeInfo amdvi_iommu_memory_region_inf= o =3D { .class_init =3D amdvi_iommu_memory_region_class_init, }; =20 -static void amdviPCI_register_types(void) +static void amdvi_register_types(void) { - type_register_static(&amdviPCI); + type_register_static(&amdvi_pci); type_register_static(&amdvi); type_register_static(&amdvi_iommu_memory_region_info); } =20 -type_init(amdviPCI_register_types); +type_init(amdvi_register_types); --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633452702658762.7556057986488; Tue, 5 Oct 2021 09:51:42 -0700 (PDT) Received: from localhost ([::1]:44758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnfJ-0001M9-LO for importer@patchew.org; Tue, 05 Oct 2021 12:51:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmwC-0002Tq-Eb for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:05:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47136) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmw6-0007j9-EX for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:05:04 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-231-0zl13TizMuyzwGV5DL9lLQ-1; Tue, 05 Oct 2021 12:04:55 -0400 Received: by mail-wm1-f72.google.com with SMTP id h24-20020a7bc938000000b0030d400be5b5so6535133wml.0 for ; Tue, 05 Oct 2021 09:04:55 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id k26sm3319286wms.39.2021.10.05.09.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449896; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=++Qz2MnOf8zg/IFXbMLXXteEF/1jvb/4aDH9kffcAs0=; b=YbIN0+cDGI/nYAz13FMKXsW7/ZPAw+gpHZ08TSkWpUZOY/pV0KIlOlsVWoqPt1zB2w5pva RVMwEz2Eem2WgygqMF8SE5xDz3SOt2hW3+tixvsMNxsjFVWkoSSacvz/PE5+VaoSxlABKj I9omY4h8h6rpolPhBf/5xNO14HBhsBs= X-MC-Unique: 0zl13TizMuyzwGV5DL9lLQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=++Qz2MnOf8zg/IFXbMLXXteEF/1jvb/4aDH9kffcAs0=; b=0x7X7pdxrZLYGHW75M2Hnu0oslDs/iq/DUJTyTE5M0HQO+6661gSthwWyh5EGeo5qT emkaGu4ZZ8wS1pZLF2q6n01lFNmO1MyVGJb1SOkhvN729/loRo1oOGJHXlYFMnTHYFkK rYROTUgqvPJyAkJCw+blKpCZYIRZi+su7cSMVjb2nfCFcX0lZUY9U2Oz2sARjJw4rpuB tN8E8f3MrClPW/HOK1pkfeliE9IBTIqhs0Cy2P3WrnyI/5P7AagliJtfy5bTbaj90uLi I16aiNtFBXFGSoTNawbAeCtF/d5KXUgsSnEKDlvnckmlDyrsBH/psqeJ2owGt3B3GrfD LhFA== X-Gm-Message-State: AOAM5306xqbPcsYr1MEwdWaL0h/88b9Q3KXVgjFh/BLZ/geg1HZM8NIR fuU3xTjtA3eFzDPhuTqncgQABpd9AIaxTijDhdp8P/KnS9nKVJHwO/6PZoFKgz7MDdsubZ7rJMo joFnIKQ/GZ1n2K73uXqdt08KDSEp0KyXEpnolVLGIvTJRZ1AopOAhDau17V4p X-Received: by 2002:a1c:21d7:: with SMTP id h206mr4293868wmh.23.1633449893309; Tue, 05 Oct 2021 09:04:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKURsWXpFTlOk3UwlZ/clIicKn5ewxJNd6B7StKVgNJuHRA0Yz50/Otn/gv/udhcR8CANppQ== X-Received: by 2002:a1c:21d7:: with SMTP id h206mr4293729wmh.23.1633449892237; Tue, 05 Oct 2021 09:04:52 -0700 (PDT) Date: Tue, 5 Oct 2021 12:04:47 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 56/57] hw/i386/amd_iommu: Rename SysBus specific functions as amdvi_sysbus_X() Message-ID: <20211005155946.513818-57-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=216.205.24.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633452704342100001 From: Philippe Mathieu-Daud=C3=A9 Various functions are SysBus specific. Rename them using the consistent amdvi_sysbus_XXX() pattern, to differentiate them from PCI specific functions (which we'll add in the next commit). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210926175648.1649075-3-f4bug@amsat.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 0c994facde..9014690ba3 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1526,7 +1526,7 @@ static void amdvi_init(AMDVIState *s) AMDVI_MAX_PH_ADDR | AMDVI_MAX_GVA_ADDR | AMDVI_MAX_VA_ADDR); } =20 -static void amdvi_reset(DeviceState *dev) +static void amdvi_sysbus_reset(DeviceState *dev) { AMDVIState *s =3D AMD_IOMMU_DEVICE(dev); =20 @@ -1534,7 +1534,7 @@ static void amdvi_reset(DeviceState *dev) amdvi_init(s); } =20 -static void amdvi_realize(DeviceState *dev, Error **errp) +static void amdvi_sysbus_realize(DeviceState *dev, Error **errp) { int ret =3D 0; AMDVIState *s =3D AMD_IOMMU_DEVICE(dev); @@ -1585,27 +1585,27 @@ static void amdvi_realize(DeviceState *dev, Error *= *errp) amdvi_init(s); } =20 -static const VMStateDescription vmstate_amdvi =3D { +static const VMStateDescription vmstate_amdvi_sysbus =3D { .name =3D "amd-iommu", .unmigratable =3D 1 }; =20 -static void amdvi_instance_init(Object *klass) +static void amdvi_sysbus_instance_init(Object *klass) { AMDVIState *s =3D AMD_IOMMU_DEVICE(klass); =20 object_initialize(&s->pci, sizeof(s->pci), TYPE_AMD_IOMMU_PCI); } =20 -static void amdvi_class_init(ObjectClass *klass, void* data) +static void amdvi_sysbus_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); X86IOMMUClass *dc_class =3D X86_IOMMU_DEVICE_CLASS(klass); =20 - dc->reset =3D amdvi_reset; - dc->vmsd =3D &vmstate_amdvi; + dc->reset =3D amdvi_sysbus_reset; + dc->vmsd =3D &vmstate_amdvi_sysbus; dc->hotpluggable =3D false; - dc_class->realize =3D amdvi_realize; + dc_class->realize =3D amdvi_sysbus_realize; dc_class->int_remap =3D amdvi_int_remap; /* Supported by the pc-q35-* machine types */ dc->user_creatable =3D true; @@ -1613,12 +1613,12 @@ static void amdvi_class_init(ObjectClass *klass, vo= id* data) dc->desc =3D "AMD IOMMU (AMD-Vi) DMA Remapping device"; } =20 -static const TypeInfo amdvi =3D { +static const TypeInfo amdvi_sysbus =3D { .name =3D TYPE_AMD_IOMMU_DEVICE, .parent =3D TYPE_X86_IOMMU_DEVICE, .instance_size =3D sizeof(AMDVIState), - .instance_init =3D amdvi_instance_init, - .class_init =3D amdvi_class_init + .instance_init =3D amdvi_sysbus_instance_init, + .class_init =3D amdvi_sysbus_class_init }; =20 static const TypeInfo amdvi_pci =3D { @@ -1648,7 +1648,7 @@ static const TypeInfo amdvi_iommu_memory_region_info = =3D { static void amdvi_register_types(void) { type_register_static(&amdvi_pci); - type_register_static(&amdvi); + type_register_static(&amdvi_sysbus); type_register_static(&amdvi_iommu_memory_region_info); } =20 --=20 MST From nobody Wed May 8 08:20:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633453053738515.8623748001581; Tue, 5 Oct 2021 09:57:33 -0700 (PDT) Received: from localhost ([::1]:59948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXnky-00038O-JM for importer@patchew.org; Tue, 05 Oct 2021 12:57:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48412) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmwC-0002Tp-AX for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:05:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48133) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXmwA-0007oX-4d for qemu-devel@nongnu.org; Tue, 05 Oct 2021 12:05:04 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-572-fbcEgVYEOfOC9HENTO0eBg-1; Tue, 05 Oct 2021 12:05:00 -0400 Received: by mail-wm1-f72.google.com with SMTP id x23-20020a05600c21d700b0030d23749278so1505281wmj.2 for ; Tue, 05 Oct 2021 09:04:59 -0700 (PDT) Received: from redhat.com ([2.55.147.134]) by smtp.gmail.com with ESMTPSA id 2sm2275726wmf.30.2021.10.05.09.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 09:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633449901; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bY8TOa5uB6WnEZxzhG2jkPTKURYR/E+YFIiS/+Ed54w=; b=Yr6v+6aARTHh22v4RWVOn5dSO13nJ/2EJSvn2t9dFCRPLqL9qv7P3ouls34Cgnj2woHIs+ kLo4rhz2YGO/joq1i2LnLFye66PuFVBQwd/XU0TT70LXf7OEWwUe7AlK5kpKEvfaUV0TXI 0bbROPkCsWJH48f7dZYfY+EgRaF5fic= X-MC-Unique: fbcEgVYEOfOC9HENTO0eBg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=bY8TOa5uB6WnEZxzhG2jkPTKURYR/E+YFIiS/+Ed54w=; b=x0BJXaJ2pKGkMg81bLapVpNOsb4WC+HSa/aa4OkEU8/Z+O5fL0HC1w3Pb3I0YPOcZu hDysOpWccqfIWatbr26pqYqfWzSIleF52NCZpDQ9AN3yBG+y9G00axxK60D8m5J2TzPy Jp2EsrBTjaeuC3UXcMdLZyVCXvMd2gkhy+EDhDDA6swBNTJSMcgQhn85E66+C5kci8bJ DqaxsWme4WCZ9GQTFmcDgw0RDw6o686FSuFtalU0MthxEzqAPR1H9RLS7ucoNxwvE+/f gRCYV/0dmbEgOeOxBKVvPiRTtk+DRJ5QG21fDmxKzaKXfGtDlH6GFFdiu9Ee19sUDdXV /Rtw== X-Gm-Message-State: AOAM531rnQnqle6M650ikSCdLBz9U6+bJ4zU7tagsnqkLzHNgOhHIOOC ZAUDUGJX6WmWM1DDupiHsbyqCK2e9P8EjA0rw563uiC1EudwTyP0/OHPo3v/sjKErReYspujDuM hxNJlN+dpF5aMZVCW0RfdIwt3VXqYaurNICLVQqpdvklLxu40QosQ2NkBYX1x X-Received: by 2002:a05:6000:1864:: with SMTP id d4mr9588350wri.345.1633449898448; Tue, 05 Oct 2021 09:04:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTZJkQycmqfISX97OEkTZ3TjKblo/yOV0QasL4fD6jJMgA1MgG/gUi6xdLtlwWWOAH3eiRsg== X-Received: by 2002:a05:6000:1864:: with SMTP id d4mr9588311wri.345.1633449898181; Tue, 05 Oct 2021 09:04:58 -0700 (PDT) Date: Tue, 5 Oct 2021 12:04:53 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 57/57] hw/i386/amd_iommu: Add description/category to TYPE_AMD_IOMMU_PCI Message-ID: <20211005155946.513818-58-mst@redhat.com> References: <20211005155946.513818-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211005155946.513818-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633453055394100001 From: Philippe Mathieu-Daud=C3=A9 TYPE_AMD_IOMMU_PCI is user-creatable but not well described. Implement its class_init() handler to add it to the 'Misc devices' category, and add a description. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210926175648.1649075-4-f4bug@amsat.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 9014690ba3..9242a0d3ed 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1621,10 +1621,19 @@ static const TypeInfo amdvi_sysbus =3D { .class_init =3D amdvi_sysbus_class_init }; =20 +static void amdvi_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + set_bit(DEVICE_CATEGORY_MISC, dc->categories); + dc->desc =3D "AMD IOMMU (AMD-Vi) DMA Remapping device"; +} + static const TypeInfo amdvi_pci =3D { .name =3D TYPE_AMD_IOMMU_PCI, .parent =3D TYPE_PCI_DEVICE, .instance_size =3D sizeof(AMDVIPCIState), + .class_init =3D amdvi_pci_class_init, .interfaces =3D (InterfaceInfo[]) { { INTERFACE_CONVENTIONAL_PCI_DEVICE }, { }, --=20 MST