From nobody Sat Nov 15 19:29:00 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748792175; cv=none; d=zohomail.com; s=zohoarc; b=alDbUzInWO+82YDT/7ulvctSI4nTA92Ok9qItUaQE7ns1ZbIBmlNPQLCTjwolFxvdhBGQI3jCo/6ZNPCxsr+IoVIw0HINLgMtYEAFfclOy12vVYc1odRqEvpj6JjjD8iS0vmu1q+vRxF9+oxHP53A1pH9X/5W4zxpkbCXtpXiB4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748792175; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hKEH6Z9JCQimLJL8lPwV9KIkJSWOuDTn31SzP3o0in0=; b=R9CjeW9o4ucVJyJN9Q0wwy1G8gV4IFCydbjj9AhuJULEMdgA6335DFQTgt6/KGv5hBUGwhOEJhxENev3XKoo3SqrY6lkZpjGp5rG94kg+BUMA3lrVotO1vuvmKPS2h1UhdT/fJZgwCIgxUReD/bcl8Y0b+nCra5tHqMrYJLD1A8= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174879217573383.05375909830434; Sun, 1 Jun 2025 08:36:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uLkjN-0004Tu-8f; Sun, 01 Jun 2025 11:36:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uLkjA-0004I5-S0 for qemu-devel@nongnu.org; Sun, 01 Jun 2025 11:36:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uLkiv-0005bm-2Q for qemu-devel@nongnu.org; Sun, 01 Jun 2025 11:36:00 -0400 Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-TB5h96x0MiWmahhCZMJlpA-1; Sun, 01 Jun 2025 11:35:37 -0400 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-55324bc26dcso1698209e87.1 for ; Sun, 01 Jun 2025 08:35:37 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1517:1000:ea83:8e5f:3302:3575]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a4efe5b89dsm11909055f8f.19.2025.06.01.08.24.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Jun 2025 08:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748792138; 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=hKEH6Z9JCQimLJL8lPwV9KIkJSWOuDTn31SzP3o0in0=; b=glS9+XTQkat2uzwCtLf0Vna8AA/r0QMl9cOiPQzB66efpVEFrmzgVwv/GW9Q66yDwAjTVn BVT8tbBheL1SUtS1EH2+VHt8A1AX53HhQIlGgGrAeIOcmbVdLPz03ocBh9txyc84tNE3Ul qMgONcDmLPQpVEiGknewsEF2fAI5XTs= X-MC-Unique: TB5h96x0MiWmahhCZMJlpA-1 X-Mimecast-MFC-AGG-ID: TB5h96x0MiWmahhCZMJlpA_1748792136 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748792136; x=1749396936; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hKEH6Z9JCQimLJL8lPwV9KIkJSWOuDTn31SzP3o0in0=; b=fTx8uHw+2zDcJSwEd8ZEaBxcU2Y1lusMmgZyy7kXnrsdiqQfIsQj6a/32k41buu38M sRKXO4K7IamUyQ52G76bZfWuPeSrNtzIOWUeXryAf7vHYqU5hsgqFLPlg1JcPfZ3udhc VEvMUsuXlz3omj+xtk8Rh32KTyavECg1ib5t1idVg1OkhzdQlwn+RTIt4wAdUG6afMcE Zp6xhOSxVNQ5U9YeHq+5IwxiHzqRdunErpU7qeEDNv4iGQswzDrUHZKyhDh87BE7fXvC P/hy8b4y+Lget73MxMj+/ZDSJcNe217fr2vf/UX9aWwaRCilqaaLvBaK3fch9Y3Oc4Ud HTIQ== X-Gm-Message-State: AOJu0Yz5C5iuUucgoJ0uOvVhJNzjq7YnKORQRI4dlZqFC0MlD3lW0Q6t 8F0IQyifU/XGBhLa60XzpFv2tZ/p4e+tnmJo7In+ryEBgJbZ5fZ5MdgABE9shZ7A369Jd5Q8GNI XMh3bR6v3k+LSvrqyjc/aYTE0xc6ski8bYFBYel75W2qo2X4PnlFl+ef+2sgQQwMWGGAn85qe8U 26ZZQMouLuB0skFLzvb43mDB2Jq+sDmQViQA== X-Gm-Gg: ASbGncvx1Jdy/hKfh56YvUJGkMD5Jm3IrdBD2QwEr9n8sPadGau0vFe+J3yst8opl0i N2GzNsjtn4AUKvwWqJNWo4XmSRzLT2Nr98vHdacpzvhef+nQaFNafco6TCOw/nLDCH3kyevt/Dm 8nCx57+gGx88sY1Sownos63m0NoIj0ysTktRLUAij2cL0SVRlP4Wx3kHubaZmrF4hfAz/HPBm9c DToRsAcoUkQUg7rALldbdGDBCZxWfIBs6qTqo5BRVbDwt9Nhy7Pb89um4lfLSZtUtSSm6Bv5KGX Nx4L3D41kBR/sqmn X-Received: by 2002:a05:600c:3f92:b0:442:f904:1305 with SMTP id 5b1f17b1804b1-450d6b5999bmr95833935e9.6.1748791487749; Sun, 01 Jun 2025 08:24:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHmKWDFQhl1SCz6HHk2dYVS/WFA74r7SfcWFfZWGmgNxihnFEFlOEzISUoCOe0f5IwNy5AWvw== X-Received: by 2002:a05:600c:3f92:b0:442:f904:1305 with SMTP id 5b1f17b1804b1-450d6b5999bmr95833705e9.6.1748791487265; Sun, 01 Jun 2025 08:24:47 -0700 (PDT) Date: Sun, 1 Jun 2025 11:24:45 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Yuri Benditovich Subject: [PULL 01/31] virtio: check for validity of indirect descriptors Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.071, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1748792177750116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Yuri Benditovich virtio processes indirect descriptors even if the respected feature VIRTIO_RING_F_INDIRECT_DESC was not negotiated. If qemu is used with reduced set of features to emulate the hardware device that does not support indirect descriptors, the will probably trigger problematic flows on the hardware setup but do not reveal the mistake on qemu. Add LOG_GUEST_ERROR for such case. This will issue logs with '-d guest_errors' in the command line Signed-off-by: Yuri Benditovich Message-Id: <20250515063237.808293-1-yuri.benditovich@daynix.com> Signed-off-by: Yuri Benditovich --- hw/virtio/virtio.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 2e98cecf64..5534251e01 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -205,6 +205,15 @@ static const char *virtio_id_to_name(uint16_t device_i= d) return name; } =20 +static void virtio_check_indirect_feature(VirtIODevice *vdev) +{ + if (!virtio_vdev_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC)) { + qemu_log_mask(LOG_GUEST_ERROR, + "Device %s: indirect_desc was not negotiated!\n", + vdev->name); + } +} + /* Called within call_rcu(). */ static void virtio_free_region_cache(VRingMemoryRegionCaches *caches) { @@ -1733,6 +1742,7 @@ static void *virtqueue_split_pop(VirtQueue *vq, size_= t sz) virtio_error(vdev, "Invalid size for indirect buffer table"); goto done; } + virtio_check_indirect_feature(vdev); =20 /* loop over the indirect descriptor table */ len =3D address_space_cache_init(&indirect_desc_cache, vdev->dma_a= s, @@ -1870,6 +1880,7 @@ static void *virtqueue_packed_pop(VirtQueue *vq, size= _t sz) virtio_error(vdev, "Invalid size for indirect buffer table"); goto done; } + virtio_check_indirect_feature(vdev); =20 /* loop over the indirect descriptor table */ len =3D address_space_cache_init(&indirect_desc_cache, vdev->dma_a= s, --=20 MST