From nobody Sat May 11 17:35:34 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=1709921562; cv=none; d=zohomail.com; s=zohoarc; b=KzC6SUr3nzTpBWz7GKWltJX+qzY/1QgifUNKYul5ibAKaeL1g24mlP0MuO/mC/6prGSrfQTn5JzYQdWaft40Iq/cyAtCSPVGj/LWUxbsw+JxW3n+LwRi2sIwoGsP27T5fIaL5aUTrnTZrxuOzlmeoZuSQiMB98MRSAe/cwV+UbI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709921562; h=Content-Type:Content-Transfer-Encoding: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=btK1kyt8BalfNBwPiYgdVCxNdJNeq5gpu69gZVwdFqg=; b=KzHXXeUiD2lOcOJ4nBnC3BWugcKtDieyN08aLy/rwDu3FOOwsQg4howHEZRLmBjUP0znHadkx7m9AMqjLTrO8j2VGF1ieK80XvGj1M6MDkhEMjAl7RJeD5glVfP0tpOUT7PRzm94ieCcUN/Mk/Piwlusu+MyVoOedTCoo4TIisY= 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 1709921562021875.5884269633018; Fri, 8 Mar 2024 10:12:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riehc-00076D-5O; Fri, 08 Mar 2024 13:12:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rieha-000761-Ak for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:14 -0500 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 1riehX-0005nF-W4 for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:13 -0500 Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-112-nJKrFPj4MYiAttHll2N0VA-1; Fri, 08 Mar 2024 13:12:09 -0500 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-5135cb04b9fso2888426e87.3 for ; Fri, 08 Mar 2024 10:12:09 -0800 (PST) Received: from [192.168.10.118] ([151.49.77.21]) by smtp.gmail.com with ESMTPSA id n15-20020a170906688f00b00a449cb924dbsm35484ejr.124.2024.03.08.10.12.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 10:12:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709921530; 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=btK1kyt8BalfNBwPiYgdVCxNdJNeq5gpu69gZVwdFqg=; b=Z66/M7+GQ3GLFNCSbABWQrpkk9wwe1q/iRtAk7dUv/8f2YAGfXjXpmn88rH+6bIl9lhBFO ZFFDypESEFPIp+Th7VOwM2juOW+BkYsihfPgirH5XgSYVcgHOFRXIn9nt4HLhNadKNHdVw cBzy2koQZB1jSY/OjGiVYKff3OsLtC8= X-MC-Unique: nJKrFPj4MYiAttHll2N0VA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709921526; x=1710526326; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=btK1kyt8BalfNBwPiYgdVCxNdJNeq5gpu69gZVwdFqg=; b=Dz4lvuo0hBK9oVqCi7MCLYHl+SzlYlwKmooleYUKNHV2ZaYBxodeejSW5jUc43hFgy aSv1qS8wNiqRVM79P1pYtCNOTxWFbPqYw1hpkGh3qZjK4U0CYUCoM8SKNAaCFqtFjHY4 OsYgbl7blhZiIZACGeZ++MZ2FjGfMKbo4EKuQvrqHNGf+f9UTSHSzB0bPhcCGyQ1UAZc TuZCifOSL11mxKK4PoYPSSBv5OJg7+nCGd0oMFMwv65oVhdBDrEmjCcCKHVfFHPcfnot z6zCuDj8dtXVYVMmCr6mncNJ8XFGLkANLSrWcZlLmsJQmvOnQMWH0m3P2tdJ81CQmnFo CKkQ== X-Gm-Message-State: AOJu0YwcFvY6B/IcPfNGigyo6EieLSIEk71R6Gd7HDZmwsWSrxvolcrY X756Zvhd9AwSwCJTloFnFqPr341W1YjhU1kr0x7xe9AUJWpPC0m/hQoN26uEfW17btf6xJRRzXg DqwUNDV1TI921zOebIXUOFKzT3ON2zlP5Z8xuKbpRG+OQbDSjZrQvyv8+elJ6qXn9Wic+ObUP20 coDzBxE2szveX2itt8fGqx8fxqk3FDnQ+XOjaG X-Received: by 2002:a19:915b:0:b0:513:84dc:9568 with SMTP id y27-20020a19915b000000b0051384dc9568mr2961416lfj.32.1709921526588; Fri, 08 Mar 2024 10:12:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgKHQHGOpZVdJDnx5t2dOt7tjRkpvxhagcF1AMNOTIthYnwCIH7DQ7C/Gd2bSNkdwtwxg2XQ== X-Received: by 2002:a19:915b:0:b0:513:84dc:9568 with SMTP id y27-20020a19915b000000b0051384dc9568mr2961388lfj.32.1709921526064; Fri, 08 Mar 2024 10:12:06 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Sven Schnelle , Peter Maydell Subject: [PULL 1/9] hw/scsi/lsi53c895a: add timer to scripts processing Date: Fri, 8 Mar 2024 19:11:53 +0100 Message-ID: <20240308181202.617329-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240308181202.617329-1-pbonzini@redhat.com> References: <20240308181202.617329-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.572, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709921563352100003 Content-Type: text/plain; charset="utf-8" From: Sven Schnelle HP-UX 10.20 seems to make the lsi53c895a spinning on a memory location under certain circumstances. As the SCSI controller and CPU are not running at the same time this loop will never finish. After some time, the check loop interrupts with a unexpected device disconnect. This works, but is slow because the kernel resets the scsi controller. Instead of signaling UDC, start a timer and exit the loop. Until the timer fires, the CPU can process instructions which might changes the memory location. The limit of instructions is also reduced because scripts running on the SCSI processor are usually very short. This keeps the time until the loop is exit short. Suggested-by: Peter Maydell Signed-off-by: Sven Schnelle Message-ID: <20240229204407.1699260-1-svens@stackframe.org> Signed-off-by: Paolo Bonzini --- hw/scsi/lsi53c895a.c | 43 +++++++++++++++++++++++++++++++++---------- hw/scsi/trace-events | 2 ++ 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index d607a5f9fb1..4ff94703816 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -188,7 +188,7 @@ static const char *names[] =3D { #define LSI_TAG_VALID (1 << 16) =20 /* Maximum instructions to process. */ -#define LSI_MAX_INSN 10000 +#define LSI_MAX_INSN 100 =20 typedef struct lsi_request { SCSIRequest *req; @@ -205,6 +205,7 @@ enum { LSI_WAIT_RESELECT, /* Wait Reselect instruction has been issued */ LSI_DMA_SCRIPTS, /* processing DMA from lsi_execute_script */ LSI_DMA_IN_PROGRESS, /* DMA operation is in progress */ + LSI_WAIT_SCRIPTS, /* SCRIPTS stopped because of instruction count limi= t */ }; =20 enum { @@ -224,6 +225,7 @@ struct LSIState { MemoryRegion ram_io; MemoryRegion io_io; AddressSpace pci_io_as; + QEMUTimer *scripts_timer; =20 int carry; /* ??? Should this be an a visible register somewhere? */ int status; @@ -415,6 +417,7 @@ static void lsi_soft_reset(LSIState *s) s->sbr =3D 0; assert(QTAILQ_EMPTY(&s->queue)); assert(!s->current); + timer_del(s->scripts_timer); } =20 static int lsi_dma_40bit(LSIState *s) @@ -1127,6 +1130,12 @@ static void lsi_wait_reselect(LSIState *s) } } =20 +static void lsi_scripts_timer_start(LSIState *s) +{ + trace_lsi_scripts_timer_start(); + timer_mod(s->scripts_timer, qemu_clock_get_us(QEMU_CLOCK_VIRTUAL) + 50= 0); +} + static void lsi_execute_script(LSIState *s) { PCIDevice *pci_dev =3D PCI_DEVICE(s); @@ -1136,6 +1145,11 @@ static void lsi_execute_script(LSIState *s) int insn_processed =3D 0; static int reentrancy_level; =20 + if (s->waiting =3D=3D LSI_WAIT_SCRIPTS) { + timer_del(s->scripts_timer); + s->waiting =3D LSI_NOWAIT; + } + reentrancy_level++; =20 s->istat1 |=3D LSI_ISTAT1_SRUN; @@ -1143,8 +1157,8 @@ again: /* * Some windows drivers make the device spin waiting for a memory loca= tion * to change. If we have executed more than LSI_MAX_INSN instructions = then - * assume this is the case and force an unexpected device disconnect. = This - * is apparently sufficient to beat the drivers into submission. + * assume this is the case and start a timer. Until the timer fires, t= he + * host CPU has a chance to run and change the memory location. * * Another issue (CVE-2023-0330) can occur if the script is programmed= to * trigger itself again and again. Avoid this problem by stopping after @@ -1152,13 +1166,8 @@ again: * which should be enough for all valid use cases). */ if (++insn_processed > LSI_MAX_INSN || reentrancy_level > 8) { - if (!(s->sien0 & LSI_SIST0_UDC)) { - qemu_log_mask(LOG_GUEST_ERROR, - "lsi_scsi: inf. loop with UDC masked"); - } - lsi_script_scsi_interrupt(s, LSI_SIST0_UDC, 0); - lsi_disconnect(s); - trace_lsi_execute_script_stop(); + s->waiting =3D LSI_WAIT_SCRIPTS; + lsi_scripts_timer_start(s); reentrancy_level--; return; } @@ -2197,6 +2206,9 @@ static int lsi_post_load(void *opaque, int version_id) return -EINVAL; } =20 + if (s->waiting =3D=3D LSI_WAIT_SCRIPTS) { + lsi_scripts_timer_start(s); + } return 0; } =20 @@ -2294,6 +2306,15 @@ static const struct SCSIBusInfo lsi_scsi_info =3D { .cancel =3D lsi_request_cancelled }; =20 +static void scripts_timer_cb(void *opaque) +{ + LSIState *s =3D opaque; + + trace_lsi_scripts_timer_triggered(); + s->waiting =3D LSI_NOWAIT; + lsi_execute_script(s); +} + static void lsi_scsi_realize(PCIDevice *dev, Error **errp) { LSIState *s =3D LSI53C895A(dev); @@ -2313,6 +2334,7 @@ static void lsi_scsi_realize(PCIDevice *dev, Error **= errp) "lsi-ram", 0x2000); memory_region_init_io(&s->io_io, OBJECT(s), &lsi_io_ops, s, "lsi-io", 256); + s->scripts_timer =3D timer_new_us(QEMU_CLOCK_VIRTUAL, scripts_timer_cb= , s); =20 /* * Since we use the address-space API to interact with ram_io, disable= the @@ -2337,6 +2359,7 @@ static void lsi_scsi_exit(PCIDevice *dev) LSIState *s =3D LSI53C895A(dev); =20 address_space_destroy(&s->pci_io_as); + timer_del(s->scripts_timer); } =20 static void lsi_class_init(ObjectClass *klass, void *data) diff --git a/hw/scsi/trace-events b/hw/scsi/trace-events index d72f741ed85..f0f2a98c2ee 100644 --- a/hw/scsi/trace-events +++ b/hw/scsi/trace-events @@ -302,6 +302,8 @@ lsi_execute_script_stop(void) "SCRIPTS execution stoppe= d" lsi_awoken(void) "Woken by SIGP" lsi_reg_read(const char *name, int offset, uint8_t ret) "Read reg %s 0x%x = =3D 0x%02x" lsi_reg_write(const char *name, int offset, uint8_t val) "Write reg %s 0x%= x =3D 0x%02x" +lsi_scripts_timer_triggered(void) "SCRIPTS timer triggered" +lsi_scripts_timer_start(void) "SCRIPTS timer started" =20 # virtio-scsi.c virtio_scsi_cmd_req(int lun, uint32_t tag, uint8_t cmd) "virtio_scsi_cmd_r= eq lun=3D%u tag=3D0x%x cmd=3D0x%x" --=20 2.43.2 From nobody Sat May 11 17:35:34 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=1709921597; cv=none; d=zohomail.com; s=zohoarc; b=XFVPLSX4QKXWmcLIpIjIu+uEvNgdQ3RgEI7glYxRcpbpn+u9Ak5G81gEpDMcq8Mhp2Xijm+OuGQuBNZv4+FCJZMen0d0kZGA2c5A9MmVrBKSRdDUon1OFTMr3DkM3W55ih/pmZPTunPmEV/8sL2GxAy9l+dQOELi2NjWplyDX4k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709921597; h=Content-Type:Content-Transfer-Encoding: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=3zgiv6UZ6Oh2NFmnmSITDqW1+MhIa91EcBCRfhCM6ng=; b=QzKD9vF0C/iKUScLmgTRhBMP3pkPlIVkgSz1PGK+CwuwGwYEp1oUuhJlznM+vMplhYByJ5w/ZcV1Gvz39tBFisl7JdMN/Z3rCYx9R24Mua6rAdgH4rK2oK13AiHkuD3zC7iA9R6EpwQPa6ZF47C5dXPRt5NPJSeGEElZvlczi/c= 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 1709921597754693.7956086501157; Fri, 8 Mar 2024 10:13:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riehj-00077p-Pf; Fri, 08 Mar 2024 13:12:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riehe-00076d-9a for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:19 -0500 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 1rieha-0005nR-5F for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:17 -0500 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-20-e02MUPo9OSisFZBaEPB4bQ-1; Fri, 08 Mar 2024 13:12:11 -0500 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a450265c7b6so142675066b.0 for ; Fri, 08 Mar 2024 10:12:11 -0800 (PST) Received: from [192.168.10.118] ([151.49.77.21]) by smtp.gmail.com with ESMTPSA id qk2-20020a170906d9c200b00a3fb9f1f10csm34462ejb.161.2024.03.08.10.12.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 10:12:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709921533; 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=3zgiv6UZ6Oh2NFmnmSITDqW1+MhIa91EcBCRfhCM6ng=; b=R3Dl5OWil3Tv6mrbFLl1G//UmrBvMzigLXQqCqIjRC/vcYPBj/6FRcLP4MNY3GQx3ex1lI D8CwaykPz+iArlNF55bO5mDSidQ4fG9r09MrCzW3OixBrnqHYCVS7a4RXbmU9lxCVUmFpZ zWPTXwgizww40RdPO/Gddm8QL8ayxbI= X-MC-Unique: e02MUPo9OSisFZBaEPB4bQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709921529; x=1710526329; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3zgiv6UZ6Oh2NFmnmSITDqW1+MhIa91EcBCRfhCM6ng=; b=mE/LcDqSVMHoPdEO38mNG5PXO9l6t5bHKPePuYGB5zMdR9iasS0rMDseSN/gWYWcLi CHotN7664ae80XMVfQQDbx5uCJSy0GcKWeeZZ5OGlwQXMXhlTIzl4D/O+CfFCr7hqiNn UcxtpIcqFGAUPAr5tqmw3Y7ws3ThtReyh+rRAwwWeGUhwfHqLv7rTpEyL8kVc10rbFIc 0YwR6Y3EAjqh6sPyNTPvKSHZXFW09AmGz6C7kV+qLjBxmmdLGzPGMDjOTxm9QyzQkuU4 cTrNuevJUgO/81jup9SaP2WSMkdHhrROngzr8juOlmaSpB0nVWtHP9c6Ix2v+IDz3wAQ yBmg== X-Gm-Message-State: AOJu0YwS1eC/4S0vjHi+kjuTl5DKlzPdia488IlnNknJjw4R/sJNerCV Le3djbMGw8MbvLT7tkwMQFe9dpL9TJbPbei/466EL6O2BnWJ0tt6ccDIgkIurcf7klaE76Dzise tzAbii6B0n5hvQDqr53QNGAwj3xWDtG95QUKpRnZyghq5xEmRmoYX3WhUqib/5GVtrmNpryp6ON FzNXlB45QpmfMczXctGeNQjPoQB8s0GLZd7pqG X-Received: by 2002:a17:906:5a9a:b0:a44:48db:9060 with SMTP id l26-20020a1709065a9a00b00a4448db9060mr13864474ejq.19.1709921529511; Fri, 08 Mar 2024 10:12:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYXYgTpjHVOuKD6hlcLFJDwpr/l1BA+IeuIzlRiODg8q/CRESZpSO+iBDeDanQBBqO+b9I+A== X-Received: by 2002:a17:906:5a9a:b0:a44:48db:9060 with SMTP id l26-20020a1709065a9a00b00a4448db9060mr13864461ejq.19.1709921529115; Fri, 08 Mar 2024 10:12:09 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Dmitrii Gavrilov , qemu-stable@nongnu.org Subject: [PULL 2/9] system/qdev-monitor: move drain_call_rcu call under if (!dev) in qmp_device_add() Date: Fri, 8 Mar 2024 19:11:54 +0100 Message-ID: <20240308181202.617329-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240308181202.617329-1-pbonzini@redhat.com> References: <20240308181202.617329-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.572, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1709921599519100005 Content-Type: text/plain; charset="utf-8" From: Dmitrii Gavrilov Original goal of addition of drain_call_rcu to qmp_device_add was to cover the failure case of qdev_device_add. It seems call of drain_call_rcu was misplaced in 7bed89958bfbf40df what led to waiting for pending RCU callbacks under happy path too. What led to overall performance degradation of qmp_device_add. In this patch call of drain_call_rcu moved under handling of failure of qdev_device_add. Signed-off-by: Dmitrii Gavrilov Message-ID: <20231103105602.90475-1-ds-gavr@yandex-team.ru> Fixes: 7bed89958bf ("device_core: use drain_call_rcu in in qmp_device_add",= 2020-10-12) Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- system/qdev-monitor.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index a13db763e5d..874d65191ce 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -858,19 +858,18 @@ void qmp_device_add(QDict *qdict, QObject **ret_data,= Error **errp) return; } dev =3D qdev_device_add(opts, errp); - - /* - * Drain all pending RCU callbacks. This is done because - * some bus related operations can delay a device removal - * (in this case this can happen if device is added and then - * removed due to a configuration error) - * to a RCU callback, but user might expect that this interface - * will finish its job completely once qmp command returns result - * to the user - */ - drain_call_rcu(); - if (!dev) { + /* + * Drain all pending RCU callbacks. This is done because + * some bus related operations can delay a device removal + * (in this case this can happen if device is added and then + * removed due to a configuration error) + * to a RCU callback, but user might expect that this interface + * will finish its job completely once qmp command returns result + * to the user + */ + drain_call_rcu(); + qemu_opts_del(opts); return; } --=20 2.43.2 From nobody Sat May 11 17:35:34 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=1709921617; cv=none; d=zohomail.com; s=zohoarc; b=GyRzOgwPVf8d+eRgsTHASODclsWHVs9IGSbQUt54e85opXyo7zuqbWd5tQq4CbJ2BaWf75eMm6Jp5SM+u6tbw5F4XOYJGnTZvLxzFPI+q57Jk/GG3lAsTBtFokyvNNQRZVvriyjKwMWjJ28xShcJ+Qn5BiZAyAmf2csgJt4rPEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709921617; h=Content-Type:Content-Transfer-Encoding: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=qSLSAV6AzeUGqChFbxsNaHAkQhSsp716NDVyKQt1iAM=; b=mV6HRAW/qZwZZ44ejiyBVXNd9cDcDm98WUxTFMbnBAvItEzEn0t+/QMpoV2Q+DRGqLu4Y5nrl/0tmgrIGnKbRGt5fnePnt17DnPpxSm4aqPV1cJ683qVgkewefjWiMiojDgjFo80KqMZRNnW4jzpjCOcsSvUANV+yO0+O4D8CLc= 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 1709921617035824.0040989022037; Fri, 8 Mar 2024 10:13:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riehq-0007BY-8H; Fri, 08 Mar 2024 13:12:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rieho-0007Al-JQ for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riehe-0005nj-05 for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:28 -0500 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-387-cmEtV2S-PemMw9SV7S3FXg-1; Fri, 08 Mar 2024 13:12:14 -0500 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a3fb52f121eso160594666b.0 for ; Fri, 08 Mar 2024 10:12:14 -0800 (PST) Received: from [192.168.10.118] ([151.49.77.21]) by smtp.gmail.com with ESMTPSA id m22-20020a1709066d1600b00a451d07711csm40056ejr.82.2024.03.08.10.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 10:12:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709921536; 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=qSLSAV6AzeUGqChFbxsNaHAkQhSsp716NDVyKQt1iAM=; b=XiiMMfEJmsdY5ZpJEeohpLn/Edzpjc40ig3pvvHYr/ae5mmcdQ6hlSU83dsxycBzo5iETm U90VqnJLVxs6uCowGp/E+Ycu4yiq9mrHyfBdlJS1wDbWOo72prcEnH118HEpSZFiLSp0NU EFVUCiaE1AFWagjRmS62+6qtE8vZWtI= X-MC-Unique: cmEtV2S-PemMw9SV7S3FXg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709921532; x=1710526332; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qSLSAV6AzeUGqChFbxsNaHAkQhSsp716NDVyKQt1iAM=; b=cbjwyngxZ4YbKGHtvSoGdsgafTytBf26MsqEOYzqRvuC5417TtR9sKhH/1YDh74eDK V7WoE8906LZEIh5zoHc0mXmo4R8KXmWT/YMm9ud/xgLVLuO+AtKnY8qI74XucyOLqMoq UwafRwCw5G20YaMRkSRRlJ8lVV8JwxG60hscHu27crbXJOCn/y1L8KSleS8VwMgDrHvA 5jXYw2fEK/l3iE2YOfUXRd9dp9isHqemHjdDzIc3TyqRkxhCwqymmd7CwJN8bmuj4ZyQ UeRloWv7JkZZTMXi6/e4RRXbiu9t/HZRXVk5waTomW2F/naa36sjmrgkOyeQxNJgn+1t Qi3Q== X-Gm-Message-State: AOJu0YxsqIGrw+QDgt81ZFbgGtBqwcchT5IhUV9LYAKzF4SRt/bUOCdK WCEmI4mLVNYRhKgEpbb5avrbwVyE7rjbrJiztfSiOJ5YnLXuAzy5DmhCoMtR4loWOT2jsEGRfkc VsLk/dD6e9ZgWSeq19UYIetkr9MTA7hQntNTbnh0ibKw5eamH7Vpk5MACY7lu3WaM+FEBzlFGlE 41NeGqVRoqvqNMG3HiyMVb9xQXx7sEnnQr9lvh X-Received: by 2002:a17:906:55d3:b0:a45:ae8b:eece with SMTP id z19-20020a17090655d300b00a45ae8beecemr7403456ejp.59.1709921532401; Fri, 08 Mar 2024 10:12:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFej94m18XeJGwayhUbLTLyfuG5eHDVsXiw9n/XdoERJ+y/irFVZR8bGMQL0kyXcOIPKbUzQ== X-Received: by 2002:a17:906:55d3:b0:a45:ae8b:eece with SMTP id z19-20020a17090655d300b00a45ae8beecemr7403436ejp.59.1709921532051; Fri, 08 Mar 2024 10:12:12 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Akihiko Odaki Subject: [PULL 3/9] meson: Remove --warn-common ldflag Date: Fri, 8 Mar 2024 19:11:55 +0100 Message-ID: <20240308181202.617329-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240308181202.617329-1-pbonzini@redhat.com> References: <20240308181202.617329-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709921617469100001 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki --warn-common ldflag causes warnings for multiple definitions of ___asan_globals_registered when enabling AddressSanitizer with clang. The warning is somewhat obsolete so just remove it. The common block is used to allow duplicate definitions of uninitialized global variables. In the past, GCC and clang used to place such variables in a common block by default, which prevented programmers for noticing accidental duplicate definitions. Commit 49237acdb725 ("Enable ld flag --warn-common") added --warn-common ldflag so that ld warns in such a case. Today, both of GCC and clang don't use common blocks by default[1][2] so any remaining use of common blocks should be intentional. Remove --warn-common ldflag to suppress warnings for intentional use of common blocks. [1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D85678 [2]: https://reviews.llvm.org/D75056 Signed-off-by: Akihiko Odaki Message-ID: <20240304-common-v1-1-1a2005d1f350@daynix.com> Signed-off-by: Paolo Bonzini --- meson.build | 5 ----- 1 file changed, 5 deletions(-) diff --git a/meson.build b/meson.build index c59ca496f2d..f9dbe7634e5 100644 --- a/meson.build +++ b/meson.build @@ -476,11 +476,6 @@ if host_os =3D=3D 'windows' qemu_ldflags +=3D cc.get_supported_link_arguments('-Wl,--dynamicbase', '= -Wl,--high-entropy-va') endif =20 -# Exclude --warn-common with TSan to suppress warnings from the TSan libra= ries. -if host_os !=3D 'sunos' and not get_option('tsan') - qemu_ldflags +=3D cc.get_supported_link_arguments('-Wl,--warn-common') -endif - if get_option('fuzzing') # Specify a filter to only instrument code that is directly related to # virtual-devices. --=20 2.43.2 From nobody Sat May 11 17:35:34 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=1709921633; cv=none; d=zohomail.com; s=zohoarc; b=UBwUOvoomgJbcpSd8NGzZpANZWznsGsNPo/l4atruiZOnq8RMhO3EIEIBXRRZOo++b77XJaWWMKgk4W5M+jaPcktvzodTemFsTIefBCudgUJeF2e2yFud3REBuu8dvh2vHxpXdUSBbp/H6PGQ+ZsRU519NZVFtApanPCRFpg/DA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709921633; h=Content-Type:Content-Transfer-Encoding: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=Ff3Hzr/qQnFeHJ3R0iUom7wtGXBzK9NGYQzCU5YsyUA=; b=UjcH81MCOBGj3fONlhHz8953f7raH/Gz6e9YE0D+bkiKjuWFCNOONt37VbR7PasLT/LXpItDqqrnFTNSnVCEonEGX9d99y4pEFo2eHd4W+EkTZsA1NNsi5TYs3yDIycEeFIrGtFc4LF0iKmLPJcnDCLEsvDAqQS4b9FRPu7OL/o= 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 1709921633146972.5218848820693; Fri, 8 Mar 2024 10:13:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riehm-00079z-0P; Fri, 08 Mar 2024 13:12:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riehj-000780-UL for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:24 -0500 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 1riehh-0005o0-G8 for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:23 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-JNZ7ypJBPZK1txaij32Wug-1; Fri, 08 Mar 2024 13:12:18 -0500 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5670ee87ca4so1108720a12.2 for ; Fri, 08 Mar 2024 10:12:17 -0800 (PST) Received: from [192.168.10.118] ([151.49.77.21]) by smtp.gmail.com with ESMTPSA id x14-20020aa7dace000000b005671100145dsm22397eds.55.2024.03.08.10.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 10:12:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709921539; 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=Ff3Hzr/qQnFeHJ3R0iUom7wtGXBzK9NGYQzCU5YsyUA=; b=IuqpmqQhWftqmnZDu6ftGxdifvL87JTbFywVOaSolwdbpJxSeEimQnSJwp/OyuefJAgg9z aNTgrnSXigSJ3xaB9BnasDdndFi5hupmtRW19/wHg6FNGH/1tESUvz2DBMPs8q/M3IT9h3 L6kAThQbz2xXbFgKTtGvm7zhBgQxqeo= X-MC-Unique: JNZ7ypJBPZK1txaij32Wug-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709921535; x=1710526335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ff3Hzr/qQnFeHJ3R0iUom7wtGXBzK9NGYQzCU5YsyUA=; b=Bsb6T45IuTxHpNI0cFivXsjCG6ZlVuCwfOyLKToxNHMSpJhA9HGGbd+qz/JkccQCMt JXzWFsHwcgWFY9r44x9I6eQJB8nxcfhWOJLJnvVhzqCVwUd2z8TmckKWTwpSTE7p5z7R ZyCvXc8raw9aUUmcNxxXXc0AACIVLWk6DG6TWgIxjtMrZefStZ+VE7u6jNeVcJbEWFGb EHKbPUcHz59mcE/3Tvr9tmlYeEPXXn3x0U3G4TNLs8Lm8tcMYVWrcJOSOqeoU16iN+T6 Dqihv8qv/+3kkzdHTE+mIi15hQYfKc5hFvhPJMHoI7Myl7wPJJAAWGCKaFxhs2MIaqS/ fIgA== X-Gm-Message-State: AOJu0Yy3D4mXKn+h6dpY8hfc5ghgof+SECWFZL+qjRR5WGOHsURIqFbC ZCo074NBTy7lMFgePJAeqhZ7UUPnTtVISpBYPpfKm+Tf7Aez+aR98H5ckft7QbgvgppNictTTey r7sHQRrl3B0gYdER7IDghiNMWFiFF9ePHC3fqGqjSqKdxIAFUMYStH5RLlkx35JG6ED+E1dNH1o BLSpIPkDWRGuboNSUxwFEIWDCXaZutiWaX9rC3 X-Received: by 2002:a50:9faa:0:b0:565:59a:a103 with SMTP id c39-20020a509faa000000b00565059aa103mr29893edf.33.1709921535244; Fri, 08 Mar 2024 10:12:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPnsqjXmf/kRkEMik4h43dtMchE9C+ZRTsPbTw4NMAyyI5/k3Ji+e91QH6IqGuhsqS1o5hsw== X-Received: by 2002:a50:9faa:0:b0:565:59a:a103 with SMTP id c39-20020a509faa000000b00565059aa103mr29876edf.33.1709921534821; Fri, 08 Mar 2024 10:12:14 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Sven Schnelle , Helge Deller Subject: [PULL 4/9] hw/scsi/lsi53c895a: stop script on phase mismatch Date: Fri, 8 Mar 2024 19:11:56 +0100 Message-ID: <20240308181202.617329-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240308181202.617329-1-pbonzini@redhat.com> References: <20240308181202.617329-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.572, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709921633561100001 Content-Type: text/plain; charset="utf-8" From: Sven Schnelle Netbsd isn't happy with qemu lsi53c895a emulation: cd0(esiop0:0:2:0): command with tag id 0 reset esiop0: autoconfiguration error: phase mismatch without command esiop0: autoconfiguration error: unhandled scsi interrupt, sist=3D0x80 ssta= t1=3D0x0 DSA=3D0x23a64b1 DSP=3D0x50 This is because lsi_bad_phase() triggers a phase mismatch, which stops SCRIPT processing. However, after returning to lsi_command_complete(), SCRIPT is restarted with lsi_resume_script(). Fix this by adding a return value to lsi_bad_phase(), and only resume script processing when lsi_bad_phase() didn't trigger a host interrupt. Signed-off-by: Sven Schnelle Tested-by: Helge Deller Message-ID: <20240302214453.2071388-1-svens@stackframe.org> Signed-off-by: Paolo Bonzini --- hw/scsi/lsi53c895a.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index 4ff94703816..59b88aff3fb 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -573,8 +573,9 @@ static inline void lsi_set_phase(LSIState *s, int phase) s->sstat1 =3D (s->sstat1 & ~PHASE_MASK) | phase; } =20 -static void lsi_bad_phase(LSIState *s, int out, int new_phase) +static int lsi_bad_phase(LSIState *s, int out, int new_phase) { + int ret =3D 0; /* Trigger a phase mismatch. */ if (s->ccntl0 & LSI_CCNTL0_ENPMJ) { if ((s->ccntl0 & LSI_CCNTL0_PMJCTL)) { @@ -587,8 +588,10 @@ static void lsi_bad_phase(LSIState *s, int out, int ne= w_phase) trace_lsi_bad_phase_interrupt(); lsi_script_scsi_interrupt(s, LSI_SIST0_MA, 0); lsi_stop_script(s); + ret =3D 1; } lsi_set_phase(s, new_phase); + return ret; } =20 =20 @@ -792,7 +795,7 @@ static int lsi_queue_req(LSIState *s, SCSIRequest *req,= uint32_t len) static void lsi_command_complete(SCSIRequest *req, size_t resid) { LSIState *s =3D LSI53C895A(req->bus->qbus.parent); - int out; + int out, stop =3D 0; =20 out =3D (s->sstat1 & PHASE_MASK) =3D=3D PHASE_DO; trace_lsi_command_complete(req->status); @@ -800,7 +803,10 @@ static void lsi_command_complete(SCSIRequest *req, siz= e_t resid) s->command_complete =3D 2; if (s->waiting && s->dbc !=3D 0) { /* Raise phase mismatch for short transfers. */ - lsi_bad_phase(s, out, PHASE_ST); + stop =3D lsi_bad_phase(s, out, PHASE_ST); + if (stop) { + s->waiting =3D 0; + } } else { lsi_set_phase(s, PHASE_ST); } @@ -810,7 +816,9 @@ static void lsi_command_complete(SCSIRequest *req, size= _t resid) lsi_request_free(s, s->current); scsi_req_unref(req); } - lsi_resume_script(s); + if (!stop) { + lsi_resume_script(s); + } } =20 /* Callback to indicate that the SCSI layer has completed a transfer. */ --=20 2.43.2 From nobody Sat May 11 17:35:34 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=1709921636; cv=none; d=zohomail.com; s=zohoarc; b=FK+pxH5oDqgES3VpTqWFztgeK/5gex9MRVA0d66dmxiWXahaJtiv6fDHoGV+ekCNWBesfOBlvjzi8gminDxaj9R5mLI+9qMT8hWDERxuGGm0naO2cBbYw8zw7r4vqWXj3vtQq/LS4tFNqxYBsuBbqFKs73Y0a1P1oW2/k+oV3D8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709921636; h=Content-Type:Content-Transfer-Encoding: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=is4uaTsB7JqW33WeDjUhKzI7gp3GUbX8PHe/5xTz5cQ=; b=im3Exp7FZxoJzSk+jT7U+n/WiaKFC6748ArUnduHhhPS66KrvYHkFaByXqyyUyid/lyvWwVBGLaAyF98OOHhSbjidxFqt0S3og7YIhzl3wGyDYDiGKm8qUCW3bahaMir2FAYBGEZ3hmmRJGNc2GnHBQ0jYdOOZc0LBSUCYYGtso= 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 1709921636847253.88625873062415; Fri, 8 Mar 2024 10:13:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riehm-0007A7-HG; Fri, 08 Mar 2024 13:12:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riehl-00079y-Si for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riehi-0005o9-2s for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:24 -0500 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-169-pNafbxupPzqctGn2qtm23A-1; Fri, 08 Mar 2024 13:12:20 -0500 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a4489805a2dso43607966b.2 for ; Fri, 08 Mar 2024 10:12:19 -0800 (PST) Received: from [192.168.10.118] ([151.49.77.21]) by smtp.gmail.com with ESMTPSA id j7-20020a170906278700b00a4324ae24dbsm40450ejc.62.2024.03.08.10.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 10:12:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709921541; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=is4uaTsB7JqW33WeDjUhKzI7gp3GUbX8PHe/5xTz5cQ=; b=Pi2AYXJr5sRjKU8TsxFtTvjPlHBO1Kt2/r9FM5nyZH/Js8Wvu/ncA6MoYWihq5fxCvl1eF /QZwWi4GQOkGjC9BAeBsBH/QSfxv64x4q5VX2sgcX/MT1dh4Y03nKmlGvtWgQL3HM8b98x vAfFVrXlBk+uTWb9B6nBZv8WjsbIURo= X-MC-Unique: pNafbxupPzqctGn2qtm23A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709921538; x=1710526338; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=is4uaTsB7JqW33WeDjUhKzI7gp3GUbX8PHe/5xTz5cQ=; b=k/EMQ5Sproozyqum9kuM7NRPYjvpqYFTZoToXjT4ALLx6Eh/9wFR7K/rHOTO+pSqom 6jH30DtejNewApe77TuiUe1JOpMflgN/Y1cts9wqsLXDgRJk0e1u14zBOJCSJBOYEl1y 0jg2OhXXXrDJnPFlr7zC/EWrKaVxBrN+tnTDQadRGhgaoYJP/7gNw+XdQ3Uq2kVc8qt+ tHipxqpjL4XGfY3eYfit4J+XZ0OtDx/zysofUK4x2KiGZgBA3veeJEUKAfII9m1X/a9d mWzBicCzDyPDh+K/0y/y15aX6NsGLT04l4HQ9SCt0SJlAMPg/AKyv/IJYa9JdBcsbTex oPAQ== X-Gm-Message-State: AOJu0YwjP0NY2zM5zrv3sL5q5jPZmTLu99udOaFGVmHMpkuyzvapOmbS 6M9qciiSCGxxKNTmuIyAL1MTKSCYimJJtrPCDaqCgpvqfNe3qfn+8YWW3Ep4lITnV91Iy75iUHs svVY/+yS+AVcFXRxkHwtUFOPKLeJewD/G7AUSJqvS2aa6GSFdsyKdiH60FmOW5FAJBynKbLkhK3 5yNausWHqLd/RPd13ZA7NLgprbnK71Jdp4fmwp X-Received: by 2002:a17:906:4109:b0:a45:a3e9:debd with SMTP id j9-20020a170906410900b00a45a3e9debdmr8126507ejk.59.1709921538571; Fri, 08 Mar 2024 10:12:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEGZIJA4sb4gzAYwgu1CNu5gtYm00yZm1oZIG1uSvRqPlfmJpJUKRZ7JaB/aeI+bBhxQpJwnw== X-Received: by 2002:a17:906:4109:b0:a45:a3e9:debd with SMTP id j9-20020a170906410900b00a45a3e9debdmr8126498ejk.59.1709921538325; Fri, 08 Mar 2024 10:12:18 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bui Quang Minh Subject: [PULL 5/9] hw/intc/apic: fix memory leak Date: Fri, 8 Mar 2024 19:11:57 +0100 Message-ID: <20240308181202.617329-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240308181202.617329-1-pbonzini@redhat.com> References: <20240308181202.617329-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset=UTF-8 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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709921637589100001 deliver_bitmask is allocated on the heap in apic_deliver(), but there are many paths in the function that return before the corresponding g_free() is reached. Fix this by switching to g_autofree and, while at it, also switch to g_new. Do the same in apic_deliver_irq() as well for consistency. Fixes: b5ee0468e9d ("apic: add support for x2APIC mode", 2024-02-14) Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Bui Quang Minh Signed-off-by: Paolo Bonzini --- hw/intc/apic.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/intc/apic.c b/hw/intc/apic.c index 1d887d66b86..4186c57b34c 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -291,14 +291,13 @@ static void apic_deliver_irq(uint32_t dest, uint8_t d= est_mode, uint8_t delivery_mode, uint8_t vector_num, uint8_t trigger_mode) { - uint32_t *deliver_bitmask =3D g_malloc(max_apic_words * sizeof(uint32_= t)); + g_autofree uint32_t *deliver_bitmask =3D g_new(uint32_t, max_apic_word= s); =20 trace_apic_deliver_irq(dest, dest_mode, delivery_mode, vector_num, trigger_mode); =20 apic_get_delivery_bitmask(deliver_bitmask, dest, dest_mode); apic_bus_deliver(deliver_bitmask, delivery_mode, vector_num, trigger_m= ode); - g_free(deliver_bitmask); } =20 bool is_x2apic_mode(DeviceState *dev) @@ -662,7 +661,7 @@ static void apic_deliver(DeviceState *dev, uint32_t des= t, uint8_t dest_mode, APICCommonState *s =3D APIC(dev); APICCommonState *apic_iter; uint32_t deliver_bitmask_size =3D max_apic_words * sizeof(uint32_t); - uint32_t *deliver_bitmask =3D g_malloc(deliver_bitmask_size); + g_autofree uint32_t *deliver_bitmask =3D g_new(uint32_t, max_apic_word= s); uint32_t current_apic_id; =20 if (is_x2apic_mode(dev)) { @@ -708,7 +707,6 @@ static void apic_deliver(DeviceState *dev, uint32_t des= t, uint8_t dest_mode, } =20 apic_bus_deliver(deliver_bitmask, delivery_mode, vector_num, trigger_m= ode); - g_free(deliver_bitmask); } =20 static bool apic_check_pic(APICCommonState *s) --=20 2.43.2 From nobody Sat May 11 17:35:34 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=1709921875; cv=none; d=zohomail.com; s=zohoarc; b=VaLwc6VIwGfEcwgQmOFYcEn1M/PLrMuuoGHXOYLbkpXbjc+1VDzYPWXDafwWRhbBKNfhFmETvSIIStdFVU3rdFv+OeipDCSqmqNknAgNYeUbY+LPSHE8dix2hx73bbT/Heu83BXA2/9BRYdeCWsKlHzVuqK/ftqcPv4r7l5Uu2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709921875; h=Content-Type:Content-Transfer-Encoding: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=Q0rmMaJt4MALPwGW3i+DaPD4OmnBD3wO03Edu/ZWJ8Q=; b=HXFdCTEqf7K1CUyxvcJ/AhcvFGa7JCvUquZn0E1K2UtmIf4jVdU6ag7wbCcoskGiPyxz+yW9XeQsuPlIIS/m6Y4yiFpqG1Na7hSjjjg/mRAzTsW4Wx/jz8nNpAcH1PY9T8bFKlgA+MeTplvJvnsaAyJPwOZ8pK+z8Isv+ZhcJqw= 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 1709921875199685.8872286781058; Fri, 8 Mar 2024 10:17:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riemk-0005Gp-Qt; Fri, 08 Mar 2024 13:17:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riemj-0005GY-0D for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:17:33 -0500 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 1riemh-0006Wd-Mp for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:17:32 -0500 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-456-vDmTjBYzNmKYQzbsAww_rQ-1; Fri, 08 Mar 2024 13:17:29 -0500 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-568375181b6so122545a12.3 for ; Fri, 08 Mar 2024 10:17:28 -0800 (PST) Received: from [192.168.10.118] ([151.49.77.21]) by smtp.gmail.com with ESMTPSA id x25-20020aa7d6d9000000b005682aa466c0sm24090edr.29.2024.03.08.10.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 10:12:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709921850; 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=Q0rmMaJt4MALPwGW3i+DaPD4OmnBD3wO03Edu/ZWJ8Q=; b=FE4ryMavcyZ6916J4cggXQFDRK0pldo4TTNUdbTZZlSMhUxd2/qnfprEclQerFQNypGHo2 W8dG5EtQMO8eYAzx5st6QIWUaxM6hC7F8e46Zfu+oAgya/dVLfd6NWBJApgkNVPFUQ02ua tGSqYDPA9ih8rn1LMHv3Y7+VPIelmMg= X-MC-Unique: vDmTjBYzNmKYQzbsAww_rQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709921541; x=1710526341; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q0rmMaJt4MALPwGW3i+DaPD4OmnBD3wO03Edu/ZWJ8Q=; b=snDXnMRLtkvRoRSD6ECFwiebHv8a97ffczmJ1JKwGdXyhgN5J098kbSgSRl+YHMgkJ Ws1y5GKNBMs8uDcsLuKeadePKD4CvMCZ1TtYoXe2vhcAlg9xfj+zb8JXlXLBP4k4P1cE n0U9hvdxr7gN+gM+aMkFSSwnHjn7YsbrQZQwDIL1J6x+y+Rs9zD9JTA4TxEGAohhVRgW trMPfYhPlOQkrADUnckBp66EzxvD9P2zjQeMfV3SRb3xBmgj4dmBijnqUB0m+iDBCII3 7lCYYdHhd2983gQAZGuPYhQySZQ1hhntkNmyiOIqwLxUTnTbxkTRRszoOlRiWzDjxO// MuUA== X-Gm-Message-State: AOJu0YzgdyWw4NXsgY1yPoE+bt2hVzoRdxs5ND0bBMz4zu4dhVnWeMz7 ef3oJpvYJj6cUSt+sxL1O+qMYQUDjq2HXx6yauClMfk6yPp7TogEOf0QAOg+AMnTg/Xgn4WBYvp vR46HCPm5mFlWWAB86UaUjoThh99mvhEAg1c3c9EhDu2/+LtccDdKx5u36S7JIz0mLKZhqcLlW8 MJkoFvOBgjFKK/uAJGBCL/F3ifQheqikH7zKPQ X-Received: by 2002:a50:9513:0:b0:568:3362:cccd with SMTP id u19-20020a509513000000b005683362cccdmr40805eda.18.1709921541229; Fri, 08 Mar 2024 10:12:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIX+EvfcKhby1K7uu2EGAt4ASAvNiB6e5c/doL/0Vyb/gRyefxKShNFntcuwMUtR051N/qvQ== X-Received: by 2002:a50:9513:0:b0:568:3362:cccd with SMTP id u19-20020a509513000000b005683362cccdmr40796eda.18.1709921540948; Fri, 08 Mar 2024 10:12:20 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Mark Kanda Subject: [PULL 6/9] oslib-posix: fix memory leak in touch_all_pages Date: Fri, 8 Mar 2024 19:11:58 +0100 Message-ID: <20240308181202.617329-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240308181202.617329-1-pbonzini@redhat.com> References: <20240308181202.617329-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.572, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709921876114100003 Content-Type: text/plain; charset="utf-8" touch_all_pages() can return early, before creating threads. In this case, however, it leaks the MemsetContext that it has allocated at the beginning of the function. Reported by Coverity as CID 1534922. Fixes: 04accf43df8 ("oslib-posix: initialize backend memory objects in para= llel", 2024-02-06) Reviewed-by: Mark Kanda Signed-off-by: Paolo Bonzini --- util/oslib-posix.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 3c379f96c26..e76441695bd 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -467,11 +467,13 @@ static int touch_all_pages(char *area, size_t hpagesi= ze, size_t numpages, * preallocating synchronously. */ if (context->num_threads =3D=3D 1 && !async) { + ret =3D 0; if (qemu_madvise(area, hpagesize * numpages, QEMU_MADV_POPULATE_WRITE)) { - return -errno; + ret =3D -errno; } - return 0; + g_free(context); + return ret; } touch_fn =3D do_madv_populate_write_pages; } else { --=20 2.43.2 From nobody Sat May 11 17:35:34 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=1709921628; cv=none; d=zohomail.com; s=zohoarc; b=O/IYPh+eXiqerdOZAOESqZ5Euq9T+hGlvndGB9vVnIseKbtV/51UaWATsNDaEz+QsSTKzmFRecTqM+wwnnRNKe2/a4XC8VrlcKeimBSV6p9ZSsvv5oMne/5GjaeyM0LkXrWOEL+bNigKvLF0us9z0cNzvK62BpadCjXVi6r4fU4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709921628; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=3KoCC3GLxKllev6oWHU5ANiWBK8CXBJdkMjLAQdqd4w=; b=g1eTfvsyt2rHVaBCNRAwp5txeuYoWI14nubp+7orr8OGDvNKxP3nI90FH+B6r8fKgZAx3stEIyl5NJS8GrKcpSt4JpuK58hkE6eO6MYeTS+v/an5zXgamv6bFEh73gD+5Kk5VsNqSS1yv1k3x7gxygrpZWLnklPkAj5x/tE0tmc= 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 1709921628712177.66701920657704; Fri, 8 Mar 2024 10:13:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riehr-0007Ch-Py; Fri, 08 Mar 2024 13:12:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riehq-0007Bn-P7 for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riehp-0005q1-6B for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:30 -0500 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-325-49ZmrepCO1SFTZ2YveS47g-1; Fri, 08 Mar 2024 13:12:26 -0500 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a45b4f09107so91456166b.1 for ; Fri, 08 Mar 2024 10:12:26 -0800 (PST) Received: from [192.168.10.118] ([151.49.77.21]) by smtp.gmail.com with ESMTPSA id w15-20020a170906480f00b00a45beabb104sm34549ejq.159.2024.03.08.10.12.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 10:12:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709921548; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3KoCC3GLxKllev6oWHU5ANiWBK8CXBJdkMjLAQdqd4w=; b=H3IueYVFSpvtptGf0rZsoqeAHHzwKjawRp7hRiBv3ELCIO7vce3v3/OHxZbaySPFtpSW80 SMVs6m2bOkDF2k5blX5uX6Npui6QOJRdYjwd5zNuj8NbCM9fYlaq0Ehn6BketSgoMU75k8 rP6Kb6mBv5IRF9jUeDW9FrKkNxHpH2s= X-MC-Unique: 49ZmrepCO1SFTZ2YveS47g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709921544; x=1710526344; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3KoCC3GLxKllev6oWHU5ANiWBK8CXBJdkMjLAQdqd4w=; b=VF3R61X/RlhJcxXUUhlemlpjbl9giDAac/fUjDXtotsavRFhWb1Oc3fxWc9SiZ/Cf5 8EpEXIcr6VtIu4cpRDWEpg0CXvms1NE2Yek2NvCSVvQYa3gRl97qLBxStNewfnySY3ie bYEVc1SITPVN97yn30N7vCGA48h8YXPSaV9w92ac+tSNweuIHHq57Qo6JwIdQBP5Z7oX zO02Y9Mk7Etk18uzEntcF4fAqUIp7cbJ31Y5G0dKLLGtxGjgzBrto8tpIHsRvEOqa+lk n3LXEuMLqTGGfGdF9pIOGwOrmHpmS0NVt9vOboo/AkKkkFISraHiqHQxR/AFKOjALhH4 Aj9w== X-Gm-Message-State: AOJu0YxSmJzf2MQiIsPFdUEVn9pZYTtvXU4AoNNtw3ruhL1L27td56FN eLVogI1rnC9/i1Gw9NF4dhAj452jbUmmhSZHoabqeDTZHkSGdNgISeToHPB+mY2y5C6vrpnM9UL lmOD6YpDtRk+I67y7jHjy+ljvz6YeORpKBgW14pkfPuEzDImbqEP9212N8o0lMQQsiW1mL2axIV OlVzToWwkuBidwtrUEy2pySDyvVbmmaVVflucf X-Received: by 2002:a17:906:6bda:b0:a45:b1d8:200c with SMTP id t26-20020a1709066bda00b00a45b1d8200cmr7007311ejs.14.1709921544530; Fri, 08 Mar 2024 10:12:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+viANonRhxNsuIVU7/lpqV7pJpp/09BgxJ6igXRlFIJ3RmNo5X9MhbnggJh5FvBlNXWln2A== X-Received: by 2002:a17:906:6bda:b0:a45:b1d8:200c with SMTP id t26-20020a1709066bda00b00a45b1d8200cmr7007292ejs.14.1709921544025; Fri, 08 Mar 2024 10:12:24 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 7/9] mips: do not list individual devices from configs/ Date: Fri, 8 Mar 2024 19:11:59 +0100 Message-ID: <20240308181202.617329-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240308181202.617329-1-pbonzini@redhat.com> References: <20240308181202.617329-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709921629556100001 Content-Type: text/plain; charset="utf-8" Add new "select" and "imply" directives if needed. The resulting config-devices.mak files are the same as before. Builds without default devices will become much smaller than before, and qtests fail (as expected, though suboptimal) for mips64-softmmu because most tests do not use -nodefaults, so remove it from build-without-defaults Signed-off-by: Paolo Bonzini --- configs/devices/mips-softmmu/common.mak | 28 +++----------------- configs/devices/mips64el-softmmu/default.mak | 3 --- .gitlab-ci.d/buildtest.yml | 2 +- hw/display/Kconfig | 2 +- hw/mips/Kconfig | 20 +++++++++++++- 5 files changed, 25 insertions(+), 30 deletions(-) diff --git a/configs/devices/mips-softmmu/common.mak b/configs/devices/mips= -softmmu/common.mak index 1a853841b27..416a5d353e8 100644 --- a/configs/devices/mips-softmmu/common.mak +++ b/configs/devices/mips-softmmu/common.mak @@ -1,28 +1,8 @@ # Common mips*-softmmu CONFIG defines =20 -CONFIG_ISA_BUS=3Dy -CONFIG_PCI=3Dy -CONFIG_PCI_DEVICES=3Dy -CONFIG_VGA_ISA=3Dy -CONFIG_VGA_MMIO=3Dy -CONFIG_VGA_CIRRUS=3Dy -CONFIG_VMWARE_VGA=3Dy -CONFIG_SERIAL=3Dy -CONFIG_SERIAL_ISA=3Dy -CONFIG_PARALLEL=3Dy -CONFIG_I8254=3Dy -CONFIG_PCSPK=3Dy -CONFIG_PCKBD=3Dy -CONFIG_FDC=3Dy -CONFIG_I8257=3Dy -CONFIG_IDE_ISA=3Dy -CONFIG_PFLASH_CFI01=3Dy -CONFIG_I8259=3Dy -CONFIG_MC146818RTC=3Dy -CONFIG_MIPS_CPS=3Dy -CONFIG_MIPS_ITU=3Dy +# Uncomment the following lines to disable these optional devices: +# CONFIG_PCI_DEVICES=3Dn +# CONFIG_TEST_DEVICES=3Dn + CONFIG_MALTA=3Dy -CONFIG_PCNET_PCI=3Dy CONFIG_MIPSSIM=3Dy -CONFIG_SMBUS_EEPROM=3Dy -CONFIG_TEST_DEVICES=3Dy diff --git a/configs/devices/mips64el-softmmu/default.mak b/configs/devices= /mips64el-softmmu/default.mak index d5188f7ea58..88a37cf27f1 100644 --- a/configs/devices/mips64el-softmmu/default.mak +++ b/configs/devices/mips64el-softmmu/default.mak @@ -3,8 +3,5 @@ include ../mips-softmmu/common.mak CONFIG_FULOONG=3Dy CONFIG_LOONGSON3V=3Dy -CONFIG_ATI_VGA=3Dy -CONFIG_RTL8139_PCI=3Dy CONFIG_JAZZ=3Dy -CONFIG_VT82C686=3Dy CONFIG_MIPS_BOSTON=3Dy diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml index a1c030337b1..901265af95d 100644 --- a/.gitlab-ci.d/buildtest.yml +++ b/.gitlab-ci.d/buildtest.yml @@ -659,7 +659,7 @@ build-without-defaults: --disable-pie --disable-qom-cast-debug --disable-strip - TARGETS: avr-softmmu mips64-softmmu s390x-softmmu sh4-softmmu + TARGETS: avr-softmmu s390x-softmmu sh4-softmmu sparc64-softmmu hexagon-linux-user i386-linux-user s390x-linux-user MAKE_CHECK_ARGS: check =20 diff --git a/hw/display/Kconfig b/hw/display/Kconfig index 07acb37dc66..234c7de027c 100644 --- a/hw/display/Kconfig +++ b/hw/display/Kconfig @@ -55,7 +55,7 @@ config VGA_MMIO =20 config VMWARE_VGA bool - default y if PCI_DEVICES && PC_PCI + default y if PCI_DEVICES && (PC_PCI || MIPS) depends on PCI select VGA =20 diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig index e57db4f6412..5c83ef49cf6 100644 --- a/hw/mips/Kconfig +++ b/hw/mips/Kconfig @@ -1,8 +1,15 @@ config MALTA bool + imply PCNET_PCI + imply PCI_DEVICES + imply TEST_DEVICES select FDC37M81X select GT64120 + select MIPS_CPS select PIIX + select PFLASH_CFI01 + select SERIAL + select SMBUS_EEPROM =20 config MIPSSIM bool @@ -31,17 +38,26 @@ config JAZZ =20 config FULOONG bool + imply PCI_DEVICES + imply TEST_DEVICES + imply ATI_VGA + imply RTL8139_PCI select PCI_BONITO + select SMBUS_EEPROM select VT82C686 =20 config LOONGSON3V bool + imply PCI_DEVICES + imply TEST_DEVICES + imply VIRTIO_PCI + imply VIRTIO_NET imply VIRTIO_VGA imply QXL if SPICE + imply USB_OHCI_PCI select SERIAL select GOLDFISH_RTC select LOONGSON_LIOINTC - select PCI_DEVICES select PCI_EXPRESS_GENERIC_BRIDGE select MSI_NONBROKEN select FW_CFG_MIPS @@ -53,6 +69,8 @@ config MIPS_CPS =20 config MIPS_BOSTON bool + imply PCI_DEVICES + imply TEST_DEVICES select FITLOADER select MIPS_CPS select PCI_EXPRESS_XILINX --=20 2.43.2 From nobody Sat May 11 17:35:34 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=1709921617; cv=none; d=zohomail.com; s=zohoarc; b=BNRd/dVgSFRpyIhPbtDw/+9W32nzjEl1blJAAQ/cOCK32QmyUzmjmP4bdW8XLqFePjupPmnco65Nahxa0Wo1IzhtdIfgS7GVv8vfb5qWltSzvRnKMNzc1Gev/im3ASH6/7VSz/V6oGoumawGdtNhdD4bU4/QTAnuXYtYKxPOTjY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709921617; h=Content-Type:Content-Transfer-Encoding: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=Wm7tvlRtPpXlePloTVjRajx+JpxbgNJey9a3Qa3vQcU=; b=ethxhQnOuDOBFK0vi6x0lYl7vy02EkCvJ9T91UGaHegLSaKJ7N6CBpxRxtYhFgWo2kN66cxMzJn8ecnGC7tswo/6UkTBb5F10XLf4fdA2nUvD83b/rIKaBWp3b5pnMytI7XZBHoh3fLlQlnGcpw0v85NXgvrzi8OSUjN7zVgQ7A= 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 1709921617551557.7228818612031; Fri, 8 Mar 2024 10:13:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riehu-0007Fd-B3; Fri, 08 Mar 2024 13:12:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riehs-0007Ds-SG for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riehr-0005qF-1J for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:32 -0500 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-1CleVlx5OgytrLIznhq_gA-1; Fri, 08 Mar 2024 13:12:29 -0500 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a45ac612a4dso363314166b.0 for ; Fri, 08 Mar 2024 10:12:27 -0800 (PST) Received: from [192.168.10.118] ([151.49.77.21]) by smtp.gmail.com with ESMTPSA id i10-20020a1709061cca00b00a3f28bf94f8sm33677ejh.199.2024.03.08.10.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 10:12:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709921550; 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=Wm7tvlRtPpXlePloTVjRajx+JpxbgNJey9a3Qa3vQcU=; b=dhxu0xCN71SuqofWqGWggFIyXm8mDsKjmBAMwJO5AKchGLqd2meJME6AXZZ6Lb+Q6TZNch 9Rgk6ub/TndScO5egb0SXJMlz3QGNhR1zeMdsopbILr+qlqLD5qRPcsj1iwOdPJ+wJZJZa j/oqmc8BYcegIis/YV7zunHLs5uMQiY= X-MC-Unique: 1CleVlx5OgytrLIznhq_gA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709921545; x=1710526345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wm7tvlRtPpXlePloTVjRajx+JpxbgNJey9a3Qa3vQcU=; b=tOLmAvKc+hV+pXaWqNHGEnPIdv5ycWGxwlL4TuSPfOVoHj1hyyXoJ5APbk4vPb3DrC a1Dr8FrivppOtcFxtRnm52TGZOPog9rniWnuUN7gWWfbvAtTI7EBZ9iWTVob+6mFYWJb qyqpg/jS2HXjK9f2SELZl5vIqLj158l2E7G9eo7vtfjpONJDvkvqNktoh124ECr4jcoJ i+v4Hgqje2NxHe7lV1DNzTFhKWjA7dUlKosj9GcETLA+EHnc+JRXM/DxIcme4Oh/JAYH m18elgQILS5De536+qcr/BaAk3556izsDV2OnZyEhYi9Xvx6v+gNWFG7YygqaUEcVaT2 YnpA== X-Gm-Message-State: AOJu0YyU7/4HR3g0xu9AgpLZ1xWesWvgwNk8lS/Ei0jfDy9Ld+P1pPNT c9k5iiQ2DZECrF5nrPSF5Dl83R9gJD2+YnKC49RHC2xaoPGAKT0nqBRfdqWoswTzn7SwT3pD9CF fVe8VzBFyHXrIxmPWzlNKYjBrouzr0JFuCwy/+SqWoUcRyuGyZatf2BdSKJ/8J8LUXTnXUwCnVd 2DeCzEzCHYV3mESWaG1pFyroWH+deKufbsegSI X-Received: by 2002:a17:906:68cd:b0:a45:af32:5e04 with SMTP id y13-20020a17090668cd00b00a45af325e04mr932649ejr.30.1709921545333; Fri, 08 Mar 2024 10:12:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IFoKUVenB5vA3VAfgooEXYtn6mNCEfmcVmEISv/gHiJ7o8U/9ZpLQtOH+7LnWWZJhZYbU+xug== X-Received: by 2002:a17:906:68cd:b0:a45:af32:5e04 with SMTP id y13-20020a17090668cd00b00a45af325e04mr932636ejr.30.1709921544992; Fri, 08 Mar 2024 10:12:24 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PULL 8/9] run-coverity-scan: add --check-upload-only option Date: Fri, 8 Mar 2024 19:12:00 +0100 Message-ID: <20240308181202.617329-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240308181202.617329-1-pbonzini@redhat.com> References: <20240308181202.617329-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709921619536100007 Content-Type: text/plain; charset="utf-8" Add an option to check if upload is permitted without actually attempting a build. This can be useful to add a third outcome beyond success and failure---namely, a CI job can self-cancel if the uploading quota has been reached. There is a small change here in that a failure to do the upload check changes the exit code from 1 to 99. 99 was chosen because it is what Autotools and Meson use to represent a problem in the setup (as opposed to a failure in the test). Reviewed-by: Peter Maydell Signed-off-by: Paolo Bonzini --- scripts/coverity-scan/run-coverity-scan | 59 ++++++++++++++++++------- 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/scripts/coverity-scan/run-coverity-scan b/scripts/coverity-sca= n/run-coverity-scan index d56c9b66776..43cf770f5e3 100755 --- a/scripts/coverity-scan/run-coverity-scan +++ b/scripts/coverity-scan/run-coverity-scan @@ -28,6 +28,7 @@ # project settings, if you have maintainer access there. =20 # Command line options: +# --check-upload-only : return success if upload is possible # --dry-run : run the tools, but don't actually do the upload # --docker : create and work inside a container # --docker-engine : specify the container engine to use (docker/podman/a= uto); @@ -57,18 +58,18 @@ # putting it in a file and using --tokenfile. Everything else has # a reasonable default if this is run from a git tree. =20 -check_upload_permissions() { - # Check whether we can do an upload to the server; will exit the script - # with status 1 if the check failed (usually a bad token); - # will exit the script with status 0 if the check indicated that we - # can't upload yet (ie we are at quota) - # Assumes that COVERITY_TOKEN, PROJNAME and DRYRUN have been initializ= ed. +upload_permitted() { + # Check whether we can do an upload to the server; will exit *the scri= pt* + # with status 99 if the check failed (usually a bad token); + # will return from the function with status 1 if the check indicated + # that we can't upload yet (ie we are at quota) + # Assumes that COVERITY_TOKEN and PROJNAME have been initialized. =20 echo "Checking upload permissions..." =20 if ! up_perm=3D"$(wget https://scan.coverity.com/api/upload_permitted = --post-data "token=3D$COVERITY_TOKEN&project=3D$PROJNAME" -q -O -)"; then echo "Coverity Scan API access denied: bad token?" - exit 1 + exit 99 fi =20 # Really up_perm is a JSON response with either @@ -76,25 +77,40 @@ check_upload_permissions() { # We do some hacky string parsing instead of properly parsing it. case "$up_perm" in *upload_permitted*true*) - echo "Coverity Scan: upload permitted" + return 0 ;; *next_upload_permitted_at*) - if [ "$DRYRUN" =3D yes ]; then - echo "Coverity Scan: upload quota reached, continuing dry = run" - else - echo "Coverity Scan: upload quota reached; stopping here" - # Exit success as this isn't a build error. - exit 0 - fi + return 1 ;; *) echo "Coverity Scan upload check: unexpected result $up_perm" - exit 1 + exit 99 ;; esac } =20 =20 +check_upload_permissions() { + # Check whether we can do an upload to the server; will exit the script + # with status 99 if the check failed (usually a bad token); + # will exit the script with status 0 if the check indicated that we + # can't upload yet (ie we are at quota) + # Assumes that COVERITY_TOKEN, PROJNAME and DRYRUN have been initializ= ed. + + if upload_permitted; then + echo "Coverity Scan: upload permitted" + else + if [ "$DRYRUN" =3D yes ]; then + echo "Coverity Scan: upload quota reached, continuing dry run" + else + echo "Coverity Scan: upload quota reached; stopping here" + # Exit success as this isn't a build error. + exit 0 + fi + fi +} + + build_docker_image() { # build docker container including the coverity-scan tools echo "Building docker container..." @@ -152,9 +168,14 @@ update_coverity_tools () { DRYRUN=3Dno UPDATE=3Dyes DOCKER=3Dno +PROJNAME=3DQEMU =20 while [ "$#" -ge 1 ]; do case "$1" in + --check-upload-only) + shift + DRYRUN=3Dcheck + ;; --dry-run) shift DRYRUN=3Dyes @@ -251,6 +272,11 @@ if [ -z "$COVERITY_TOKEN" ]; then exit 1 fi =20 +if [ "$DRYRUN" =3D check ]; then + upload_permitted + exit $? +fi + if [ -z "$COVERITY_BUILD_CMD" ]; then NPROC=3D$(nproc) COVERITY_BUILD_CMD=3D"make -j$NPROC" @@ -266,7 +292,6 @@ if [ -z "$SRCDIR" ]; then SRCDIR=3D"$PWD" fi =20 -PROJNAME=3DQEMU TARBALL=3Dcov-int.tar.xz =20 if [ "$UPDATE" =3D only ]; then --=20 2.43.2 From nobody Sat May 11 17:35:34 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=1709921620; cv=none; d=zohomail.com; s=zohoarc; b=MHYVVWomsKEo/4qJqJJMivT8+1zV9+/8NsialfgAJ4Xulg4sBGPxvHo66ObpyvfqMgBts4iNvyYTf5XoBA7B5h9KsdxbvLGfyFW8u1BERIeXVpzjJ2UoJydjOPXy/iwpPBHao8ocAr0R5uvrtaV9HG/MXnrgPwlekDlsHES8e1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709921620; h=Content-Type:Content-Transfer-Encoding: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=hFcOcpwXgUreDcP7/fCdgESL2rGpCnlA8DYZygfuJgc=; b=SPOv0MFNDVPWlOMkR3p4R+oQQYWhpdLlcpxAv5v/hvGtoBpaPiPT+oYDczfnemSD+dsKekq4mVtQE1dxJQP12Dv5q9027Hz1+nptVq3m0Vw8LgCXMZ2/4RhanuLNgoK2GYWd6wzcRlIIMffHYjkVkNR+0kAziGwauPmExrgtb6Q= 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 1709921620245872.7054949934914; Fri, 8 Mar 2024 10:13:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riehw-0007GJ-5n; Fri, 08 Mar 2024 13:12:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riehu-0007Fv-V9 for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:34 -0500 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 1rieht-0005qU-9Y for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:34 -0500 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-92-8IJbH3YpOvSnyNviJPUQcg-1; Fri, 08 Mar 2024 13:12:31 -0500 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a45f6ae4f58so27935366b.0 for ; Fri, 08 Mar 2024 10:12:31 -0800 (PST) Received: from [192.168.10.118] ([151.49.77.21]) by smtp.gmail.com with ESMTPSA id qu21-20020a170907111500b00a45d17148a3sm42178ejb.13.2024.03.08.10.12.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 10:12:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709921552; 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=hFcOcpwXgUreDcP7/fCdgESL2rGpCnlA8DYZygfuJgc=; b=dChZNZk4jl53ylN1aG2Y6xiB47yWD35hqn8wsl0K+jVGhab2KB7sD6WDJ4Myw9e499N8O5 7lTNZ3qhln+KMCeI8xPxRi2U0yJO8kX1M8t1HE8U3lg1S2zAcoRlD98qcgzZ9jR3soMrPI xel0/8JHLMz+xPR7hcOom1au3uuJ1uA= X-MC-Unique: 8IJbH3YpOvSnyNviJPUQcg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709921549; x=1710526349; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hFcOcpwXgUreDcP7/fCdgESL2rGpCnlA8DYZygfuJgc=; b=v086NdkWh6r1/U8wK6H2ewtERMGy4euWNLTUNzh5HHX9IMN+0JNJHeYJSWHV6Q9bgu I+KeVMGA2TNEhXz4FqBuwkBjTdnOM7g8sKr5cpoiAXPV6QefyhFTd8lGb7tDJjPPZdvF 0/W5KP3rgEIQiV1bttS155K79/AsVqfoFFAd3CFCp/1eeYHk2IFsTZxTK7Vlp8atTE+I iM7Bj7IZ5AuV6DQsVIpTwRvQxGiG5YEKLMI1vMID2FOeWOPTlgR0QSeFQzH9Cl4t5bSn OSQhkVdVMC7+vI2zBuFkAK26va2LAo245tPgJyQ/17s32jj1UzpnXZ+NMbUpB9IuZE1N nnDQ== X-Gm-Message-State: AOJu0YzMPXoEXAuov2f2TOIeQIsiA93xoriAMSxjxCxYz5cFJmMUbPMr C+HCB9TasgKzOvZ2rMyaq0byuKF180ApYsttnxiJNZ7VpAnY/VHdvOG9xKpPddsTbp0jUzyDzKV KYPGTOvJIrv6AnHsTOFDoTP16dqjJgXh/3ww0Lf5h4NU2OKV4oI5B4Y6y945e7D+x/3wqwB9zYY ScXxBqfJ4FGpzNwaKB1JqEPfl9B4TIKICiukDl X-Received: by 2002:a17:906:e002:b0:a45:b5a0:f3a with SMTP id cu2-20020a170906e00200b00a45b5a00f3amr5468332ejb.17.1709921549251; Fri, 08 Mar 2024 10:12:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBnTN8k36SpZNmLJU4kr3iGyfQK+UPJux5qDSbHHb2RLUxUjFoscBgv5ssBV2edR18F+Xgjg== X-Received: by 2002:a17:906:e002:b0:a45:b5a0:f3a with SMTP id cu2-20020a170906e00200b00a45b5a00f3amr5468316ejb.17.1709921548856; Fri, 08 Mar 2024 10:12:28 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PULL 9/9] gitlab-ci: add manual job to run Coverity Date: Fri, 8 Mar 2024 19:12:01 +0100 Message-ID: <20240308181202.617329-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240308181202.617329-1-pbonzini@redhat.com> References: <20240308181202.617329-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.572, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709921621519100009 Add a job that can be run, either manually or on a schedule, to upload a build to Coverity Scan. The job uses the run-coverity-scan script in multiple phases of check, download tools and upload, in order to avoid both wasting time (skip everything if you are above the upload quota) and avoid filling the log with the progress of downloading the tools. The job is intended to run on a scheduled pipeline run, and scheduled runs will not get any other job. It requires two variables to be in GitLab CI, COVERITY_TOKEN and COVERITY_EMAIL. Those are already set up in qemu-project's configuration as protected and masked variables. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- .gitlab-ci.d/base.yml | 4 ++++ .gitlab-ci.d/buildtest.yml | 37 +++++++++++++++++++++++++++++++++++++ .gitlab-ci.d/opensbi.yml | 4 ++++ 3 files changed, 45 insertions(+) diff --git a/.gitlab-ci.d/base.yml b/.gitlab-ci.d/base.yml index ef173a34e63..2dd8a9b57cb 100644 --- a/.gitlab-ci.d/base.yml +++ b/.gitlab-ci.d/base.yml @@ -41,6 +41,10 @@ variables: - if: '$CI_PROJECT_NAMESPACE =3D=3D $QEMU_CI_UPSTREAM && $CI_COMMIT_TA= G' when: never =20 + # Scheduled runs on mainline don't get pipelines except for the specia= l Coverity job + - if: '$CI_PROJECT_NAMESPACE =3D=3D $QEMU_CI_UPSTREAM && $CI_PIPELINE_= SOURCE =3D=3D "schedule"' + when: never + # Cirrus jobs can't run unless the creds / target repo are set - if: '$QEMU_JOB_CIRRUS && ($CIRRUS_GITHUB_REPO =3D=3D null || $CIRRUS= _API_TOKEN =3D=3D null)' when: never diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml index 901265af95d..c7d92fc3018 100644 --- a/.gitlab-ci.d/buildtest.yml +++ b/.gitlab-ci.d/buildtest.yml @@ -729,3 +729,40 @@ pages: - public variables: QEMU_JOB_PUBLISH: 1 + +coverity: + image: $CI_REGISTRY_IMAGE/qemu/fedora:$QEMU_CI_CONTAINER_TAG + stage: build + allow_failure: true + timeout: 3h + needs: + - job: amd64-fedora-container + optional: true + before_script: + - dnf install -y curl wget + script: + # would be nice to cancel the job if over quota (https://gitlab.com/gi= tlab-org/gitlab/-/issues/256089) + # for example: + # curl --request POST --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "${CI_= SERVER_URL}/api/v4/projects/${CI_PROJECT_ID}/jobs/${CI_JOB_ID}/cancel + - 'scripts/coverity-scan/run-coverity-scan --check-upload-only || { ex= itcode=3D$?; if test $exitcode =3D 1; then + exit 0; + else + exit $exitcode; + fi; }; + scripts/coverity-scan/run-coverity-scan --update-tools-only > update= -tools.log 2>&1 || { cat update-tools.log; exit 1; }; + scripts/coverity-scan/run-coverity-scan --no-update-tools' + rules: + - if: '$COVERITY_TOKEN =3D=3D null' + when: never + - if: '$COVERITY_EMAIL =3D=3D null' + when: never + # Never included on upstream pipelines, except for schedules + - if: '$CI_PROJECT_NAMESPACE =3D=3D $QEMU_CI_UPSTREAM && $CI_PIPELINE_= SOURCE =3D=3D "schedule"' + when: on_success + - if: '$CI_PROJECT_NAMESPACE =3D=3D $QEMU_CI_UPSTREAM' + when: never + # Forks don't get any pipeline unless QEMU_CI=3D1 or QEMU_CI=3D2 is set + - if: '$QEMU_CI !=3D "1" && $QEMU_CI !=3D "2"' + when: never + # Always manual on forks even if $QEMU_CI =3D=3D "2" + - when: manual diff --git a/.gitlab-ci.d/opensbi.yml b/.gitlab-ci.d/opensbi.yml index fd293e6c317..42f137d624e 100644 --- a/.gitlab-ci.d/opensbi.yml +++ b/.gitlab-ci.d/opensbi.yml @@ -24,6 +24,10 @@ - if: '$QEMU_CI =3D=3D "1" && $CI_PROJECT_NAMESPACE !=3D "qemu-project= " && $CI_COMMIT_MESSAGE =3D~ /opensbi/i' when: manual =20 + # Scheduled runs on mainline don't get pipelines except for the specia= l Coverity job + - if: '$CI_PROJECT_NAMESPACE =3D=3D $QEMU_CI_UPSTREAM && $CI_PIPELINE_= SOURCE =3D=3D "schedule"' + when: never + # Run if any files affecting the build output are touched - changes: - .gitlab-ci.d/opensbi.yml --=20 2.43.2